/* ============================================================
   CloudeGatePass — site.css
   Mobile-first, fully responsive PWA-style UI.
   Breakpoints: mobile-first, tablet 640px+, desktop 1024px+
   ============================================================ */

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

:root {
    --c-primary:      #1a56db;
    --c-primary-dark: #1347bc;
    --c-primary-light:#dbeafe;
    --c-success:      #16a34a;
    --c-success-light:#dcfce7;
    --c-danger:       #dc2626;
    --c-danger-light: #fee2e2;
    --c-warning:      #d97706;
    --c-warning-light:#fef3c7;
    --c-text:         #111827;
    --c-text-muted:   #6b7280;
    --c-border:       #e5e7eb;
    --c-bg:           #f9fafb;
    --c-white:        #ffffff;
    --c-sidebar-bg:   #1e2433;
    --c-sidebar-text: #c9d1e9;
    --c-sidebar-hover:#2d3451;
    --c-sidebar-active:#3b82f6;
    --sidebar-w:      240px;
    --navbar-h:       56px;
    --radius:         8px;
    --radius-lg:      12px;
    --shadow:         0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:      0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --transition:     150ms ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--c-text);
    background: var(--c-bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Typography ───────────────────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.375rem; font-weight: 600; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 1rem;     font-weight: 600; }
small, .text-muted { font-size: .875rem; color: var(--c-text-muted); }
code { font-family: 'SF Mono', 'Fira Code', monospace; font-size: .85em;
       background: #f3f4f6; padding: 2px 6px; border-radius: 4px; }

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 100;
    height: var(--navbar-h);
    background: var(--c-white);
    border-bottom: 1px solid var(--c-border);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px;
    box-shadow: var(--shadow);
}

.navbar-brand { display: flex; align-items: center; gap: 10px; }

.nav-toggle {
    display: flex; flex-direction: column; gap: 4px;
    background: none; border: none; cursor: pointer; padding: 6px;
}
.nav-toggle span {
    display: block; width: 20px; height: 2px;
    background: var(--c-text); border-radius: 2px;
    transition: var(--transition);
}

.brand-link {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; font-size: 1rem; color: var(--c-text);
}
.brand-link:hover { text-decoration: none; }
.brand-icon { font-size: 1.25rem; }

.navbar-actions { display: flex; align-items: center; gap: 8px; }

.icon-btn {
    position: relative;
    background: none; border: none; cursor: pointer;
    padding: 8px; border-radius: var(--radius);
    color: var(--c-text-muted);
    transition: background var(--transition);
}
.icon-btn:hover { background: var(--c-bg); }
.icon-btn svg { width: 20px; height: 20px; display: block; }

.notif-badge {
    position: absolute; top: 4px; right: 4px;
    background: var(--c-danger); color: white;
    font-size: .625rem; font-weight: 700;
    min-width: 16px; height: 16px;
    border-radius: 8px; padding: 0 3px;
    display: flex; align-items: center; justify-content: center;
}

.user-menu { position: relative; }
.user-btn {
    background: none; border: none; cursor: pointer; padding: 4px;
    border-radius: 50%;
}
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--c-primary); color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: .875rem; font-weight: 600;
}
.avatar--lg { width: 44px; height: 44px; font-size: 1.1rem; }

.user-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    background: var(--c-white); border: 1px solid var(--c-border);
    border-radius: var(--radius-lg); padding: 8px 0;
    min-width: 180px; box-shadow: var(--shadow-md);
    display: none;
}
.user-dropdown.open { display: block; }
.user-info { padding: 8px 16px 12px; border-bottom: 1px solid var(--c-border); }
.user-info strong { display: block; font-size: .9rem; }
.user-dropdown a {
    display: block; padding: 8px 16px; color: var(--c-text);
    font-size: .875rem;
}
.user-dropdown a:hover { background: var(--c-bg); text-decoration: none; }
.logout-link { color: var(--c-danger) !important; }

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: var(--navbar-h); bottom: 0; left: 0;
    width: var(--sidebar-w);
    background: var(--c-sidebar-bg);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 250ms ease;
    z-index: 90;
}
.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 89;
}
.sidebar-overlay.open { display: block; }

