/* ============================================================
   assets/css/style.css
   Smart Campus AMS — Interface Stylesheet
   Enterprise / institutional visual system built on Bootstrap 5.
   ============================================================ */

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

/* ── Design tokens ── */
:root {
    /* Brand / primary — deep academic navy */
    --primary:        #1D3F66;
    --primary-dark:   #142C49;
    --primary-light:  #E7ECF3;
    --primary-lighter:#DCE4EF;

    /* Semantic status colors */
    --success:        #1E7145;
    --success-dark:   #145433;
    --success-light:  #DFF0E6;

    --warning:         #A3690C;
    --warning-dark:    #7A4E09;
    --warning-ink:     #5C3D08;
    --warning-light:   #F6ECD9;

    --danger:          #B23A2E;
    --danger-dark:     #8C2E24;
    --danger-light:    #F5E2DF;

    --info:            #1E504E;
    --info-dark:       #163B3A;
    --info-mid:        #2A6F6D;
    --info-light:      #DEEDEC;

    /* Neutrals */
    --ink:             #1C2530;
    --ink-soft:        #3E4A5C;
    --muted:           #5B6878;
    --muted-soft:      #8FA0B5;
    --border:          #E1E6ED;
    --border-soft:     #EEF1F5;
    --surface:         #FFFFFF;
    --surface-alt:     #F6F8FA;
    --bg-app:          #F2F4F6;

    /* Sidebar */
    --sidebar-w:       260px;
    --sidebar-bg:      #14202F;
    --sidebar-hover:   #1D2C40;
    --sidebar-active:  #1D3F66;
    --sidebar-border:  #223349;
    --sidebar-text:    #8FA0B5;
    --sidebar-text-s:  #E8EDF3;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(28,37,48,.06), 0 1px 1px rgba(28,37,48,.04);
    --shadow-md: 0 4px 10px -2px rgba(28,37,48,.10), 0 2px 4px -2px rgba(28,37,48,.06);
    --shadow-lg: 0 10px 24px -8px rgba(28,37,48,.16), 0 4px 8px -4px rgba(28,37,48,.08);

    /* Radius — 8 to 12px range, no oversized corners */
    --radius-sm: 8px;
    --radius-md: 10px;
    --radius-lg: 12px;

    --transition: all .15s ease;
    --font-main: 'Public Sans', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-main);
    background: var(--bg-app);
    color: var(--ink);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
    line-height: 1.5;
}

h1, h2, h3, h4, h5, h6 { font-family: var(--font-main); font-weight: 700; color: var(--ink); letter-spacing: -.01em; }
code, kbd, samp { font-family: var(--font-mono); }

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}

/* Accessible focus ring, used everywhere instead of the browser default */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, .nav-link:focus-visible, .btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Global scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD3DD; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #A9B4C2; }

/* ── Bootstrap utility overrides — keep the whole system on one palette ── */
.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning-dark) !important; }
.text-danger  { color: var(--danger) !important; }
.text-info    { color: var(--info-mid) !important; }
.text-muted   { color: var(--muted) !important; }
.text-dark    { color: var(--ink) !important; }
.text-secondary { color: var(--muted) !important; }

.alert { border-radius: var(--radius-md); border: 1px solid transparent; font-size: .875rem; }
.alert-primary { background: var(--primary-light); color: var(--primary); }
.alert-success { background: var(--success-light); color: var(--success-dark); }
.alert-warning { background: var(--warning-light); color: var(--warning-ink); }
.alert-danger  { background: var(--danger-light);  color: var(--danger-dark); }
.alert-info    { background: var(--info-light);    color: var(--info-dark); }

/* Badges — soft tint + solid text reads as calmer, more institutional than solid-fill pills */
.badge { font-family: var(--font-main); font-size: .72rem; font-weight: 600; padding: .32rem .6rem; border-radius: 5px; letter-spacing: .01em; }
.badge.bg-primary   { background: var(--primary-light) !important;  color: var(--primary) !important; }
.badge.bg-success   { background: var(--success-light) !important;  color: var(--success-dark) !important; }
.badge.bg-warning   { background: var(--warning-light) !important;  color: var(--warning-ink) !important; }
.badge.bg-danger    { background: var(--danger-light) !important;   color: var(--danger-dark) !important; }
.badge.bg-info      { background: var(--info-light) !important;     color: var(--info-dark) !important; }
.badge.bg-secondary { background: var(--border-soft) !important;    color: var(--muted) !important; }
.badge.bg-light      { background: var(--border-soft) !important;   color: var(--ink-soft) !important; }

