/* ==========================================================================
   ECG Companion & Tutor — Enfermero.cl
   Estilos unificados con la plataforma principal + Responsividad 100% Móvil
   ========================================================================== */

:root {
    /* Paleta de colores unificada con Enfermero.cl */
    --clr-navy:        #0d2c54;
    --clr-navy-deep:   #071929;
    --clr-navy-mid:    #122d4e;
    --clr-coral:       #bd4f2a;
    --clr-coral-light: #d96b42;
    --clr-coral-dim:   rgba(189, 79, 42, 0.15);
    --clr-ink:         #0f1923;
    --clr-text:        #1e293b;
    --clr-muted:       #64748b;
    --clr-surface:     #f8fafc;
    --clr-white:       #ffffff;
    --clr-ai-blue:     #1d6fa4;
    --clr-ai-glow:     rgba(29, 111, 164, 0.25);

    /* Variables del Tutor (Tema Oscuro por Defecto) */
    --bg-primary: #071929;
    --bg-secondary: #122d4e;
    --bg-tertiary: #1a385c;
    --bg-card: #0f243a;
    --bg-hover: #1b3d64;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-red: #bd4f2a;          /* Usamos el Coral insignia de Enfermero.cl */
    --accent-red-hover: #a64222;
    --accent-coral: #bd4f2a;
    --accent-coral-light: #d96b42;
    --accent-blue: #1d6fa4;
    --accent-blue-hover: #15557e;
    --accent-cyan: #06b6d4;
    --accent-green: #10b981;
    --accent-amber: #f59e0b;

    --border-color: rgba(255, 255, 255, 0.1);
    --border-light: rgba(255, 255, 255, 0.18);

    --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;

    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 26px;

    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 6px 18px rgba(7, 25, 41, 0.35);
    --shadow-lg: 0 12px 36px rgba(7, 25, 41, 0.5), 0 4px 12px rgba(0, 0, 0, 0.2);

    --sidebar-width: 320px;
    --header-height: 64px;
    --demo-ad-safe-space: 150px;
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-hover: #e2e8f0;

    --text-primary: #0f1923;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --border-color: #e2e8f0;
    --border-light: #cbd5e1;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 14px rgba(13, 44, 84, 0.08);
    --shadow-lg: 0 10px 28px rgba(13, 44, 84, 0.12);
}

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

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Header & Navigation (Estilo Enfermero.cl)
   ========================================================================== */
.app-header {
    height: var(--header-height);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    z-index: 50;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    gap: 1rem;
}

/* Marca Logo */
.app-brand {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    text-decoration: none;
    color: var(--text-primary);
}

.app-brand-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--clr-navy) 0%, var(--clr-ai-blue) 100%);
    border-radius: 50px;
    overflow: hidden;
}
.app-brand-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.app-brand-text {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    line-height: 1.1;
}

.brand-dot {
    color: var(--accent-coral);
    font-style: normal;
}

.brand-sub {
    display: block;
    font-weight: 500;
    font-size: 0.72rem;
    color: var(--accent-cyan);
    letter-spacing: 0.02em;
    font-family: var(--font-body);
}

/* Barra de Navegación */
.app-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    height: 100%;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0.85rem;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    height: 40px;
    white-space: nowrap;
}

.nav-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.nav-btn.active {
    background-color: var(--clr-coral-dim);
    color: var(--accent-coral-light);
    border: 1px solid rgba(189, 79, 42, 0.35);
    box-shadow: 0 2px 8px rgba(189, 79, 42, 0.15);
}

.nav-btn.demo-locked,
.drawer-nav-item.demo-locked {
    color: var(--accent-amber);
}

.nav-btn.demo-locked .lock-icon,
.drawer-nav-item.demo-locked .lock-icon {
    stroke-width: 2.25;
}

.nav-btn.demo-locked:hover,
.drawer-nav-item.demo-locked:hover {
    background-color: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.28);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border-light);
}

/* Selector de Idioma Dropdown */
.lang-dropdown-wrapper {
    position: relative;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.65rem;
    height: 38px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.lang-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.lang-flag {
    font-size: 1.05rem;
    line-height: 1;
}

.lang-menu {
    position: absolute;
    right: 0;
    top: 46px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
    min-width: 145px;
    overflow: hidden;
    z-index: 200;
}

.lang-menu.active {
    display: flex;
}

.lang-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.85rem;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s ease;
}

.lang-menu-item:hover {
    background-color: var(--bg-hover);
}

.lang-menu-item.active {
    background-color: var(--clr-coral-dim);
    color: var(--accent-coral-light);
}

/* ==========================================================================
   Contenedor Principal & Tabs
   ========================================================================== */
