/* ═══════════════════════════════════════════════════════════
   TAT Competency Exam System — Design System
   Dark mode with glassmorphism, vibrant accents
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Noto+Sans+Thai:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ─────────────────────────────────────── */
:root {
    /* Colors */
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-glass: rgba(255, 255, 255, 0.05);
    --bg-glass-hover: rgba(255, 255, 255, 0.08);
    --border-glass: rgba(255, 255, 255, 0.1);
    --border-glass-hover: rgba(255, 255, 255, 0.2);

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

    --accent-blue: #3b82f6;
    --accent-blue-glow: rgba(59, 130, 246, 0.3);
    --accent-purple: #8b5cf6;
    --accent-purple-glow: rgba(139, 92, 246, 0.3);
    --accent-emerald: #10b981;
    --accent-emerald-glow: rgba(16, 185, 129, 0.3);
    --accent-amber: #f59e0b;
    --accent-amber-glow: rgba(245, 158, 11, 0.3);
    --accent-rose: #f43f5e;
    --accent-rose-glow: rgba(244, 63, 94, 0.3);
    --accent-cyan: #06b6d4;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --gradient-success: linear-gradient(135deg, #10b981, #06b6d4);
    --gradient-danger: linear-gradient(135deg, #f43f5e, #f59e0b);
    --gradient-bg: linear-gradient(135deg, #0a0e1a 0%, #1a1040 50%, #0a0e1a 100%);

    /* Spacing */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow-blue: 0 0 24px rgba(59, 130, 246, 0.2);
    --shadow-glow-purple: 0 0 24px rgba(139, 92, 246, 0.2);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ── Reset & Base ─────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', 'Noto Sans Thai', sans-serif;
    background: var(--gradient-bg);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Animated background orbs */
body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    z-index: -1;
    animation: float 20s ease-in-out infinite;
}
body::before {
    width: 600px;
    height: 600px;
    background: var(--accent-blue);
    top: -200px;
    right: -200px;
}
body::after {
    width: 500px;
    height: 500px;
    background: var(--accent-purple);
    bottom: -200px;
    left: -200px;
    animation-delay: -10s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    25% { transform: translate(30px, -30px) rotate(5deg); }
    50% { transform: translate(-20px, 20px) rotate(-5deg); }
    75% { transform: translate(15px, 15px) rotate(3deg); }
}

/* ── Glass Card ───────────────────────────────────────── */
.glass-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 2rem;
    transition: var(--transition-base);
}
.glass-card:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-glass-hover);
    box-shadow: var(--shadow-md);
}

/* ── Container ────────────────────────────────────────── */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.container-sm {
    max-width: 500px;
    margin: 0 auto;
    padding: 2rem;
}

.container-md {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem;
}

/* ── Typography ───────────────────────────────────────── */
h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.3;
    color: var(--text-primary);
}
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }

.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-center { text-align: center; }

/* ── Buttons ──────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-glow-blue);
}
.btn-primary:hover {
    box-shadow: 0 0 32px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.2);
}
.btn-success:hover {
    box-shadow: 0 0 32px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--gradient-danger);
    color: white;
}
.btn-danger:hover {
    box-shadow: 0 0 32px rgba(244, 63, 94, 0.4);
    transform: translateY(-1px);
}

.btn-ghost {
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}
.btn-ghost:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-glass-hover);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

.btn-block {
    width: 100%;
}

/* ── Form Inputs ──────────────────────────────────────── */
.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    outline: none;
    transition: var(--transition-base);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--accent-blue-glow);
}

