/* ===== FSX cockpit UI + layout sticky ===== */
:root {
    --bg: #050e1c;
    --amber: #ff9d00;
    --amber-hot: #ffb84d;
    --amber-glow: rgba(255, 157, 0, 0.65);
    --radio: #00ff66;
    --cyan: #3de7ff;
    --ink: #ffffff;
    --panel-dark: #121820;
    --font: Arial, Helvetica, "Segoe UI", sans-serif;
    --shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

html { font-size: 18px; }

body {
    font-family: var(--font);
    color: var(--ink);
    background-color: #071428;
    background-image:
        linear-gradient(180deg, rgba(5, 14, 28, 0.72) 0%, rgba(5, 14, 28, 0.88) 100%),
        url("img/metal-plate.png");
    background-size: auto, 420px auto;
    background-repeat: no-repeat, repeat;
    background-position: center, center;
    background-blend-mode: normal, soft-light;
    overflow: hidden; /* el scroll vive solo en .results-zone */
}

.skip-link {
    position: absolute;
    left: 1rem;
    top: -4rem;
    z-index: 100;
    padding: 0.7rem 1rem;
    background: var(--amber);
    color: #111;
    font-weight: 800;
    text-decoration: none;
    border-radius: 8px;
}
.skip-link:focus { top: 1rem; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}

.metal {
    position: relative;
    background-color: #8f99a4;
    background-image:
        linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(20, 28, 38, 0.18) 55%, rgba(0, 0, 0, 0.22)),
        url("img/metal-plate.png");
    background-size: auto, 280px auto;
    background-repeat: no-repeat, repeat;
    background-position: center, center;
    background-blend-mode: soft-light, multiply;
    border: 2px solid #6d7681;
    border-radius: 14px;
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.screw {
    position: absolute;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #e8edf2, #5c6570 60%, #2a3038);
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}
.screw::after {
    content: "";
    position: absolute;
    left: 2px; right: 2px; top: 4.5px;
    height: 2px;
    background: #1b2128;
    transform: rotate(40deg);
}
.screw.tl { top: 8px; left: 8px; }
.screw.tr { top: 8px; right: 8px; }
.screw.bl { bottom: 8px; left: 8px; }
.screw.br { bottom: 8px; right: 8px; }

/* ===== App shell: altura de ventana ===== */
.app {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) minmax(280px, 340px);
    gap: 0.75rem;
    width: min(1440px, 100%);
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    padding: 0.75rem;
    min-height: 0;
}

/* Left nav */
.side-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 0.45rem;
    border-right: 3px solid var(--amber);
    border-radius: 0 14px 14px 0;
    min-height: 0;
    overflow: auto;
}
.nav-btn {
    width: 56px;
    min-height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    background: linear-gradient(180deg, #3a424c, #1f252c);
    border: 2px solid #5b6570;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 4px 0 #12161b;
}
.nav-ico { font-size: 1.35rem; line-height: 1; }
.nav-txt { font-size: 0.55rem; font-weight: 800; letter-spacing: 0.04em; }

/* ===== Columna central: top fijo + resultados scroll + teclado fijo ===== */
.main {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-width: 0;
    min-height: 0;
    height: 100%;
}

.main-top {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.hero { text-align: center; padding: 0.15rem 0 0; }
.hero-title-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}
.hero-title {
    margin: 0;
    font-size: clamp(1.2rem, 2.6vw, 1.95rem);
    font-weight: 900;
    letter-spacing: 0.04em;
    color: #fff;
    text-shadow: 0 2px 0 #000;
}
.plane-ico {
    color: var(--amber);
    font-size: 1.35rem;
    text-shadow: 0 0 12px var(--amber-glow);
}
.plane-flip { transform: scaleX(-1); }
.hero-line {
    height: 3px;
    margin: 0.35rem auto;
    width: min(520px, 90%);
    background: linear-gradient(90deg, transparent, var(--amber), transparent);
}

.search-shell { padding: 0.85rem 1.15rem 0.75rem; }
.search-field { position: relative; }
.search-input {
    width: 100%;
    padding: 0.9rem 3rem 0.9rem 1rem;
    font: inherit;
    font-size: clamp(1rem, 1.8vw, 1.3rem);
    font-weight: 700;
    color: #e8eef6;
    background: #1a222c;
    border: 2px solid #d7dee6;
    border-radius: 12px;
    box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.45);
}
.search-input::placeholder { color: #9aa5b3; font-weight: 600; }
.search-input:focus {
    outline: 3px solid var(--amber);
    outline-offset: 2px;
}
.search-ico {
    position: absolute;
    right: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.25rem;
    opacity: 0.85;
    pointer-events: none;
}
.search-hint,
.results-count {
    margin: 0.45rem 0 0;
    color: #1a222c;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
}
.results-count {
    min-height: 1.15em;
    font-weight: 800;
}

/* ÚNICA zona con scroll */
.results-zone {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding-right: 0.15rem;
    scrollbar-gutter: stable;
}
.results-zone::-webkit-scrollbar { width: 10px; }
.results-zone::-webkit-scrollbar-thumb {
    background: #5c6570;
    border-radius: 8px;
}
.results-zone::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.25); }