.app-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.tab-pane {
    display: none;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.tab-pane.active {
    display: flex;
}

/* Overlay Telón Móvil para Menú Lateral */
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(7, 25, 41, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 140;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* ==========================================================================
   TAB 1: Libro / Manual ECG
   ========================================================================== */
.book-layout {
    display: flex;
    width: 100%;
    height: 100%;
}

.book-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-search {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-input-wrapper svg {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 0.6rem 0.75rem 0.6rem 2.25rem;
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s ease;
}

.search-input:focus {
    border-color: var(--accent-coral);
    box-shadow: 0 0 0 3px var(--clr-coral-dim);
}

.tree-container {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.tree-section-title {
    font-size: 0.72rem;
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent-cyan);
    padding: 0.75rem 0.5rem 0.25rem;
    font-weight: 700;
}

.tree-node {
    list-style: none;
}

.tree-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.55rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s ease;
    margin-bottom: 2px;
}

.tree-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.tree-item.active {
    background-color: var(--accent-blue);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(29, 111, 164, 0.3);
}

.tree-item-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-toggle-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
    color: var(--text-muted);
}

.tree-item.open .tree-toggle-icon {
    transform: rotate(90deg);
}

.tree-children {
    padding-left: 1rem;
    display: none;
}

.tree-item.open + .tree-children {
    display: block;
}

/* Área de Lectura */
.book-content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    overflow: hidden;
}

.reader-toolbar {
    height: 48px;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
}

.reader-topic-title {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.reader-iframe-container {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
    background-color: #ffffff;
    padding-bottom: var(--demo-ad-safe-space);
}

.reader-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* ==========================================================================
   TAB 2: Galería de ECGs Clínicos
   ========================================================================== */
.gallery-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 1.5rem;
    gap: 1.25rem;
    -webkit-overflow-scrolling: touch;
}

.gallery-controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: var(--bg-secondary);
    padding: 1.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

@media (min-width: 992px) {
    .gallery-controls {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.gallery-controls-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 100%;
}

@media (min-width: 992px) {
    .gallery-controls-actions {
        width: auto;
        max-width: 380px;
        flex-shrink: 0;
        flex: 1;
        justify-content: flex-end;
    }
}

.gallery-controls-actions .search-input-wrapper {
    flex: 1;
}

#gallery-count {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.tag-btn {
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.825rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.tag-btn:hover {
    border-color: var(--accent-coral);
    color: var(--text-primary);
}

.tag-btn.active {
    background-color: var(--accent-coral);
    color: #ffffff;
    border-color: var(--accent-coral);
    box-shadow: 0 2px 8px rgba(189, 79, 42, 0.3);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
    padding-bottom: 2rem;
}

.ecg-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
}

.ecg-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-coral);
}

.ecg-card-thumb {
    width: 100%;
    height: 155px;
    background-color: #05080c;
    overflow: hidden;
    position: relative;
}

.ecg-card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.ecg-card:hover .ecg-card-thumb img {
    transform: scale(1.05);
}

.ecg-card-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: space-between;
    gap: 0.75rem;
}

.ecg-card-title {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.35;
}

.ecg-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    border-radius: var(--radius-sm);
    background-color: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.25);
}

/* ==========================================================================
   TAB 3: Intérprete Diagnóstico & Wizard
   ========================================================================== */
.interpreter-layout {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 1.5rem;
    gap: 1.5rem;
    -webkit-overflow-scrolling: touch;
}

.interpreter-hero {
    background: linear-gradient(135deg, rgba(13, 44, 84, 0.6) 0%, rgba(189, 79, 42, 0.2) 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    box-shadow: var(--shadow-md);
}

.interpreter-hero h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
}

.wizard-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.wizard-steps {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.wizard-step-dot {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background-color: var(--bg-tertiary);
    transition: background-color 0.3s ease;
}

.wizard-step-dot.active {
    background-color: var(--accent-coral);
}

.wizard-question {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.wizard-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.wizard-option-btn {
    padding: 0.9rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.925rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.wizard-option-btn:hover {
    border-color: var(--accent-coral);
    background-color: var(--bg-hover);
}

.wizard-option-btn.selected {
    border-color: var(--accent-coral);
    background-color: var(--clr-coral-dim);
}

.wizard-result {
    padding: 1.25rem;
    border-radius: var(--radius-md);
    background-color: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.interp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.interp-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.interp-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-blue);
}

.interp-card-img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    background-color: #ffffff;
    border-radius: var(--radius-md);
    padding: 4px;
}

/* ==========================================================================
   TAB 4: Quiz Clínico
   ========================================================================== */
.quiz-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    padding: 1.5rem;
    -webkit-overflow-scrolling: touch;
}

