﻿@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
    /* ===== Blue & White Premium Color Palette ===== */
    --primary-color: #2563eb;
    --primary-hover: #3b82f6;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --primary-50: #eff6ff;
    --secondary-color: #f8fafc;
    --text-dark: #0f172a;
    --text-muted: #475569;
    --text-light: #64748b;
    --white: #ffffff;
    --red: #ef4444;
    --yellow: #f59e0b;
    --orange: #f97316;
    --green: #10b981;
    --blue: #3b82f6;
    --purple: #8b5cf6;

    /* Gradients */
    --bg-gradient: linear-gradient(135deg, #eff6ff 0%, #f1f5f9 50%, #e0f2fe 100%);
    --login-gradient: linear-gradient(135deg, #bfdbfe 0%, #eff6ff 50%, #c7d2fe 100%);
    --primary-gradient: linear-gradient(135deg, #2563eb 0%, #3b82f6 50%, #60a5fa 100%);
    --sidebar-gradient: linear-gradient(180deg, #1e3a5f 0%, #1e40af 100%);

    /* Borders & Shadows */
    --border-color: rgba(226, 232, 240, 0.8);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --shadow-glass: 0 8px 32px 0 rgba(37, 99, 235, 0.07);
    --shadow-primary: 0 4px 14px 0 rgba(37, 99, 235, 0.35);

    /* Layout */
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-width: 270px;
    --topbar-height: 72px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Kanit', sans-serif;
}

body {
    background: var(--bg-gradient);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #94a3b8; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* ===== Utilities ===== */
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-danger { color: var(--red); }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.mt-4 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.p-3 { padding: 1rem; }
.bg-light { background-color: rgba(255, 255, 255, 0.5); }
.rounded { border-radius: 0.75rem; }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.flex-1 { flex: 1; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

/* Status Colors */
.bg-blue { background-color: rgba(59, 130, 246, 0.12); color: var(--blue); }
.bg-red { background-color: rgba(239, 68, 68, 0.12); color: var(--red); }
.bg-orange { background-color: rgba(249, 115, 22, 0.12); color: var(--orange); }
.bg-yellow { background-color: rgba(245, 158, 11, 0.12); color: var(--yellow); }
.bg-green { background-color: rgba(16, 185, 129, 0.12); color: var(--green); }
.bg-teal { background-color: rgba(59, 130, 246, 0.12); color: var(--primary-color); }
.bg-purple { background-color: rgba(139, 92, 246, 0.12); color: var(--purple); }

/* ===== Global Loader ===== */
.loader-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.85);
    display: flex; justify-content: center; align-items: center;
    z-index: 99999;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.spinner-wrap {
    display: flex; flex-direction: column; align-items: center; gap: 1.25rem;
}
.spinner {
    border: 3px solid rgba(37, 99, 235, 0.15);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    width: 48px; height: 48px;
    animation: spin 0.8s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}
.spinner-text {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUpFade {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    padding: 0.65rem 1.3rem;
    border: none; border-radius: 0.65rem;
    font-size: 1rem; font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    font-family: 'Kanit', sans-serif;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary-gradient);
    color: var(--white);
    box-shadow: var(--shadow-primary);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.4);
}

.btn-outline {
    background-color: rgba(255, 255, 255, 0.9);
    border: 1.5px solid var(--primary-color);
    color: var(--primary-color);
    backdrop-filter: blur(4px);
}
.btn-outline:hover {
    background-color: var(--primary-color);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.2);
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626, #ef4444);
    color: var(--white);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.3);
}
.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-success {
    background: linear-gradient(135deg, #059669, #10b981);
    color: var(--white);
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.3);
}

.btn-block { width: 100%; }
.btn-sm { padding: 0.4rem 0.85rem; font-size: 0.875rem; border-radius: 0.5rem; }
.btn-lg { padding: 0.85rem 2rem; font-size: 1.1rem; border-radius: 0.75rem; }

.btn-icon {
    background: rgba(255, 255, 255, 0.6); border: 1px solid transparent;
    font-size: 1.1rem; color: var(--text-muted);
    cursor: pointer; width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.btn-icon:hover {
    background: var(--white); color: var(--primary-color);
    box-shadow: var(--shadow); border-color: var(--border-color);
    transform: scale(1.08);
}

/* ===== Layout ===== */
.view-section { display: none; }
.view-section.active { display: block; animation: fadeIn 0.4s ease forwards; }

#main-view { display: none; min-height: 100vh; }
#main-view.active { display: flex; width: 100%; max-width: 100vw; }

/* ===== Sidebar โ€” Dark Navy Blue ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-gradient);
    display: flex; flex-direction: column;
    position: fixed; height: 100vh; left: 0; top: 0; z-index: 100;
    transition: var(--transition);
    box-shadow: 4px 0 24px rgba(30, 58, 95, 0.15);
}

.sidebar-header {
    padding: 1.5rem 1.25rem;
    display: flex; align-items: center; gap: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.logo-wrapper {
    background: linear-gradient(135deg, #60a5fa, #3b82f6);
    color: var(--white); width: 42px; height: 42px;
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    flex-shrink: 0;
}
.sidebar-header h3 {
    font-size: 1rem; font-weight: 600;
    color: #ffffff;
    line-height: 1.3;
}
.sidebar-header h3 small {
    display: block; font-size: 0.75rem; font-weight: 400;
    color: #93c5fd; margin-top: 2px;
}
.close-sidebar {
    display: none; background: none; border: none;
    font-size: 1.25rem; cursor: pointer; color: rgba(255,255,255,0.6);
    margin-left: auto;
    transition: var(--transition);
}
.close-sidebar:hover { color: #fff; }

.user-info {
    padding: 1.25rem;
    display: flex; align-items: center; gap: 0.85rem;
    background: rgba(255, 255, 255, 0.06);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.user-avatar {
    font-size: 1.2rem; color: white;
    background: linear-gradient(135deg, #60a5fa, #818cf8);
    border-radius: 50%; width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 3px 10px rgba(96, 165, 250, 0.3);
    flex-shrink: 0;
}
.user-name { font-weight: 600; font-size: 0.95rem; color: #ffffff; }
.user-role { font-size: 0.8rem; color: #93c5fd; font-weight: 500; }

.nav-links { list-style: none; padding: 1rem 0.75rem; flex: 1; overflow-y: auto; }
.nav-links li { margin-bottom: 3px; }
.nav-item {
    display: flex; align-items: center; gap: 0.85rem;
    padding: 0.8rem 1rem;
    color: rgba(255, 255, 255, 0.65);
    font-weight: 500; font-size: 0.95rem;
    text-decoration: none;
    border-radius: 0.65rem;
    transition: var(--transition);
    position: relative;
}
.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    transform: translateX(4px);
}
.nav-item.active {
    background: rgba(59, 130, 246, 0.25);
    color: #ffffff;
    font-weight: 600;
}
.nav-item.active::before {
    content: '';
    position: absolute; left: 0; top: 50%;
    transform: translateY(-50%);
    width: 4px; height: 60%;
    background: linear-gradient(180deg, #60a5fa, #818cf8);
    border-radius: 0 4px 4px 0;
}
.nav-item i { width: 22px; text-align: center; font-size: 1.05rem; }

.sidebar-footer { padding: 1.25rem; border-top: 1px solid rgba(255, 255, 255, 0.1); }

/* ===== Main Content ===== */
.content-area {
    flex: 1; margin-left: var(--sidebar-width);
    display: flex; flex-direction: column; min-height: 100vh;
    transition: var(--transition);
    min-width: 0;
}

.topbar {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    height: var(--topbar-height);
    display: flex; align-items: center; padding: 0 2rem;
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 50; gap: 1rem;
}
.topbar-title h2 {
    font-size: 1.4rem; font-weight: 600;
    color: var(--text-dark); margin: 0;
    display: flex; align-items: center; gap: 0.5rem;
}
.topbar-title h2 i { color: var(--primary-color); font-size: 1.1rem; }

.page-container {
    padding: 2rem; flex: 1;
    max-width: 1400px; margin: 0 auto; width: 100%;
    min-width: 0;
}
.page { display: none; animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
.page.active { display: block; }

/* ===== Cards ===== */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(226, 232, 240, 0.6);
    border-radius: 1.15rem;
    box-shadow: var(--shadow);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

/* ===== Dashboard ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem; margin-bottom: 2rem;
}
.stat-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 1.15rem;
    box-shadow: var(--shadow);
    display: flex; align-items: center; gap: 1.15rem;
    border: 1px solid rgba(226, 232, 240, 0.4);
    transition: var(--transition);
    position: relative; overflow: hidden;
}
.stat-card::after {
    content: ''; position: absolute; right: -25px; top: -25px;
    width: 100px; height: 100px;
    border-radius: 50%;
    opacity: 0.08;
}
.stat-card:nth-child(1)::after { background: var(--primary-color); }
.stat-card:nth-child(2)::after { background: var(--yellow); }
.stat-card:nth-child(3)::after { background: var(--blue); }
.stat-card:nth-child(4)::after { background: var(--green); }
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }

.stat-icon {
    width: 56px; height: 56px; border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem; flex-shrink: 0;
}
.stat-details p { color: var(--text-muted); font-size: 0.85rem; font-weight: 500; margin-bottom: 4px; }
.stat-details h3 { font-size: 1.75rem; font-weight: 700; color: var(--text-dark); line-height: 1; }

.recent-table-wrap { margin-top: 1.5rem; }
.recent-table-wrap h3 {
    font-size: 1.15rem; font-weight: 600; margin-bottom: 1rem;
    display: flex; align-items: center; gap: 0.5rem;
    color: var(--text-dark);
}
.recent-table-wrap h3 i { color: var(--primary-color); }

/* ===== Forms ===== */
.form-section-title {
    color: var(--primary-color); font-weight: 600;
    margin-bottom: 1.5rem; font-size: 1.15rem;
    border-bottom: 2px solid var(--primary-light);
    padding-bottom: 0.75rem;
    display: flex; align-items: center; gap: 0.5rem;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.25rem; margin-bottom: 1.25rem;
}
.form-group { display: flex; flex-direction: column; gap: 0.5rem; }
.form-group.full-width { grid-column: 1 / -1; }

.form-group label {
    font-weight: 500; font-size: 0.9rem; color: var(--text-dark);
    display: flex; align-items: center; gap: 0.35rem;
}
.form-group label .required { color: var(--red); font-weight: 700; }
.form-group label .editable-badge {
    font-size: 0.7rem; background: var(--primary-light);
    color: var(--primary-color); padding: 1px 6px;
    border-radius: 4px; font-weight: 600;
}

.form-group input:not([type="radio"]):not([type="checkbox"]),
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: 0.6rem;
    font-size: 0.95rem; outline: none;
    transition: var(--transition);
    background: var(--white); color: var(--text-dark);
    font-family: 'Kanit', sans-serif;
}
.form-group input:not([type="radio"]):not([type="checkbox"]):focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}
.form-group textarea { resize: vertical; min-height: 80px; }

.readonly-input {
    background-color: #f8fafc !important;
    color: var(--text-muted) !important;
    cursor: not-allowed;
    border-color: transparent !important;
}

.editable-input {
    background-color: #eff6ff !important;
    border-color: #93c5fd !important;
}
.editable-input:focus {
    border-color: var(--primary-color) !important;
    background-color: var(--white) !important;
}

/* ===== Search Box with Autocomplete ===== */
.search-box { position: relative; width: 100%; }
.search-box input {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.8rem;
    border: 1.5px solid var(--border-color);
    border-radius: 0.75rem;
    font-size: 1rem;
    background: var(--white);
    transition: var(--transition);
    outline: none;
}
.search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}
.search-box .search-icon {
    position: absolute; left: 1rem; top: 50%;
    transform: translateY(-50%);
    color: var(--text-light); font-size: 1rem;
}
.search-box .clear-btn {
    position: absolute; right: 0.75rem; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    color: var(--text-light); cursor: pointer;
    font-size: 0.9rem; padding: 4px;
    display: none;
}
.search-box .clear-btn.visible { display: block; }

