/* CSS reset */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

body {
    line-height: 1.5;
    font-family: 'Geist Mono', monospace;
}

/* Dark High Contrast Theme */
:root {
    /* Colors */
    --bg-primary: #0d0d0d;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #262626;
    --bg-card: #333333;

    /* Accent Colors */
    --accent-primary: #2563eb;
    --accent-secondary: #059669;
    --accent-warning: #dc2626;
    --accent-info: #0891b2;

    /* Text Colors */
    --text-primary: #ffffff;
    --text-secondary: #cccccc;
    --text-muted: #999999;

    /* Borders */
    --border-primary: #404040;
    --border-accent: #2563eb;
}

body {
    height: 100vh;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Geist Mono', monospace;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.terminal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 0px;
    max-width: 900px;
    width: 100%;
    overflow: hidden;
}

.terminal-header {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.window-controls {
    display: flex;
    gap: 8px;
}

.control {
    width: 12px;
    height: 12px;
    border-radius: 0px;
    display: inline-block;
    border: 1px solid var(--border-primary);
}

.control.close {
    background: #dc2626;
}

.control.minimize {
    background: #d97706;
}

.control.maximize {
    background: #059669;
}

.title-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.prompt {
    color: var(--accent-secondary);
}

.title {
    color: var(--text-primary);
    letter-spacing: 0.5px;
    font-weight: 700;
}

.cursor {
    color: var(--accent-primary);
    animation: blink 1s infinite;
}

@keyframes blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0;
    }
}

.terminal-body {
    padding: 20px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-primary);
}

.app-title {
    color: var(--text-primary);
    font-size: 1em;
    font-weight: 600;
}

.status-bar {
    display: flex;
    gap: 8px;
}

.status-item {
    background: var(--bg-card);
    padding: 4px 8px;
    border-radius: 0px;
    font-size: 0.75em;
    color: var(--accent-secondary);
    border: 1px solid var(--border-primary);
}

.container {
    width: 100%;
    margin: 15px 0;
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 0px;
    padding: 20px;
}

/* Search Form - Single Horizontal Line */
.search-form {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 0;
    width: 100%;
}

.search-form label {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9em;
    white-space: nowrap;
    min-width: fit-content;
}

#search-input {
    height: 40px;
    padding: 0 12px;
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    color: var(--text-primary);
    font-family: 'Geist Mono', monospace;
    font-size: 0.9em;
    border-radius: 0px;
    min-width: 200px;
}

#search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

#search-input::placeholder {
    color: var(--text-muted);
}

#search-button {
    padding: 0 20px;
    border-radius: 0px;
    background: #1e40af;
    /* Darker blue */
    color: var(--text-primary);
    border: 1px solid #1e40af;
    font-family: 'Geist Mono', monospace;
    font-weight: 600;
    cursor: pointer;
    min-width: 100px;
    height: 40px;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

#search-button:hover {
    background: #1e3a8a;
    /* Even darker on hover */
}

.output {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Top Container - Collapsible when empty */
.top-container {
    background: var(--bg-secondary);
    padding: 15px;
    border: 1px solid var(--border-primary);
    border-radius: 0px;
    min-height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    transition: min-height 0.3s ease;
}

/* Show placeholder when empty */
.top-container:not(:has(#creature-name:not(:empty)))::before {
    content: "ENTER_CREATURE_NAME_OR_ID_TO_SEARCH";
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    font-size: 0.9em;
}

/* Expand when creature data exists */
.top-container:has(#creature-name:not(:empty)) {
    min-height: 180px;
    justify-content: flex-start;
}

.top-container:has(#creature-name:not(:empty))::before {
    display: none;
}

/* Hide sections when empty */
.name-and-id:has(#creature-name:empty) {
    display: none;
}

#types:empty {
    display: none;
}

.top-container>div:last-child:has(#special-name:empty) {
    display: none;
}

/* Name and ID Section */
.name-and-id {
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-primary);
}

#creature-name {
    font-weight: 700;
    color: var(--accent-info);
    font-size: 1.3em;
    text-transform: uppercase;
    display: inline-block;
    margin-right: 10px;
}

#creature-id {
    color: var(--accent-secondary);
    font-size: 0.9em;
    font-weight: 600;
    display: inline-block;
}

.size {
    display: flex;
    gap: 20px;
    margin-top: 8px;
}

#weight,
#height {
    color: var(--text-secondary);
    font-size: 0.85em;
}