.sidebar-nav { padding: 16px 0; }

.nav-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 20px;
    color: var(--c-sidebar-text);
    font-size: .875rem;
    border-left: 3px solid transparent;
    transition: background var(--transition), border-color var(--transition);
}
.nav-item:hover { background: var(--c-sidebar-hover); text-decoration: none; }
.nav-item.active {
    background: var(--c-sidebar-hover);
    border-left-color: var(--c-sidebar-active);
    color: white;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Main content ─────────────────────────────────────────── */
.main-content {
    padding: calc(var(--navbar-h) + 20px) 16px 40px;
    min-height: 100vh;
}
@media (min-width: 1024px) {
    .nav-toggle { display: none; }

    .sidebar {
        transform: translateX(0);
        position: fixed;
    }
    .main-content.with-sidebar {
        margin-left: var(--sidebar-w);
        padding-left: 28px;
        padding-right: 28px;
    }
}

/* ── Auth pages ───────────────────────────────────────────── */
.auth-page { background: #f0f4ff; min-height: 100vh;
             display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-container { width: 100%; max-width: 400px; }
.auth-card {
    background: var(--c-white); border-radius: var(--radius-lg);
    padding: 32px 28px; box-shadow: var(--shadow-md);
}
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand .auth-icon { font-size: 2.5rem; display: block; margin-bottom: 8px; }
.auth-brand h1 { font-size: 1.5rem; }
.auth-brand p { color: var(--c-text-muted); font-size: .875rem; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--c-text-muted); font-size: .875rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--c-border); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px; font-size: .875rem; font-weight: 500;
    border-radius: var(--radius); cursor: pointer;
    border: 1px solid transparent;
    transition: background var(--transition), border-color var(--transition), opacity var(--transition);
    white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--c-primary); color: white; }
.btn-primary:hover { background: var(--c-primary-dark); }
.btn-outline  { background: var(--c-white); color: var(--c-text); border-color: var(--c-border); }
.btn-outline:hover { background: var(--c-bg); }
.btn-danger   { background: var(--c-danger); color: white; }
.btn-sm       { padding: 6px 12px; font-size: .8125rem; }
.btn-full     { width: 100%; }
.mt-2 { margin-top: 8px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group  { margin-bottom: 18px; }
.form-label, label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 10px 12px;
    border: 1px solid var(--c-border); border-radius: var(--radius);
    font-size: .9375rem; background: var(--c-white); color: var(--c-text);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
}
.form-control:focus { outline: none; border-color: var(--c-primary);
                      box-shadow: 0 0 0 3px var(--c-primary-light); }
