:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #818cf8;
    --bg-main: #f1f5f9;
    --bg-card: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
}

* {
    font-family: 'Sarabun', sans-serif;
}

body {
    background: var(--bg-main);
    color: var(--text-primary);
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 20px;
    color: white;
    margin-bottom: 1rem;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.login-header p {
    color: var(--text-secondary);
    margin-bottom: 0;
    font-size: 0.9rem;
}

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Admin Layout */
.admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 260px;
    height: 100vh;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    color: white;
    z-index: 1000;
    overflow-y: auto;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.sidebar-header small {
    color: rgba(255,255,255,0.6);
    font-size: 0.8rem;
}

.sidebar-nav {
    padding: 1rem 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: white;
    background: rgba(255,255,255,0.1);
}

.sidebar-nav a.active {
    border-left: 3px solid var(--primary-light);
}

.sidebar-nav .nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 0.5rem 1.5rem;
}

.admin-content {
    margin-left: 260px;
    padding: 2rem;
    min-height: 100vh;
}

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.admin-topbar h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

/* Cards */
.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-card .stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.stat-card .stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.card-panel {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-panel .panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-panel .panel-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.card-panel .panel-body {
    padding: 1.5rem;
}

/* Table */
.table-modern {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table-modern thead th {
    background: #f8fafc;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.table-modern tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.table-modern tbody tr:hover {
    background: #f8fafc;
}

.table-modern tbody tr:last-child td {
    border-bottom: none;
}

/* Badges */
.badge-status {
    padding: 0.35em 0.75em;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-waiting { background: #f1f5f9; color: #475569; }
.badge-selecting { background: #fef3c7; color: #92400e; }
.badge-selected { background: #d1fae5; color: #065f46; }
.badge-absent { background: #fee2e2; color: #991b1b; }

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

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

/* Dashboard (Public Display) */
.dashboard-page {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    min-height: 100vh;
    color: white;
    padding: 2rem;
}

.dashboard-title {
    text-align: center;
    margin-bottom: 2rem;
}

.dashboard-title h1 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.dashboard-title .subtitle {
    font-size: 1.1rem;
    color: rgba(255,255,255,0.6);
}

.current-student-card {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border-radius: 20px;
    padding: 2.5rem;
    text-align: center;
    margin-bottom: 2rem;
    box-shadow: 0 20px 40px rgba(79, 70, 229, 0.3);
    position: relative;
    overflow: hidden;
}

.current-student-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 60%);
    animation: pulse-bg 3s ease-in-out infinite;
}

@keyframes pulse-bg {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.1); opacity: 1; }
}

.current-student-card .label {
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    opacity: 0.8;
    margin-bottom: 0.5rem;
    position: relative;
}

.current-student-card .queue-number {
    font-size: 4rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 0.5rem;
    position: relative;
}

.current-student-card .student-name {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    position: relative;
}

.current-student-card .student-school {
    font-size: 1.1rem;
    opacity: 0.8;
    position: relative;
}

.current-student-card .selected-classroom {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 0.5rem 1.5rem;
    border-radius: 50px;
    font-size: 1.3rem;
    font-weight: 700;
    margin-top: 1rem;
    position: relative;
}

/* Waiting list */
.waiting-list-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    overflow: hidden;
}

.waiting-list-card .card-header-dark {
    padding: 1rem 1.5rem;
    background: rgba(255,255,255,0.05);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-weight: 600;
    font-size: 1.1rem;
}

.waiting-list-card .waiting-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    transition: background 0.2s;
}

.waiting-list-card .waiting-item:last-child {
    border-bottom: none;
}

.waiting-list-card .waiting-item.next-up {
    background: rgba(251, 191, 36, 0.1);
}

.waiting-item .queue-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.waiting-item.next-up .queue-badge {
    background: rgba(251, 191, 36, 0.3);
    color: #fbbf24;
}

.waiting-item .student-info {
    flex: 1;
    min-width: 0;
}

.waiting-item .student-info .name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.waiting-item .student-info .school {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.5);
}

/* Classroom stats on dashboard */
.classroom-stat-card {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    padding: 1.5rem;
    text-align: center;
}

.classroom-stat-card .classroom-name {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.classroom-stat-card .progress-ring {
    width: 100px;
    height: 100px;
    margin: 0 auto 1rem;
    position: relative;
}

.classroom-stat-card .count-display {
    font-size: 2rem;
    font-weight: 700;
}

.classroom-stat-card .count-display .total {
    font-size: 1rem;
    color: rgba(255,255,255,0.5);
}

.classroom-stat-card .remaining {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.6);
    margin-top: 0.5rem;
}

.remaining-badge {
    display: inline-block;
    padding: 0.25em 0.75em;
    border-radius: 50px;
    font-weight: 700;
}

.remaining-full { background: rgba(239, 68, 68, 0.2); color: #fca5a5; }
.remaining-low { background: rgba(245, 158, 11, 0.2); color: #fcd34d; }
.remaining-available { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }

/* Selection page */
.selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.classroom-btn {
    padding: 1.25rem;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: white;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.classroom-btn:hover:not(.disabled) {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.15);
}

.classroom-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.classroom-btn.selected {
    border-color: var(--success);
    background: #f0fdf4;
}

.classroom-btn .classroom-btn-name {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.classroom-btn .classroom-btn-count {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Import area */
.import-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.import-zone:hover {
    border-color: var(--primary);
    background: #f8fafc;
}

.import-zone.dragover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

/* Copy table */
.copy-table-wrapper {
    position: relative;
}

.copy-btn-floating {
    position: absolute;
    top: -45px;
    right: 0;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
}

/* Dashboard time */
.dashboard-time {
    text-align: center;
    font-size: 1rem;
    color: rgba(255,255,255,0.4);
    margin-top: 2rem;
}

/* No-data placeholder */
.no-data {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.no-data svg {
    width: 64px;
    height: 64px;
    color: var(--border);
    margin-bottom: 1rem;
}

/* Animation */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-up {
    animation: slideUp 0.4s ease-out;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }

    .admin-sidebar.show {
        transform: translateX(0);
    }

    .admin-content {
        margin-left: 0;
        padding: 1rem;
    }

    .dashboard-page {
        padding: 1rem;
    }

    .current-student-card .queue-number {
        font-size: 3rem;
    }

    .current-student-card .student-name {
        font-size: 1.5rem;
    }
}

/* Selection page call button */
.btn-call {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
    color: white;
    font-weight: 700;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-size: 1rem;
}

.btn-call:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    color: white;
}

.btn-absent {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    border: none;
    color: white;
    font-weight: 600;
}

.btn-absent:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    color: white;
}

/* Highlight row for current selecting */
.row-selecting {
    background: #fffbeb !important;
    border-left: 3px solid #f59e0b;
}

/* No round selected */
.round-selector {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.round-selector select {
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 0.4rem 2rem 0.4rem 0.75rem;
    font-weight: 600;
}