/* Hide size when empty */
.size:has(#weight:empty):has(#height:empty) {
    display: none;
}

/* Types Section */
#types {
    min-height: 28px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
}

.type {
    padding: 5px 10px;
    font-size: 0.7rem;
    text-align: center;
    border-radius: 0px;
    text-transform: uppercase;
    font-weight: 600;
    border: 1px solid;
    min-width: 65px;
}

/* Special Ability Section */
#special-name {
    font-weight: 600;
    color: var(--accent-primary);
    font-size: 0.95em;
    margin: 15px 0 6px 0;
}

#special-description {
    font-size: 0.85em;
    color: var(--text-secondary);
    line-height: 1.4;
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
}

/* Stats Table */
.bottom-container {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 0px;
    overflow: hidden;
}

table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.9em;
}

th {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-weight: 600;
    padding: 12px;
    text-align: center;
    border: 1px solid var(--border-primary);
}

td {
    padding: 10px;
    text-align: center;
    font-weight: 600;
    border: 1px solid var(--border-primary);
}

tr:nth-child(even) {
    background: var(--bg-card);
}

tr:nth-child(odd) {
    background: var(--bg-secondary);
}

td:first-child {
    color: var(--text-secondary);
    text-align: right;
    width: 40%;
}

td:last-child {
    color: var(--accent-info);
    text-align: left;
    width: 60%;
}

.terminal-footer {
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-primary);
    padding: 10px 20px;
}

.footer-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.75em;
    color: var(--text-secondary);
}

.stat {
    font-family: 'Geist Mono', monospace;
}

#status {
    color: var(--accent-secondary);
}

#total-loaded {
    color: var(--accent-info);
}

/* Type Colors - High Contrast */
.normal {
    background: #a8a878;
    color: #0d0d0d;
    border-color: #a8a878;
}

.fire {
    background: #f08030;
    color: #0d0d0d;
    border-color: #f08030;
}

.water {
    background: #6890f0;
    color: #0d0d0d;
    border-color: #6890f0;
}

.electric {
    background: #f8d030;
    color: #0d0d0d;
    border-color: #f8d030;
}

.grass {
    background: #78c850;
    color: #0d0d0d;
    border-color: #78c850;
}

.ice {
    background: #98d8d8;
    color: #0d0d0d;
    border-color: #98d8d8;
}

.fighting {
    background: #c03028;
    color: #ffffff;
    border-color: #c03028;
}

.poison {
    background: #a040a0;
    color: #ffffff;
    border-color: #a040a0;
}

.ground {
    background: #e0c068;
    color: #0d0d0d;
    border-color: #e0c068;
}

.flying {
    background: #a890f0;
    color: #0d0d0d;
    border-color: #a890f0;
}

.psychic {
    background: #f85888;
    color: #0d0d0d;
    border-color: #f85888;
}

.bug {
    background: #a8b820;
    color: #0d0d0d;
    border-color: #a8b820;
}

.rock {
    background: #b8a038;
    color: #0d0d0d;
    border-color: #b8a038;
}

.ghost {
    background: #705898;
    color: #ffffff;
    border-color: #705898;
}

.dragon {
    background: #7038f8;
    color: #ffffff;
    border-color: #7038f8;
}

.dark {
    background: #705848;
    color: #ffffff;
    border-color: #705848;
}

.steel {
    background: #b8b8d0;
    color: #0d0d0d;
    border-color: #b8b8d0;
}

.fairy {
    background: #ee99ac;
    color: #0d0d0d;
    border-color: #ee99ac;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }

    .terminal-body {
        padding: 15px;
    }

    .app-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .search-form {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .search-form label {
        margin-bottom: 0;
    }

    #search-button {
        width: 100%;
        min-width: auto;
    }

    .footer-stats {
        flex-direction: column;
        gap: 6px;
    }

    .size {
        flex-direction: column;
        gap: 6px;
    }

    table {
        font-size: 0.85em;
    }

    td,
    th {
        padding: 8px 6px;
    }
}

@media screen and (max-width: 480px) {
    .terminal-header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .title-bar {
        justify-content: center;
    }

    .container {
        padding: 15px;
    }

    .top-container,
    .bottom-container {
        padding: 12px;
    }

    #types {
        justify-content: center;
    }

    #creature-name,
    #creature-id {
        display: block;
        margin-right: 0;
    }
}