/* ============================================================
   CyberSentinel Academy — Main Stylesheet
   ============================================================ */

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

:root {
    --bg:          #0f172a;
    --bg2:         #1e293b;
    --bg3:         #334155;
    --surface:     #1e293b;
    --surface2:    #273549;
    --border:      #334155;
    --text:        #e2e8f0;
    --text-muted:  #94a3b8;
    --primary:     #3b82f6;
    --primary-h:   #2563eb;
    --success:     #22c55e;
    --warning:     #f59e0b;
    --danger:      #ef4444;
    --info:        #38bdf8;
    --radius:      8px;
    --radius-lg:   12px;
    --shadow:      0 4px 24px rgba(0,0,0,0.35);
    --font:        'Segoe UI', system-ui, -apple-system, sans-serif;
    --nav-h:       60px;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-h); text-decoration: underline; }

img { max-width: 100%; }

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

.topnav-brand { flex-shrink: 0; }
.brand-link {
    display: flex; align-items: center; gap: 10px;
    color: var(--text); font-weight: 700; font-size: 1.05rem;
    text-decoration: none;
}
.brand-link:hover { color: var(--primary); text-decoration: none; }

.topnav-links {
    display: flex; align-items: center; gap: 4px;
    flex: 1; overflow: hidden;
}

.nav-link {
    padding: 6px 14px; border-radius: 6px;
    color: var(--text-muted); font-size: 0.9rem;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.nav-link:hover { background: var(--bg3); color: var(--text); text-decoration: none; }
.nav-link.active { background: rgba(59,130,246,0.15); color: var(--primary); }

.topnav-right {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}

/* ── Notification Bell ────────────────────────────────────── */
.notif-wrapper { position: relative; }

.notif-btn {
    position: relative;
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 8px;
    border-radius: 6px; transition: background 0.15s;
}
.notif-btn:hover { background: var(--bg3); color: var(--text); }

.notif-badge {
    position: absolute; top: 2px; right: 2px;
    background: var(--danger); color: #fff;
    font-size: 0.65rem; font-weight: 700;
    min-width: 16px; height: 16px; padding: 0 3px;
    border-radius: 999px; display: flex; align-items: center; justify-content: center;
}

.notif-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    width: 320px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); overflow: hidden; z-index: 200;
}

.notif-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    font-weight: 600; font-size: 0.9rem;
}
.notif-mark-read { font-size: 0.8rem; color: var(--primary); }

.notif-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    color: var(--text); transition: background 0.1s;
}
.notif-item:hover { background: var(--bg3); text-decoration: none; }
.notif-item.unread { background: rgba(59,130,246,0.06); }

.notif-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.notif-dot-info    { background: var(--info); }
.notif-dot-success { background: var(--success); }
.notif-dot-warning { background: var(--warning); }
.notif-dot-danger  { background: var(--danger); }

.notif-title { font-size: 0.85rem; }
.notif-time  { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.notif-empty { padding: 20px; text-align: center; color: var(--text-muted); font-size: 0.9rem; }

/* ── User Menu ────────────────────────────────────────────── */
.user-menu-wrapper { position: relative; }

.user-menu-btn {
    display: flex; align-items: center; gap: 8px;
    background: none; border: 1px solid var(--border);
    border-radius: 6px; cursor: pointer; padding: 6px 10px;
    color: var(--text); font-size: 0.9rem;
    transition: background 0.15s;
}
.user-menu-btn:hover { background: var(--bg3); }

.user-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--primary); color: #fff;
    font-weight: 700; font-size: 0.8rem;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.user-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.user-dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    min-width: 180px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow); z-index: 200; overflow: hidden;
}

.dropdown-item {
    display: block; padding: 10px 16px;
    color: var(--text); font-size: 0.9rem;
    transition: background 0.1s;
}
.dropdown-item:hover { background: var(--bg3); text-decoration: none; }
.dropdown-item.text-danger { color: var(--danger); }

