/* checkdiemfu.com — Reddit-inspired theme with dark/light mode */

/* ═══ Dark theme (default) ═══ */
[data-theme="dark"] {
    --bg: #030303;
    --surface: #1a1a1b;
    --surface2: #272729;
    --surface3: #2d2d2f;
    --border: #343536;
    --border-hover: #4a4a4c;
    --text: #d7dadc;
    --text-secondary: #b0b3b8;
    --text-muted: #818384;
    --primary: #ff4500;
    --primary-hover: #ff5722;
    --primary-soft: rgba(255, 69, 0, 0.1);
    --link: #4fbcff;
    --success: #46d160;
    --success-soft: rgba(70, 209, 96, 0.1);
    --warning: #ffd635;
    --warning-soft: rgba(255, 214, 53, 0.1);
    --danger: #ff585b;
    --danger-soft: rgba(255, 88, 91, 0.1);
    --shadow: 0 2px 4px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 28px rgba(0,0,0,0.5);
}
[data-theme="dark"] .theme-icon-dark { display: inline; }
[data-theme="dark"] .theme-icon-light { display: none; }

/* ═══ Light theme ═══ */
[data-theme="light"] {
    --bg: #dae0e6;
    --surface: #ffffff;
    --surface2: #f6f7f8;
    --surface3: #edeff1;
    --border: #ccc;
    --border-hover: #999;
    --text: #1c1c1c;
    --text-secondary: #576f76;
    --text-muted: #878a8c;
    --primary: #ff4500;
    --primary-hover: #e03d00;
    --primary-soft: rgba(255, 69, 0, 0.08);
    --link: #0079d3;
    --success: #46d160;
    --success-soft: rgba(70, 209, 96, 0.1);
    --warning: #e69500;
    --warning-soft: rgba(230, 149, 0, 0.1);
    --danger: #ea0027;
    --danger-soft: rgba(234, 0, 39, 0.08);
    --shadow: 0 2px 4px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 28px rgba(0,0,0,0.12);
}
[data-theme="light"] .theme-icon-dark { display: none; }
[data-theme="light"] .theme-icon-light { display: inline; }

:root {
    --radius: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;
    --transition: 0.15s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    font-size: 14px;
    display: flex;
    flex-direction: column;
}
.page { flex: 1; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ═══ Top loader bar ═══ */
.toploader {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: var(--primary);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 0 8px var(--primary);
}

/* ═══ Navbar ═══ */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    height: 48px;
}
.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}
.navbar .logo {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 4px;
}
.navbar .logo:hover { color: var(--text); text-decoration: none; }
.navbar .logo span { color: var(--text-muted); font-weight: 400; font-size: 15px; }
.nav-right { display: flex; align-items: center; gap: 6px; }
.navbar nav { display: flex; gap: 4px; align-items: center; }
.navbar nav a {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    transition: all var(--transition);
}
.navbar nav a:hover {
    color: var(--text);
    background: var(--surface2);
    text-decoration: none;
}
/* Navbar buttons */
.btn-nav-primary {
    background: var(--primary);
    color: #fff !important;
    font-size: 13px;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: var(--radius-full);
    transition: all var(--transition);
}
.btn-nav-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-nav-outline {
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 700;
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    transition: all var(--transition);
}
.btn-nav-outline:hover { border-color: var(--text-muted); color: var(--text); text-decoration: none; }
/* Theme toggle */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all var(--transition);
    flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--text-muted); color: var(--text); background: var(--surface2); }

/* ═══ Layout ═══ */
.container { max-width: 1000px; margin: 0 auto; padding: 0 16px; }
.page { padding: 20px 0 40px; }
.page-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}

/* ═══ Cards ═══ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 12px;
}
.card:hover { border-color: var(--border-hover); }
.card-header {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 12px;
}

/* ═══ Grid ═══ */
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }

/* ═══ Forms ═══ */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}
.form-group input:focus,
.form-group select:focus {
    border-color: var(--text-secondary);
}
.form-group input::placeholder { color: var(--text-muted); }
.form-group small { display: block; margin-top: 4px; font-size: 12px; color: var(--text-muted); }

