/* =========================================================
   UNIFIED PORTAL — Design System
   Dark slate base, indigo accent, clean typography
   ========================================================= */

:root {
    --bg:          #0d0f17;
    --surface:     #151822;
    --surface-2:   #1c1f2e;
    --surface-3:   #232740;
    --border:      #2a2f45;
    --border-light:#333857;
    --text:        #e4e6f0;
    --text-muted:  #8b90a8;
    --text-dim:    #5a5f7a;
    --accent:      #6366f1;
    --accent-h:    #4f52d6;
    --accent-soft: rgba(99,102,241,0.12);
    --green:       #22c55e;
    --green-soft:  rgba(34,197,94,0.12);
    --red:         #ef4444;
    --red-soft:    rgba(239,68,68,0.12);
    --amber:       #f59e0b;
    --amber-soft:  rgba(245,158,11,0.12);
    --blue:        #3b82f6;
    --blue-soft:   rgba(59,130,246,0.12);
    --radius:      8px;
    --radius-lg:   12px;
    --shadow:      0 4px 20px rgba(0,0,0,0.4);
    --nav-h:       64px;
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 15px;
    line-height: 1.6;
}

/* ── Top Navigation Bar ─────────────────────────── */
.topnav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.nav-brand {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    text-decoration: none;
    letter-spacing: -0.5px;
    margin-right: 32px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.nav-brand span { color: var(--accent); }

.nav-modules {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.nav-link {
    padding: 7px 14px;
    border-radius: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }

.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

/* Profile dropdown */
.nav-profile { position: relative; }

.profile-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: border-color 0.15s;
}

.profile-btn:hover { border-color: var(--accent); }

.profile-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--surface-3);
    flex-shrink: 0;
}

.profile-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    width: 200px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 200;
}

.profile-dropdown.open { display: flex; }

.profile-dropdown a {
    padding: 10px 16px;
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.1s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-dropdown a:hover { background: var(--surface-3); }
.profile-dropdown a.danger { color: var(--red); }
.profile-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }

/* ── Page Layout ──────────────────────────────────── */
.page-wrap {
    padding-top: calc(var(--nav-h) + 32px);
    padding-bottom: 48px;
    padding-left: 24px;
    padding-right: 24px;
    max-width: 1320px;
    margin: 0 auto;
}

.page-wrap.narrow { max-width: 860px; }
.page-wrap.wide   { max-width: 1600px; }

/* ── Cards ──────────────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

/* ── Typography ─────────────────────────────────── */
h1 { font-size: 26px; font-weight: 800; color: #fff; letter-spacing: -0.5px; }
h2 { font-size: 20px; font-weight: 700; color: #fff; }
h3 { font-size: 16px; font-weight: 700; color: #fff; }
h4 { font-size: 14px; font-weight: 600; color: var(--text); }

.page-title {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* ── Buttons ────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 7px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: none;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }

.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-3); border-color: var(--border-light); }

.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(0.9); }

.btn-danger    { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(0.9); }

.btn-ghost     { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 8px; font-size: 12px; }

