/* ============================================================
   ZCSA Design System — adapted from Ontech ICTM framework
   Zambia Cyber Security Awareness Platform
   ============================================================ */

/* ── CSS Variables ──────────────────────────────────────── */
:root {
    --primary: #0ea5e9;
    --primary-dark: #0284c7;
    --primary-light: rgba(14, 165, 233, 0.08);
    --accent: #10b981;
    --accent-dark: #059669;

    --gray-50: #f8fafc; --gray-100: #f1f5f9; --gray-200: #e2e8f0;
    --gray-300: #cbd5e1; --gray-400: #94a3b8; --gray-500: #64748b;
    --gray-600: #475569; --gray-700: #334155; --gray-800: #1e293b;
    --gray-900: #0f172a;

    --success: #10b981; --warning: #f59e0b; --danger: #ef4444; --info: #8b5cf6;
    --text-primary: var(--gray-900); --text-secondary: var(--gray-600); --text-muted: var(--gray-400);
    --bg-body: var(--gray-50); --bg-card: #ffffff; --bg-sidebar: #ffffff;
    --border-color: var(--gray-200);

    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --topbar-height: 64px;

    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.08);

    --radius-sm: 4px; --radius-md: 8px; --radius-lg: 12px; --radius-xl: 16px;
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --transition: 0.3s var(--ease-out);
}

/* ── Dark Mode ──────────────────────────────────────────── */
[data-theme="dark"] {
    --text-primary: #f1f5f9; --text-secondary: #94a3b8; --text-muted: #64748b;
    --bg-body: #0f172a; --bg-card: #1e293b; --bg-sidebar: #1e293b;
    --border-color: #334155;
    --gray-50: #1e293b; --gray-100: #334155; --gray-200: #475569;
    --primary-light: rgba(14, 165, 233, 0.15);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
}
[data-theme="dark"] body { background: var(--bg-body); color: var(--text-primary); }
[data-theme="dark"] .card, [data-theme="dark"] .sidebar, [data-theme="dark"] .topbar { background: var(--bg-card); border-color: var(--border-color); }
[data-theme="dark"] .table { color: var(--text-primary); --bs-table-bg: var(--bg-card); }
[data-theme="dark"] .table thead th { background: var(--gray-100); color: var(--text-secondary); }
[data-theme="dark"] .form-control, [data-theme="dark"] .form-select { background: var(--gray-100); color: var(--text-primary); border-color: var(--border-color); }
[data-theme="dark"] .dropdown-menu { background: var(--bg-card); border-color: var(--border-color); }
[data-theme="dark"] .dropdown-item { color: var(--text-primary); }
[data-theme="dark"] .dropdown-item:hover { background: var(--gray-100); }
[data-theme="dark"] .btn-outline-primary { color: var(--primary); border-color: var(--primary); }

/* ── Base ───────────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; font-size: 0.875rem; line-height: 1.6; color: var(--text-primary); background: var(--bg-body); }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ── Sidebar ────────────────────────────────────────────── */
.sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: var(--sidebar-width); background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    z-index: 1040; overflow-y: auto; overflow-x: hidden;
    transition: width var(--transition);
    display: flex; flex-direction: column;
}
.sidebar::-webkit-scrollbar { width: 5px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }

.sidebar-header { padding: 1rem 1.25rem; display: flex; align-items: center; gap: 0.75rem; border-bottom: 1px solid var(--border-color); min-height: var(--topbar-height); }
.sidebar-logo { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; }
.sidebar-logo-icon { width: 36px; height: 36px; border-radius: var(--radius-md); background: linear-gradient(135deg, var(--primary), var(--accent)); display: flex; align-items: center; justify-content: center; color: white; font-size: 1.1rem; flex-shrink: 0; }
.sidebar-logo-text { font-weight: 800; font-size: 1.1rem; color: var(--text-primary); white-space: nowrap; overflow: hidden; }
.sidebar-logo-text span { color: var(--primary); }

.sidebar-nav { flex: 1; padding: 0.75rem 0; }
.nav-section { margin-bottom: 0.25rem; }
.nav-section-title { padding: 0.5rem 1.25rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); font-weight: 600; cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.nav-section-title:hover { color: var(--text-secondary); }
.section-chevron { font-size: 0.6rem; transition: transform var(--transition); }
.section-collapsed .section-chevron { transform: rotate(-90deg); }
.section-collapsed .nav-link { display: none; }

.nav-link { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 1.25rem; color: var(--text-secondary); font-size: 0.8rem; font-weight: 500; border-left: 3px solid transparent; transition: all 0.15s ease; white-space: nowrap; overflow: hidden; }
.nav-link:hover { background: var(--primary-light); color: var(--primary); border-left-color: transparent; }
.nav-link.active { background: var(--primary-light); color: var(--primary); border-left-color: var(--primary); font-weight: 600; }
.nav-icon { width: 22px; text-align: center; font-size: 0.9rem; flex-shrink: 0; }

.sidebar-footer { padding: 0.75rem 1.25rem; border-top: 1px solid var(--border-color); }
.sidebar-footer button { background: none; border: none; color: var(--text-muted); cursor: pointer; padding: 0.4rem; border-radius: var(--radius-sm); width: 100%; text-align: center; }
.sidebar-footer button:hover { background: var(--gray-100); color: var(--text-primary); }

