@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@600;700;800&family=Public+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
    /* ExamPass Engineering brand tokens - blueprint navy + steel + a
       "pass" green, echoing the logo marks (see logo_concepts artifact). */
    --bg-dark: #eef2f6;
    --bg-panel: rgba(255, 255, 255, 0.92);
    --panel-soft: #f7f9fb;
    --primary: #173a5e;
    --primary-hover: #0f2a45;
    --secondary: #2e6e9e;
    --accent: #1e8f5b;
    --accent-soft: #e4f5ec;
    --text-main: #101b2d;
    --text-muted: #5c6b7c;
    --border: rgba(16, 27, 45, 0.10);
    --border-strong: rgba(16, 27, 45, 0.18);
    --success: #1e8f5b;
    --error: #c6433f;
    --gold: #b8872f;
    --gold-soft: #f6ead2;
    --font-display: 'Archivo', system-ui, sans-serif;
    --font-body: 'Public Sans', system-ui, sans-serif;
    --font-mono: 'IBM Plex Mono', 'SFMono-Regular', monospace;
}

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

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    background-image:
        linear-gradient(rgba(16,27,45,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(16,27,45,0.05) 1px, transparent 1px),
        radial-gradient(circle at 12% 8%, rgba(23,58,94,0.08), transparent 32%),
        radial-gradient(circle at 88% 82%, rgba(30,143,91,0.07), transparent 32%);
    background-size: 36px 36px, 36px 36px, auto, auto;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

/* Glassmorphism Containers */
.app-container {
    background: var(--bg-panel);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: 24px;
    width: 95%;
    max-width: 900px;
    min-height: 85vh;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

h1, h2, h3 { font-family: var(--font-display); }

.screen { display: none; width: 100%; height: 100%; flex-direction: column; padding: 2.5rem; animation: fadeIn 0.4s ease-out; }
.screen.active { display: flex; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Logo & Headers */
.logo-container { text-align: center; margin-bottom: 3rem; }
.logo-img { max-width: 120px; border-radius: 50%; box-shadow: 0 0 30px rgba(23,58,94,0.4); margin-bottom: 1rem; border: 2px solid rgba(255,255,255,0.1); }
.logo-mark {
    width: 92px; height: 92px; margin: 0 auto 1rem; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    box-shadow: 0 0 30px rgba(23,58,94,0.4);
}
.logo-mark svg { width: 52px; height: 52px; }

/* El logo real (logo.png) trae su propio emblema + wordmark en un
   lienzo cuadrado - se muestra entero, sin recorte circular, porque
   forzar un circulo le cortaria el texto. Solo se usa en tamanos
   grandes (encabezados de pantalla): a 30-42px (appbar, nav) el detalle
   fino se vuelve ilegible, ahi se sigue usando el sello simple (ver
   .appbar-mark). */
.brand-logo-img { width: 130px; height: auto; display: block; margin: 0 auto 1rem; }
.brand-title { font-size: 2.8rem; font-weight: 800; background: linear-gradient(135deg, var(--primary), var(--secondary)); background-clip: text; -webkit-background-clip: text; color: transparent; margin-bottom: 0.5rem; letter-spacing: -1px; }
.brand-subtitle { font-size: 1.1rem; color: var(--text-muted); }

/* Custom Buttons */
.mode-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    width: 100%;
    margin: 0 auto;
}
.mode-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    text-align: left;
    transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 2px rgba(16,27,45,0.04);
}
.mode-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-4px);
    box-shadow: 0 16px 32px -12px rgba(16,27,45,0.16);
}
.mode-card-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}
.mode-card-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    color: var(--text-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.mode-card-desc {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1.5rem;
    flex-grow: 1;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none; color: white; padding: 1.1rem 2rem; font-size: 1rem; font-weight: 600;
    font-family: var(--font-body);
    border-radius: 12px; cursor: pointer; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%; letter-spacing: 0.01em; box-shadow: 0 10px 20px -5px rgba(23,58,94,0.35);
    display: flex; justify-content: center; align-items: center; gap: 0.8rem;
}
.primary-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 24px -6px rgba(23,58,94,0.42); }
.primary-btn:active { transform: translateY(0); }