.autocomplete-dropdown {
    position: absolute; top: 100%; left: 0; right: 0;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    box-shadow: var(--shadow-lg);
    max-height: 320px; overflow-y: auto;
    z-index: 1000; display: none; margin-top: 4px;
}
.autocomplete-dropdown.visible { display: block; animation: slideUpFade 0.2s ease; }

.autocomplete-item {
    padding: 0.85rem 1rem; cursor: pointer;
    border-bottom: 1px solid rgba(226, 232, 240, 0.5);
    transition: var(--transition);
    display: flex; justify-content: space-between; align-items: center;
}
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--primary-50); }
.autocomplete-item .student-info { display: flex; flex-direction: column; gap: 2px; }
.autocomplete-item .student-name { font-weight: 500; color: var(--text-dark); font-size: 0.95rem; }
.autocomplete-item .student-meta { font-size: 0.8rem; color: var(--text-muted); }
.autocomplete-item .serial-tag {
    font-size: 0.75rem; background: var(--primary-light);
    color: var(--primary-color); padding: 2px 8px;
    border-radius: 6px; font-weight: 500;
}
.autocomplete-no-result {
    padding: 1.5rem; text-align: center; color: var(--text-muted);
    font-size: 0.9rem;
}

/* ===== Student Info Card ===== */
.student-selected-card {
    background: var(--primary-50);
    border: 1.5px solid var(--primary-light);
    border-radius: 0.85rem;
    padding: 1rem 1.25rem;
    display: flex; align-items: center; justify-content: space-between;
    gap: 1rem; margin-bottom: 1.5rem;
    animation: slideInRight 0.3s ease;
}
.student-selected-card .info { display: flex; align-items: center; gap: 1rem; }
.student-selected-card .avatar {
    width: 48px; height: 48px; border-radius: 50%;
    background: var(--primary-gradient);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1.2rem;
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.25);
}
.student-selected-card .detail h4 { font-size: 1.05rem; font-weight: 600; color: var(--text-dark); }
.student-selected-card .detail p { font-size: 0.85rem; color: var(--text-muted); }
.student-selected-card .btn-change {
    background: var(--white); border: 1px solid var(--border-color);
    padding: 0.4rem 0.85rem; border-radius: 0.5rem;
    font-size: 0.85rem; cursor: pointer; color: var(--text-muted);
    transition: var(--transition);
}
.student-selected-card .btn-change:hover { border-color: var(--red); color: var(--red); }