/* Collapsed sidebar */
.sidebar.collapsed { width: var(--sidebar-collapsed-width); }
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .nav-section-title span,
.sidebar.collapsed .nav-link span:not(.nav-icon) { display: none; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 0.65rem; }
.sidebar.collapsed .nav-icon { width: auto; font-size: 1rem; }
.sidebar.collapsed .section-chevron { display: none; }

/* Mobile */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 1035; }
@media (max-width: 991px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0 !important; }
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
    position: sticky; top: 0; z-index: 1030; height: var(--topbar-height);
    background: var(--bg-card); border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.5rem; box-shadow: var(--shadow-sm);
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); margin: 0; }
.sidebar-toggle { display: none; background: none; border: none; font-size: 1.2rem; color: var(--text-secondary); cursor: pointer; padding: 0.5rem; }
@media (max-width: 991px) { .sidebar-toggle { display: block; } }

.topbar-icon { position: relative; padding: 0.5rem 0.6rem; background: var(--gray-100); border-radius: var(--radius-md); cursor: pointer; color: var(--text-secondary); border: none; }
.topbar-icon:hover { background: var(--primary-light); color: var(--primary); }
.notification-badge { position: absolute; top: 2px; right: 2px; background: var(--danger); color: white; font-size: 0.6rem; font-weight: 700; border-radius: 50%; width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; }

.user-dropdown-btn { display: flex; align-items: center; gap: 0.75rem; padding: 0.4rem 0.75rem; background: var(--gray-100); border: 1px solid var(--border-color); border-radius: var(--radius-md); cursor: pointer; }
.user-dropdown-btn:hover { background: var(--primary-light); }
.user-avatar { width: 32px; height: 32px; border-radius: var(--radius-md); background: linear-gradient(135deg, var(--primary), var(--accent)); color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem; flex-shrink: 0; }
.user-info { text-align: left; }
.user-name { font-weight: 600; font-size: 0.8rem; color: var(--text-primary); }
.user-role { font-size: 0.7rem; color: var(--text-muted); }

/* ── Main Content ───────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-width); min-height: 100vh; transition: margin-left var(--transition); }
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed-width); }

/* ── Cards ───────────────────────────────────────────────── */
.card { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-header { background: var(--gray-50); border-bottom: 1px solid var(--border-color); padding: 0.75rem 1rem; }
.stat-card { padding: 1.25rem; border-radius: var(--radius-lg); border: 1px solid var(--border-color); background: var(--bg-card); }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1.2; }
.stat-card .stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; }

/* ── Tables ──────────────────────────────────────────────── */
.table { font-size: 0.8rem; }
.table thead th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; color: var(--text-muted); background: var(--gray-50); padding: 0.75rem 1rem; border-bottom: 2px solid var(--border-color); }
.table td { padding: 0.75rem 1rem; vertical-align: middle; border-bottom: 1px solid var(--border-color); }
.table-hover tbody tr:hover { background: var(--primary-light); }

/* ── Forms ────────────────────────────────────────────────── */
.form-control, .form-select { font-size: 0.85rem; border-radius: var(--radius-md); border-color: var(--border-color); padding: 0.5rem 0.75rem; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15); }
.form-label { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.25rem; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn { font-size: 0.8rem; font-weight: 600; border-radius: var(--radius-md); padding: 0.5rem 1rem; transition: all 0.15s ease; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-dark); }

/* ── Badges ──────────────────────────────────────────────── */
.badge { font-weight: 600; font-size: 0.7rem; padding: 0.3em 0.65em; border-radius: var(--radius-sm); }

/* ── Status Colors ───────────────────────────────────────── */
.severity-critical, .bg-severity-critical { background: var(--danger) !important; color: white !important; }
.severity-high, .bg-severity-high { background: var(--warning) !important; color: white !important; }
.severity-medium, .bg-severity-medium { background: var(--info) !important; color: white !important; }
.severity-low, .bg-severity-low { background: var(--gray-400) !important; color: white !important; }

/* ── Toast Notifications ─────────────────────────────────── */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem; }
.toast-custom { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); font-size: 0.85rem; animation: slideIn 0.3s var(--ease-out); max-width: 400px; }
.toast-success { background: #ecfdf5; border-left: 4px solid var(--success); color: #065f46; }
.toast-danger { background: #fef2f2; border-left: 4px solid var(--danger); color: #991b1b; }
.toast-warning { background: #fffbeb; border-left: 4px solid var(--warning); color: #92400e; }
.toast-info { background: #eff6ff; border-left: 4px solid var(--primary); color: #1e40af; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ── Alerts (override Bootstrap) ─────────────────────────── */
.alert { border-radius: var(--radius-md); font-size: 0.85rem; border: none; border-left: 4px solid; }

/* ── Progress bars ───────────────────────────────────────── */
.progress { height: 6px; border-radius: 3px; background: var(--gray-200); }

/* ── Utilities ───────────────────────────────────────────── */
.text-primary { color: var(--primary) !important; }
.text-accent { color: var(--accent) !important; }
.fw-800 { font-weight: 800; }
.gap-3 { gap: 1rem; }