.secondary-btn {
    background: rgba(0,0,0,0.05); border: 1px solid rgba(0,0,0,0.1); color: var(--text-main);
    padding: 1.2rem 2rem; font-size: 1.1rem; font-weight: 600; border-radius: 12px; cursor: pointer;
    transition: all 0.3s ease; width: 100%; display: flex; justify-content: center; align-items: center; gap: 0.8rem;
}
.secondary-btn:hover { background: rgba(0,0,0,0.08); border-color: rgba(0,0,0,0.2); }

.ghost-btn { background: transparent; border: none; color: var(--text-muted); cursor: pointer; font-weight: 600; transition: 0.2s; }
.ghost-btn:hover { color: var(--primary); }

/* Exam Layout */
.exam-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; padding-bottom: 1.5rem; border-bottom: 1px solid var(--border); }
.badge { background: rgba(0,0,0,0.05); padding: 0.4rem 1rem; border-radius: 30px; font-size: 0.85rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }

.problem-container { background: rgba(255,255,255,0.6); padding: 2rem; border-radius: 16px; border: 1px solid var(--border); margin-bottom: 2rem; box-shadow: inset 0 2px 10px rgba(0,0,0,0.02); }
#problem-text { font-size: 1.3rem; line-height: 1.6; font-family: var(--font-display); }

.options-container { display: flex; flex-direction: column; gap: 1rem; }
.option-item { background: rgba(0,0,0,0.02); border: 1px solid var(--border); padding: 1.2rem; border-radius: 12px; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 1rem; }
.option-item:hover { background: rgba(0,0,0,0.05); border-color: var(--primary); }
.option-item.selected { background: rgba(23,58,94,0.1); border-color: var(--primary); border-width: 2px; }
.option-letter { font-weight: 800; color: var(--primary); font-size: 1.2rem; }

/* Tools Bar */
.exam-footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 2rem; }
.help-actions { display: flex; gap: 1rem; }
.help-btn { background: rgba(0,0,0,0.05); border: 1px solid var(--border); color: var(--text-main); width: 45px; height: 45px; border-radius: 50%; display: flex; justify-content: center; align-items: center; cursor: pointer; transition: 0.2s; font-size: 1.2rem; }
.help-btn:hover { background: var(--secondary); border-color: var(--secondary); color: white; transform: translateY(-2px); }

/* Modals */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.4); backdrop-filter: blur(8px); display: flex; justify-content: center; align-items: flex-start; padding: 5vh 1rem; overflow-y: auto; z-index: 1000; opacity: 0; pointer-events: none; transition: 0.3s; }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content { background: var(--bg-dark); border: 1px solid var(--border); border-radius: 20px; padding: 3rem; max-width: 500px; width: 100%; margin: auto; text-align: center; box-shadow: 0 25px 50px rgba(0,0,0,0.15); transform: translateY(20px); transition: 0.3s; }
.modal-content::-webkit-scrollbar { width: 6px; }
.modal-content::-webkit-scrollbar-track { background: transparent; }
.modal-content::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 10px; }
.modal-overlay.active .modal-content { transform: translateY(0); }