textarea.form-control { resize: vertical; min-height: 80px; }
.password-wrap { position: relative; }
.password-wrap .form-control { padding-right: 44px; }
.toggle-pw {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; color: var(--c-text-muted);
}
.toggle-pw svg { width: 18px; height: 18px; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--c-white); border: 1px solid var(--c-border);
    border-radius: var(--radius-lg); padding: 20px;
    box-shadow: var(--shadow);
}
.form-card { max-width: 560px; }
.form-card .card { padding: 24px; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
    padding: 12px 16px; border-radius: var(--radius);
    margin-bottom: 16px; font-size: .875rem;
}
.alert-success { background: var(--c-success-light); color: #14532d; }
.alert-error   { background: var(--c-danger-light);  color: #7f1d1d; }
.alert-info    { background: var(--c-primary-light);  color: #1e3a8a; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 8px; font-size: .75rem; font-weight: 600;
    border-radius: 12px;
}
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-completed { background: var(--c-success-light); color: #14532d; }
.badge-expired   { background: #f3f4f6; color: #374151; }
.badge-rejected  { background: var(--c-danger-light); color: #7f1d1d; }

.role-badge     { display: inline-block; padding: 2px 8px; border-radius: 12px;
                  font-size: .7rem; font-weight: 600; margin-top: 2px; }
.role-admin      { background: #e9d5ff; color: #581c87; }
.role-teacher    { background: #dbeafe; color: #1e3a8a; }
.role-parent     { background: #dcfce7; color: #14532d; }
.role-gatekeeper { background: #fef3c7; color: #78350f; }

/* ── Page header ──────────────────────────────────────────── */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px; margin-bottom: 24px;
}
.page-header h2 { margin: 0; }
.section-label { font-size: .75rem; font-weight: 600; text-transform: uppercase;
                 letter-spacing: .05em; color: var(--c-text-muted); margin-bottom: 10px; }
.mb-4 { margin-bottom: 16px; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { text-align: left; padding: 10px 12px; font-weight: 600;
            border-bottom: 2px solid var(--c-border); color: var(--c-text-muted); }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f9fafb; }

/* ── Gate pass cards (shared) ─────────────────────────────── */
.pass-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.pass-card {
    background: var(--c-white); border: 1px solid var(--c-border);
    border-radius: var(--radius-lg); padding: 16px;
    box-shadow: var(--shadow);
}
.pass-card--active { border-color: var(--c-primary); }
.pass-header { display: flex; align-items: center; justify-content: space-between;
               margin-bottom: 10px; }
.pass-number { font-family: monospace; font-size: .875rem; font-weight: 600; }
.pass-meta   { font-size: .8125rem; color: var(--c-text-muted); }

/* Teacher pass card */
.teacher-pass-card, .gk-pass-card {
    background: var(--c-white); border: 1px solid var(--c-border);
    border-radius: var(--radius-lg); overflow: hidden;
    box-shadow: var(--shadow);
    transition: transform var(--transition);
}
.teacher-pass-card--new { animation: slideIn .3s ease; border-color: var(--c-primary); }
.pass-card-header, .gk-pass-header {
    padding: 12px 16px; background: #f8faff;
    border-bottom: 1px solid var(--c-border);
    display: flex; align-items: center; justify-content: space-between;
}
.pass-card-body, .gk-pass-body { padding: 14px 16px; }
.info-row, .gk-info-row {
    display: flex; gap: 8px; font-size: .8125rem; margin-bottom: 6px;
}
.info-label, .gk-label {
    min-width: 72px; color: var(--c-text-muted); font-weight: 500; flex-shrink: 0;
}

/* ── Student cards ────────────────────────────────────────── */
.card-grid { display: grid; gap: 12px;
             grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.card-grid--sm { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }

.student-card {
    background: var(--c-white); border: 1px solid var(--c-border);
    border-radius: var(--radius-lg); padding: 14px;
    display: flex; align-items: center; gap: 12px;
    box-shadow: var(--shadow);
}
.student-card div { display: flex; flex-direction: column; gap: 2px; }

/* Student select list (request pass form) */
.student-select-list { display: flex; flex-direction: column; gap: 8px; }
.student-select-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px; border: 2px solid var(--c-border);
    border-radius: var(--radius-lg); cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.student-select-item:has(input:checked) {
    border-color: var(--c-primary);
    background: var(--c-primary-light);
}
.student-select-item input { width: 18px; height: 18px; flex-shrink: 0; accent-color: var(--c-primary); }
.student-select-info { display: flex; align-items: center; gap: 12px; }
.student-select-info > div { display: flex; flex-direction: column; }

/* ── QR Code display ──────────────────────────────────────── */
.qr-page {
    display: flex; justify-content: center; padding: 8px 0;
}
.qr-card {
    background: var(--c-white); border-radius: var(--radius-lg);
    padding: 28px 24px; box-shadow: var(--shadow-md);
    width: 100%; max-width: 400px;
    text-align: center;
}
.qr-header { margin-bottom: 12px; }
.qr-pass-number { margin-bottom: 16px; }
.qr-image-wrap { position: relative; margin: 0 auto 16px; max-width: 260px; }
.qr-image { width: 100%; height: auto; border-radius: var(--radius); display: none; }
.qr-loading { padding: 40px 0; }
.qr-countdown { font-size: 1.125rem; margin-bottom: 16px; }
.countdown-value { font-size: 1.375rem; color: var(--c-success); }
.countdown-value.urgent  { color: var(--c-warning); }
.countdown-value.expired { color: var(--c-danger);  }
.qr-meta { text-align: left; background: var(--c-bg); border-radius: var(--radius);
           padding: 12px; margin-bottom: 16px; }
.qr-meta-row { display: flex; justify-content: space-between; gap: 8px;
               font-size: .875rem; padding: 4px 0; }
.qr-meta-row span:first-child { color: var(--c-text-muted); }
.qr-hint { font-size: .8125rem; color: var(--c-text-muted); margin-bottom: 20px; }
.qr-actions { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 400px) { .qr-actions { flex-direction: row; } }

.qr-status-banner { padding: 16px; border-radius: var(--radius-lg); font-weight: 600;
                    font-size: .9375rem; margin-bottom: 20px; }
.qr-status--completed { background: var(--c-success-light); color: #14532d; }
.qr-status--expired   { background: var(--c-danger-light);  color: #7f1d1d; }

/* Countdown (shared) */
.countdown { font-weight: 600; color: var(--c-success); }
.countdown.expiring { color: var(--c-warning); }
.countdown.expired  { color: var(--c-danger);  }

/* ── Scanner ──────────────────────────────────────────────── */
.scan-page { max-width: 480px; margin: 0 auto; }
.scan-card {
    background: var(--c-white); border: 1px solid var(--c-border);
    border-radius: var(--radius-lg); padding: 20px;
    box-shadow: var(--shadow); margin-bottom: 16px;
}
.scan-label { font-size: .875rem; color: var(--c-text-muted); margin-bottom: 12px; text-align: center; }
.scanner-box { position: relative; border-radius: var(--radius); overflow: hidden; }
#reader { width: 100%; }
.scan-frame {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
}
.scan-frame::before {
    content: ''; display: block; width: 200px; height: 200px;
    border: 2px solid var(--c-primary); border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,.35);
}
.scan-result { margin-top: 16px; padding: 16px; border-radius: var(--radius-lg); text-align: center; }
.scan-result--ok   { background: var(--c-success-light); color: #14532d; }
.scan-result--fail { background: var(--c-danger-light);  color: #7f1d1d; }
.verify-check { font-size: 2rem; display: block; }
.verify-x     { font-size: 2rem; display: block; color: var(--c-danger); }

/* ── Notification panel ───────────────────────────────────── */
.notif-panel {
    position: fixed; top: var(--navbar-h); right: 0;
    width: 340px; max-width: 100vw;
    background: var(--c-white); border-left: 1px solid var(--c-border);
    bottom: 0; overflow-y: auto; z-index: 95;
    box-shadow: -4px 0 12px rgba(0,0,0,.08);
}
.notif-panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px; border-bottom: 1px solid var(--c-border);
    position: sticky; top: 0; background: var(--c-white);
}
.notif-panel-header h3 { font-size: 1rem; }
.close-btn { background: none; border: none; cursor: pointer; font-size: 1.25rem;
             color: var(--c-text-muted); }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--c-border); font-size: .875rem; }
.notif-item.unread { background: #f0f7ff; }
.notif-item-title  { font-weight: 600; margin-bottom: 2px; }
.notif-item-msg    { color: var(--c-text-muted); }
.notif-item-time   { font-size: .75rem; color: var(--c-text-muted); margin-top: 4px; }
.notif-empty { padding: 24px; text-align: center; color: var(--c-text-muted); }

/* ── Empty states ─────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--c-text-muted); }
.empty-state p { margin-bottom: 8px; }

/* ── Spinner ──────────────────────────────────────────────── */
.spinner {
    width: 32px; height: 32px; margin: 0 auto 8px;
    border: 3px solid var(--c-border);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin  { to { transform: rotate(360deg); } }
@keyframes slideIn { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

.fade-out { animation: fadeOut .5s forwards; }
@keyframes fadeOut { to { opacity: 0; transform: scale(.97); } }
