/* ===== ChattonSystem HERMES Active Recall — Theme ===== */
:root {
    --navy: #001524;
    --navy-50: #0a2030;
    --navy-100: #012a3d;
    --navy-200: #013249;
    --cyan: #00E5FF;
    --cyan-soft: #7df0ff;
    --cyan-deep: #00b8cc;
    --white: #FFFFFF;
    --gray: #E0E6ED;
    --text-dim: #94a3b8;
    --text-muted: #64748b;
    --red: #ff4757;
    --orange: #ffa502;
    --green: #2ed573;
    --radius: 16px;
    --transition: cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 16px; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--navy);
    color: var(--white);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== Canvas Background ===== */
#bg-network {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    opacity: 0.15;
    pointer-events: none;
}

/* ===== Header ===== */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    background: rgba(0, 21, 36, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 229, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 100;
}

.header-logo img { height: 32px; }

.header-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cyan), var(--cyan-deep));
    color: var(--navy);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
    text-transform: uppercase;
    font-family: 'Space Grotesk', sans-serif;
}

.user-avatar::before { content: attr(data-initial); }

.user-name {
    font-size: 14px;
    color: var(--gray);
}

.btn-logout {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text-dim);
    width: 36px; height: 36px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.25s var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.btn-logout:hover {
    border-color: var(--red);
    color: var(--red);
    box-shadow: 0 0 12px rgba(255,71,87,0.3);
}

/* ===== Main ===== */
.app-main {
    position: relative;
    z-index: 1;
    padding-top: 80px;
    padding-bottom: 60px;
    max-width: 1200px;
    margin: 0 auto;
    padding-left: 24px;
    padding-right: 24px;
}

/* ===== Footer ===== */
.app-footer {
    position: fixed;
    bottom: 12px;
    right: 16px;
    z-index: 100;
    opacity: 0.5;
    transition: opacity 0.25s var(--transition);
}
.app-footer:hover {
    opacity: 1;
}
.footer-brand img {
    height: 30px;
    display: block;
}

/* ===== Glass Cards ===== */
.glass-card {
    background: rgba(10, 32, 48, 0.8);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 229, 255, 0.15);
    border-radius: var(--radius);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    transition: all 0.25s var(--transition);
}

.glass-card:hover {
    border-color: rgba(0, 229, 255, 0.3);
}

/* ===== Login Page ===== */
.login-container {
    min-height: calc(100vh - 80px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.login-logo { margin-bottom: 8px; }

.login-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 28px;
    color: var(--cyan);
    text-align: center;
    text-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
}

.login-subtitle {
    color: var(--text-dim);
    font-size: 15px;
    margin-bottom: 12px;
}

.login-card {
    padding: 32px;
    width: 100%;
    max-width: 400px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-label {
    font-size: 14px;
    color: var(--gray);
    font-weight: 500;
}

.form-input {
    background: rgba(0, 21, 36, 0.6);
    border: 1px solid rgba(0, 229, 255, 0.2);
    border-radius: 10px;
    padding: 14px 16px;
    color: var(--white);
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    transition: all 0.25s var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--cyan);
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.3);
}

.existing-users {
    margin-top: 20px;
    width: 100%;
    max-width: 400px;
}

.users-label {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 12px;
    text-align: center;
}

.users-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.user-card-form { display: inline; }

.user-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(10, 32, 48, 0.8);
    border: 1px solid rgba(0, 229, 255, 0.15);
    border-radius: 12px;
    cursor: pointer;
    color: var(--white);
    font-size: 14px;
    transition: all 0.25s var(--transition);
}

.user-card:hover {
    border-color: var(--cyan);
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.25);
}

/* ===== Buttons ===== */
.btn-cyan {
    background: var(--cyan);
    color: var(--navy);
    border: none;
    border-radius: 10px;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: all 0.25s var(--transition);
    box-shadow: 0 0 20px rgba(0, 229, 255, 0.3);
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-cyan:hover {
    background: var(--cyan-soft);
    box-shadow: 0 0 28px rgba(0, 229, 255, 0.5);
    transform: translateY(-1px);
}

.btn-cyan:active {
    transform: translateY(0);
}

.btn-large {
    font-size: 17px;
    padding: 16px 36px;
}

.btn-outline {
    background: transparent;
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: var(--cyan);
    border-radius: 10px;
    padding: 14px 28px;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    transition: all 0.25s var(--transition);
}

.btn-outline:hover {
    border-color: var(--cyan);
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.25);
}

.btn-text {
    background: none;
    border: none;
    color: var(--cyan);
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-text:hover { color: var(--cyan-soft); }

/* ===== Index Page ===== */
.page-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
}

.page-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 26px;
    color: var(--white);
}

