/* ============================================================
   Random_Test - Modern Cyber-Academic Glassmorphism Design
   โรงเรียนบ้านคลองพลูประชาสรรค์ (KPS School)
   ============================================================ */

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

:root {
    --font-main: 'Prompt', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    
    /* Dark KPS Theme Palette matching reference screenshot */
    --bg-base: #111428;
    --bg-darker: #0b0d1b;
    --bg-card: rgba(30, 32, 60, 0.85);
    --bg-card-hover: rgba(45, 48, 85, 0.9);
    --bg-glass: rgba(17, 20, 40, 0.88);
    
    /* Neon & Accent Colors */
    --primary: #5850ec;       /* KPS Royal Purple/Blue */
    --primary-hover: #4338ca;
    --primary-glow: rgba(88, 80, 236, 0.4);
    --accent-cyan: #06b6d4;   /* Cyan Glow */
    --accent-emerald: #10b981;/* Emerald Success */
    --accent-amber: #f59e0b;  /* Warning Gold */
    --accent-rose: #ef4444;   /* Red Alert / Answer */
    --accent-purple: #8b5cf6; /* Purple Art */
    
    /* Text colors */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    
    /* Borders & Glass */
    --border-glass: rgba(255, 255, 255, 0.12);
    --border-glow: rgba(88, 80, 236, 0.35);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    
    --shadow-glass: 0 12px 40px 0 rgba(0, 0, 0, 0.45);
    --shadow-glow: 0 0 25px rgba(88, 80, 236, 0.35);
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-base);
    background-image: 
        radial-gradient(ellipse at 50% 30%, rgba(88, 80, 236, 0.22) 0%, transparent 65%),
        radial-gradient(at 10% 90%, rgba(6, 182, 212, 0.15) 0px, transparent 50%),
        radial-gradient(at 90% 10%, rgba(139, 92, 246, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.6);
}
::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.3);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ============================================================
   FULLSCREEN LOGIN PORTAL (Matching Reference Image)
   ============================================================ */
.login-screen-wrapper {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background-color: #111428;
    background-image: 
        radial-gradient(circle at 50% 40%, rgba(79, 70, 229, 0.25) 0%, rgba(17, 20, 40, 0.95) 70%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    overflow-y: auto;
}

.login-card {
    width: 100%;
    max-width: 480px;
    background: rgba(30, 34, 64, 0.9);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(88, 80, 236, 0.2);
    padding: 2.5rem 2rem 2rem;
    text-align: center;
    position: relative;
}

.login-logo-container {
    width: 96px;
    height: 96px;
    margin: -70px auto 1.25rem;
    border-radius: 50%;
    background: #ffffff;
    padding: 4px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4), 0 0 0 4px rgba(88, 80, 236, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 50%;
}

.login-school-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.25rem;
    letter-spacing: 0.3px;
}

.login-sub-title {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-bottom: 1.75rem;
}

.login-form-group {
    text-align: left;
    margin-bottom: 1.25rem;
}

.login-form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #cbd5e1;
    margin-bottom: 0.4rem;
    display: block;
}

.login-select, .login-input {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(18, 22, 45, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: #ffffff;
    font-family: var(--font-main);
    font-size: 0.92rem;
    outline: none;
    transition: var(--transition);
}

.login-select:focus, .login-input:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35);
}

.login-select option {
    background: #181b36;
    color: #ffffff;
}

.login-hint {
    font-size: 0.78rem;
    color: #a5b4fc;
    margin-top: 0.5rem;
    text-align: left;
}

.login-btn-submit {
    width: 100%;
    padding: 0.85rem 1.5rem;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #ffffff;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.4);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.login-btn-submit:hover {
    background: linear-gradient(135deg, #4338ca, #4f46e5);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.6);
}

.login-footer-text {
    margin-top: 2rem;
    font-size: 0.76rem;
    color: #64748b;
    text-align: center;
}

/* Glassmorphism Card */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-glass);
    transition: var(--transition);
}

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

/* Top Navbar with School Logo */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    padding: 0.65rem 1.5rem;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.15rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
}

.nav-school-logo {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: contain;
    background: #fff;
    padding: 2px;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.4);
}

.brand-title {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-title .school-name {
    font-size: 1rem;
    font-weight: 700;
    color: #ffffff;
}

.brand-title .proj-name {
    font-size: 0.75rem;
    color: var(--accent-cyan);
    font-weight: 500;
}

.role-switcher {
    display: flex;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-glass);
    padding: 4px;
    border-radius: var(--radius-full);
    gap: 4px;
}

.role-btn {
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 0.45rem 1.1rem;
    border-radius: var(--radius-full);
    font-family: var(--font-main);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.role-btn:hover {
    color: var(--text-main);
}

.role-btn.active {
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: #fff;
    box-shadow: 0 2px 10px rgba(88, 80, 236, 0.4);
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: #fff;
}

.user-info {
    display: flex;
    flex-direction: column;
    font-size: 0.82rem;
}

.user-name {
    font-weight: 600;
    color: var(--text-main);
}

.user-role-label {
    color: var(--accent-cyan);
    font-size: 0.75rem;
}

/* Layout Container */
.main-wrapper {
    max-width: 1400px;
    margin: 1.5rem auto;
    padding: 0 1.5rem;
    min-height: calc(100vh - 120px);
}

/* Buttons & Inputs */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #4f46e5);
    color: #fff;
    box-shadow: 0 4px 15px rgba(88, 80, 236, 0.35);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(88, 80, 236, 0.5);
}