/* Pricing Cards */
.pricing-grid { display: grid; gap: 1.5rem; margin: 2rem 0; }
.pricing-card { background: rgba(0,0,0,0.02); border: 1px solid var(--border); border-radius: 16px; padding: 2rem; cursor: pointer; transition: 0.3s; position: relative; overflow: hidden; }
.pricing-card:hover { border-color: var(--primary); transform: translateY(-4px); background: rgba(23,58,94,0.05); }
.pricing-card.premium { border-color: var(--gold); background: linear-gradient(135deg, rgba(184,135,47,0.05), transparent); }
.pricing-price { font-size: 2.5rem; font-family: var(--font-display); font-weight: 800; margin: 1rem 0; color: var(--text-main); }
.tag {
    display: inline-flex; align-items: center; gap: 0.35em;
    position: static; width: fit-content;
    background: var(--gold-soft); color: var(--gold);
    font-family: var(--font-mono); font-size: 0.68rem; font-weight: 600;
    letter-spacing: 0.08em; padding: 0.3em 0.75em; border-radius: 999px;
    margin-bottom: 0.9rem;
}
.tag::before { content: '\2726'; font-size: 0.85em; }
.tag.tag-primary { background: rgba(23,58,94,0.1); color: var(--primary); }

/* Forms */
.form-group { margin-bottom: 1.5rem; text-align: left; }
.form-input { width: 100%; padding: 1rem; background: rgba(255,255,255,0.8); border: 1px solid var(--border); border-radius: 8px; color: var(--text-main); font-family: var(--font-body); outline: none; transition: 0.2s; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(23,58,94,0.2); }

/* Results */
.score-container { text-align: center; padding: 3rem; background: rgba(0,0,0,0.03); border-radius: 20px; border: 1px solid var(--border); margin: 2rem auto; max-width: 400px; }
.score-percentage { font-size: 5rem; font-family: var(--font-display); font-weight: 800; line-height: 1; margin-bottom: 0.5rem; }
.score-percentage.pass { color: var(--success); text-shadow: 0 0 30px rgba(16, 185, 129, 0.4); }
.score-percentage.fail { color: var(--error); text-shadow: 0 0 30px rgba(239, 68, 68, 0.4); }
.status-badge { display: inline-block; padding: 0.6rem 2rem; border-radius: 30px; font-weight: 800; letter-spacing: 1px; }

/* Study List */
.study-list { display: flex; flex-direction: column; gap: 1.5rem; margin-top: 2rem; overflow-y: auto; padding-right: 1rem; max-height: 60vh; }
.study-list::-webkit-scrollbar { width: 8px; }
.study-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); border-radius: 10px; }
.study-list::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 10px; }