/* ── Login page ── */
.login-page {
    min-height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.login-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 2.75rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 24px 48px rgba(0,0,0,.28);
    border: 1px solid rgba(255,255,255,.06);
}
.login-logo {
    width: 56px; height: 56px;
    background: var(--primary);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 1.5rem;
}
.login-logo i { font-size: 1.6rem; color: #fff; }
.login-title { font-weight: 700; font-size: 1.4rem; color: var(--ink); text-align: center; letter-spacing: -.01em; }
.login-sub { color: var(--muted); font-size: .8rem; text-align: center; margin-bottom: 1.75rem; line-height: 1.55; }

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

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: #2E3E58; border-radius: 4px; }

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1.375rem 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
}
.brand-icon {
    width: 38px; height: 38px;
    background: var(--primary);
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.brand-icon i { font-size: 1.1rem; color: #fff; }
.brand-title { font-weight: 700; color: var(--sidebar-text-s); font-size: .92rem; display: block; letter-spacing: -.005em; }
.brand-sub { font-size: .68rem; color: var(--sidebar-text); letter-spacing: .02em; }

.sidebar-admin {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: .9rem 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
}
.admin-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,.06);
    border: 1px solid var(--sidebar-border);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.admin-avatar i { font-size: 1.2rem; color: var(--sidebar-text); }
.admin-name { font-size: .78rem; font-weight: 600; color: var(--sidebar-text-s); display: block; }
.admin-role { font-size: .68rem; color: var(--sidebar-text); }

.sidebar-nav {
    list-style: none;
    padding: .75rem 0;
    flex: 1;
}
.nav-label {
    padding: .9rem 1.25rem .35rem;
    font-size: .64rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #56698A;
}
.nav-item { padding: .0625rem .75rem; }
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: .58rem .8rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: .845rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}
.nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-s); }
.nav-link.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-link i { font-size: 1rem; flex-shrink: 0; width: 18px; text-align: center; }

.pulse-badge { font-size: .62rem; padding: .18rem .42rem; }

/* ── Main content ── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── Top bar ── */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .8rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 999;
}
.topbar-left { display: flex; align-items: center; gap: .75rem; }
.sidebar-toggle {
    width: 34px; height: 34px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--muted);
    transition: var(--transition);
}
.sidebar-toggle:hover { background: var(--surface-alt); border-color: #C9D2DE; }
.page-title { font-weight: 700; font-size: 1.05rem; color: var(--ink); }

.topbar-right { display: flex; align-items: center; gap: 1rem; }
.live-clock { font-size: .78rem; color: var(--muted); text-align: right; }
.live-clock .time { font-size: .95rem; font-weight: 700; color: var(--ink); display: block; }

/* ── Page content ── */
.page-content { padding: 1.5rem 1.75rem; flex: 1; }

/* ── Stat cards — compact, flat, no decorative fluff ── */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 1.15rem 1.25rem;
    border: 1px solid var(--border);
    border-left: 3px solid var(--card-accent, var(--primary));
    transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-sm); }
.stat-icon {
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    margin-bottom: .85rem;
}
.stat-number { font-size: 1.6rem; font-weight: 800; color: var(--ink); line-height: 1; letter-spacing: -.015em; }
.stat-label { font-size: .78rem; color: var(--muted); font-weight: 500; margin-top: .35rem; }
.stat-change { font-size: .74rem; margin-top: .55rem; display: flex; align-items: center; gap: .3rem; color: var(--muted); }
.stat-change.up { color: var(--success); }
.stat-change.neutral { color: var(--muted); }

/* ── Card ── */
.card {
    background: var(--surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    padding: 1.05rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    background: var(--surface-alt);
}
.card-title { font-weight: 700; font-size: .92rem; color: var(--ink); margin: 0; letter-spacing: -.005em; display: flex; align-items: center; }
.card-body { padding: 1.25rem; }

/* ── Tables ── */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .845rem; }
thead tr { background: var(--surface-alt); }
th { padding: .75rem .9rem; text-align: left; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: .75rem .9rem; border-bottom: 1px solid var(--border-soft); color: var(--ink); vertical-align: middle; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: var(--surface-alt); }
tbody tr:last-child td { border-bottom: none; }
code { font-size: .82em; color: var(--ink-soft); background: var(--border-soft); padding: .1rem .35rem; border-radius: 4px; }
td code { background: transparent; padding: 0; color: var(--primary); }

/* ── Forms ── */
.form-label { font-size: .82rem; font-weight: 600; color: var(--ink-soft); margin-bottom: .35rem; }
.form-control, .form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: .5rem .8rem;
    font-size: .875rem;
    font-family: var(--font-main);
    color: var(--ink);
    transition: var(--transition);
    background: #fff;
}
.form-control:hover, .form-select:hover { border-color: #C2CCDA; }
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(29,63,102,.14);
    outline: none;
}
.input-group-text { background: var(--surface-alt); border-color: var(--border); color: var(--muted); }