/* ═══ Buttons ═══ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 20px;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    line-height: 1.4;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
    text-decoration: none;
}
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #3bba54; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #e5494c; text-decoration: none; }
.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-outline:hover {
    border-color: var(--text-muted);
    color: var(--text);
    background: var(--surface2);
    text-decoration: none;
}
.btn-sm { padding: 4px 12px; font-size: 12px; }
.btn-block { display: flex; width: 100%; }

/* ═══ Table ═══ */
table { width: 100%; border-collapse: collapse; }
th, td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
th {
    color: var(--text-muted);
    font-weight: 700;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* ═══ Badge ═══ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.badge-pending { background: var(--warning-soft); color: var(--warning); }
.badge-paid { background: var(--success-soft); color: var(--success); }
.badge-cancelled { background: var(--danger-soft); color: var(--danger); }
.badge-active { background: var(--primary-soft); color: var(--primary); }

/* ═══ Alert ═══ */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 12px;
    line-height: 1.5;
}
.alert-error { background: var(--danger-soft); color: #ff9b9d; }
.alert-success { background: var(--success-soft); color: #7ee895; }
.alert-info { background: rgba(79, 188, 255, 0.1); color: #7fcfff; }
.alert-warning { background: var(--warning-soft); color: #ffe066; }

/* ═══ Auth pages ═══ */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 88px);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
}
.auth-card h2 {
    text-align: center;
    margin-bottom: 24px;
    font-size: 18px;
    font-weight: 700;
}

/* ═══ Subject card ═══ */
.subject-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition);
}
.subject-card:hover {
    border-color: var(--primary);
}
.subject-card .code {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}
.subject-card .name {
    font-size: 12px;
    color: var(--text-muted);
    margin: 2px 0 12px;
}
.subject-card .price {
    font-size: 22px;
    font-weight: 700;
}
.subject-card .price span {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 400;
}

/* ═══ Key display ═══ */
.key-display {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--success);
    word-break: break-all;
    user-select: all;
}

/* ═══ Payment QR ═══ */
.payment-qr { text-align: center; padding: 16px; }
.payment-qr img {
    max-width: 240px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* ═══ Hero (landing) ═══ */
.hero {
    text-align: center;
    padding: 48px 0 36px;
}
.hero h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
}
.hero p { font-size: 14px; color: var(--text-muted); }

/* ═══ Service cards (landing) ═══ */
.service-grid {
    max-width: 680px;
    margin: 0 auto;
}
.service-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 20px 22px;
    text-align: center;
    transition: all var(--transition);
    color: var(--text);
    cursor: pointer;
}
.service-card:hover {
    text-decoration: none;
    color: var(--text);
    border-color: var(--border-hover);
    background: var(--surface2);
}
.service-active:hover { border-color: var(--primary); }
.service-coming { opacity: 0.55; }
.service-coming:hover { opacity: 1; border-color: var(--text-muted); }
.service-icon { font-size: 36px; margin-bottom: 10px; line-height: 1; }
.service-card h2 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 10px;
}
.service-status {
    display: inline-block;
    padding: 3px 12px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ═══ Coming soon ═══ */
.coming-soon-page {
    text-align: center;
    padding: 80px 20px;
}
.coming-soon-icon { font-size: 56px; margin-bottom: 16px; line-height: 1; }
.coming-soon-page h1 {
    font-size: 28px;
    font-weight: 700;
}

/* ═══ Stats ═══ */
.stat { text-align: center; padding: 16px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ═══ Tabs ═══ */
.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
}
.tab {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    transition: all var(--transition);
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--text); border-bottom-color: var(--primary); }