.estado {
    padding: 1rem 1.15rem;
    background: rgba(18, 24, 32, 0.9);
    border: 2px solid #4a515a;
    border-radius: 12px;
    color: #d7dde5;
    font-size: 1.1rem;
}
.estado.error { border-color: #ff6b6b; color: #ffd0d0; }

.cards {
    display: grid;
    gap: 0.45rem;
    padding-bottom: 0.25rem;
}

.card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem 0.65rem;
    align-items: center;
    padding: 0.55rem 0.7rem;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 35%),
        linear-gradient(180deg, rgba(42, 50, 60, 0.92) 0%, rgba(21, 27, 35, 0.96) 100%);
    border: 2px solid #6d7785;
    border-radius: 10px;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.12);
    cursor: pointer;
    position: relative;
}
.card .screw {
    width: 8px;
    height: 8px;
}
.card .screw.tl { top: 5px; left: 5px; }
.card .screw.tr { top: 5px; right: 5px; }
.card .screw.bl { bottom: 5px; left: 5px; }
.card .screw.br { bottom: 5px; right: 5px; }

.card-eyebrow {
    margin: 0 0 0.15rem;
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: #fff;
}
.card-title {
    margin: 0 0 0.2rem;
    font-size: clamp(0.95rem, 1.6vw, 1.15rem);
    font-weight: 900;
    line-height: 1.15;
    color: var(--amber);
    text-transform: uppercase;
}
.card-desc {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.35;
    color: #fff;
}

