/* =============================================
   ระบบคลังข้อสอบ - Main Stylesheet
   ============================================= */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 60px;
    --topbar-height: 56px;
    --primary: #2c5f8a;
    --primary-dark: #1e4263;
    --primary-light: #e8f0f7;
    --accent: #d4a843;
    --bg-light: #f4f6f9;
    --text-dark: #2c3e50;
    --text-muted: #7f8c8d;
    --border-color: #dee2e6;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; }

body {
    font-family: 'Sarabun', sans-serif;
    font-size: 15px;
    background: var(--bg-light);
    color: var(--text-dark);
    margin: 0;
    min-height: 100vh;
}

/* =============================================
   Sidebar
   ============================================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: linear-gradient(180deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #fff;
    z-index: 1000;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width 0.3s ease;
    box-shadow: 2px 0 10px rgba(0,0,0,0.15);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}

.sidebar.collapsed .sidebar-text { display: none; }
.sidebar.collapsed .sidebar-section { display: none; }

.sidebar-header {
    padding: 16px 20px;
    font-size: 18px;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.sidebar-header i { font-size: 24px; color: var(--accent); }

.sidebar-nav { padding: 10px 0; }

.sidebar-section {
    padding: 14px 20px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.45);
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.sidebar-link.active {
    background: rgba(255,255,255,0.15);
    color: #fff;
    border-left-color: var(--accent);
    font-weight: 600;
}

.sidebar-link i { font-size: 18px; min-width: 20px; text-align: center; }

/* =============================================
   Main Content
   ============================================= */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed);
}

.top-navbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.sidebar-toggle {
    font-size: 22px;
    color: var(--text-dark);
    padding: 4px 8px;
}

.content-wrapper {
    padding: 24px;
}

/* =============================================
   Cards
   ============================================= */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.card-header {
    background: #fff;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    padding: 14px 20px;
    border-radius: 10px 10px 0 0 !important;
}

.card-body { padding: 20px; }

/* Stat Cards */
.stat-card {
    border-radius: 12px;
    padding: 20px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.stat-card .stat-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 48px;
    opacity: 0.2;
}

.stat-card .stat-number {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 13px;
    opacity: 0.85;
    margin-top: 4px;
}

.stat-bg-1 { background: linear-gradient(135deg, #2c5f8a, #3a7bc8); }
.stat-bg-2 { background: linear-gradient(135deg, #27ae60, #2ecc71); }
.stat-bg-3 { background: linear-gradient(135deg, #d4a843, #f0c14b); }
.stat-bg-4 { background: linear-gradient(135deg, #8e44ad, #9b59b6); }

/* =============================================
   Tables
   ============================================= */
.table { font-size: 14px; }
.table th {
    background: var(--primary-light);
    font-weight: 600;
    color: var(--primary-dark);
    white-space: nowrap;
    padding: 10px 12px;
}

.table td { padding: 10px 12px; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8f9ff; }

/* =============================================
   Forms
   ============================================= */
.form-label { font-weight: 500; margin-bottom: 4px; font-size: 14px; }
.form-control, .form-select { font-size: 14px; border-radius: 6px; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(44,95,138,0.15); }

/* =============================================
   Buttons
   ============================================= */
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

.btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.btn-accent:hover {
    background: #c19a3a;
    border-color: #c19a3a;
    color: #fff;
}

/* =============================================
   Filter Bar
   ============================================= */
.filter-bar {
    background: #fff;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.filter-bar .form-group { margin-bottom: 8px; }
.filter-bar label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }

/* =============================================
   Badges
   ============================================= */
.badge { font-weight: 500; font-size: 12px; padding: 4px 10px; }

/* =============================================
   Login Page
   ============================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.login-card .logo-area {
    text-align: center;
    margin-bottom: 30px;
}

.login-card .logo-area i { font-size: 48px; color: var(--primary); }
.login-card .logo-area h4 { color: var(--primary-dark); margin-top: 10px; font-weight: 700; }

/* =============================================
   Question Display
   ============================================= */
.question-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--primary);
}

.question-card.used { border-left-color: var(--accent); }
.question-card.draft { border-left-color: #95a5a6; }

.question-number {
    font-size: 13px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.question-text {
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 12px;
}

.question-choices {
    padding-left: 0;
    list-style: none;
}

.question-choices li {
    padding: 6px 12px;
    margin: 4px 0;
    border-radius: 6px;
    background: var(--bg-light);
    font-size: 14px;
}

.question-choices li.correct {
    background: #d4edda;
    font-weight: 600;
}

.question-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    font-size: 12px;
}

.question-meta .meta-tag {
    background: var(--primary-light);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 12px;
}

/* =============================================
   Exam Create Modes
   ============================================= */
.mode-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.mode-card {
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.mode-card:hover { border-color: var(--primary); background: var(--primary-light); }
.mode-card.selected { border-color: var(--primary); background: var(--primary-light); box-shadow: 0 0 0 3px rgba(44,95,138,0.2); }
.mode-card i { font-size: 36px; color: var(--primary); margin-bottom: 10px; }
.mode-card h5 { font-weight: 700; }
.mode-card p { font-size: 13px; color: var(--text-muted); margin: 0; }

/* =============================================
   Practice / Kahoot Style
   ============================================= */
.practice-join {
    text-align: center;
    padding: 40px;
}

.practice-join .code-display {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 8px;
    color: var(--primary);
    margin: 20px 0;
}

.practice-choice {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 20px;
}

.practice-choice-btn {
    border: none;
    border-radius: 10px;
    padding: 20px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s;
}

.practice-choice-btn:hover { transform: scale(1.03); }
.practice-choice-btn:active { transform: scale(0.97); }

.choice-a { background: #e74c3c; }
.choice-b { background: #3498db; }
.choice-c { background: #f39c12; }
.choice-d { background: #27ae60; }

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }
    .sidebar.show { transform: translateX(0); }
    .main-content { margin-left: 0 !important; }
    .mode-selector { grid-template-columns: 1fr; }
    .practice-choice { grid-template-columns: 1fr; }
    .content-wrapper { padding: 16px; }
}

/* =============================================
   Print Styles
   ============================================= */
@media print {
    .sidebar, .top-navbar, .filter-bar, .btn { display: none !important; }
    .main-content { margin-left: 0 !important; }
    .content-wrapper { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ddd; }
}