/* ═══ Utility ═══ */
.text-center { text-align: center; }
.text-dim { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--primary); }
.text-sm { font-size: 12px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ═══ Footer ═══ */
.footer {
    border-top: 1px solid var(--border);
    padding: 16px 0;
    text-align: center;
}
.footer-links {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 6px;
}
.footer-links a {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
}
.footer-links a:hover { color: var(--text-secondary); text-decoration: underline; }
.footer-copy {
    color: var(--text-muted);
    font-size: 12px;
}

/* ═══ Policy page ═══ */
.policy-page { max-width: 720px; margin: 0 auto; }
.policy-page h1 { font-size: 22px; font-weight: 700; margin-bottom: 8px; }
.policy-page .policy-date { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.policy-page h2 { font-size: 16px; font-weight: 700; margin: 24px 0 8px; }
.policy-page p, .policy-page li {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 8px;
}
.policy-page ul, .policy-page ol { padding-left: 20px; margin-bottom: 12px; }
.policy-page strong { color: var(--text); }

/* ═══ Responsive ═══ */
@media (max-width: 640px) {
    .navbar nav { gap: 0; }
    .navbar nav a { font-size: 12px; padding: 6px 8px; }
    .btn-nav-primary, .btn-nav-outline { font-size: 12px; padding: 5px 10px; }
    .hero h1 { font-size: 20px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .auth-card { padding: 20px; }
    .footer-links { gap: 10px; }
    .match-columns { flex-direction: column; }
    .countdown-float { bottom: 16px; right: 16px; }
    .countdown-timer { font-size: 1.2em; padding: 8px 14px; }
}

/* ═══════════════════════════════════════
   EXAM ROOM
   ═══════════════════════════════════════ */

/* Room header info */
.room-header-info {
    display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap;
}
.room-header-info h1 { margin: 0; font-size: 1.3em; }

/* Floating countdown - fixed bottom right */
.countdown-float {
    position: fixed; bottom: 24px; right: 24px; z-index: 100;
}

/* Toast */
.toast-notify {
    position: fixed; bottom: 100px; right: 24px; z-index: 999;
    background: #22c55e; color: #fff; font-weight: 600; font-size: 0.9em;
    padding: 10px 20px; border-radius: 8px;
    opacity: 0; transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
    pointer-events: none;
}
.toast-notify.show { opacity: 1; transform: translateY(0); }

/* Countdown timer */
.room-countdown { }
.countdown-timer {
    font-size: 1.6em; font-weight: 900; color: #22c55e; letter-spacing: 3px;
    padding: 12px 20px; border: 2px solid #22c55e; border-radius: 12px;
    background: var(--surface-2);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    animation: countdownPulse 2s ease-in-out infinite;
    display: inline-block;
}
.countdown-urgent {
    color: #ef4444 !important; border-color: #ef4444 !important;
    animation: countdownPulse 0.8s ease-in-out infinite !important;
}
.countdown-expired {
    font-size: 1.1em; font-weight: 700; color: #ef4444;
    padding: 6px 14px; border: 2px solid #ef4444; border-radius: 8px;
}
@keyframes countdownPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.room-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid var(--border); padding-bottom: 0; flex-wrap: wrap; }
.room-tab { padding: 10px 18px; background: none; border: none; color: var(--text-secondary); cursor: pointer; font-size: 0.9em; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.2s; }
.room-tab:hover { color: var(--text-primary); }
.room-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.tab-count { font-size: 0.8em; opacity: 0.7; margin-left: 4px; }

.room-content { margin-top: 10px; }

.room-question { display: flex; gap: 14px; padding: 16px; margin-bottom: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.q-number { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.85em; flex-shrink: 0; }
.q-body { flex: 1; min-width: 0; }
.q-text { margin-bottom: 12px; line-height: 1.6; white-space: pre-wrap; }
.q-img { margin-bottom: 12px; }
.q-img img { max-width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--border); }
.q-choice .q-img { margin: 4px 0 0 0; display: inline-block; }
.q-choice .q-img img { max-width: 300px; border: none; }

.q-choices { display: flex; flex-direction: column; gap: 6px; }
.q-choice { padding: 10px 14px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; transition: all 0.15s; display: flex; align-items: flex-start; gap: 8px; }
.q-choice:hover { border-color: var(--primary); background: rgba(255,69,0,0.05); }
.q-choice.selected { border-color: var(--primary); background: rgba(255,69,0,0.12); color: var(--primary); font-weight: 600; }
.choice-letter { font-weight: 700; min-width: 18px; }

.q-fillblank { margin-top: 8px; display: flex; align-items: center; gap: 10px; }
.q-fillblank label { font-weight: 600; font-size: 0.9em; white-space: nowrap; }
.input-fill { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1); color: var(--text-primary); font-size: 0.95em; }
.input-fill:focus { border-color: var(--primary); outline: none; }
select.input-fill { cursor: pointer; min-width: 200px; max-width: 100%; }
select.input-fill option { background: var(--surface-1); color: var(--text-primary); }

.input-writing { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1); color: var(--text-primary); font-size: 0.95em; resize: vertical; font-family: inherit; }
.input-writing:focus { border-color: var(--primary); outline: none; }

.match-columns { display: flex; gap: 24px; margin-bottom: 16px; }
.match-col { flex: 1; }
.match-col-header { font-weight: 700; font-size: 0.95em; margin-bottom: 10px; color: var(--text-secondary); }
.match-text { padding: 6px 0; line-height: 1.6; }
.match-answer-grid { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; max-width: 200px; }
.match-answer-header { display: flex; justify-content: space-between; padding: 8px 12px; background: var(--surface-1); font-weight: 700; font-size: 0.85em; color: var(--text-secondary); border-bottom: 1px solid var(--border); }
.match-answer-row { display: flex; align-items: center; justify-content: space-between; padding: 4px 12px; border-bottom: 1px solid var(--border); }
.match-answer-row:last-child { border-bottom: none; }
.match-row-num { font-weight: 700; min-width: 28px; text-align: center; }
.match-input { width: 60px; text-align: center; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface-1); color: var(--text-primary); font-size: 0.95em; font-weight: 700; text-transform: uppercase; transition: border-color 0.2s; }
.match-input:focus { border-color: var(--accent); outline: none; }

.room-passage { background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 16px; }
.passage-text { line-height: 1.8; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); white-space: pre-wrap; }

/* Room cards for room list */
.room-card { display: block; padding: 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--text-primary); transition: all 0.2s; }
.room-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.room-card-closed { opacity: 0.6; }
.room-code { font-size: 1.3em; font-weight: 700; color: var(--primary); }
.room-exam { font-size: 1em; margin: 6px 0; }
.room-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.room-time { margin-top: 6px; }
