/* =====================================================
   ระบบเช็คเวลาเรียน — Minimal Government Theme
   โทนสี: เทา + ขาว + น้ำเงินราชการ
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&display=swap');

:root {
    /* Primary — น้ำเงินราชการ (สุภาพ ไม่จัด) */
    --primary: #2c5282;
    --primary-light: #3d6ba5;
    --primary-subtle: #ebf2fa;

    /* Neutrals */
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Status */
    --success: #059669;
    --success-bg: #ecfdf5;
    --danger: #dc2626;
    --danger-bg: #fef2f2;

    /* Spacing & Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'IBM Plex Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-100);
    min-height: 100vh;
    padding: 20px;
    color: var(--gray-800);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
}

.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== LOGIN ===== */
.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    max-width: 420px;
    margin: 80px auto;
    box-shadow: var(--shadow-lg);
    text-align: center;
    border: 1px solid var(--gray-200);
}

.login-card h1 {
    color: var(--gray-900);
    margin-bottom: 8px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.subtitle {
    color: var(--gray-500);
    margin-bottom: 32px;
    font-size: 14px;
    font-weight: 400;
}

.input-group {
    margin-bottom: 16px;
}

.input-group input {
    width: 100%;
    padding: 14px 16px;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 15px;
    font-family: inherit;
    margin-bottom: 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: var(--gray-50);
    color: var(--gray-800);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.12);
    background: var(--white);
}

.input-group input::placeholder {
    color: var(--gray-400);
}

.input-group button {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.input-group button:hover {
    background: var(--primary-light);
}

.input-group button:active {
    transform: scale(0.98);
}

.error-msg {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    display: none;
    font-weight: 500;
}

.error-msg.show {
    display: block;
}

.loading {
    display: none;
    color: var(--primary);
    margin-top: 16px;
    font-weight: 500;
    font-size: 14px;
}

.loading.show {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.loading.show::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== DASHBOARD ===== */
.dashboard {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
}

/* Profile */
.profile-card {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 24px;
    background: var(--gray-800);
    border-radius: var(--radius-md);
    color: var(--white);
    margin-bottom: 28px;
    position: relative;
}

.student-photo {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2.5px solid rgba(255,255,255,0.3);
    background: var(--gray-600);
}

.profile-info {
    flex: 1;
}

.profile-info h2 {
    margin-bottom: 2px;
    font-size: 18px;
    font-weight: 600;
}

.student-id {
    opacity: 0.7;
    font-size: 13px;
    font-weight: 400;
}

.logout-btn {
    padding: 8px 18px;
    background: transparent;
    border: 1.5px solid rgba(255,255,255,0.35);
    color: rgba(255,255,255,0.9);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 13px;
    font-family: inherit;
    transition: background 0.2s, border-color 0.2s;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.5);
}

/* Statistics */
.stats-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--gray-50);
    padding: 24px 20px;
    border-radius: var(--radius-md);
    text-align: center;
    border: 1px solid var(--gray-200);
    transition: border-color 0.2s;
}

.stat-card:hover {
    border-color: var(--gray-300);
}

.stat-card.highlight {
    background: var(--primary-subtle);
    border-color: rgba(44, 82, 130, 0.2);
}

.stat-card.highlight .stat-value {
    color: var(--primary);
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--gray-900);
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 500;
}

/* Progress Bar */
.progress-container {
    margin-bottom: 28px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: var(--gray-200);
    border-radius: 99px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.5s ease;
    border-radius: 99px;
}

.progress-text {
    text-align: right;
    color: var(--gray-500);
    font-size: 13px;
    font-weight: 500;
}

/* Table */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
}

.table-container h3 {
    margin-bottom: 16px;
    color: var(--gray-800);
    font-size: 16px;
    font-weight: 600;
    padding: 0 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: var(--gray-50);
}

th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1.5px solid var(--gray-200);
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
    color: var(--gray-700);
}

tbody tr:hover {
    background: var(--gray-50);
}

tbody tr:last-child td {
    border-bottom: none;
}

.status-present {
    color: var(--success);
    font-weight: 600;
    font-size: 13px;
}

.status-absent {
    color: var(--danger);
    font-weight: 600;
    font-size: 13px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .login-card {
        margin: 40px auto;
        padding: 32px 24px;
    }

    .dashboard {
        padding: 20px 16px;
    }

    .profile-card {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }

    .logout-btn {
        width: 100%;
        text-align: center;
    }

    .stats-container {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .stat-value {
        font-size: 28px;
    }

    th, td {
        padding: 10px 8px;
        font-size: 12px;
    }

    .table-container h3 {
        padding: 0;
    }
}

@media (max-width: 480px) {
    .login-card h1 {
        font-size: 20px;
    }
}