/* ── Forms ──────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 7px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 7px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s;
    outline: none;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

input[type="file"] { padding: 8px 12px; cursor: pointer; color: var(--text-muted); }

textarea { resize: vertical; min-height: 100px; }

select option { background: var(--surface-2); }

/* ── Alerts / Messages ──────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: 7px;
    font-size: 14px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: var(--green-soft); color: var(--green); border: 1px solid rgba(34,197,94,0.25); }
.alert-error   { background: var(--red-soft);   color: var(--red);   border: 1px solid rgba(239,68,68,0.25); }
.alert-warning { background: var(--amber-soft);  color: var(--amber); border: 1px solid rgba(245,158,11,0.25); }
.alert-info    { background: var(--blue-soft);   color: var(--blue);  border: 1px solid rgba(59,130,246,0.25); }

/* ── Tables ─────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 2px solid var(--border);
}

td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    font-size: 14px;
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

/* ── Badges ─────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.badge-green  { background: var(--green-soft);  color: var(--green); }
.badge-red    { background: var(--red-soft);    color: var(--red); }
.badge-amber  { background: var(--amber-soft);  color: var(--amber); }
.badge-blue   { background: var(--blue-soft);   color: var(--blue); }
.badge-indigo { background: var(--accent-soft); color: var(--accent); }
.badge-gray   { background: var(--surface-3);   color: var(--text-muted); }

/* Role tags */
.role-admin    { background: rgba(239,68,68,0.15); color: #fca5a5; }
.role-employee { background: rgba(59,130,246,0.15); color: #93c5fd; }
.role-tech     { background: rgba(245,158,11,0.15); color: #fcd34d; }

/* ── Modals ─────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 999;
    backdrop-filter: blur(4px);
}

.modal-overlay.active { display: flex; }

.modal-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px;
    width: 100%;
    max-width: 500px;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    position: relative;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 4px;
}

.modal-close:hover { color: var(--red); background: var(--red-soft); }

/* ── Grid helpers ───────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }

/* ── Search / Filter inputs ─────────────────────── */
.search-bar {
    position: relative;
    max-width: 300px;
}

.search-bar input {
    padding-left: 38px;
}

.search-bar::before {
    content: '🔍';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
    pointer-events: none;
}

/* ── File row layout ────────────────────────────── */
.file-row {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
    transition: background 0.1s;
}

.file-row:hover { background: var(--surface-2); }

.file-icon {
    width: 36px; height: 36px;
    border-radius: 8px;
    background: var(--accent-soft);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.file-name  { flex: 1; font-weight: 500; color: #fff; word-break: break-all; }
.file-meta  { font-size: 13px; color: var(--text-muted); }
.file-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Upload zone ────────────────────────────────── */
.upload-zone {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    padding: 28px;
    text-align: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

/* ── Status pipeline badges ─────────────────────── */
.status-pastdue    { background: var(--red-soft);   color: var(--red); }
.status-urgent     { background: var(--amber-soft);  color: var(--amber); }
.status-assigned   { background: var(--blue-soft);   color: var(--blue); }
.status-passed     { background: var(--green-soft);  color: var(--green); }
.status-completed  { background: var(--green-soft);  color: var(--green); }

/* ── Action links ───────────────────────────────── */
.link-blue   { color: var(--blue);   text-decoration: none; font-weight: 600; font-size: 13px; }
.link-amber  { color: var(--amber);  text-decoration: none; font-weight: 600; font-size: 13px; }
.link-red    { color: var(--red);    text-decoration: none; font-weight: 600; font-size: 13px; }
.link-green  { color: var(--green);  text-decoration: none; font-weight: 600; font-size: 13px; }

.link-blue:hover, .link-amber:hover, .link-red:hover, .link-green:hover { text-decoration: underline; }

/* ── Stat cards ─────────────────────────────────── */
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 46px; height: 46px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.stat-value { font-size: 26px; font-weight: 800; color: #fff; line-height: 1.1; }

/* ── Video player anti-cheat wrapper ──────────────── */
.video-wrap video {
    width: 100%;
    border-radius: var(--radius);
    background: #000;
    display: block;
}

/* ── PDF scroll viewport ────────────────────────── */
.pdf-viewport {
    height: 520px;
    overflow-y: scroll;
    border: 2px dashed var(--border-light);
    border-radius: var(--radius);
    background: var(--surface-2);
    padding: 8px;
}

.pdf-embed { width: 100%; height: 1600px; border: none; background: #fff; border-radius: 4px; }

/* ── Canvas signature pad ───────────────────────── */
#sig-canvas {
    width: 100%;
    height: 180px;
    border: 2px dashed var(--border-light);
    border-radius: var(--radius);
    background: var(--surface-3);
    cursor: crosshair;
    display: block;
    touch-action: none;
}

/* ── Split layout ───────────────────────────────── */
.split-view {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

@media (max-width: 900px) {
    .split-view { grid-template-columns: 1fr; }
}

/* ── Misc helpers ───────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 13px; }
.text-xs     { font-size: 12px; }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.full-width { width: 100%; }
.no-list { list-style: none; }

/* ── Scrollbar styling ──────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ── Login page ─────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 30% 20%, rgba(99,102,241,0.08) 0%, transparent 60%),
                radial-gradient(ellipse at 80% 80%, rgba(99,102,241,0.05) 0%, transparent 50%),
                var(--bg);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo .brand {
    font-size: 22px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.5px;
}

.login-logo .brand span { color: var(--accent); }

.login-logo .sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Response cards for quiz ────────────────────── */
.response-card {
    padding: 14px;
    border-radius: 7px;
    margin-bottom: 12px;
    border-left: 4px solid var(--border);
    background: var(--surface-2);
}

.response-card.correct { border-left-color: var(--green); }
.response-card.wrong   { border-left-color: var(--red); }

/* ── Danger zone ────────────────────────────────── */
.danger-zone {
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--radius-lg);
    padding: 24px;
    background: rgba(239,68,68,0.04);
}

.danger-zone h3 { color: var(--red); margin-bottom: 8px; }

/* ── Responsive nav (mobile) ────────────────────── */
@media (max-width: 768px) {
    .topnav { padding: 0 16px; gap: 8px; }
    .nav-modules { display: none; }
    .page-wrap { padding-left: 16px; padding-right: 16px; }
}
