:root {
    --bg-dark: #F5F7FA; /* Fondo claro/blanco suave en lugar de oscuro */
    --paper-white: #FDFBF7;
    --ink-black: #000000;
    --gold-pop: #E9B824;
    --green-radio: #2ECC71;
    --orange-exp: #FF6B00;
    --white: #FFFFFF;
    --yellow-soft: #FFFBC4;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    font-family: 'Poppins', sans-serif;
    color: var(--ink-black);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* CONTENEDOR PRINCIPAL - OCUPA TODO EL ESPACIO */
#main-container {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap; /* ESTRICTAMENTE EN UNA SOLA FILA */
    height: 100vh;
    width: 100vw;
    gap: 8px;
    padding: 8px;
    background-color: var(--bg-dark);
    overflow-y: auto; /* Permitir scroll vertical en celular cuando se apilan */
}

/* PANELES */
.panel {
    display: flex;
    flex-direction: column;
    background-color: var(--paper-white);
    border: 3px solid var(--ink-black);
    box-shadow: 4px 4px 0px var(--ink-black);
    border-radius: 8px;
    overflow: hidden;
    height: 100%;
    transition: flex 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.panel.hidden {
    display: none !important;
}

/* SISTEMA DE ANCHO DE PANEL DINÁMICO (SIN PERDERSE ABAJO) */
.panel {
    flex: 1 1 0%; /* Todos del mismo tamaño por defecto, con flex-basis 0% para forzar igualdad matemática */
    width: 0; /* Anula el contenido interno para que Flexbox mande absolutamente */
    min-width: 250px; /* Un mínimo para que en pantallas pequeñas haya scroll en lugar de aplastarse demasiado */
}

/* Cuando el usuario presiona el botón de agrandar, toma más espacio de la fila */
.panel.enlarged {
    flex: 2.2 !important; /* Más del doble de ancho */
}

/* HEADER DEL PANEL */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background-color: var(--gold-pop);
    border-bottom: 3px solid var(--ink-black);
    gap: 8px;
    height: 48px;
    flex-shrink: 0;
}

.panel-secondary .panel-header {
    background-color: var(--green-radio);
}

