/* ============================================================
   ALSP Design System — Pure CSS
   Font: Sarabun (Thai) + IBM Plex Mono (code)
   Theme: Deep Navy + Teal accent, clean data-dense layout
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700;800&family=IBM+Plex+Mono:wght@400;600&display=swap');

/* ── Variables ───────────────────────────────────────────── */
:root {
    --navy:       #0a1628;
    --navy-2:     #0f2044;
    --navy-3:     #1a3260;
    --blue:       #1e4fc2;
    --blue-lt:    #3b6fee;
    --teal:       #0d9488;
    --teal-lt:    #14b8a6;
    --teal-bg:    #f0fdfa;
    --amber:      #d97706;
    --amber-bg:   #fffbeb;
    --red:        #dc2626;
    --red-bg:     #fef2f2;
    --green:      #16a34a;
    --green-bg:   #f0fdf4;
    --purple:     #7c3aed;
    --purple-bg:  #f5f3ff;
    --gray-50:    #f9fafb;
    --gray-100:   #f3f4f6;
    --gray-200:   #e5e7eb;
    --gray-300:   #d1d5db;
    --gray-400:   #9ca3af;
    --gray-500:   #6b7280;
    --gray-700:   #374151;
    --gray-900:   #111827;
    --white:      #ffffff;

    --font:       'Sarabun', sans-serif;
    --mono:       'IBM Plex Mono', monospace;
    --radius:     10px;
    --radius-lg:  16px;
    --shadow:     0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
    --shadow-lg:  0 8px 32px rgba(10,22,40,.14);
    --transition: .15s ease;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font);
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Layout ──────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    min-width: 240px;
    background: var(--navy);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
}
.sidebar-logo {
    padding: 20px 16px 12px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo .app-name {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--teal-lt);
    display: block;
    margin-bottom: 4px;
}
.sidebar-logo .app-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--white);
    line-height: 1.2;
}

.sidebar-user {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    font-size: 12.5px;
}
.sidebar-user .uname { color: var(--white); font-weight: 700; }
.sidebar-user .urole {
    display: inline-block;
    margin-top: 3px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--teal);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

.sidebar-nav { flex: 1; padding: 8px 0; }
.nav-group-label {
    padding: 16px 16px 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(255,255,255,.35);
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: rgba(255,255,255,.7);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid transparent;
    text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active {
    background: rgba(20,184,166,.12);
    color: var(--teal-lt);
    border-left-color: var(--teal-lt);
    font-weight: 700;
}
.nav-item .icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .badge-count {
    margin-left: auto;
    background: var(--teal);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 999px;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.08);
}

/* ── Main content ────────────────────────────────────────── */
.main {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--navy);
}
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.content { padding: 24px; flex: 1; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.card-header h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--navy);
}
.card-body { padding: 20px; }

/* ── Stats grid ──────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--teal);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-card.s-blue   { border-left-color: var(--blue); }
.stat-card.s-amber  { border-left-color: var(--amber); }
.stat-card.s-red    { border-left-color: var(--red); }
.stat-card.s-purple { border-left-color: var(--purple); }
.stat-label { font-size: 11.5px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--navy); line-height: 1; }
.stat-sub   { font-size: 11.5px; color: var(--gray-400); }

/* ── Table ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}
thead th {
    background: var(--navy);
    color: rgba(255,255,255,.88);
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: 10px 14px;
    text-align: left;
    white-space: nowrap;
}
thead th:first-child { border-radius: 8px 0 0 0; }
thead th:last-child  { border-radius: 0 8px 0 0; }
tbody tr { border-bottom: 1px solid var(--gray-100); transition: background var(--transition); }
tbody tr:hover { background: var(--teal-bg); }
tbody td { padding: 10px 14px; vertical-align: middle; }
tbody tr:last-child td:first-child { border-radius: 0 0 0 8px; }
tbody tr:last-child td:last-child  { border-radius: 0 0 8px 0; }
.td-mono { font-family: var(--mono); font-size: 12px; }
.td-actions { white-space: nowrap; display: flex; gap: 4px; }

/* ── Badges ──────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    white-space: nowrap;
}
.badge-green  { background: var(--green-bg);  color: var(--green);  }
.badge-red    { background: var(--red-bg);    color: var(--red);    }
.badge-amber  { background: var(--amber-bg);  color: var(--amber);  }
.badge-blue   { background: #eff6ff;          color: var(--blue);   }
.badge-teal   { background: var(--teal-bg);   color: var(--teal);   }
.badge-purple { background: var(--purple-bg); color: var(--purple); }
.badge-gray   { background: var(--gray-100);  color: var(--gray-500);}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover { opacity: .88; text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn-primary  { background: var(--navy);  color: #fff; }
.btn-teal     { background: var(--teal);  color: #fff; }
.btn-blue     { background: var(--blue);  color: #fff; }
.btn-amber    { background: var(--amber); color: #fff; }
.btn-red      { background: var(--red);   color: #fff; }
.btn-outline  { background: transparent; border: 1.5px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { border-color: var(--blue); color: var(--blue); background: #eff6ff; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; }
.btn-xs { padding: 2px 8px;  font-size: 11px; border-radius: 6px; }
.btn-icon { padding: 6px; min-width: 32px; justify-content: center; }

/* ── Forms ───────────────────────────────────────────────── */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; color: var(--gray-700); }
label .req { color: var(--red); margin-left: 2px; }
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="time"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 14px;
    color: var(--gray-900);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}
textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11.5px; color: var(--gray-400); }
.field-error { font-size: 12px; color: var(--red); }
.form-actions { display: flex; gap: 10px; align-items: center; padding-top: 8px; }

/* ── Filter bar ──────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    flex-wrap: wrap;
    padding: 14px 20px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-100);
}
.filter-bar .fgroup { display: flex; flex-direction: column; gap: 3px; min-width: 140px; }
.filter-bar label { font-size: 11px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .05em; }
.filter-bar input, .filter-bar select { font-size: 13px; padding: 7px 10px; }

/* ── Alert / Flash ───────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    font-weight: 500;
    margin-bottom: 16px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.alert-success { background: var(--green-bg);  color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--red-bg);    color: var(--red); border: 1px solid #fecaca; }
.alert-warning { background: var(--amber-bg);  color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: #eff6ff;           color: var(--blue); border: 1px solid #bfdbfe; }

/* ── Detail page ─────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 0; }
.detail-row  { padding: 10px 16px; border-bottom: 1px solid var(--gray-100); display: flex; flex-direction: column; gap: 2px; }
.detail-label { font-size: 11px; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: .06em; }
.detail-value { font-size: 14px; color: var(--gray-900); font-weight: 500; }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; gap: 0; }
.tab-btn {
    padding: 10px 20px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--gray-500);
    cursor: pointer;
    border: none;
    background: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-family: var(--font);
    transition: var(--transition);
}
.tab-btn:hover { color: var(--teal); }
.tab-btn.active { color: var(--teal); border-bottom-color: var(--teal); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Pagination ──────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; justify-content: center; padding-top: 16px; }
.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    border: 1.5px solid var(--gray-200);
    background: var(--white);
    transition: var(--transition);
    text-decoration: none;
}
.page-btn:hover { border-color: var(--teal); color: var(--teal); text-decoration: none; }
.page-btn.active { background: var(--teal); color: #fff; border-color: var(--teal); }

/* ── Breadcrumb ──────────────────────────────────────────── */
.breadcrumb { display: flex; gap: 6px; align-items: center; font-size: 12.5px; color: var(--gray-400); margin-bottom: 16px; }
.breadcrumb a { color: var(--gray-500); }
.breadcrumb a:hover { color: var(--teal); }
.breadcrumb .sep { color: var(--gray-300); }
.breadcrumb .current { color: var(--navy); font-weight: 600; }

/* ── Section divider ─────────────────────────────────────── */
.section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--gray-400);
    padding-bottom: 8px;
    border-bottom: 1.5px solid var(--gray-100);
    margin-bottom: 16px;
    margin-top: 20px;
}
.section-title:first-child { margin-top: 0; }

/* ── Confirm modal ───────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 8px; color: var(--navy); }
.modal-body  { font-size: 14px; color: var(--gray-700); margin-bottom: 20px; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--gray-400);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* ── Login page ──────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--navy);
}
.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--white);
    border-radius: 20px;
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .brand { font-size: 13px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--teal); }
.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--navy); line-height: 1.2; margin-top: 6px; }

/* ── Attendance table special ────────────────────────────── */
.att-table input[type="number"] { width: 80px; padding: 4px 8px; font-size: 13px; }
.att-table .radio-group { display: flex; gap: 12px; }
.att-table .radio-group label { font-size: 13px; font-weight: 500; display: flex; gap: 5px; cursor: pointer; }

/* ── Report page ─────────────────────────────────────────── */
.report-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1.5px solid var(--gray-200);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    transition: var(--transition);
}
.report-card:hover { border-color: var(--teal); box-shadow: 0 4px 16px rgba(13,148,136,.12); }
.report-card .req-badge {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 600;
    background: var(--navy);
    color: var(--teal-lt);
    padding: 2px 7px;
    border-radius: 4px;
}
.report-card .r-title { font-size: 14px; font-weight: 700; color: var(--navy); }
.report-card .r-desc  { font-size: 12px; color: var(--gray-500); }

/* ── Utility ─────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-sm     { font-size: 12px; }
.text-muted  { color: var(--gray-400); }
.font-mono   { font-family: var(--mono); }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.d-none { display: none; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform .25s ease; }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .topbar { padding: 0 16px; }
    .content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-grid  { grid-template-columns: 1fr; }
}

/* ── Print ───────────────────────────────────────────────── */
@media print {
    .sidebar, .topbar, .btn, .filter-bar { display: none !important; }
    .main { margin-left: 0; }
    table { font-size: 11px; }
}