.quiz-box {
    width: 100%;
    max-width: 760px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.75rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    box-shadow: var(--shadow-lg);
}

.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    font-family: var(--font-display);
}

.quiz-score-badge {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    color: var(--accent-amber);
    font-size: 0.95rem;
}

.quiz-image-container {
    width: 100%;
    max-height: 280px;
    background-color: #000000;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.quiz-image-container img {
    max-width: 100%;
    max-height: 280px;
    object-fit: contain;
}

.quiz-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.75rem;
}

.quiz-opt-btn {
    padding: 0.9rem 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
}

.quiz-opt-btn:hover {
    border-color: var(--accent-coral);
    background-color: var(--bg-hover);
}

.quiz-opt-btn.correct {
    background-color: rgba(16, 185, 129, 0.2) !important;
    border-color: var(--accent-green) !important;
    color: #34d399 !important;
}

.quiz-opt-btn.wrong {
    background-color: rgba(189, 79, 42, 0.2) !important;
    border-color: var(--accent-coral) !important;
    color: #f87171 !important;
}

/* Botones Principales */
.btn-primary {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    border: none;
    background: linear-gradient(135deg, var(--clr-coral) 0%, #d96b42 100%);
    color: #ffffff;
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(189, 79, 42, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #a64222 0%, #c85a32 100%);
    transform: translateY(-1px);
}

.btn-secondary {
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-secondary:hover {
    background-color: var(--bg-hover);
}

/* ==========================================================================
   Visor de Alta Resolución Modal Inspector
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(7, 25, 41, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 300;
    padding: 1.5rem;
}

.modal-overlay.active {
    display: flex;
}

.full-version-modal {
    position: fixed;
    inset: 0;
    z-index: 360;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background-color: rgba(7, 25, 41, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.full-version-modal.active {
    display: flex;
}

.full-version-card {
    position: relative;
    width: min(420px, 100%);
    padding: 2rem 1.5rem 1.5rem;
    border: 1px solid rgba(245, 158, 11, 0.28);
    border-radius: var(--radius-lg);
    background:
        linear-gradient(145deg, rgba(245, 158, 11, 0.12), transparent 42%),
        var(--bg-secondary);
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.full-version-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
}

.full-version-close:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.full-version-lock {
    width: 70px;
    height: 70px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    border-radius: 999px;
    background: rgba(245, 158, 11, 0.16);
    color: var(--accent-amber);
}

.full-version-card h2 {
    margin: 0 0 0.45rem;
    font-family: var(--font-display);
    font-size: 1.35rem;
    color: var(--text-primary);
}

.full-version-card p {
    margin: 0 0 1.2rem;
    color: var(--text-secondary);
}

.google-play-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    width: 100%;
    min-height: 46px;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: var(--clr-ink);
    color: var(--clr-white);
    font-family: var(--font-display);
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.google-play-link:hover {
    transform: translateY(-1px);
    background: #000;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 95%;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-toolbar {
    padding: 0.5rem 1.25rem;
    background-color: var(--bg-tertiary);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.modal-body {
    flex: 1;
    overflow: auto;
    background-color: #03060a;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
}

.modal-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.15s ease, filter 0.2s ease;
    cursor: grab;
}

.modal-image.inverted {
    filter: invert(1) hue-rotate(180deg);
}

.modal-image:active {
    cursor: grabbing;
}

/* ==========================================================================
   Hamburger & Mobile Navigation Drawer
   ========================================================================== */
#menu-toggle-btn {
    display: none;
}

.mobile-menu-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 290px;
    height: 100vh;
    height: 100dvh;
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 250;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mobile-menu-drawer.open {
    right: 0;
}

.drawer-header {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    -webkit-overflow-scrolling: touch;
}

.drawer-section-title {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-cyan);
    margin-bottom: 0.5rem;
}

.drawer-nav {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.drawer-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    width: 100%;
}

.drawer-nav-item:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.drawer-nav-item.active {
    background-color: var(--clr-coral-dim);
    color: var(--accent-coral-light);
    border: 1px solid rgba(189, 79, 42, 0.35);
}

.drawer-separator {
    height: 1px;
    background-color: var(--border-color);
    margin: 0.5rem 0;
}

.drawer-setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

/* ==========================================================================
   Breakpoints Responsivos para Dispositivos Móviles (Celulares & Tablets)
   ========================================================================== */

/* Tablets & Pantallas Medianas (<= 868px) */
@media (max-width: 868px) {
    .app-header {
        padding: 0 0.85rem;
    }

    .app-brand-text {
        font-size: 1rem;
    }

    .brand-sub {
        font-size: 0.68rem;
    }

    /* Ocultamos navegación normal en cabecera */
    .app-nav {
        display: none !important;
    }
    
    .header-actions .lang-dropdown-wrapper,
    .header-actions #theme-toggle {
        display: none !important;
    }

    /* Mostramos botón de hamburguesa */
    #menu-toggle-btn {
        display: flex !important;
    }

    .book-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 150;
        width: 85vw;
        max-width: 320px;
        transform: translateX(-100%);
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    }

    .book-sidebar.open {
        transform: translateX(0);
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Celulares Móviles (<= 640px) */
@media (max-width: 640px) {
    :root {
        --header-height: 58px;
    }

    .app-header {
        padding: 0 0.65rem;
        gap: 0.5rem;
    }

    .app-brand-icon {
        width: 32px;
        height: 32px;
    }

    .app-brand-icon svg {
        width: 18px;
        height: 18px;
    }

    .app-brand-text {
        font-size: 0.95rem;
    }

    .icon-btn {
        width: 34px;
        height: 34px;
    }

    /* Galería */
    .gallery-layout {
        padding: 0.85rem;
        gap: 1rem;
    }

    .gallery-controls {
        padding: 0.85rem;
        flex-direction: column;
        align-items: stretch;
    }

    .filter-tags {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 0.35rem;
        scrollbar-width: none;
    }

    .filter-tags::-webkit-scrollbar {
        display: none;
    }

    .gallery-grid {
        grid-template-columns: 1fr;
    }

    .ecg-card-thumb {
        height: 160px;
    }

    /* Intérprete */
    .interpreter-layout {
        padding: 0.85rem;
    }

    .interpreter-hero {
        padding: 1rem;
    }

    .interpreter-hero h2 {
        font-size: 1.15rem;
    }

    .wizard-card {
        padding: 1rem;
    }

    .wizard-options {
        grid-template-columns: 1fr;
    }

    .interp-grid {
        grid-template-columns: 1fr;
    }

    /* Quiz */
    .quiz-layout {
        padding: 0.85rem 0.5rem;
    }

    .quiz-box {
        padding: 1rem;
        gap: 1rem;
    }

    .quiz-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.4rem;
    }

    .quiz-image-container {
        max-height: 200px;
    }

    .quiz-options-grid {
        grid-template-columns: 1fr;
    }

    /* Visor Inspector Modal */
    .modal-overlay {
        padding: 0;
    }

    .modal-content {
        width: 100%;
        height: 100vh;
        height: 100dvh;
        border-radius: 0;
        border: none;
    }

    .modal-toolbar span[data-i18n="modalHint"] {
        display: none;
    }

    .modal-toolbar {
        padding: 0.4rem 0.85rem;
        justify-content: space-between;
    }
}