/* ── Buttons ── */
.btn {
    font-family: var(--font-main);
    font-weight: 600;
    font-size: .84rem;
    border-radius: var(--radius-sm);
    padding: .5rem 1rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: .4rem;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: var(--success-dark); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-dark); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: var(--warning-dark); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-info:hover { background: var(--info-dark); color: #fff; }
.btn-outline-primary { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline-primary:hover { background: var(--primary-light); color: var(--primary); }
.btn-sm { font-size: .78rem; padding: .38rem .75rem; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; }

/* ── QR Scanner ── */
.scanner-container {
    background: var(--sidebar-bg);
    border-radius: var(--radius-lg);
    overflow: hidden;
    position: relative;
    box-shadow: var(--shadow-md);
}
.scanner-header {
    background: var(--primary);
    padding: 1.35rem;
    text-align: center;
    color: white;
}
.scanner-header h4 { font-weight: 700; margin: 0; font-size: 1.05rem; }
#reader { border-radius: 0; }
#reader video { border-radius: 0 !important; }
.scan-result-box {
    background: #1D2C40;
    padding: 1.5rem;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.scan-success { text-align: center; color: var(--success); }
.scan-success i { font-size: 2.4rem; }
.scan-waiting { text-align: center; color: var(--sidebar-text); }
.scan-waiting i { font-size: 1.9rem; }

/* ── QR code display ── */
.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: white;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}
.qr-container img { max-width: 150px; border-radius: 4px; }

/* ── Avatar ── */
.student-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border);
}
.avatar-placeholder {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary-light);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: 700;
    font-size: .85rem;
    flex-shrink: 0;
}

/* ── Modal ── */
.modal-content { border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-lg); }
.modal-backdrop.show { opacity: .5; }
.modal-header { border-bottom: 1px solid var(--border); padding: 1.1rem 1.35rem; }
.modal-title { font-weight: 700; letter-spacing: -.005em; font-size: 1rem; }
.modal-body { padding: 1.35rem; }
.modal-footer { border-top: 1px solid var(--border); padding: .9rem 1.35rem; }

/* ── Toast ── */
.toast-container { z-index: 9999; }
.toast { border-radius: var(--radius-md); border: 1px solid var(--border); box-shadow: var(--shadow-lg); min-width: 300px; }
.toast-body { font-size: .845rem; font-weight: 500; color: var(--ink); }

/* ── Empty state ── */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty-state i {
    font-size: 1.6rem;
    width: 56px; height: 56px;
    display: inline-flex; align-items: center; justify-content: center;
    margin-bottom: .9rem;
    border-radius: 50%;
    background: var(--surface-alt);
    color: var(--muted-soft);
}
.empty-state p { font-size: .875rem; }

/* ── Breadcrumb ── */
.breadcrumb { font-size: .78rem; margin: 0; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--muted-soft); }
.breadcrumb-item a { color: var(--muted); text-decoration: none; }
.breadcrumb-item a:hover { color: var(--primary); }
.breadcrumb-item.active { color: var(--ink-soft); }

/* ── Profile picture preview ── */
.pic-preview {
    width: 92px; height: 92px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--border-soft);
    display: block;
    margin: 0 auto .75rem;
}

/* ── Loading ── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20,32,47,.55);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.loading-spinner {
    width: 42px; height: 42px;
    border: 3px solid rgba(255,255,255,.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Pagination ── */
.pagination .page-link {
    color: var(--primary);
    border-color: var(--border);
    font-size: .8rem;
    padding: .4rem .75rem;
}
.pagination .page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ── Dashboard chart area ── */
.chart-container { position: relative; height: 260px; }

/* ── Responsive ── */
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.show { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .main-content { margin-left: 0; }
    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15,23,32,.45);
        z-index: 999;
    }
    .sidebar-overlay.show { display: block; }
}
@media (max-width: 767px) {
    .live-clock { display: none; }
}
@media (max-width: 576px) {
    .page-content { padding: 1rem; }
    .topbar { padding: .7rem .9rem; }
    .stat-number { font-size: 1.4rem; }
    .stat-card { padding: 1rem; }
    .stat-icon { width: 36px; height: 36px; font-size: 1rem; margin-bottom: .65rem; }
    .card-header { padding: .9rem 1rem; }
    .card-body { padding: 1rem; }
    .login-card { padding: 2rem 1.5rem; }
}