.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Flash Messages ───────────────────────────────────────── */
.flash-message {
    position: fixed; top: calc(var(--nav-h) + 12px); left: 50%; transform: translateX(-50%);
    padding: 12px 20px; border-radius: var(--radius); z-index: 900;
    display: flex; align-items: center; gap: 12px;
    font-size: 0.9rem; box-shadow: var(--shadow);
    animation: slideDown 0.2s ease;
}
.flash-success { background: rgba(34,197,94,0.15); border: 1px solid var(--success); color: var(--success); }
.flash-danger  { background: rgba(239,68,68,0.15);  border: 1px solid var(--danger);  color: var(--danger); }
.flash-warning { background: rgba(245,158,11,0.15); border: 1px solid var(--warning); color: var(--warning); }
.flash-info    { background: rgba(56,189,248,0.15); border: 1px solid var(--info);    color: var(--info); }

.flash-close { background: none; border: none; color: inherit; cursor: pointer; font-size: 1.2rem; }

@keyframes slideDown { from { opacity:0; transform: translateX(-50%) translateY(-10px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }

/* ── Main Layout ──────────────────────────────────────────── */
.main-content {
    margin-top: var(--nav-h);
    padding: 32px 24px;
    max-width: 1400px;
    margin-left: auto;
    margin-right: auto;
}

.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 28px; flex-wrap: wrap; gap: 12px;
}
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-top: 2px; }

/* ── Cards ────────────────────────────────────────────────── */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 24px;
}
.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: 1rem; font-weight: 600; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }

.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 20px;
    display: flex; align-items: flex-start; gap: 16px;
}
.stat-icon {
    width: 44px; height: 44px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(59,130,246,0.15); }
.stat-icon.green  { background: rgba(34,197,94,0.15); }
.stat-icon.yellow { background: rgba(245,158,11,0.15); }
.stat-icon.red    { background: rgba(239,68,68,0.15); }
.stat-icon.purple { background: rgba(168,85,247,0.15); }

.stat-body { flex: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.2; }
.stat-change { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

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

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th {
    padding: 12px 16px; text-align: left;
    font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--text-muted); border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 14px 16px; border-bottom: 1px solid rgba(51,65,85,0.5);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; border-radius: var(--radius);
    font-size: 0.9rem; font-weight: 500; cursor: pointer;
    border: 1px solid transparent; transition: all 0.15s;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm  { padding: 5px 12px; font-size: 0.8rem; }
.btn-lg  { padding: 12px 24px; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-h); border-color: var(--primary-h); text-decoration: none; color: #fff; }

.btn-secondary { background: var(--bg3); color: var(--text); border-color: var(--bg3); }
.btn-secondary:hover { background: #3f5068; text-decoration: none; color: var(--text); }

.btn-success { background: rgba(34,197,94,0.15); color: var(--success); border-color: rgba(34,197,94,0.3); }
.btn-success:hover { background: rgba(34,197,94,0.25); text-decoration: none; }

.btn-danger { background: rgba(239,68,68,0.15); color: var(--danger); border-color: rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); text-decoration: none; }

.btn-warning { background: rgba(245,158,11,0.15); color: var(--warning); border-color: rgba(245,158,11,0.3); }
.btn-warning:hover { background: rgba(245,158,11,0.25); text-decoration: none; }

.btn-outline { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-outline:hover { background: var(--bg3); color: var(--text); text-decoration: none; }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 6px; }

.form-control {
    width: 100%; padding: 10px 14px;
    background: var(--bg3); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text);
    font-family: var(--font); font-size: 0.9rem;
    transition: border-color 0.15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }
.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

.form-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