/* Teclas físicas 3D (compactas en tarjetas) */
.key-stack {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    align-items: center;
    min-width: 3.6rem;
}
.keycap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 3.2rem;
    min-height: 2.55rem;
    padding: 0.18rem;
    font-weight: 900;
    color: #111;
    text-align: center;
    background: linear-gradient(180deg, #f7f8fa 0%, #e2e6ec 45%, #c8d0d8 100%);
    border: 1px solid #7a8490;
    border-radius: 7px;
    box-shadow:
        inset 0 1px 0 #fff,
        inset 0 -3px 0 rgba(0, 0, 0, 0.12),
        0 4px 0 #4a5562,
        0 6px 10px rgba(0, 0, 0, 0.3);
}
.keycap__small {
    font-size: 0.42rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    opacity: 0.75;
    line-height: 1;
}
.keycap__big {
    font-size: 1.05rem;
    line-height: 1;
    margin-top: 0.05rem;
}
.keycap.is-primary {
    background: linear-gradient(180deg, #ffd27a 0%, var(--amber) 45%, #e07f00 100%);
    border-color: #c56f00;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.55),
        inset 0 -3px 0 rgba(0, 0, 0, 0.15),
        0 0 10px var(--amber-glow),
        0 4px 0 #9a5a00,
        0 6px 12px rgba(255, 157, 0, 0.3);
}

/* Teclado anclado abajo — base negra, teclas blancas (sin textura) */
.keyboard-shell {
    flex: 0 0 auto;
    position: relative;
    padding: 0.5rem 0.55rem 0.65rem;
    z-index: 5;
    background:
        linear-gradient(180deg, #2a2e34 0%, #0a0c10 40%, #000000 100%);
    border: 2px solid #3a3f48;
    border-radius: 14px;
    box-shadow:
        var(--shadow),
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        inset 0 -2px 8px rgba(0, 0, 0, 0.65);
}
.keyboard-shell .screw {
    background: radial-gradient(circle at 35% 30%, #9aa3ad, #3a4048 60%, #111);
}
.kb-heading {
    margin: 0 0 0.35rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    color: #d7dde5;
}

.keyboard {
    overflow-x: auto;
    padding-bottom: 0.15rem;
}

.keyboard-wrap.kb-realistic {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-end;
    justify-content: center;
    gap: 0.55rem;
    min-width: max-content;
    margin: 0 auto;
}

.kb-main {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
}

.kb-row {
    display: flex;
    align-items: stretch;
    gap: 0.18rem;
}

.kb-spacer { flex: 0 0 auto; }
.kb-spacer-sm { width: 0.7rem; }

.kb-key {
    box-sizing: border-box;
    flex: 0 0 auto;
    width: 2.05rem;
    height: 2.05rem;
    margin: 0;
    padding: 0 0.1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: 800 0.68rem/1.05 var(--font);
    color: #111;
    text-align: center;
    background:
        linear-gradient(180deg, #ffffff 0%, #f3f5f7 48%, #e4e8ee 100%);
    border: 1px solid #c5ccd5;
    border-bottom-color: #8b949e;
    border-radius: 6px;
    box-shadow:
        inset 0 1px 0 #fff,
        inset 0 -2px 0 rgba(0, 0, 0, 0.06),
        0 2px 0 #2a2e34,
        0 3px 5px rgba(0, 0, 0, 0.45);
    user-select: none;
    cursor: default;
    transition: background 0.12s ease, box-shadow 0.12s ease, transform 0.12s ease, color 0.12s ease;
}

.kb-key:active {
    transform: translateY(1px);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.2),
        0 1px 0 #4a5562;
}

.kb-fn {
    width: 2rem;
    height: 1.55rem;
    font-size: 0.58rem;
}

.kb-w-backspace { width: 4.4rem; font-size: 0.62rem; }
.kb-w-tab { width: 3.15rem; font-size: 0.62rem; }
.kb-w-enter { width: 3.4rem; font-size: 0.62rem; }
.kb-w-caps { width: 3.7rem; font-size: 0.58rem; }
.kb-w-shift { width: 3.35rem; font-size: 0.62rem; }
.kb-w-mod { width: 2.55rem; font-size: 0.58rem; }
.kb-w-space {
    flex: 1 1 auto;
    width: auto;
    min-width: 14rem;
    font-size: 0.7rem;
}

/* Navegación */
.kb-nav {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.55rem;
    padding-bottom: 0.02rem;
}

.kb-nav-cluster {
    display: grid;
    grid-template-columns: repeat(3, 2.05rem);
    grid-template-rows: repeat(2, 2.05rem);
    gap: 0.18rem;
}

.kb-arrows {
    display: grid;
    grid-template-columns: repeat(3, 2.05rem);
    grid-template-rows: repeat(2, 2.05rem);
    gap: 0.18rem;
}

.kb-arrow-spacer { visibility: hidden; }
.kb-nav-key { width: 2.05rem; font-size: 0.55rem; }

/* Numpad — grid real con + y Enter altos, 0 doble ancho */
.kb-numpad {
    display: grid;
    grid-template-columns: repeat(4, 2.15rem);
    grid-template-rows: repeat(5, 2.05rem);
    gap: 0.18rem;
    align-content: end;
}

.kb-numpad .kb-key {
    width: 100%;
    height: 100%;
    font-size: 0.78rem;
}

.kb-np-tall {
    grid-row: span 2;
    height: 100%;
}

.kb-np-wide {
    grid-column: span 2;
    width: 100%;
}

.kb-key.is-lit {
    color: #111;
    background: linear-gradient(180deg, #ffd27a, var(--amber) 55%, #e07f00);
    border-color: #ffb84d;
    box-shadow:
        0 0 12px var(--amber-glow),
        0 0 22px rgba(255, 157, 0, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.55),
        0 2px 0 #9a5a00;
    transform: translateY(-1px);
}

/* Copiloto */
.copilot {
    display: flex;
    flex-direction: column;
    padding: 0.85rem 0.75rem 0.9rem;
    min-height: 0;
    height: 100%;
    background-color: #7e8791;
    background-image:
        linear-gradient(180deg, rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.42)),
        url("img/metal-plate.png");
    background-size: auto, 260px auto;
    background-repeat: no-repeat, repeat;
    background-blend-mode: multiply, multiply;
}
.copilot-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.4rem 0.5rem;
    margin-bottom: 0.5rem;
    background: #0a0f14;
    border: 2px solid #1f6b3a;
    border-radius: 8px;
    flex: 0 0 auto;
}
.copilot-head-main {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
    flex: 1 1 auto;
}
.avatar-comandante {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    object-position: center top;
    border: 2px solid #ff9900; /* Borde estilo ámbar de panel de instrumentos */
    flex-shrink: 0;
}
.copilot-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 900;
    letter-spacing: 0.02em;
    color: var(--radio);
    text-shadow: 0 0 8px rgba(0, 255, 102, 0.35);
    line-height: 1.2;
}
.led {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #1a2a20;
    border: 1px solid #000;
}
.led.on {
    background: var(--radio);
    box-shadow: 0 0 10px var(--radio);
}

.chat-log {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 0.7rem;
    margin-bottom: 0.55rem;
    background: #0b1118;
    border: 2px solid var(--amber);
    border-radius: 8px;
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.92rem;
}
.chat-bubble { margin: 0 0 0.8rem; white-space: pre-wrap; word-break: break-word; }
.chat-bubble.user { color: #fff; }
.chat-bubble.bot { color: var(--radio); }
.chat-bubble .who {
    display: block;
    margin-bottom: 0.2rem;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    opacity: 0.85;
}

.chat-form {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.chat-label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.06em;
    color: #1a222c;
}
/* Zona de escritura: caja ancha arriba, botones abajo (sin aplastar el texto) */
.chat-input-area {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}
.chat-input {
    display: block;
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    resize: vertical;
    min-height: 6.5rem;
    height: 6.5rem;
    max-height: 12rem;
    margin: 0;
    padding: 0.75rem 0.85rem;
    font: inherit;
    font-size: 1.15rem;
    line-height: 1.45;
    color: #e8fff0;
    background: #0b1118;
    border: 2px solid var(--amber);
    border-radius: 8px;
    box-sizing: border-box;
    position: static;
}
.chat-input:focus {
    outline: 3px solid var(--cyan);
    outline-offset: 1px;
}
.chat-actions {
    display: flex;
    flex-shrink: 0;
    flex-wrap: nowrap;
    gap: 10px;
    align-items: stretch;
    width: 100%;
}
.chat-mic {
    flex: 1 1 auto;
    flex-shrink: 0;
    box-sizing: border-box;
    min-height: 3.4rem;
    padding: 0.7rem 0.85rem;
    font: inherit;
    font-size: 1rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    color: #fff;
    border-radius: 10px;
    cursor: pointer;
    position: static;
    background: linear-gradient(180deg, #2f9e5f, #176b3a);
    border: 2px solid #0f4a28;
    box-shadow: 0 4px 0 #0a2f1a;
    min-width: 4.8rem;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
/* Estado escuchando: rojo brillante + pulso (sin scale para no invadir el input) */
.chat-mic.is-listening {
    color: #fff;
    background: linear-gradient(180deg, #ff3b3b, #d50000);
    border-color: #ffeb3b;
    border-width: 3px;
    box-shadow:
        0 0 0 3px rgba(255, 235, 59, 0.55),
        0 0 22px rgba(255, 40, 40, 0.95),
        0 4px 0 #7a0000;
    animation: mic-pulse 0.85s ease-in-out infinite;
    transform: none;
}
@keyframes mic-pulse {
    0%, 100% {
        filter: brightness(1);
        box-shadow:
            0 0 0 3px rgba(255, 235, 59, 0.45),
            0 0 14px rgba(255, 40, 40, 0.7),
            0 4px 0 #7a0000;
    }
    50% {
        filter: brightness(1.35);
        box-shadow:
            0 0 0 6px rgba(255, 235, 59, 0.75),
            0 0 32px rgba(255, 60, 60, 1),
            0 4px 0 #7a0000;
    }
}
.chat-mic:disabled { opacity: 0.6; cursor: wait; }
.chat-voice-toggle {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin-top: 0.45rem;
    font-size: 0.82rem;
    font-weight: 800;
    color: #1a222c;
    cursor: pointer;
    user-select: none;
}
.chat-voice-toggle input {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--amber);
}
.chat-status {
    min-height: 1.1em;
    margin: 0.35rem 0 0;
    color: #1a222c;
    font-size: 0.8rem;
    font-weight: 700;
}
.knobs {
    display: flex;
    justify-content: center;
    gap: 1.1rem;
    margin-top: 0.5rem;
    flex: 0 0 auto;
}
.knob {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #d7dde5, #4a515a 60%, #1f252c);
    box-shadow: inset 0 1px 0 #fff, 0 2px 4px rgba(0, 0, 0, 0.45);
}

@media (max-width: 1100px) {
    body { overflow: auto; }
    .app {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        grid-template-columns: 64px 1fr;
    }
    .main {
        height: auto;
        min-height: 70vh;
    }
    .results-zone {
        max-height: 42vh;
    }
    .copilot {
        grid-column: 1 / -1;
        height: auto;
        max-height: none;
    }
    .chat-log {
        min-height: 180px;
        max-height: 28vh;
    }
}

@media (max-width: 720px) {
    .app { grid-template-columns: 1fr; }
    .side-nav {
        flex-direction: row;
        justify-content: center;
        border-right: none;
        border-bottom: 3px solid var(--amber);
        border-radius: 14px;
    }
    .card {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
    }
    .kb-w-space { min-width: 8rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }
}