/* ===== Problem Checkboxes ===== */
.problem-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.75rem;
}
.problem-checkbox {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: var(--white);
    border: 1.5px solid var(--border-color);
    border-radius: 0.7rem;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}
.problem-checkbox:hover {
    border-color: var(--primary-hover);
    background: var(--primary-50);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.problem-checkbox.checked {
    border-color: var(--primary-color);
    background: var(--primary-light);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}
.problem-checkbox input[type="checkbox"] { display: none; }
.problem-checkbox .check-icon {
    width: 24px; height: 24px;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
    font-size: 0.75rem; color: transparent;
}
.problem-checkbox.checked .check-icon {
    background: var(--primary-gradient);
    border-color: var(--primary-color);
    color: white;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}
.problem-checkbox .check-label {
    font-size: 0.92rem; color: var(--text-dark); font-weight: 400;
}
.problem-checkbox.checked .check-label {
    font-weight: 500; color: var(--primary-dark);
}

.other-problem-input { margin-top: 0.5rem; display: none; }
.other-problem-input.visible { display: block; animation: slideUpFade 0.2s ease; }

/* ===== Form Divider ===== */
.form-divider {
    border: none; height: 1px;
    background: linear-gradient(to right, transparent, var(--border-color), transparent);
    margin: 1.5rem 0;
}

/* ===== Form Actions ===== */
.form-actions {
    display: flex; justify-content: flex-end; gap: 1rem;
    margin-top: 2rem; align-items: center;
    padding-top: 1.5rem;
    border-top: 1px dashed var(--border-color);
}

/* ===== Tables ===== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 0.85rem;
    border: 1px solid var(--border-color);
}
.data-table {
    width: 100%; border-collapse: separate; border-spacing: 0;
    text-align: left; background: var(--white);
}
.data-table th, .data-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.data-table th {
    background: linear-gradient(180deg, #f8fafc, #f1f5f9);
    font-weight: 600; color: var(--text-muted);
    font-size: 0.82rem; text-transform: uppercase;
    letter-spacing: 0.05em;
    position: sticky; top: 0;
}
.data-table tbody tr { transition: var(--transition); }
.data-table tbody tr:hover { background-color: var(--primary-50); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table td { font-size: 0.9rem; }

/* ===== Status Badges ===== */
.status-badge {
    display: inline-flex; align-items: center; gap: 0.3rem;
    padding: 0.3rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8rem; font-weight: 600;
    white-space: nowrap;
}
.status-pending { background: rgba(245, 158, 11, 0.12); color: #b45309; }
.status-in-progress { background: rgba(59, 130, 246, 0.12); color: #1d4ed8; }
.status-completed { background: rgba(16, 185, 129, 0.12); color: #047857; }

/* ===== Search Bar (History Page) ===== */
.search-bar {
    display: flex; gap: 0.75rem;
    max-width: 550px; margin-bottom: 1.5rem;
}
.search-bar input {
    flex: 1; padding: 0.7rem 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: 0.6rem;
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
    font-family: 'Kanit', sans-serif;
}
.search-bar input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center; color: var(--text-muted);
    padding: 4rem 2rem;
    font-size: 1rem;
}
.empty-state i {
    font-size: 3rem; color: #cbd5e1;
    margin-bottom: 1rem; display: block;
}

/* ===== PDF Link ===== */
.pdf-link {
    display: inline-flex; align-items: center; gap: 0.3rem;
    color: var(--primary-color); text-decoration: none;
    font-weight: 500; font-size: 0.85rem;
    transition: var(--transition);
}
.pdf-link:hover { color: var(--primary-hover); text-decoration: underline; }

/* ===== Success Modal ===== */
.success-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex; justify-content: center; align-items: center;
    z-index: 100000;
    backdrop-filter: blur(6px);
    animation: fadeIn 0.2s ease;
}
.success-modal {
    background: var(--white);
    border-radius: 1.25rem;
    padding: 2.5rem 2rem;
    max-width: 450px; width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: slideUpFade 0.3s ease;
}
.success-modal .success-icon {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.1);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.25rem;
    font-size: 2rem; color: var(--green);
}
.success-modal h3 { font-size: 1.3rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-dark); }
.success-modal p { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 0.5rem; }
.success-modal .repair-no {
    background: var(--primary-50);
    border: 1px solid var(--primary-light);
    border-radius: 0.6rem; padding: 0.5rem 1rem;
    font-weight: 600; color: var(--primary-color);
    font-size: 1.1rem; margin: 1rem 0;
    display: inline-block;
}
.success-modal .modal-actions {
    display: flex; gap: 0.75rem; justify-content: center; margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* ===== Tablet Info Display ===== */
.tablet-info-bar {
    background: linear-gradient(135deg, #eff6ff, #e0f2fe);
    border: 1.5px solid #93c5fd;
    border-radius: 0.85rem;
    padding: 1rem 1.25rem;
    display: flex; align-items: center; gap: 1rem;
    margin-bottom: 1.25rem;
    animation: slideInRight 0.3s ease;
}
.tablet-info-bar .tablet-icon {
    width: 44px; height: 44px;
    background: var(--primary-gradient);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 1.2rem;
    flex-shrink: 0;
}
.tablet-info-bar .tablet-detail { flex: 1; }
.tablet-info-bar .tablet-detail .label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }
.tablet-info-bar .tablet-detail .value { font-size: 1rem; font-weight: 600; color: var(--text-dark); letter-spacing: 0.5px; }
.tablet-info-bar .tablet-detail .sub { font-size: 0.8rem; color: var(--text-light); margin-top: 2px; }

/* ===== Chart ===== */
.chart-container { padding: 1.5rem; }
.chart-container h3 {
    font-weight: 600; margin-bottom: 1rem;
    display: flex; align-items: center; gap: 0.5rem;
    color: var(--text-dark); font-size: 1.1rem;
}
.chart-container h3 i { color: var(--primary-color); }

/* ===== Login Section ===== */
.login-container {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh;
    background: var(--login-gradient);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
}
.login-container::before {
    content: '';
    position: absolute;
    top: -150px; right: -150px;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.08);
    animation: float 6s ease-in-out infinite;
}
.login-container::after {
    content: '';
    position: absolute;
    bottom: -100px; left: -100px;
    width: 300px; height: 300px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.06);
    animation: float 8s ease-in-out infinite reverse;
}
.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 2.75rem 2.25rem;
    border-radius: 1.5rem;
    box-shadow: 0 20px 60px rgba(37, 99, 235, 0.12), 0 4px 20px rgba(0, 0, 0, 0.06);
    width: 100%; max-width: 420px;
    position: relative; z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.6);
}
.login-header {
    text-align: center; margin-bottom: 2rem;
}
.login-header h2 {
    font-size: 1.4rem; color: var(--text-dark); margin-bottom: 0.25rem;
}
.login-header p {
    color: var(--primary-color); font-size: 0.95rem; font-weight: 500;
}
.input-with-icon {
    position: relative;
    display: flex; align-items: center;
}
.input-with-icon i {
    position: absolute; left: 1rem;
    color: var(--text-light); font-size: 1.1rem;
    z-index: 1;
}
.input-with-icon input {
    width: 100%;
    padding: 0.85rem 1rem 0.85rem 2.75rem !important;
    border: 1.5px solid var(--border-color);
    border-radius: 0.75rem;
    font-size: 1rem; font-family: 'Kanit', sans-serif;
    transition: var(--transition);
    background: var(--white);
}
.input-with-icon input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* ===== Responsive ===== */
@media (max-width: 992px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .problem-checkboxes { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        width: 280px;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0,0,0,0.2);
    }
    .content-area { margin-left: 0 !important; }
    .close-sidebar { display: block; }
    .topbar { padding: 0 1.25rem; height: 60px; }
    .topbar-title h2 { font-size: 1.15rem; }
    .page-container { padding: 1.25rem; }
    .form-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; }
    .student-selected-card { flex-direction: column; text-align: center; }
    .student-selected-card .info { flex-direction: column; }
    .tablet-info-bar { flex-direction: column; text-align: center; }
    .search-bar { flex-direction: column; max-width: 100%; }
    .btn { white-space: normal; height: auto; }
}

