/* design tokens */
:root {
    --maroon: #7b1113;
    --maroon-dark: #5d0d0e;
    --gold: #f0b429;
    --ink: #1c1c1e;
    --muted: #6b7280;
    --line: #e5e7eb;
    --bg: #f6f6f7;
    --surface: #ffffff;
    --ok: #1a7f37;
    --late: #b45309;
    --danger: #b42318;
    --radius: 12px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.10);
    --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}

/* reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); line-height: 1.5; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

/* layout container */
.container { max-width: 1080px; margin: 0 auto; padding: 28px 20px 64px; }

/* typography */
.page-head { margin-bottom: 24px; }
.page-title { font-size: 1.6rem; font-weight: 700; margin: 0; letter-spacing: -0.01em; }
.page-sub { color: var(--muted); margin: 4px 0 0; }
.section-title { font-size: 1.05rem; font-weight: 600; margin: 28px 0 12px; }

/* ===== app shell (logged-in, liquid glass) ===== */
body.app {
    color: #f5f5f7;
    background-color: #0a0a0d;
    background-image:
        radial-gradient(45% 40% at 100% 0%, rgba(123, 17, 19, 0.40), transparent 60%),
        radial-gradient(40% 40% at 0% 100%, rgba(240, 180, 41, 0.06), transparent 55%),
        linear-gradient(180deg, #140406, #0a0a0d 60%);
    background-attachment: fixed;
    min-height: 100vh;
}

.shell { display: flex; align-items: stretch; min-height: 100vh; }

/* glass side navigation */
.sidebar { width: 250px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 22px 16px; background: rgba(255, 255, 255, 0.045); -webkit-backdrop-filter: blur(20px) saturate(140%); backdrop-filter: blur(20px) saturate(140%); border-right: 1px solid rgba(255, 255, 255, 0.09); }
.sidebar__brand { display: flex; align-items: center; gap: 11px; padding: 4px 6px 18px; margin-bottom: 14px; border-bottom: 1px solid rgba(255, 255, 255, 0.09); }
.sidebar__logos { display: inline-flex; gap: 4px; flex-shrink: 0; }
.sidebar__logos img { width: 26px; height: 26px; object-fit: contain; border-radius: 50%; background: #0a0a0d; border: 1px solid rgba(255, 255, 255, 0.18); padding: 2px; }
.sidebar__brand-text { font-weight: 700; font-size: 0.88rem; line-height: 1.15; color: #fff; }
.sidebar__nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.sidebar__nav a { display: flex; align-items: center; padding: 11px 13px; border-radius: 10px; color: rgba(245, 245, 247, 0.68); font-size: 0.92rem; font-weight: 500; border: 1px solid transparent; transition: background 0.15s, color 0.15s, border-color 0.15s; }
.sidebar__icon { width: 18px; height: 18px; margin-right: 12px; flex-shrink: 0; opacity: 0.72; transition: opacity 0.15s; }
.sidebar__nav a:hover .sidebar__icon, .sidebar__nav a.is-active .sidebar__icon { opacity: 1; }
.sidebar__nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.sidebar__nav a.is-active { background: linear-gradient(90deg, rgba(123, 17, 19, 0.55), rgba(123, 17, 19, 0.18)); color: #fff; border-color: rgba(240, 180, 41, 0.30); }
.sidebar__user { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.09); display: flex; flex-direction: column; gap: 12px; }
.sidebar__id { display: flex; flex-direction: column; gap: 1px; padding: 0 4px; }
.sidebar__name { color: #fff; font-weight: 600; font-size: 0.9rem; }
.sidebar__role { color: rgba(245, 245, 247, 0.5); font-size: 0.78rem; }
.sidebar .btn--ghost { color: #fff; border-color: rgba(255, 255, 255, 0.25); }
.sidebar .btn--ghost:hover { background: rgba(255, 255, 255, 0.10); border-color: rgba(255, 255, 255, 0.45); }

/* main content area on the dark shell */
.content { flex: 1; min-width: 0; padding: 30px 36px 56px; }
body.app .page-sub { color: rgba(245, 245, 247, 0.6); }
body.app .section-title { color: #fff; }

/* app shell ghost buttons (removes dark toggle hover effect) */
body.app .btn--ghost {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.20);
    background: transparent;
}
body.app .btn--ghost:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.40);
    color: #fff;
}

/* footer (guest pages) */
.footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 24px; border-top: 1px solid var(--line); }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; font-size: 0.92rem; padding: 10px 16px; border-radius: 9px; border: 1px solid transparent; cursor: pointer; transition: background 0.15s, border-color 0.15s; }
.btn--primary { background: var(--maroon); color: #fff; }
.btn--primary:hover { background: var(--maroon-dark); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { background: var(--bg); }
.btn--block { width: 100%; }
.btn--sm { padding: 6px 12px; font-size: 0.85rem; }

/* tables */
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 0.92rem; }
.table th { background: var(--bg); color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.table tr:last-child td { border-bottom: none; }
.table__empty { text-align: center; color: var(--muted); padding: 28px; }

/* status badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; }
.badge--present { background: #e6f4ea; color: var(--ok); }
.badge--late { background: #fef3e2; color: var(--late); }

/* forms */
.form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); max-width: 520px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 0.85rem; font-weight: 600; color: var(--ink); }
.field__input { font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fff; transition: border-color 0.15s, box-shadow 0.15s; }
.field__input:focus { outline: none; border-color: var(--maroon); box-shadow: 0 0 0 3px rgba(123, 17, 19, 0.12); }

/* alerts */
.alert { padding: 10px 14px; border-radius: 9px; font-size: 0.9rem; font-weight: 500; }
.alert--error { background: #fdecec; color: var(--danger); border: 1px solid #f7c9c9; }

/* responsive: collapse the sidebar into a top bar */
@media (max-width: 820px) {
    .shell { flex-direction: column; }
    .sidebar { width: auto; height: auto; position: static; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 16px; }
    .sidebar__brand { border-bottom: none; margin: 0; padding: 0 8px 0 0; }
    .sidebar__nav { flex-direction: row; flex-wrap: wrap; flex: 1 0 100%; gap: 4px; }
    .sidebar__user { flex: 1 0 100%; flex-direction: row; align-items: center; justify-content: space-between; margin: 0; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, 0.09); }
    .sidebar__user .btn { width: auto; }
    .content { padding: 22px 18px 40px; }
}

/* ===== Offline Splash Overlay ===== */
.offline-splash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(10, 10, 13, 0.82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.offline-splash.is-visible {
    opacity: 1;
    pointer-events: all;
}

.offline-splash__card {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 40px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    color: #fff;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.offline-splash.is-visible .offline-splash__card {
    transform: scale(1);
}

.offline-splash__icon-wrapper {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.15);
    animation: offline-pulse 2s infinite;
}

.offline-splash__icon {
    width: 36px;
    height: 36px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

.offline-splash__title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 12px;
    letter-spacing: -0.02em;
}

.offline-splash__text {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 28px;
    line-height: 1.6;
}

.offline-splash__button {
    background: #fff;
    color: #000;
    border: none;
    border-radius: 12px;
    padding: 12px 24px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.15);
}

