/* =========================================================
   ระบบนิเทศชั้นเรียนภายในสถานศึกษา
   Theme: Deep navy + slate teal + warm gold accent
   ========================================================= */
:root {
    --navy-950: #0f2438;
    --navy-900: #14304a;
    --navy-800: #1c4162;
    --navy-700: #26537c;
    --teal-600: #2f7d76;
    --teal-500: #3b9a91;
    --gold-500: #c99a3b;
    --gold-400: #dcb45f;
    --ink-900: #1a2530;
    --ink-600: #4d5c6a;
    --ink-400: #7c8b98;
    --paper-0: #ffffff;
    --paper-50: #f5f7f9;
    --paper-100: #eaeef2;
    --line-200: #dbe2e8;
    --danger: #b5452f;
    --success: #2f7d4d;
    --radius: 10px;
    --shadow-sm: 0 1px 3px rgba(15, 36, 56, 0.08);
    --shadow-md: 0 6px 20px rgba(15, 36, 56, 0.10);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Sarabun', 'Noto Sans Thai', -apple-system, sans-serif;
    background: var(--paper-50);
    color: var(--ink-900);
    font-size: 15.5px;
    line-height: 1.6;
}

a { color: inherit; text-decoration: none; }

/* ---------- Layout: sidebar + main ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--navy-950), var(--navy-900) 70%);
    color: #dbe6ee;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    padding: 22px 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-brand .mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px; height: 38px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--gold-500), var(--gold-400));
    color: var(--navy-950);
    font-weight: 700;
    font-size: 17px;
    margin-bottom: 10px;
}
.sidebar-brand .title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1.4;
}
.sidebar-brand .subtitle {
    font-size: 12px;
    color: #9fb3c4;
    margin-top: 2px;
}

.sidebar-user {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    font-size: 13.5px;
}
.sidebar-user .name { color: #fff; font-weight: 600; }
.sidebar-user .role {
    display: inline-block;
    margin-top: 6px;
    font-size: 11.5px;
    padding: 2px 9px;
    border-radius: 20px;
    background: rgba(201,154,59,0.18);
    color: var(--gold-400);
    letter-spacing: .3px;
}

.nav-menu { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav-menu .nav-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #6f8497;
    padding: 12px 10px 6px;
}
.nav-menu a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #c4d3de;
    font-size: 14.5px;
    margin-bottom: 2px;
    transition: background .15s, color .15s;
}
.nav-menu a .ic { width: 18px; text-align: center; opacity: .9; }
.nav-menu a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-menu a.active {
    background: linear-gradient(90deg, rgba(201,154,59,0.22), rgba(201,154,59,0.05));
    color: #fff;
    border-right: 3px solid var(--gold-500);
}

.sidebar-footer {
    padding: 14px 20px 18px;
    border-top: 1px solid rgba(255,255,255,0.08);
}
.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #f0c4b8;
    font-size: 13.5px;
    padding: 8px 10px;
    border-radius: 8px;
}
.btn-logout:hover { background: rgba(181,69,47,0.18); }

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--paper-0);
    border-bottom: 1px solid var(--line-200);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; }
.topbar .crumb { font-size: 12.5px; color: var(--ink-400); margin-top: 3px; }
.topbar-date { font-size: 13px; color: var(--ink-600); }

.content { padding: 26px 28px 50px; }

/* ---------- Cards ---------- */
.card {
    background: var(--paper-0);
    border: 1px solid var(--line-200);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-header h2 { font-size: 16px; margin: 0; font-weight: 700; }
.card-body { padding: 20px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat-card {
    background: var(--paper-0);
    border: 1px solid var(--line-200);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute; top:0; left:0; bottom:0; width: 4px;
    background: var(--accent, var(--teal-500));
}
.stat-card .label { font-size: 12.5px; color: var(--ink-400); margin-bottom: 6px; }
.stat-card .value { font-size: 26px; font-weight: 700; color: var(--navy-900); }
.stat-card .sub { font-size: 12px; color: var(--ink-400); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: filter .15s, background .15s;
    font-family: inherit;
}
.btn-primary { background: var(--navy-900); color: #fff; }
.btn-primary:hover { filter: brightness(1.15); }
.btn-gold { background: linear-gradient(135deg, var(--gold-500), var(--gold-400)); color: var(--navy-950); }
.btn-gold:hover { filter: brightness(1.06); }
.btn-outline { background: #fff; color: var(--navy-900); border-color: var(--line-200); }
.btn-outline:hover { background: var(--paper-100); }
.btn-danger { background: #fdece8; color: var(--danger); }
.btn-danger:hover { background: #fbdcd5; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 18px; }
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 13.5px; font-weight: 600; color: var(--ink-600); }
input[type=text], input[type=password], input[type=date], input[type=time],
input[type=email], input[type=tel], input[type=number], select, textarea {
    padding: 10px 12px;
    border: 1px solid var(--line-200);
    border-radius: 8px;
    font-size: 14.5px;
    font-family: inherit;
    background: #fff;
    color: var(--ink-900);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--teal-500);
    box-shadow: 0 0 0 3px rgba(59,154,145,0.15);
}
textarea { resize: vertical; min-height: 80px; }
.hint { font-size: 12px; color: var(--ink-400); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    text-align: left;
    font-size: 12.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-400);
    padding: 10px 14px;
    border-bottom: 1px solid var(--line-200);
    white-space: nowrap;
}
tbody td { padding: 12px 14px; border-bottom: 1px solid var(--paper-100); vertical-align: middle; }
tbody tr:hover { background: var(--paper-50); }
tbody tr:last-child td { border-bottom: none; }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-excellent { background: #e2f4ec; color: var(--success); }
.badge-good { background: #e5f2ef; color: var(--teal-600); }
.badge-fair { background: #fdf1de; color: var(--gold-500); }
.badge-poor { background: #fdece8; color: var(--danger); }
.badge-pending { background: #fdf1de; color: #a97417; }
.badge-completed { background: #e2f4ec; color: var(--success); }
.badge-cancelled { background: #f1f1f1; color: #7c8b98; }
.badge-admin { background: #eaf0fb; color: #2d4f8f; }
.badge-teacher { background: #f1e9fb; color: #6c3fa8; }

/* ---------- Alerts / flash ---------- */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 18px;
    border: 1px solid transparent;
}
.alert-success { background: #e2f4ec; color: var(--success); border-color: #bfe4cf; }
.alert-error { background: #fdece8; color: var(--danger); border-color: #f4c6ba; }

/* ---------- Login page ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 15% 20%, rgba(201,154,59,0.12), transparent 40%),
        linear-gradient(160deg, var(--navy-950), var(--navy-800));
    padding: 24px;
}
.login-card {
    width: 100%;
    max-width: 380px;
    background: #fff;
    border-radius: 14px;
    padding: 34px 32px 30px;
    box-shadow: var(--shadow-md);
}
.login-card .mark {
    width: 46px; height: 46px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--gold-500), var(--gold-400));
    color: var(--navy-950);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 20px;
    margin-bottom: 16px;
}
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.login-card p.sub { font-size: 13.5px; color: var(--ink-400); margin: 0 0 22px; }
.login-card .btn { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }
.demo-box {
    margin-top: 20px;
    padding: 12px 14px;
    background: var(--paper-50);
    border-radius: 8px;
    font-size: 12.5px;
    color: var(--ink-600);
    line-height: 1.7;
}

/* ---------- Score rubric table ---------- */
.rubric-category {
    font-weight: 700;
    color: var(--navy-800);
    background: var(--paper-50);
}
.score-select { width: 90px; }
.score-total-box {
    background: var(--navy-950);
    color: #fff;
    border-radius: var(--radius);
    padding: 20px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}
.score-total-box .num { font-size: 30px; font-weight: 700; color: var(--gold-400); }
.score-total-box .label { font-size: 12.5px; color: #a9bccb; }

/* ---------- Misc ---------- */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--ink-400);
}
.empty-state .ic { font-size: 34px; margin-bottom: 10px; }
.filters-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 18px;
}
.filters-bar .form-group { margin-bottom: 0; min-width: 150px; }
.avatar-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.avatar-chip .dot {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--navy-800);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700;
    flex-shrink: 0;
}
.text-muted { color: var(--ink-400); }
.print-only { display: none; }

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .content { padding: 0; }
    body { background: #fff; }
    .print-only { display: block; }
}

@media (max-width: 900px) {
    .sidebar { position: fixed; left: -260px; z-index: 50; transition: left .2s; }
    .sidebar.open { left: 0; }
    .form-grid { grid-template-columns: 1fr; }
    .content { padding: 18px; }
    .topbar { padding: 14px 18px; }
}
/* =========================================================
   SUPERVISOR MODAL
========================================================= */

.modal-backdrop {
    position: fixed;
    inset: 0;

    z-index: 1000;

    display: none;

    align-items: center;
    justify-content: center;

    padding: 20px;

    background: rgba(15, 36, 56, .55);

    backdrop-filter: blur(4px);

    animation: modalFadeIn .2s ease;
}

.modal-backdrop.show {
    display: flex;
}

.supervisor-modal {
    width: 100%;
    max-width: 500px;

    background: #fff;

    border-radius: 14px;

    overflow: hidden;

    box-shadow:
        0 25px 70px rgba(15,36,56,.22);

    animation: modalSlideIn .25s ease;
}


/* Header */

.supervisor-modal-header {
    padding: 18px 22px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    border-bottom: 1px solid var(--line-200);

    background:
        linear-gradient(
            135deg,
            #fff,
            #f8fafb
        );
}

.supervisor-modal-title {
    display: flex;
    align-items: center;
    gap: 9px;

    color: var(--navy-900);

    font-size: 17px;
    font-weight: 700;
}

.supervisor-modal-title i {
    color: var(--gold-500);
}

.supervisor-modal-subtitle {
    margin-top: 3px;

    color: var(--ink-400);

    font-size: 12px;
}

.modal-close {
    width: 34px;
    height: 34px;

    border: 0;
    border-radius: 8px;

    background: transparent;

    color: var(--ink-400);

    cursor: pointer;

    font-size: 17px;
}

.modal-close:hover {
    background: var(--paper-100);
    color: var(--danger);
}


/* Body */

.supervisor-modal-body {
    padding: 22px;
}

.supervisor-modal-body .form-group {
    margin-bottom: 17px;
}

.required {
    color: var(--danger);
}

.label-hint {
    color: var(--danger);
}

.input-icon {
    position: relative;
}

.input-icon > i {
    position: absolute;

    left: 13px;
    top: 50%;

    transform: translateY(-50%);

    color: var(--ink-400);

    font-size: 14px;

    pointer-events: none;
}

.input-icon input {
    width: 100%;

    padding-left: 38px;
}

.password-input input {
    padding-right: 45px;
}

.password-show {
    position: absolute;

    right: 9px;
    top: 50%;

    transform: translateY(-50%);

    width: 32px;
    height: 32px;

    border: 0;

    background: transparent;

    color: var(--ink-400);

    cursor: pointer;
}

.password-show:hover {
    color: var(--navy-700);
}

.hint {
    margin-top: 5px;
    font-size: 11.5px;
    color: var(--ink-400);
}


/* Switch */

.switch-row {
    display: inline-flex;

    align-items: center;

    gap: 9px;

    cursor: pointer;

    font-weight: 500;
}

.switch-row input {
    display: none;
}

.switch {
    width: 40px;
    height: 22px;

    border-radius: 20px;

    background: #cbd5dc;

    position: relative;

    transition: .2s;
}

.switch::after {
    content: '';

    position: absolute;

    width: 16px;
    height: 16px;

    left: 3px;
    top: 3px;

    border-radius: 50%;

    background: #fff;

    box-shadow: 0 1px 3px rgba(0,0,0,.2);

    transition: .2s;
}

.switch-row input:checked + .switch {
    background: var(--teal-500);
}

.switch-row input:checked + .switch::after {
    transform: translateX(18px);
}


/* Footer */

.supervisor-modal-footer {
    padding: 15px 22px;

    display: flex;
    justify-content: flex-end;

    gap: 8px;

    background: var(--paper-50);

    border-top: 1px solid var(--line-200);
}


/* Animation */

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(15px) scale(.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}


/* Mobile */

@media (max-width: 600px) {

    .modal-backdrop {
        padding: 12px;
        align-items: flex-end;
    }

    .supervisor-modal {
        max-width: none;

        border-radius: 14px 14px 10px 10px;

        max-height: 94vh;
        overflow-y: auto;
    }

    .supervisor-modal-body {
        padding: 18px;
    }

    .supervisor-modal-footer {
        padding: 13px 18px;
    }

    .supervisor-modal-footer .btn {
        flex: 1;
        justify-content: center;
    }

}