@media (max-width: 480px) {
    .card { padding: 1.25rem; border-radius: 0.85rem; }
    .stat-card { padding: 1.15rem; }
    .stat-icon { width: 48px; height: 48px; font-size: 1.3rem; }
    .stat-details h3 { font-size: 1.5rem; }
}

/* ===== เธเธธเนเธกเน€เธเธฅเธตเนเธขเธเธชเธ–เธฒเธเธฐเนเธเธ•เธฒเธฃเธฒเธ ===== */
.btn-status-edit {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.3rem 0.7rem;
    background: rgba(37, 99, 235, 0.08);
    border: 1px solid rgba(37, 99, 235, 0.25);
    border-radius: 0.5rem;
    color: var(--primary-color);
    font-size: 0.8rem; font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-family: 'Kanit', sans-serif;
}
.btn-status-edit:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(37, 99, 235, 0.25);
}

/* ===== Pagination ===== */
#history-pagination { padding: 1rem 0.25rem 0.25rem; }
.pagination-wrap {
    display: flex; align-items: center;
    justify-content: space-between;
    flex-wrap: wrap; gap: 0.75rem;
}
.pagination-info { font-size: 0.85rem; color: var(--text-muted); }
.pagination-info strong { color: var(--text-dark); }
.pagination-controls { display: flex; align-items: center; gap: 0.3rem; }
.page-btn {
    min-width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1.5px solid var(--border-color);
    background: var(--white);
    border-radius: 0.5rem;
    font-size: 0.875rem; font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Kanit', sans-serif;
    padding: 0 0.5rem;
}
.page-btn:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--primary-50);
}
.page-btn.active {
    background: var(--primary-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-ellipsis {
    color: var(--text-light);
    padding: 0 0.2rem;
    font-size: 0.9rem;
    line-height: 36px;
}

/* ===== Status Update Modal ===== */
.status-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex; justify-content: center; align-items: center;
    z-index: 100000;
    backdrop-filter: blur(6px);
    animation: fadeIn 0.2s ease;
}
.status-modal {
    background: var(--white);
    border-radius: 1.25rem;
    width: 90%; max-width: 480px;
    box-shadow: var(--shadow-lg);
    animation: slideUpFade 0.3s ease;
    overflow: hidden;
}
.status-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--primary-50);
}
.status-modal-header h3 {
    font-size: 1.1rem; font-weight: 600;
    color: var(--primary-dark);
    display: flex; align-items: center; gap: 0.5rem;
    margin: 0;
}
.modal-close-x {
    background: none; border: none;
    font-size: 1.2rem; cursor: pointer;
    color: var(--text-light);
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 0.4rem;
    transition: var(--transition);
}
.modal-close-x:hover { background: rgba(0,0,0,0.06); color: var(--text-dark); }
.status-modal-body { padding: 1.5rem; }
.status-modal-repairno {
    background: var(--secondary-color);
    border-radius: 0.5rem;
    padding: 0.5rem 0.85rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
    display: flex; align-items: center; gap: 0.4rem;
}
.status-modal-repairno strong { color: var(--text-dark); }
.status-label {
    font-size: 0.9rem; font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 0.75rem;
}
.status-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.65rem;
    margin-bottom: 0.5rem;
}
.status-option {
    display: flex; flex-direction: column; align-items: center;
    gap: 0.5rem;
    padding: 0.85rem 0.5rem;
    border: 2px solid var(--border-color);
    border-radius: 0.75rem;
    background: var(--white);
    cursor: pointer;
    font-size: 0.82rem; font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
    font-family: 'Kanit', sans-serif;
}
.status-option i { font-size: 1.3rem; }
.status-option:hover {
    border-color: var(--primary-hover);
    background: var(--primary-50);
    color: var(--primary-color);
    transform: translateY(-2px);
}
/* เธชเธต per status */
.status-option[data-value="เธฃเธญเธ”เธณเน€เธเธดเธเธเธฒเธฃ"].selected {
    border-color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
    color: #b45309;
}
.status-option[data-value="เธเธณเธฅเธฑเธเธเนเธญเธก"].selected {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.1);
    color: #1d4ed8;
}
.status-option[data-value="เธเนเธญเธกเน€เธชเธฃเนเธเนเธฅเนเธง"].selected {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    color: #047857;
}
.status-modal-footer {
    display: flex; justify-content: flex-end; gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--secondary-color);
}

@media (max-width: 480px) {
    .status-options { grid-template-columns: 1fr; }
    .status-modal-footer { flex-direction: column-reverse; }
    .status-modal-footer .btn { width: 100%; justify-content: center; }
    .pagination-wrap { flex-direction: column; align-items: flex-start; }
}