.btn-accent {
    background: linear-gradient(135deg, var(--accent-cyan), #0891b2);
    color: #fff;
    box-shadow: 0 4px 15px rgba(6, 182, 212, 0.35);
}
.btn-accent:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.5);
}

.btn-success {
    background: linear-gradient(135deg, var(--accent-emerald), #059669);
    color: #fff;
}
.btn-success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-danger {
    background: linear-gradient(135deg, var(--accent-rose), #dc2626);
    color: #fff;
}
.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-main);
}
.btn-outline:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 6px;
}

.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control, .form-select {
    width: 100%;
    padding: 0.65rem 0.9rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: var(--font-main);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.form-select option {
    background: #0f172a;
    color: #fff;
}

/* Stat Grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
}

.stat-val {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

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

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    border-radius: var(--radius-md);
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.88rem;
}

.custom-table th {
    background: rgba(15, 23, 42, 0.8);
    padding: 0.85rem 1rem;
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border-glass);
    white-space: nowrap;
}

.custom-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    vertical-align: middle;
}

.custom-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* Badges & Chips */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 500;
}

.badge-subject {
    color: #fff;
    background: rgba(99, 102, 241, 0.2);
    border: 1px solid rgba(99, 102, 241, 0.4);
}

.badge-grade {
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-cyan);
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.badge-seq {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
    border: 1px solid rgba(245, 158, 11, 0.3);
    font-family: monospace;
    font-weight: 600;
}

/* Red Text Importer Preview Cards */
.red-text-highlight {
    color: #ef4444;
    font-weight: 700;
    background: rgba(239, 68, 68, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px dashed rgba(239, 68, 68, 0.4);
}

.correct-option-badge {
    color: #10b981;
    font-weight: 600;
    font-size: 0.8rem;
    background: rgba(16, 185, 129, 0.15);
    padding: 2px 8px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Student Test Room Engine */
.quiz-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    margin-bottom: 1.5rem;
}

.timer-box {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-cyan);
    background: rgba(6, 182, 212, 0.1);
    padding: 0.4rem 1rem;
    border-radius: var(--radius-full);
    border: 1px solid rgba(6, 182, 212, 0.3);
}

.quiz-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1.5rem;
}

@media (max-width: 992px) {
    .quiz-layout {
        grid-template-columns: 1fr;
    }
}

.question-card {
    padding: 1.75rem;
}

.question-num {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--accent-cyan);
    margin-bottom: 0.5rem;
}

.question-title {
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    color: #fff;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-sm);
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-glass);
    cursor: pointer;
    transition: var(--transition);
}

.option-item:hover {
    background: rgba(88, 80, 236, 0.15);
    border-color: rgba(88, 80, 236, 0.4);
}

.option-item.selected {
    background: rgba(88, 80, 236, 0.25);
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(88, 80, 236, 0.3);
}

.option-letter {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

.option-item.selected .option-letter {
    background: var(--primary);
    color: #fff;
}

.nav-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin-top: 1rem;
}

.nav-num-btn {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-glass);
    background: rgba(15, 23, 42, 0.6);
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.nav-num-btn.active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.nav-num-btn.answered {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--accent-emerald);
}

.nav-num-btn.flagged {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.5);
    color: var(--accent-amber);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    width: 100%;
    max-width: 650px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-darker);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    padding: 1.75rem;
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-backdrop.show .modal-content {
    transform: translateY(0);
}

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

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}
.close-btn:hover {
    color: #fff;
}

/* Printable Score Certificate & Reports */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
    }
    
    .navbar, .role-switcher, .btn, .no-print, .close-btn, .login-screen-wrapper {
        display: none !important;
    }
    
    .main-wrapper {
        margin: 0 !important;
        padding: 0 !important;
        max-width: 100% !important;
    }
    
    .glass-card {
        background: #fff !important;
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        color: #000 !important;
    }
    
    .custom-table th {
        background: #f1f5f9 !important;
        color: #000 !important;
        border-bottom: 2px solid #000 !important;
    }
    
    .custom-table td {
        border-bottom: 1px solid #ddd !important;
        color: #000 !important;
    }
    
    .print-header {
        text-align: center;
        margin-bottom: 2rem;
        border-bottom: 2px double #000;
        padding-bottom: 1rem;
    }
    
    .print-title {
        font-size: 1.6rem;
        font-weight: 700;
    }
    
    .print-subtitle {
        font-size: 1rem;
        color: #555;
    }
    
    .certificate-border {
        border: 4px double #1e293b;
        padding: 2.5rem;
        margin: 1.5rem 0;
        text-align: center;
    }
}