.panel-tertiary .panel-header {
    background-color: var(--orange-exp);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-title {
    font-family: 'Luckiest Guy', cursive;
    font-size: clamp(1rem, 1.15vw, 1.2rem);
    color: var(--ink-black);
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* CONTENEDOR DE ATAJOS INTER-PANEL */
.panel-shortcut-buttons {
    display: flex;
    gap: 4px;
}

/* Pequeños botones con estilo de cómic (Badge) */
.btn-shortcut {
    border: 2px solid var(--ink-black);
    color: var(--ink-black);
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 0.72rem;
    text-transform: uppercase;
    padding: 3px 8px;
    cursor: pointer;
    border-radius: 4px;
    box-shadow: 1px 1px 0px var(--ink-black);
    transition: all 0.1s ease;
    letter-spacing: 0.5px;
}

.btn-shortcut:active {
    transform: translate(1px, 1px);
    box-shadow: 0px 0px 0px var(--ink-black);
}

.btn-shortcut.btn-ebook { background-color: #E9B824; }
.btn-shortcut.btn-wbook { background-color: #2ECC71; }
.btn-shortcut.btn-app { background-color: #FF6B00; }

.header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* IFRAME */
.panel iframe {
    flex: 1;
    width: 100%;
    height: 100%;
    background-color: var(--white);
    border: none;
}

/* RESPONSIVE (MÓVIL) */
@media (max-width: 768px) {
    #main-container {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 8px;
        padding: 8px;
    }
    
    .panel {
        height: 80vh !important; /* Cada panel ocupa el 80% del alto para ser legible y usable */
        width: 100% !important;
        flex: none !important; /* Desactivar flex automático en móvil */
        box-shadow: 3px 3px 0px var(--ink-black);
    }
    
    /* Si se agranda una ventana en móvil, toma casi toda la pantalla */
    .panel.enlarged {
        height: 95vh !important; 
    }

    .panel-header {
        padding: 4px 8px;
        height: 44px;
    }
    
    .header-left {
        width: auto;
    }

}


/* BOTONES DE ICONO (agrandar, pantalla completa, cerrar) */
.icon-btn {
    background-color: var(--white);
    color: var(--ink-black);
    border: 2px solid var(--ink-black);
    box-shadow: 2px 2px 0px var(--ink-black);
    width: 30px;
    height: 30px;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    border-radius: 6px;
    transition: transform 0.1s, box-shadow 0.1s, background-color 0.15s;
    flex-shrink: 0;
}
.icon-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-btn:hover { background-color: var(--yellow-soft); }
.icon-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 0px 0px 0px var(--ink-black);
}
.panel.enlarged .btn-width-toggle {
    background-color: var(--ink-black);
    color: var(--white);
}

/* AVISO: TODOS LOS PANELES CERRADOS */
.all-closed {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 1rem;
    text-align: center;
    font-weight: 600;
    z-index: 50;
}
.all-closed.hidden { display: none; }
.all-closed-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.all-closed .btn-shortcut { font-size: 0.9rem; padding: 8px 16px; box-shadow: 3px 3px 0 var(--ink-black); }

/* PANTALLA DE ACCESO */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: #0C0E0C;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    overflow-y: auto;
    padding: 2rem 1rem;
    font-family: 'Poppins', sans-serif;
}
.auth-card {
    background: #FFFFFF;
    padding: 32px;
    border: 4px solid #000;
    box-shadow: 8px 8px 0px #000;
    width: 100%;
    max-width: 400px;
    margin: auto;
}
.auth-title { text-align: center; margin-bottom: 1.5rem; }
.auth-title h1 {
    font-family: 'Luckiest Guy', cursive;
    letter-spacing: 1px;
    font-size: 1.7rem;
    font-weight: 400;
    color: #000;
    margin: 0;
    text-transform: uppercase;
    line-height: 1.15;
}
.auth-form { display: flex; flex-direction: column; gap: 1rem; }
.auth-form label { display: block; font-weight: 700; margin-bottom: 0.3rem; font-size: 0.95rem; }
.auth-form input {
    width: 100%;
    padding: 12px;
    border: 1.5px solid #000;
    box-shadow: 4px 4px 0px #000;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
    font-size: 0.95rem;
    outline: none;
}
.auth-form input:focus { background-color: var(--yellow-soft); }
.auth-btn {
    width: 100%;
    background: #FF6B00;
    color: #000;
    padding: 14px;
    border: 1.5px solid #000;
    box-shadow: 4px 4px 0px #000;
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    font-size: 1.05rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: transform 0.1s, box-shadow 0.1s;
}
.auth-btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #000; }
.auth-btn:disabled { opacity: 0.7; cursor: wait; }
.auth-msg { display: none; margin-top: 16px; padding: 10px 12px; font-size: 0.88rem; font-weight: 600; text-align: center; border: 1.5px solid #000; }
.auth-msg.is-error { display: block; background: #FFF1E6; color: #000; border-left: 6px solid #FF6B00; }
.auth-msg.is-ok { display: block; background: #E9FBF0; color: #000; border-left: 6px solid #2ECC71; }
.auth-foot { text-align: center; margin-top: 1.4rem; display: flex; flex-direction: column; gap: 0.7rem; }
.auth-foot p { font-size: 0.85rem; font-weight: 500; margin: 0; color: #333; }
.auth-link {
    background: none;
    border: none;
    color: #FF6B00;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    text-decoration: underline;
    font-family: 'Poppins', sans-serif;
}
.auth-consent { font-size: 0.72rem !important; color: #666 !important; line-height: 1.45; }
.auth-consent a { color: #000; font-weight: 700; }