.study-card { background: rgba(255,255,255,0.7); border: 1px solid var(--border); border-radius: 16px; padding: 2rem; transition: 0.3s; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.study-card:hover { border-color: rgba(0,0,0,0.2); }
.study-card h2 { font-size: 1.2rem; margin: 1rem 0; font-family: var(--font-body); font-weight: 500; line-height: 1.5; }
.study-solution-title { color: var(--primary); font-weight: 700; text-transform: uppercase; font-size: 0.85rem; letter-spacing: 1px; margin-bottom: 1rem; }
.study-procedure { color: var(--text-muted); line-height: 1.6; }

/* ============================================
   APP BAR (dashboard header: brand mark + profile entry)
   ============================================ */
.appbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 2rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.appbar-brand { display: flex; align-items: center; gap: 0.85rem; text-align: left; min-width: 0; }
.appbar-mark {
    width: 42px; height: 42px; flex: none; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 18px -8px rgba(23,58,94,0.55);
}
.appbar-mark svg { width: 24px; height: 24px; display: block; }
.appbar-brand-text { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; overflow: hidden; }
.appbar-brand-text strong { font-family: var(--font-display); font-size: 1rem; font-weight: 800; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-brand-text span { font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--secondary); }

.avatar-btn {
    width: 44px; height: 44px; border-radius: 50%; flex: none;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff; border: none; cursor: pointer;
    font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 18px -8px rgba(23,58,94,0.55);
    transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.avatar-btn:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 12px 22px -8px rgba(23,58,94,0.6); }
.avatar-btn:active { transform: translateY(0) scale(0.98); }

/* ============================================
   STAT STRIP (quick stats on the dashboard)
   ============================================ */
.stat-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    width: 100%;
    margin-bottom: 2rem;
}
.stat-tile {
    background: var(--panel-soft);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.1rem 1.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.stat-tile-label {
    font-family: var(--font-mono);
    font-size: 0.64rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}
.stat-tile-value {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 800;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}
.stat-tile-value.accent { color: var(--accent); }

/* ============================================
   PROFILE SCREEN
   ============================================ */
.profile-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    text-align: left;
}
.profile-header > div { min-width: 0; flex: 1 1 200px; }
.profile-name { word-break: break-word; }
.profile-avatar-lg {
    width: 84px; height: 84px; border-radius: 50%; flex: none;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 800; font-size: 2.1rem;
    box-shadow: 0 16px 30px -12px rgba(23,58,94,0.5);
}
.profile-name { font-family: var(--font-display); font-size: 1.4rem; font-weight: 800; color: var(--text-main); margin-bottom: 0.15rem; }
.profile-sub { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 0.65rem; }
.plan-pill {
    display: inline-flex; align-items: center; gap: 0.4em;
    font-family: var(--font-mono); font-size: 0.7rem; font-weight: 600;
    letter-spacing: 0.05em; text-transform: uppercase;
    padding: 0.35em 0.9em; border-radius: 999px;
    background: var(--panel-soft); color: var(--text-muted); border: 1px solid var(--border);
}
.plan-pill.is-pro { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.plan-pill.is-pro::before { content: '\2726'; }
.plan-pill.is-gold { background: var(--gold-soft); color: var(--gold); border-color: transparent; }
.plan-pill.is-gold::before { content: '\2726'; }

.profile-section { margin-bottom: 2.25rem; text-align: left; }
.profile-section-title {
    font-family: var(--font-display); font-size: 0.95rem; font-weight: 700;
    margin-bottom: 1rem; color: var(--text-main);
}
.profile-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
}
.profile-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}
.profile-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.85rem 0; border-bottom: 1px solid var(--border);
    gap: 1rem; flex-wrap: wrap;
}
.profile-row:last-child { border-bottom: none; padding-bottom: 0; }
.profile-row-label { color: var(--text-muted); font-size: 0.9rem; }
.profile-row-value { font-weight: 600; color: var(--text-main); font-family: var(--font-mono); font-size: 0.9rem; }
.profile-actions-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.profile-actions-row > * { width: auto; flex: 1 1 180px; }

/* Responsive & Mobile Fixes */
img {
    max-width: 100%;
    height: auto;
}

/* Ensure MathJax and tables can scroll horizontally without breaking the layout */
mjx-container[display="true"] {
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
}

table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
}

.problem-container, .study-procedure {
    overflow-x: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}
#problem-text, .option-text {
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
}

@media (max-width: 768px) {
    .app-container {
        width: 100%;
        border-radius: 0;
        min-height: 100vh;
        border: none;
    }
    
    .screen {
        padding: 1.5rem 1rem;
    }
    
    .brand-title {
        font-size: 2rem;
    }
    
    .problem-container {
        padding: 1.5rem 1rem;
    }
    
    .mode-cards {
        /* minmax(0,1fr) y no solo 1fr: un track de grid sin minimo
           explicito se dimensiona por el min-content de su contenido
           (ej. el texto del boton), lo que puede desbordar el ancho
           del viewport en vez de que el texto haga wrap. Mismo arreglo
           en .stat-strip y .profile-stat-grid aqui abajo. */
        grid-template-columns: minmax(0, 1fr);
    }
    .stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .profile-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

    .exam-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .exam-header > div:last-child {
        text-align: left !important;
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .exam-footer {
        flex-direction: column;
        gap: 1.5rem;
    }
    
    .help-actions {
        width: 100%;
        justify-content: center;
    }
    
    .exam-footer > div:last-child {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }
    
    .modal-content {
        padding: 2rem 1.5rem;
    }

    .appbar-brand-text strong { font-size: 0.9rem; }
    .profile-header { gap: 1rem; }
    .profile-avatar-lg { width: 64px; height: 64px; font-size: 1.6rem; }
    .profile-actions-row > * { flex: 1 1 100%; }
}
