/* =============================================================
   LUC Staff Monitoring — design system
   ============================================================= */

:root {
    --luc-primary: #df1b22;        /* LUC institutional red */
    --luc-primary-hover: #b91218;
    --luc-primary-tint: rgba(223,27,34,.07);
    --luc-accent: #b45309;
    --luc-bg: #f7f8fa;
    --luc-surface: #ffffff;
    --luc-border: #e6e9ee;
    --luc-text: #1f2937;
    --luc-text-muted: #6b7280;
    --luc-sidebar-bg: #ffffff;
    --luc-sidebar-text: #374151;
    --luc-topbar-h: 56px;
    --luc-sidebar-w: 232px;
    --luc-radius: 10px;
}

html { font-size: 14px; }
body {
    background: var(--luc-bg);
    color: var(--luc-text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
    margin: 0;
}

/* ---------- Top bar ---------- */
.topbar {
    height: var(--luc-topbar-h);
    background: var(--luc-surface);
    border-bottom: 1px solid var(--luc-border);
    border-top: 3px solid var(--luc-primary); /* slim brand accent */
    position: sticky;
    top: 0;
    z-index: 1030;
}
.topbar .navbar-brand { color: var(--luc-text); font-size: 1rem; }
.brand-text strong { color: var(--luc-primary); }
.topbar-logo { height: 34px; width: auto; border-radius: 4px; }
.login-logo { max-width: 230px; width: 100%; height: auto; border-radius: 6px; }
.sidebar-toggle { border: 1px solid var(--luc-border); }
.user-menu { border: 1px solid var(--luc-border); background: var(--luc-surface); }

/* Sync loader + last-synced stamp */
.sync-indicator {
    display: inline-flex; align-items: center; gap: .4rem;
    font-size: .8rem; color: var(--luc-primary); font-weight: 600;
}
.sync-spin { display: inline-block; animation: syncSpin 1s linear infinite; font-size: 1rem; }
@keyframes syncSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.last-synced { font-size: .8rem; color: var(--luc-text-muted); white-space: nowrap; }
.last-synced strong { color: var(--luc-text); font-variant-numeric: tabular-nums; }

/* Live indicator */
.live-indicator { display: inline-flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--luc-text-muted); }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #9ca3af; display: inline-block; }
.live-indicator.online .live-dot { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,.18); }
.live-indicator.offline .live-dot { background: #dc2626; }

/* ---------- Shell ---------- */
.app-shell { display: flex; min-height: calc(100vh - var(--luc-topbar-h)); }

/* Desktop sidebar show/hide (toggled from the topbar; preference kept per browser). */
body.sidebar-collapsed .sidebar { display: none !important; }

.sidebar {
    width: var(--luc-sidebar-w);
    background: var(--luc-sidebar-bg);
    border-right: 1px solid var(--luc-border);
    flex-shrink: 0;
    position: sticky;
    top: var(--luc-topbar-h);
    height: calc(100vh - var(--luc-topbar-h));
    overflow-y: auto;
}
.sidebar-offcanvas { background: var(--luc-sidebar-bg); color: var(--luc-sidebar-text); max-width: 260px; }
.sidebar-offcanvas .offcanvas-header { color: var(--luc-text); border-bottom: 1px solid var(--luc-border); }

.sidebar-nav { padding: .75rem .5rem; }
.sidebar-nav .nav-section {
    font-size: .68rem; letter-spacing: .08em; text-transform: uppercase;
    color: #9ca3af; padding: .9rem .75rem .3rem;
}
.sidebar-nav .nav-link {
    color: var(--luc-sidebar-text);
    display: flex; align-items: center; gap: .65rem;
    padding: .55rem .75rem; border-radius: 8px; font-size: .92rem;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.sidebar-nav .nav-link:hover { background: var(--luc-primary-tint); color: var(--luc-primary); }
.sidebar-nav .nav-link.active { background: var(--luc-primary); color: #fff; }

.main-content {
    flex-grow: 1;
    padding: 1.25rem 1.5rem 2.5rem;
    min-width: 0; /* allow table-responsive to shrink */
}
@media (max-width: 575.98px) { .main-content { padding: 1rem .75rem 2rem; } }

/* ---------- App footer ---------- */
.app-footer {
    margin-top: 2rem;
    padding-top: .75rem;
    border-top: 1px solid var(--luc-border, #e5e7eb);
    color: var(--luc-text-muted);
    font-size: .82rem;
    gap: .5rem;
}
.footer-heart { color: #dc2626; }

/* ---------- Page header ---------- */
.page-header { margin-bottom: 1.1rem; }
.page-title { font-size: 1.35rem; font-weight: 600; margin-bottom: .1rem; }
.page-subtitle { color: var(--luc-text-muted); font-size: .88rem; margin-bottom: 0; }
.demo-badge { font-weight: 500; }

/* ---------- Cards ---------- */
.content-card, .kpi-card {
    border: 1px solid var(--luc-border);
    border-radius: var(--luc-radius);
    box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.content-card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--luc-border);
    font-size: .92rem;
    padding: .75rem 1rem;
}
.content-card .card-footer { background: transparent; border-top: 1px solid var(--luc-border); }

/* KPI cards */
.kpi-card .card-body { padding: .9rem 1rem; }
.kpi-icon {
    width: 34px; height: 34px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1rem; margin-bottom: .5rem;
}
.kpi-blue   { background: #dbeafe; color: #1d4ed8; }
.kpi-green  { background: #dcfce7; color: #15803d; }
.kpi-indigo { background: #e0e7ff; color: #4338ca; }
.kpi-amber  { background: #fef3c7; color: #b45309; }
.kpi-red    { background: #fee2e2; color: #b91c1c; }
.kpi-value { font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.kpi-value.kpi-flash { animation: kpiFlash 1.2s ease; }
@keyframes kpiFlash { 0% { color: var(--luc-primary); } 100% { color: inherit; } }
.kpi-label { font-size: .78rem; color: var(--luc-text-muted); }

/* Mini stats */
.mini-stat {
    background: var(--luc-bg);
    border: 1px solid var(--luc-border);
    border-radius: 8px;
    padding: .55rem .4rem;
    height: 100%;
}
.mini-stat-value { font-weight: 700; font-size: 1.02rem; }
.mini-stat-label { font-size: .72rem; color: var(--luc-text-muted); }

/* Section labels */
.section-label {
    font-size: .72rem; font-weight: 600; letter-spacing: .07em;
    text-transform: uppercase; color: var(--luc-text-muted); margin-bottom: .5rem;
}

/* Activity list */
.activity-list li { display: flex; gap: .6rem; padding: .3rem 0; font-size: .86rem; }
.activity-time { color: var(--luc-text-muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.inactive-chip { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; font-weight: 500; }

/* Alerts */
.alert-list .alert-item {
    display: flex; gap: .75rem; align-items: flex-start;
    padding: .8rem 1rem; border-bottom: 1px solid var(--luc-border);
}
.alert-list .alert-item:last-child { border-bottom: 0; }
.alert-item-body { min-width: 0; }

/* ---------- Tables ---------- */
.data-table thead th {
    font-size: .74rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--luc-text-muted); border-bottom-width: 1px;
    background: #fafbfc; padding: .6rem .9rem; white-space: nowrap;
}
.data-table tbody td { padding: .6rem .9rem; font-size: .88rem; }
.table-link { color: var(--luc-primary); text-decoration: none; font-weight: 500; }
.table-link:hover { text-decoration: underline; }
/* Source chips: fixed color per Moodle source, everywhere. */
.source-chip {
    background: #f3f4f6; color: #374151; border: 1px solid #e5e7eb; border-radius: 6px;
    font-size: .76rem; padding: .2rem .5rem; white-space: nowrap;
}
.source-conventional { background: #e0e7ff; color: #4338ca; border-color: #c7d2fe; }
.source-odl          { background: #ffedd5; color: #9a3412; border-color: #fed7aa; }

/* ---------- Status badges ---------- */
.status-badge {
    display: inline-flex; align-items: center; gap: .3rem;
    font-size: .74rem; font-weight: 600; border-radius: 20px;
    padding: .22rem .6rem; white-space: nowrap; border: 1px solid transparent;
}
.status-healthy   { background: #dcfce7; color: #15803d; border-color: #bbf7d0; }
.status-active    { background: #dbeafe; color: #1d4ed8; border-color: #bfdbfe; }
.status-completed { background: #d1fae5; color: #047857; border-color: #a7f3d0; }
.status-pending   { background: #fef3c7; color: #b45309; border-color: #fde68a; }
.status-delayed   { background: #ffedd5; color: #c2410c; border-color: #fed7aa; }
.status-missing   { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.status-error     { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.status-disabled  { background: #f3f4f6; color: #6b7280; border-color: #e5e7eb; }

/* ---------- Forms / filters ---------- */
.filter-form .form-label { margin-bottom: .2rem; color: var(--luc-text-muted); }
.btn-primary { background: var(--luc-primary); border-color: var(--luc-primary); }
.btn-primary:hover, .btn-primary:focus, .btn-primary:active { background: var(--luc-primary-hover) !important; border-color: var(--luc-primary-hover) !important; }
.btn-primary:focus, .btn-primary:focus-visible { box-shadow: 0 0 0 3px rgba(223,27,34,.18); }
.btn-outline-primary { color: var(--luc-primary); border-color: var(--luc-primary); }
.btn-outline-primary:hover { background: var(--luc-primary); border-color: var(--luc-primary); }

/* Focus states: one subtle brand-tinted ring on every input — never Bootstrap blue. */
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: #d99a9c;
    box-shadow: 0 0 0 3px rgba(223,27,34,.10);
    outline: 0;
}
.form-check-input:checked { background-color: var(--luc-primary); border-color: var(--luc-primary); }
a { color: var(--luc-primary); }
a:hover { color: var(--luc-primary-hover); }

/* Pagination (incl. DataTables) and dropdowns: replace Bootstrap's default blue. */
.page-link { color: var(--luc-primary); }
.page-link:hover { color: var(--luc-primary-hover); }
.page-link:focus { color: var(--luc-primary-hover); box-shadow: 0 0 0 3px rgba(223,27,34,.10); }
.active > .page-link, .page-link.active {
    background-color: var(--luc-primary); border-color: var(--luc-primary); color: #fff;
}
.dropdown-item.active, .dropdown-item:active { background-color: var(--luc-primary); color: #fff; }
.btn-link { color: var(--luc-primary); }
.btn-link:hover { color: var(--luc-primary-hover); }
.nav-tabs .nav-link { color: var(--luc-text-muted); }
.nav-tabs .nav-link.active { color: var(--luc-primary); font-weight: 600; }

/* Info list (dt/dd) */
.info-list dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--luc-text-muted); }
.info-list dd { margin-bottom: .7rem; font-weight: 500; }

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: #4a0709; /* fallback while the image loads */
    position: relative; overflow: hidden;
    padding: 1rem;
}
/* Blurred campus backdrop. Oversized inset hides the blur's soft edges. */
.login-page::before {
    content: ""; position: absolute; inset: -40px; z-index: 0;
    background: url("../images/login-bg.svg") center / cover no-repeat;
    filter: blur(10px) saturate(1.05) brightness(.8);
}
/* Contrast scrim so the login card and text always stay readable. */
.login-page::after {
    content: ""; position: absolute; inset: 0; z-index: 0;
    background: linear-gradient(165deg, rgba(28,2,3,.68) 0%, rgba(60,5,7,.45) 55%, rgba(160,16,22,.3) 100%);
}
.login-wrap { width: 100%; max-width: 400px; position: relative; z-index: 1; }
.login-card { border: 0; border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.45); background: rgba(255,255,255,.97); }
.login-page .text-muted, .login-wrap > p { color: rgba(255,255,255,.75) !important; }
.login-card .text-muted { color: var(--luc-text-muted) !important; }

/* ---------- Walkthrough ---------- */
.walkthrough-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 2000;
}
.walkthrough-highlight {
    position: relative; z-index: 2010;
    box-shadow: 0 0 0 4px rgba(223,27,34,.85), 0 0 0 8px rgba(223,27,34,.3);
    border-radius: 8px;
}
.walkthrough-card {
    position: fixed; z-index: 2020;
    background: var(--luc-surface); border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0,0,0,.3);
    width: min(340px, calc(100vw - 2rem));
    padding: 1rem 1.1rem;
}
.walkthrough-card h3 { font-size: 1rem; font-weight: 600; margin-bottom: .35rem; }
.walkthrough-card p { font-size: .86rem; color: var(--luc-text-muted); margin-bottom: .8rem; }
.walkthrough-progress { font-size: .74rem; color: var(--luc-text-muted); }

/* ---------- Page loader ---------- */
.page-loader {
    position: fixed; inset: 0; z-index: 4000;
    background: rgba(255,255,255,.94);
    display: flex; align-items: center; justify-content: center;
    opacity: 1; visibility: visible;
    transition: opacity .25s ease, visibility .25s ease;
}
.page-loader img {
    width: min(240px, 60vw); height: auto;
    animation: loaderPulse 1.4s ease-in-out infinite;
}
.page-loader.hidden { opacity: 0; visibility: hidden; }
@keyframes loaderPulse {
    0%, 100% { opacity: .45; transform: scale(.97); }
    50% { opacity: 1; transform: scale(1); }
}

/* ---------- Sync toast ---------- */
.sync-toast {
    position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 3000;
    background: var(--luc-primary); color: #fff;
    padding: .6rem 1rem; border-radius: 8px; font-size: .85rem;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
    opacity: 0; transform: translateY(8px);
    transition: opacity .3s ease, transform .3s ease;
}
.sync-toast.show { opacity: 1; transform: translateY(0); }

/* ---------- Misc ---------- */
.report-card:hover { border-color: var(--luc-primary); }
::selection { background: rgba(223,27,34,.15); }