.input-password-wrap { position: relative; }
.input-password-wrap .form-control { padding-right: 44px; }
.btn-show-pass {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    background: none; border: none; cursor: pointer; color: var(--text-muted);
    padding: 4px; font-size: 0.85rem;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.form-check { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.form-check input[type=checkbox], .form-check input[type=radio] { accent-color: var(--primary); width: 16px; height: 16px; }
.form-check label { margin: 0; font-weight: 400; cursor: pointer; }

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
    padding: 12px 16px; border-radius: var(--radius);
    margin-bottom: 16px; font-size: 0.9rem;
}
.alert-success { background: rgba(34,197,94,0.1);  border: 1px solid rgba(34,197,94,0.3);  color: var(--success); }
.alert-danger  { background: rgba(239,68,68,0.1);  border: 1px solid rgba(239,68,68,0.3);  color: var(--danger); }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: var(--warning); }
.alert-info    { background: rgba(56,189,248,0.1); border: 1px solid rgba(56,189,248,0.3); color: var(--info); }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 10px; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.badge-success { background: rgba(34,197,94,0.15);  color: var(--success); }
.badge-danger  { background: rgba(239,68,68,0.15);  color: var(--danger); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-info    { background: rgba(56,189,248,0.15); color: var(--info); }
.badge-primary { background: rgba(59,130,246,0.15); color: var(--primary); }
.badge-muted   { background: rgba(148,163,184,0.15); color: var(--text-muted); }

.badge-beginner     { background: rgba(34,197,94,0.15);  color: var(--success); }
.badge-intermediate { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-advanced     { background: rgba(239,68,68,0.15);  color: var(--danger); }

.badge-active    { background: rgba(34,197,94,0.15);  color: var(--success); }
.badge-trial     { background: rgba(56,189,248,0.15); color: var(--info); }
.badge-suspended { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-expired   { background: rgba(239,68,68,0.15);  color: var(--danger); }

/* ── Progress Bars ────────────────────────────────────────── */
.progress { background: var(--bg3); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 999px; transition: width 0.4s ease; }
.progress-bar.green  { background: var(--success); }
.progress-bar.yellow { background: var(--warning); }
.progress-bar.red    { background: var(--danger); }

/* ── Error Pages ──────────────────────────────────────────── */
.error-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.error-container { text-align: center; max-width: 480px; padding: 40px; }
.error-code { font-size: 5rem; font-weight: 900; color: var(--primary); line-height: 1; }
.error-title { font-size: 1.5rem; margin: 12px 0 8px; }
.error-message { color: var(--text-muted); margin-bottom: 28px; line-height: 1.7; }
.error-container .btn { margin: 0 6px; }

/* ── Auth Pages ───────────────────────────────────────────── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); }
.auth-wrapper { width: 100%; max-width: 440px; padding: 24px; }

.auth-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 36px;
    box-shadow: var(--shadow);
}

.auth-brand {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 28px; padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}
.auth-logo { flex-shrink: 0; }
.auth-site-name { font-size: 1.2rem; font-weight: 700; }

.auth-title    { font-size: 1.3rem; font-weight: 700; margin-bottom: 24px; }
.auth-subtitle { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 20px; margin-top: -16px; }

.auth-form .btn { margin-top: 8px; }
.auth-links { margin-top: 16px; text-align: center; font-size: 0.85rem; }

/* ── Toggle Switches ──────────────────────────────────────── */
.toggle-switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--bg3); border-radius: 999px;
    transition: background 0.2s;
}
.toggle-slider:before {
    content: ''; position: absolute;
    width: 18px; height: 18px; left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%; transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); width: 100%; max-width: 560px;
    max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow);
    animation: modalIn 0.2s ease;
}
.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-weight: 700; font-size: 1.1rem; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: 1.4rem; line-height: 1; }
.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

@keyframes modalIn { from { opacity:0; transform: scale(0.96); } to { opacity:1; transform: scale(1); } }

/* ── Pagination ───────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 20px; }
.page-btn {
    padding: 7px 12px; border-radius: 6px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); cursor: pointer;
    font-size: 0.85rem; transition: all 0.15s;
}
.page-btn:hover { background: var(--bg3); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Search & Filters ─────────────────────────────────────── */
.table-toolbar {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 16px; flex-wrap: wrap;
}
.search-box { position: relative; flex: 1; min-width: 200px; }
.search-box svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-box .form-control { padding-left: 38px; }

/* ── Utility ──────────────────────────────────────────────── */
.text-muted   { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }

.mt-1 { margin-top: 4px; }  .mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; } .mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }  .mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; } .mb-4 { margin-bottom: 24px; }

.d-flex { display: flex; } .gap-2 { gap: 8px; } .gap-3 { gap: 16px; }
.align-center { align-items: center; } .justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .topnav-links { display: none; }
    .main-content { padding: 20px 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row, .form-row-3 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 24px; }
}