.form-textarea {
    resize: vertical;
    min-height: 120px;
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

/* ── Navbar ───────────────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: rgba(10, 14, 26, 0.8);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-glass);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    font-size: 1.2rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.navbar-brand .logo-icon {
    font-size: 1.5rem;
}

.navbar-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
}

.navbar-nav a {
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition-fast);
}

.navbar-nav a:hover,
.navbar-nav a.active {
    color: var(--text-primary);
    background: var(--bg-glass);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ── Timer ────────────────────────────────────────────── */
.timer-container {
    text-align: center;
    margin-bottom: 1.5rem;
}

.timer-display {
    font-size: 3rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    letter-spacing: 2px;
}

.timer-warning { color: var(--accent-amber); }
.timer-danger { color: var(--accent-rose); animation: pulse 0.5s ease infinite; }
.timer-safe { color: var(--accent-emerald); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Progress Bar ─────────────────────────────────────── */
.progress-container {
    margin-bottom: 1.5rem;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.progress-bar {
    height: 6px;
    background: var(--bg-glass);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: 3px;
    transition: width 0.5s ease;
}

/* ── Question Card ────────────────────────────────────── */
.question-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.question-text {
    font-size: 1.15rem;
    line-height: 1.7;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.question-category {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-radius: 100px;
    margin-bottom: 1rem;
}

.category-cc { background: var(--accent-blue-glow); color: var(--accent-blue); }
.category-sc { background: var(--accent-purple-glow); color: var(--accent-purple); }
.category-fc { background: var(--accent-emerald-glow); color: var(--accent-emerald); }
.category-mc { background: var(--accent-amber-glow); color: var(--accent-amber); }

/* ── Choice Buttons ───────────────────────────────────── */
.choices-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.choice-btn {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-base);
    text-align: left;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    width: 100%;
}

.choice-btn:hover {
    background: var(--bg-glass-hover);
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 1px var(--accent-blue-glow);
    transform: translateX(4px);
}

.choice-btn.selected {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
    box-shadow: var(--shadow-glow-blue);
}

.choice-label {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: var(--transition-base);
}

.choice-btn.selected .choice-label {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
}

/* ── Badge ────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-success { background: var(--accent-emerald-glow); color: var(--accent-emerald); }
.badge-warning { background: var(--accent-amber-glow); color: var(--accent-amber); }
.badge-danger { background: var(--accent-rose-glow); color: var(--accent-rose); }
.badge-info { background: var(--accent-blue-glow); color: var(--accent-blue); }

/* ── Table ────────────────────────────────────────────── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th {
    padding: 0.85rem 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-glass);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.data-table tr:hover td {
    background: var(--bg-glass);
}

/* ── Dashboard Cards Grid ─────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: var(--transition-base);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-glass-hover);
}

.stat-card .stat-icon {
    font-size: 2rem;
    margin-bottom: 0.75rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 0.25rem;
}

.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── Exam Type Cards (Dashboard) ──────────────────────── */
.exam-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
    gap: 1.5rem;
}

.exam-type-card {
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    text-align: center;
    transition: var(--transition-base);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    position: relative;
    overflow: hidden;
}

.exam-type-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.exam-type-card.sjt-card::before {
    background: var(--gradient-primary);
}

.exam-type-card.mc-card::before {
    background: var(--gradient-success);
}

.exam-type-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-glass-hover);
}

.exam-type-card .exam-icon {
    font-size: 3.5rem;
    margin-bottom: 1rem;
}

.exam-type-card h3 {
    margin-bottom: 0.5rem;
}

.exam-type-card .exam-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.exam-type-card .exam-meta {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ── Alert Messages ───────────────────────────────────── */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    color: var(--accent-blue);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--accent-emerald);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    color: var(--accent-amber);
}

.alert-danger {
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.2);
    color: var(--accent-rose);
}

/* ── Login Page ───────────────────────────────────────── */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-glass);
    backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 3rem;
    box-shadow: var(--shadow-lg);
}

.login-card .logo-section {
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .logo-icon {
    font-size: 3rem;
    margin-bottom: 0.75rem;
}

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 2rem;
}

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

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 2rem;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
    transition: var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

/* ── Tabs ─────────────────────────────────────────────── */
.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 1px solid var(--border-glass);
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-secondary);
}

.tab-btn.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ── MC Exam Specific ─────────────────────────────────── */
.mc-answer-area {
    width: 100%;
    min-height: 300px;
    padding: 1.5rem;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-primary);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    resize: vertical;
    outline: none;
    transition: var(--transition-base);
}

.mc-answer-area:focus {
    border-color: var(--accent-emerald);
    box-shadow: 0 0 0 3px var(--accent-emerald-glow);
}

/* ── Utility ──────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.hidden { display: none !important; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 768px) {
    .container { padding: 1rem; }
    .navbar { padding: 0.75rem 1rem; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .exam-type-grid { grid-template-columns: 1fr; }
    h1 { font-size: 1.5rem; }
    .glass-card { padding: 1.25rem; }
    .login-card { padding: 2rem; }
}

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-glass); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-glass-hover); }

/* ── Loading spinner ──────────────────────────────────── */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-glass);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Complete page ────────────────────────────────────── */
.complete-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.complete-card {
    text-align: center;
    max-width: 500px;
}

.complete-icon {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: bounceIn 0.6s ease;
}

@keyframes bounceIn {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}