/* Dispositivos muy pequeños (<= 380px) */
@media (max-width: 380px) {
    .brand-sub {
        display: none;
    }
    
    .nav-btn span {
        display: none;
    }
    
    .nav-btn {
        padding: 0.4rem;
    }
}

/* ==========================================================================
   [DEMO WATERMARK - ESTILOS CSS MARCA DE AGUA]
   (CONSEJO PREMIUM: Para eliminar la marca de agua DEMO en la versión final,
   borra todo este bloque de código entre los comentarios DEMO WATERMARK)
   ========================================================================== */

/* --- Wrapper contenedor --- */
.demo-watermark-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    vertical-align: middle;
}

.demo-watermark-wrapper img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* --- Propiedades comunes de ambas bandas diagonales --- */
.demo-watermark-wrapper::before,
.demo-watermark-wrapper::after {
    content: "";
    position: absolute;

    /* La banda demo.png es horizontal de 3715×190 px.
       Rotamos -35° para obtener una diagonal natural.
       Usamos 160% de ancho para que cubra todo el ancho
       incluso en imágenes más anchas que la banda. */
    width: 160%;
    height: 190px;

    background-image: url('../img/demo.png');
    background-repeat: no-repeat;
    background-size: 100% 100%;  /* estira la banda para llenar el área */

    /* Tenue: visible pero sin saturar */
    opacity: 0.22;

    /* Diagonal de arriba-izquierda a abajo-derecha */
    transform: rotate(-35deg);
    transform-origin: center center;

    pointer-events: none;
    z-index: 10;
    left: -30%;   /* centrado horizontal con el desborde del 160% */
}

/* --- Banda 1: tercio superior --- */
.demo-watermark-wrapper::before {
    top: 15%;
}

/* --- Banda 2: tercio inferior (paralela a la primera) --- */
.demo-watermark-wrapper::after {
    bottom: 15%;
}

/* ==========================================================================
   [FIN DEMO WATERMARK - ESTILOS CSS MARCA DE AGUA]
   ========================================================================== */