.global-stats-bar {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 20px;
    background: rgba(10, 32, 48, 0.6);
    border-radius: 12px;
    border: 1px solid rgba(0, 229, 255, 0.1);
}

.stat-item.due {
    border-color: rgba(255, 71, 87, 0.3);
}

.stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 22px;
    color: var(--cyan);
}

.stat-item.due .stat-value { color: var(--red); }

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.chapters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.chapter-card {
    position: relative;
    padding: 20px;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 12px;
    overflow: hidden;
}

.chapter-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 32px rgba(0, 229, 255, 0.15);
    border-color: rgba(0, 229, 255, 0.4);
}

.chapter-top-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--accent, var(--cyan));
    box-shadow: 0 0 8px var(--accent, var(--cyan));
}

.chapter-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px; height: 48px;
    background: rgba(0, 229, 255, 0.05);
    border-radius: 12px;
}

.chapter-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chapter-number {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 12px;
    color: var(--text-muted);
}

.chapter-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 17px;
    color: var(--white);
}

.chapter-count {
    font-size: 13px;
    color: var(--text-dim);
}

.chapter-progress {
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-bar-track {
    flex: 1;
    height: 6px;
    background: var(--navy-100);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--bar-color, var(--cyan));
    border-radius: 3px;
    transition: width 0.6s var(--transition);
    box-shadow: 0 0 6px var(--bar-color, var(--cyan));
}

.progress-pct {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray);
    min-width: 40px;
    text-align: right;
}

.due-badge {
    position: absolute;
    top: 12px; right: 12px;
    background: var(--accent, var(--cyan));
    color: var(--navy);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 6px var(--accent, var(--cyan)); }
    50% { box-shadow: 0 0 16px var(--accent, var(--cyan)); }
}

.session-global {
    text-align: center;
    margin: 24px 0;
}

.stats-link {
    text-align: center;
    margin-top: 16px;
}

/* ===== Review Page ===== */
.review-page {
    max-width: 700px;
    margin: 0 auto;
}

.review-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
}

.back-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.back-link:hover { color: var(--cyan); }

.review-progress-bar {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.review-counter {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    color: var(--cyan);
    white-space: nowrap;
}

.card-container {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.flashcard {
    width: 100%;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: card-in 0.4s var(--transition);
}

@keyframes card-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.card-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.card-type-badge {
    background: rgba(0, 229, 255, 0.1);
    border: 1px solid rgba(0, 229, 255, 0.3);
    border-radius: 8px;
    padding: 4px 12px;
    font-size: 12px;
    color: var(--cyan);
    font-weight: 500;
}

.card-section-badge {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 4px 12px;
    font-size: 12px;
    color: var(--text-dim);
}

.card-content {
    min-height: 200px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.card-question {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 20px;
    line-height: 1.5;
    color: var(--white);
}

.card-image { margin: 12px 0; }
.card-image[style*="display:none"], .card-image[style*="display: none"] { display: none !important; margin: 0; }

.card-image img {
    max-width: 100%;
    border-radius: 12px;
    border: 1px solid rgba(0, 229, 255, 0.15);
    cursor: pointer;
    transition: border-color 0.25s;
}

.card-image img:hover {
    border-color: var(--cyan);
}

.card-image-caption {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: center;
}

.mcq-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.mcq-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(10, 32, 48, 0.6);
    border: 1px solid rgba(0, 229, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s var(--transition);
}

.mcq-option:hover {
    border-color: var(--cyan);
    background: rgba(0, 229, 255, 0.05);
}

.mcq-option.selected {
    border-color: var(--cyan);
    background: rgba(0, 229, 255, 0.1);
}

.mcq-option.correct {
    border-color: var(--green);
    background: rgba(46, 213, 115, 0.1);
}

.mcq-option.wrong {
    border-color: var(--red);
    background: rgba(255, 71, 87, 0.1);
}

.mcq-letter {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--navy-100);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    color: var(--cyan);
    flex-shrink: 0;
}

.mcq-option.correct .mcq-letter { background: var(--green); color: var(--navy); }
.mcq-option.wrong .mcq-letter { background: var(--red); color: var(--white); }

.btn-reveal {
    align-self: center;
    margin-top: 12px;
    animation: subtle-pulse 3s infinite;
}

@keyframes subtle-pulse {
    0%, 100% { box-shadow: 0 0 20px rgba(0, 229, 255, 0.3); }
    50% { box-shadow: 0 0 32px rgba(0, 229, 255, 0.5); }
}

.card-back {
    animation: card-flip 0.4s var(--transition);
}

@keyframes card-flip {
    from { opacity: 0; transform: rotateY(10deg); }
    to { opacity: 1; transform: rotateY(0); }
}

.card-answer-box {
    background: rgba(0, 229, 255, 0.08);
    border: 1px solid rgba(0, 229, 255, 0.2);
    border-radius: 12px;
    padding: 16px 20px;
}

.card-answer {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 16px;
    color: var(--white);
    white-space: pre-wrap;
}

.card-explanation {
    font-size: 14px;
    color: var(--text-dim);
    padding: 12px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
}

.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.leitner-boxes {
    display: flex;
    gap: 4px;
}

.leitner-box {
    width: 12px; height: 12px;
    border-radius: 3px;
    background: var(--navy-100);
}

.leitner-box.filled {
    background: var(--cyan);
    box-shadow: 0 0 6px var(--cyan);
}

.card-source-ref {
    font-size: 12px;
    color: var(--text-muted);
    text-decoration: none;
}

.card-source-ref:hover { color: var(--cyan); }

.rating-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 8px;
}

.btn-rate {
    border: none;
    border-radius: 10px;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s var(--transition);
    font-family: 'Inter', sans-serif;
    flex: 1;
}

.btn-difficult {
    background: rgba(255, 71, 87, 0.15);
    color: var(--red);
    border: 1px solid rgba(255, 71, 87, 0.3);
}

.btn-difficult:hover {
    background: rgba(255, 71, 87, 0.25);
    box-shadow: 0 0 16px rgba(255, 71, 87, 0.3);
}

.btn-medium {
    background: rgba(255, 165, 2, 0.15);
    color: var(--orange);
    border: 1px solid rgba(255, 165, 2, 0.3);
}

.btn-medium:hover {
    background: rgba(255, 165, 2, 0.25);
    box-shadow: 0 0 16px rgba(255, 165, 2, 0.3);
}

.btn-easy {
    background: rgba(0, 229, 255, 0.15);
    color: var(--cyan);
    border: 1px solid rgba(0, 229, 255, 0.3);
}

.btn-easy:hover {
    background: rgba(0, 229, 255, 0.25);
    box-shadow: 0 0 16px rgba(0, 229, 255, 0.3);
}

.review-complete {
    text-align: center;
    padding: 40px;
    animation: card-in 0.4s var(--transition);
}

.review-complete h2 {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 24px;
    margin-bottom: 12px;
    color: var(--cyan);
}

.complete-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 24px;
}