.offline-splash__button:hover {
    background: #f5f5f7;
    transform: translateY(-2px);
}

.offline-splash__button:active {
    transform: translateY(0);
}

.offline-splash__button:disabled {
    background: rgba(255, 255, 255, 0.5);
    color: rgba(0, 0, 0, 0.5);
    cursor: not-allowed;
    transform: none;
}

.offline-splash__spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    border-top-color: #000;
    border-radius: 50%;
    animation: offline-spin 1s linear infinite;
    display: inline-block;
}

@keyframes offline-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    70% {
        box-shadow: 0 0 0 16px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

@keyframes offline-spin {
    to { transform: rotate(360deg); }
}

.offline-shake {
    animation: offline-shake-anim 0.4s ease-in-out;
}

@keyframes offline-shake-anim {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-6px); }
    40%, 80% { transform: translateX(6px); }
}



/* footer legal links (guest + app) */
.app-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-top: 28px; padding: 18px 4px 4px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.82rem; }
.legal-links { display: inline-flex; align-items: center; gap: 8px; }
.legal-sep { color: var(--muted); opacity: 0.6; }
.legal-link { font: inherit; font-size: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.legal-link:hover { color: var(--maroon); }
body.guest .footer .legal-link:hover { color: var(--gold); }
body.app .app-footer { border-top-color: rgba(255, 255, 255, 0.09); color: rgba(245, 245, 247, 0.55); }
body.app .app-footer .legal-sep { color: rgba(245, 245, 247, 0.4); }
body.app .app-footer .legal-link:hover { color: var(--gold); }

/* legal modal (terms & privacy) */
body.modal-open { overflow: hidden; }
.legal-modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.legal-modal[hidden] { display: none !important; }
.legal-modal__overlay { position: absolute; inset: 0; background: rgba(16, 18, 22, 0.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.legal-modal__card { position: relative; display: flex; flex-direction: column; width: 100%; max-width: 640px; max-height: 86vh; background: var(--surface); border-radius: 16px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35); overflow: hidden; animation: legal-pop 0.18s ease-out; }
@keyframes legal-pop { from { transform: translateY(10px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.legal-modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.legal-modal__title { margin: 0; font-size: 1.15rem; color: var(--maroon); }
.legal-modal__close { font-size: 1.5rem; line-height: 1; color: var(--muted); background: none; border: 0; cursor: pointer; padding: 0 4px; }
.legal-modal__close:hover { color: var(--ink); }
.legal-modal__body { padding: 20px 22px; overflow-y: auto; color: var(--ink); font-size: 0.9rem; line-height: 1.6; }
.legal-modal__body h3 { margin: 18px 0 6px; font-size: 0.98rem; color: var(--maroon); }
.legal-modal__body p { margin: 0 0 8px; }
.legal-modal__body ul { margin: 0 0 8px; padding-left: 20px; }
.legal-modal__body li { margin-bottom: 4px; }
.legal-updated { color: var(--muted); font-size: 0.82rem; }
.legal-modal__foot { display: flex; justify-content: flex-end; padding: 14px 22px; border-top: 1px solid var(--line); }

/* ===== Scroll Reveal Animations ===== */
.reveal-on-scroll {
    opacity: 0 !important;
    will-change: transform, opacity;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
    transition-delay: var(--reveal-delay, 0s);
}

/* Default vertical slide-up behavior */
.reveal-on-scroll {
    transform: translateY(24px) translateZ(0);
}

/* Left slide reveal (e.g., login visual branding) */
.reveal-on-scroll.reveal-left {
    transform: translateX(-32px) translateZ(0);
}

/* Right slide reveal (e.g., login form card) */
.reveal-on-scroll.reveal-right {
    transform: translateX(32px) translateZ(0);
}

/* Scale and lift pop-in reveal (e.g., dashboard cards) */
.reveal-on-scroll.reveal-scale {
    transform: translateY(24px) scale(0.96) translateZ(0);
}

/* Revealed active state */
.reveal-on-scroll.revealed {
    opacity: 1 !important;
    transform: none !important;
}
