/* ============================================================
   BIG DATA - Non-color tokens (colors come from theme.php)
   ============================================================ */
:root {
    --font-display: 'Kanit', 'Sarabun', sans-serif;
    --font-body:    'Sarabun', sans-serif;
    --sidebar-w: 272px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--bg-soft);
    color: var(--text-dark);
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; margin: 0; padding: 0; }

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--navy-deep) 0%, var(--sidebar-gradient) 100%);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 1030;
    transition: transform 0.25s ease;
}

.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--navy-mid); border-radius: 3px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--navy-line);
}

.brand-mark {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}
.brand-mark .dot {
    position: absolute;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-soft);
}
.brand-mark .dot-1 { top: 2px;  left: 14px; animation: pulse 2.4s ease-in-out infinite; }
.brand-mark .dot-2 { bottom: 2px; left: 0;   background: var(--amber); box-shadow: 0 0 0 3px rgba(240,185,59,0.18); animation: pulse 2.4s ease-in-out 0.4s infinite; }
.brand-mark .dot-3 { bottom: 2px; right: 0;  animation: pulse 2.4s ease-in-out 0.8s infinite; }
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(1.35); opacity: 0.6; }
}

.brand-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: 0.5px;
    color: #fff;
}
.brand-sub {
    font-size: 0.72rem;
    color: var(--sidebar-subtitle);
    margin-top: 2px;
    line-height: 1.3;
}

.sidebar-nav { padding: 14px 12px 30px; }
.nav-item { margin-bottom: 2px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 0.92rem;
    color: var(--sidebar-link);
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
    cursor: pointer;
}
.nav-link i.bi:first-child { font-size: 1.05rem; color: var(--sidebar-icon); }
.nav-link span { flex: 1; }
.nav-link .chevron { font-size: 0.75rem; transition: transform 0.2s ease; color: var(--sidebar-icon); }

.nav-link:hover { background: var(--navy-mid); color: #fff; }
.nav-link:hover i.bi { color: var(--teal); }

.nav-link.active {
    background: var(--teal-soft);
    color: #fff;
    border-left: 3px solid var(--teal);
}
.nav-link.active i.bi:first-child { color: var(--teal); }

.nav-link.active-parent { color: #fff; }
.nav-link.active-parent i.bi:first-child { color: var(--teal); }

.nav-link[aria-expanded="true"] .chevron,
.toggle-sub.open .chevron { transform: rotate(180deg); }

.sub-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    padding-left: 14px;
    border-left: 1px dashed var(--navy-line);
    margin: 2px 0 2px 24px;
}
.sub-menu.show { max-height: 400px; }

.sub-menu li a.sub-link {
    display: block;
    padding: 9px 14px;
    font-size: 0.86rem;
    color: var(--sidebar-sublink);
    border-radius: 8px;
}
.sub-menu li a.sub-link:hover { background: var(--navy-mid); color: #fff; }
.sub-menu li a.sub-link.active { color: var(--teal); font-weight: 600; }

.nav-divider {
    height: 1px;
    background: var(--navy-line);
    margin: 14px 6px;
}

/* ============================================================
   CONTENT AREA
   ============================================================ */
.content-wrapper {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-w));
}

.main-content { display: flex; flex-direction: column; flex: 1; }

/* Topbar */
.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-soft);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    gap: 18px;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.btn-burger {
    display: none;
    border: none;
    background: var(--bg-soft);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 1.2rem;
    color: var(--navy-deep);
    align-items: center;
    justify-content: center;
}

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 {
    font-family: var(--font-display);
    font-size: 1.28rem;
    font-weight: 600;
    margin: 0 0 4px;
    color: var(--navy-deep);
}
.breadcrumb-line {
    font-size: 0.78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.breadcrumb-line .current { color: var(--teal); font-weight: 600; }
.breadcrumb-line i { font-size: 0.65rem; }

.topbar-right { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }

.school-year-pill {
    background: var(--teal-soft);
    color: var(--teal-dark);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 7px 14px;
    border-radius: 20px;
    white-space: nowrap;
}

.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--navy-deep);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 600;
}
.user-name { font-size: 0.85rem; font-weight: 600; line-height: 1.2; }
.user-role { font-size: 0.72rem; color: var(--text-muted); }

/* Page content */
.page-content { padding: 26px 28px; flex: 1; }

.content-footer {
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 16px 28px 22px;
}

/* Generic building blocks */
.page-heading {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--navy-deep);
    margin-bottom: 4px;
}
.page-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    padding: 20px 22px;
    height: 100%;
}
.stat-card .stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--teal-soft);
    color: var(--teal-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 14px;
}
.stat-card .stat-value {
    font-family: var(--font-display);
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--navy-deep);
}
.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.panel {
    background: var(--card-bg);
    border: 1px solid var(--border-soft);
    border-radius: 14px;
    padding: 22px 24px;
}
.panel-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1rem;
    color: var(--navy-deep);
    margin-bottom: 16px;
}

.placeholder-box {
    border: 1.5px dashed var(--border-soft);
    border-radius: 12px;
    padding: 46px 20px;
    text-align: center;
    color: var(--text-muted);
    background: var(--bg-soft);
}
.placeholder-box i { font-size: 2rem; color: var(--teal); display: block; margin-bottom: 10px; }

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
}
.data-table th {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--bg-soft);
}
.data-table tbody tr:hover { background: var(--bg-soft); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.auth-body {
    margin: 0;
    min-height: 100vh;
    font-family: var(--font-body);
    background: linear-gradient(160deg, var(--navy-deep) 0%, var(--sidebar-gradient) 55%, var(--navy-mid) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.auth-wrapper { width: 100%; max-width: 440px; }

.auth-card {
    background: #fff;
    border-radius: 18px;
    padding: 34px 34px 28px;
    box-shadow: 0 24px 60px rgba(6, 20, 38, 0.35);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.auth-heading {
    font-family: var(--font-display);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--navy-deep);
    margin-bottom: 2px;
}
.auth-sub {
    font-size: 0.86rem;
    color: var(--text-muted);
    margin-bottom: 20px;
}

.auth-submit-btn {
    background: var(--navy-deep);
    color: #fff;
    font-weight: 600;
    padding: 11px;
    border-radius: 10px;
    border: none;
}
.auth-submit-btn:hover { background: var(--navy-mid); color: #fff; }

.auth-footnote {
    margin-top: 18px;
    font-size: 0.76rem;
    color: var(--text-muted);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.5;
}
.auth-footnote i { margin-top: 2px; color: var(--teal); }

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 18px;
    font-size: 0.82rem;
    color: var(--text-muted);
}
.back-link:hover { color: var(--navy-deep); }

.btn-login {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--navy-deep);
    color: #fff;
    font-size: 0.88rem;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 10px;
    transition: background 0.15s ease;
}
.btn-login:hover { background: var(--navy-mid); color: #fff; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .content-wrapper { margin-left: 0; width: 100%; }
    .btn-burger { display: flex; }
    .user-info { display: none; }
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: color-mix(in srgb, var(--navy-deep) 45%, transparent);
    z-index: 1025;
}
.sidebar-backdrop.show { display: block; }

/* Term select pill inline styles */
.term-select-pill {
    background: transparent;
    border: none;
    color: var(--navy-deep);
    font: inherit;
    font-weight: 500;
    font-size: 0.875rem;
    padding: 0 1.4rem 0 .4rem;
    margin: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%235c6bc0' d='M4.646 6.646a.5.5 0 0 1 .708 0L8 9.293l2.646-2.647a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .1rem center;
    max-width: 220px;
    text-overflow: ellipsis;
}
.term-select-pill:focus { outline: none; }
