/* =====================================================================
   CBT Portal — base styles. School colours come from CSS variables
   injected by includes/theme.php (--primary, --secondary, --accent).
   ===================================================================== */

:root {
    --surface: #ffffff;
    --surface-muted: #f4f6f9;
    --border: #e5e7eb;
    --text: #111827;
    --text-muted: #6b7280;
    --radius: 12px;
    --shadow-sm: 0 1px 2px rgba(17, 24, 39, .06), 0 1px 3px rgba(17, 24, 39, .08);
    --shadow: 0 4px 16px rgba(17, 24, 39, .08);
    --sidebar-w: 260px;
}

html { scroll-behavior: smooth; }
body {
    font-family: var(--font-main, system-ui, sans-serif);
    color: var(--text);
    background: var(--surface-muted);
    -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.btn, .nav-link, .navbar-brand, .list-group-item-action, .dropdown-item, .page-link { text-decoration: none !important; }
:focus-visible { outline: 3px solid var(--accent, #f59e0b); outline-offset: 2px; }

/* ---------- Brand ---------- */
.brand-logo { height: 44px; width: auto; max-width: 160px; object-fit: contain; }
.brand-logo-lg { height: 84px; width: auto; max-width: 220px; object-fit: contain; }
.logo-fallback {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; border-radius: 10px;
    background: var(--primary); color: var(--on-primary);
    font-weight: 800; font-size: .85rem; letter-spacing: .02em;
}
.brand-logo-lg.logo-fallback { width: 84px; height: 84px; font-size: 1.4rem; border-radius: 18px; }
.text-primary-brand { color: var(--primary) !important; }
.bg-primary-brand { background: var(--primary) !important; color: var(--on-primary) !important; }
.bg-primary-soft { background: var(--primary-light) !important; }

/* ---------- Cards ---------- */
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-header { background: transparent; border-bottom: 1px solid var(--border); font-weight: 600; }
.stat-card { display: flex; gap: 1rem; align-items: center; padding: 1.1rem 1.2rem; }
.stat-icon {
    width: 48px; height: 48px; flex: 0 0 48px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center; font-size: 1.35rem;
    background: var(--primary-light); color: var(--primary);
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat-label { color: var(--text-muted); font-size: .85rem; }

/* ---------- App shell (dashboards) ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    background: var(--primary-dark); color: #fff;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    display: flex; flex-direction: column;
}
.sidebar .sidebar-brand { display: flex; gap: .75rem; align-items: center; padding: 1.1rem 1.1rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar .sidebar-brand .name { font-weight: 700; line-height: 1.2; font-size: .95rem; }
.sidebar .sidebar-brand .sub { font-size: .75rem; opacity: .75; }
.sidebar .brand-logo { height: 38px; background: #fff; border-radius: 8px; padding: 3px; }
.sidebar .logo-fallback { width: 38px; height: 38px; background: rgba(255,255,255,.18); color: #fff; }
.sidebar .nav-section { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; opacity: .6; padding: 1rem 1.25rem .35rem; }
.sidebar .nav-link {
    color: rgba(255,255,255,.85); padding: .55rem 1.25rem; display: flex; gap: .7rem; align-items: center;
    border-left: 3px solid transparent; font-size: .92rem;
}
.sidebar .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar .nav-link.active { background: rgba(255,255,255,.14); color: #fff; border-left-color: var(--accent); font-weight: 600; }
.sidebar .nav-link.disabled { color: rgba(255,255,255,.4); }
.sidebar .nav-link .badge { margin-left: auto; }
.sidebar-footer { margin-top: auto; padding: 1rem 1.25rem; font-size: .75rem; opacity: .6; }

.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: .65rem 1.25rem; display: flex; align-items: center; gap: .75rem;
    position: sticky; top: 0; z-index: 1020;
}
.topbar .page-title { font-weight: 600; font-size: 1.05rem; margin: 0; }
.content { padding: 1.5rem; flex: 1; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--primary-light); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; }
.avatar-lg { width: 96px; height: 96px; font-size: 1.8rem; }

@media (max-width: 991.98px) {
    .sidebar { position: fixed; left: 0; top: 0; z-index: 1045; transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.show { transform: translateX(0); box-shadow: var(--shadow); }
    .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1040; display: none; }
    .sidebar-backdrop.show { display: block; }
    .content { padding: 1rem; }
}

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: flex; }
.auth-side {
    flex: 1 1 50%; color: #fff; position: relative; overflow: hidden;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex; align-items: center; justify-content: center; padding: 3rem;
}
.auth-side.has-image { background-size: cover; background-position: center; }
.auth-side.has-image::before { content: ""; position: absolute; inset: 0; background: linear-gradient(135deg, rgba(0,0,0,.35), rgba(0,0,0,.65)); }
.auth-side > * { position: relative; }
.auth-side .brand-logo-lg { background: #fff; border-radius: 16px; padding: 8px; }
.auth-form { flex: 1 1 50%; display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; background: var(--surface); }
.auth-card { width: 100%; max-width: 420px; }
@media (max-width: 767.98px) {
    .auth-wrap { flex-direction: column; }
    .auth-side { flex: 0 0 auto; padding: 2rem 1rem; }
    .auth-side .lead { display: none; }
}

/* ---------- Landing page ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .navbar-brand .name { font-weight: 700; color: var(--text); line-height: 1.15; font-size: 1rem; }
.site-header .navbar-brand .motto { font-size: .75rem; color: var(--text-muted); }
.site-header .nav-link { color: var(--text); font-weight: 500; }
.site-header .nav-link:hover { color: var(--primary); }

.hero {
    position: relative; color: #fff; overflow: hidden;
    background: linear-gradient(120deg, var(--primary-dark) 0%, var(--primary) 55%, var(--secondary) 130%);
    padding: 5.5rem 0 5rem;
}
.hero.has-image { background-size: cover; background-position: center; }
.hero.has-image::before { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, rgba(0,0,0,.72) 0%, rgba(0,0,0,.45) 60%, rgba(0,0,0,.2) 100%); }
.hero > .container { position: relative; }
.hero h1 { font-weight: 800; font-size: clamp(2rem, 4.5vw, 3.2rem); line-height: 1.1; }
.hero .motto { font-style: italic; opacity: .9; font-size: 1.1rem; }
.hero .btn { padding: .7rem 1.4rem; font-weight: 600; }
.hero-badge { display: inline-flex; gap: .4rem; align-items: center; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.25); padding: .3rem .8rem; border-radius: 99px; font-size: .8rem; }

.section { padding: 4.5rem 0; }
.section-alt { background: var(--surface); }
.section-title { font-weight: 800; font-size: clamp(1.5rem, 3vw, 2rem); }
.section-kicker { color: var(--primary); text-transform: uppercase; letter-spacing: .1em; font-size: .78rem; font-weight: 700; }
.feature-card, .exam-card { height: 100%; padding: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: transform .15s ease, box-shadow .15s ease; }
.feature-card:hover, .exam-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.feature-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; background: var(--primary-light); color: var(--primary); margin-bottom: 1rem; }
.exam-card .exam-name { font-weight: 800; font-size: 1.25rem; color: var(--primary); }
.announcement { border-left: 4px solid var(--accent); background: var(--surface); padding: 1rem 1.25rem; border-radius: 0 var(--radius) var(--radius) 0; }
.gallery-img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radius); }
.contact-item { display: flex; gap: .9rem; align-items: flex-start; margin-bottom: 1rem; }
.contact-item i { font-size: 1.2rem; color: var(--primary); margin-top: .1rem; }

.site-footer { background: #0b1220; color: rgba(255,255,255,.75); padding: 2.5rem 0 1.5rem; }
.site-footer a { color: rgba(255,255,255,.85); }
.site-footer .social a { display: inline-flex; width: 38px; height: 38px; border-radius: 50%; align-items: center; justify-content: center; background: rgba(255,255,255,.08); margin-right: .35rem; }
.site-footer .social a:hover { background: var(--primary); color: var(--on-primary); text-decoration: none; }
.site-footer .brand-logo { background: #fff; border-radius: 8px; padding: 3px; }

/* ---------- Installer ---------- */
.installer { max-width: 760px; margin: 2rem auto; padding: 0 1rem; }
.steps { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.steps .step { flex: 1 1 0; min-width: 90px; font-size: .75rem; padding: .45rem .5rem; border-radius: 8px; background: #e5e7eb; color: #4b5563; text-align: center; }
.steps .step.done { background: #d1fae5; color: #065f46; }
.steps .step.current { background: var(--primary, #1e3a8a); color: #fff; font-weight: 600; }

/* ---------- Misc ---------- */
.table > :not(caption) > * > * { padding: .65rem .75rem; }
.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; background: var(--surface-muted); }
.color-swatch { width: 100%; height: 42px; padding: 3px; }
.preview-logo { max-height: 80px; max-width: 200px; object-fit: contain; background: repeating-conic-gradient(#f1f1f1 0% 25%, #fff 0% 50%) 50% / 16px 16px; border: 1px solid var(--border); border-radius: 8px; padding: 4px; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--text-muted); }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .5; }
.checklist .done { color: #047857; }
.checklist .todo { color: var(--text-muted); }
.stat-link { transition: box-shadow .15s ease, transform .15s ease; }
.stat-link:hover { box-shadow: var(--shadow); transform: translateY(-1px); text-decoration: none; }

/* ---------- Live monitoring (Phase 7) ---------- */
.live-dot { width: 12px; height: 12px; border-radius: 50%; background: #adb5bd; flex-shrink: 0; }
.live-dot.ok { background: #198754; box-shadow: 0 0 0 0 rgba(25,135,84,.6); animation: live-pulse 2s infinite; }
.live-dot.paused { background: #ffc107; }
.live-dot.error { background: #dc3545; }
@keyframes live-pulse { 0% { box-shadow: 0 0 0 0 rgba(25,135,84,.55); } 70% { box-shadow: 0 0 0 10px rgba(25,135,84,0); } 100% { box-shadow: 0 0 0 0 rgba(25,135,84,0); } }
@media (prefers-reduced-motion: reduce) { .live-dot.ok { animation: none; } }
.monitor-tile { border: 1px solid var(--bs-border-color); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.monitor-tile:hover { border-color: var(--primary); }
.monitor-tile.active { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: var(--primary-light); }
.monitor-tile:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.monitor-table .avatar { width: 32px; height: 32px; }
.monitor-table td { vertical-align: middle; }

/* ---------- Long names / titles never push the page sideways (phones) ---------- */
body { overflow-wrap: break-word; }
h1, h2, h3, h4, h5, h6, .h3, .h4, .h5, .fw-semibold, .fw-bold, .card-header, td, dd { overflow-wrap: anywhere; }
.min-w-0 { min-width: 0; }