/* ===== Stats Page ===== */
.stats-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    padding: 24px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.metric-card.due {
    border-color: rgba(255, 71, 87, 0.3);
}

.metric-icon { font-size: 28px; }

.metric-value {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 32px;
    color: var(--cyan);
}

.metric-card.due .metric-value { color: var(--red); }

.metric-label {
    font-size: 13px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.gauge-circle { margin-bottom: 4px; }

.stats-section-title {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 18px;
    margin-bottom: 16px;
    color: var(--white);
}

.stats-table-card { padding: 24px; }

.stats-table {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stats-table-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0, 229, 255, 0.05);
}

.flex-grow { flex: 1; }

.stats-chapter-name {
    min-width: 180px;
    font-size: 14px;
    color: var(--gray);
}

.stats-pct {
    font-weight: 600;
    color: var(--cyan);
    min-width: 45px;
    text-align: right;
}

.stats-cards {
    font-size: 12px;
    color: var(--text-muted);
    min-width: 80px;
}

.stats-due {
    font-size: 12px;
    color: var(--red);
    min-width: 50px;
}

.stats-due-empty { min-width: 50px; }

/* ===== Lightbox ===== */
.lightbox {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 21, 36, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
    animation: card-in 0.3s ease;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
    border: 2px solid var(--cyan);
    box-shadow: 0 0 40px rgba(0, 229, 255, 0.3);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--navy); }
::-webkit-scrollbar-thumb { background: var(--navy-200); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan-deep); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .app-main { padding-left: 16px; padding-right: 16px; }
    
    .chapters-grid {
        grid-template-columns: 1fr;
    }
    
    .chapter-card { padding: 16px; }
    
    .flashcard { padding: 20px; }
    
    .card-question { font-size: 17px; }
    
    .rating-buttons { flex-direction: column; }
    
    .btn-rate { width: 100%; }
    
    .stats-metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stats-table-row {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .stats-chapter-name { min-width: 100%; }
    
    .global-stats-bar { gap: 8px; }
    
    .stat-item { padding: 6px 14px; }
    
    .review-header { flex-direction: column; align-items: stretch; }
    
    .user-name { display: none; }
}

@media (max-width: 480px) {
    .stats-metrics-grid { grid-template-columns: 1fr; }
    .login-title { font-size: 22px; }
    .page-title { font-size: 22px; }
}