/* ============================================================
   Security Awareness Platform — Dark Blue Theme
   Base stylesheet for layout.html (Jinja2 templates)
   ============================================================ */

:root {
    /* Backgrounds — deep navy scale */
    --bg-page: #070f1c;
    /* page background            */
    --bg-surface: #0d1a2e;
    /* cards / panels             */
    --bg-surface-2: #12223b;
    /* secondary surface          */
    --bg-elevated: #182c4a;
    /* hover / elevated           */
    --bg-input: #0b1728;
    /* form inputs                */

    /* Borders */
    --border: #203a5c;
    --border-soft: #182d4a;

    /* Brand — blue / cyan accents */
    --primary: #2f6fed;
    --primary-strong: #1e55cf;
    --primary-soft: #4a86f5;
    --primary-glow: rgba(47, 111, 237, 0.35);
    --accent: #38bdf8;
    --accent-2: #22d3ee;

    /* Text */
    --text: #e8eef7;
    --text-secondary: #a8bbd3;
    --text-muted: #6f88a6;

    /* Semantic */
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #38bdf8;

    /* Geometry & effects */
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
    --font: 'Segoe UI', system-ui, -apple-system, 'Inter', 'Helvetica Neue', sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

/* ------------------------------------------------------------
   Reset & base
   ------------------------------------------------------------ */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg-page);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Subtle radial glow backdrop */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(1100px 550px at 85% -10%, rgba(47, 111, 237, 0.14), transparent 60%),
        radial-gradient(900px 500px at -10% 110%, rgba(34, 211, 238, 0.08), transparent 55%);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color .15s ease;
}

a:hover {
    color: var(--accent-2);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--text);
    font-weight: 600;
    line-height: 1.25;
    margin-bottom: .5rem;
}

h1 {
    font-size: 1.75rem;
}

h2 {
    font-size: 1.4rem;
}

h3 {
    font-size: 1.15rem;
}

p {
    margin-bottom: .75rem;
}

code,
pre {
    font-family: var(--mono);
}

img {
    max-width: 100%;
    display: block;
}

/* ------------------------------------------------------------
   Layout
   ------------------------------------------------------------ */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main {
    flex: 1;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

/* ------------------------------------------------------------
   Navbar
   ------------------------------------------------------------ */
.navbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(10, 21, 38, 0.85);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.navbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 64px;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    color: var(--text);
    font-weight: 700;
    font-size: 1.05rem;
    white-space: nowrap;
}

.brand:hover {
    color: var(--text);
}

.brand-icon {
    width: 26px;
    height: 26px;
    color: var(--accent);
    flex-shrink: 0;
}

.brand-tag {
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--bg-page);
    background: var(--accent);
    border-radius: 999px;
    padding: .1rem .5rem;
}

.nav {
    display: flex;
    align-items: center;
    flex: 1;
}

.nav-list {
    list-style: none;
    display: flex;
    align-items: center;
    gap: .25rem;
}

.nav-link {
    display: block;
    padding: .45rem .85rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: .95rem;
    transition: background .15s ease, color .15s ease;
}

.nav-link:hover {
    color: var(--text);
    background: var(--bg-elevated);
}

.nav-link.active {
    color: #fff;
    background: var(--primary);
}

.nav-link.active:hover {
    background: var(--primary-soft);
}

.navbar-end {
    display: flex;
    align-items: center;
    gap: .75rem;
}

/* Hamburger (mobile) */
.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 42px;
    height: 42px;
    padding: 9px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--text);
    border-radius: 2px;
}

/* ------------------------------------------------------------
   Flash messages / alerts
   ------------------------------------------------------------ */
.flash-stack {
    position: fixed;
    top: 76px;
    right: 1.25rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: .6rem;
    max-width: 360px;
}

.alert {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .75rem;
    padding: .8rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: .92rem;
}

.alert-text {
    flex: 1;
}

.alert-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 .15rem;
}

.alert-close:hover {
    color: var(--text);
}

.alert-success {
    border-color: rgba(34, 197, 94, .4);
    border-left: 4px solid var(--success);
}

.alert-warning {
    border-color: rgba(245, 158, 11, .4);
    border-left: 4px solid var(--warning);
}

.alert-danger,
.alert-error {
    border-color: rgba(239, 68, 68, .4);
    border-left: 4px solid var(--danger);
}

.alert-info,
.alert-message {
    border-color: rgba(56, 189, 248, .4);
    border-left: 4px solid var(--info);
}

/* ------------------------------------------------------------
   Cards & panels
   ------------------------------------------------------------ */
.card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.card-header h2,
.card-header h3 {
    margin-bottom: 0;
}

.card-title {
    font-size: 1.05rem;
    margin-bottom: 0;
}

.card-subtitle {
    color: var(--text-muted);
    font-size: .85rem;
}

/* Stat cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.15rem 1.25rem;
}

.stat-label {
    color: var(--text-muted);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: .35rem;
}

.stat-value {
    font-size: 1.9rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text);
}

.stat-value .unit {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    padding: .55rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

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

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

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--bg-surface-2);
    border-color: var(--border-light, #2b4564);
}

.btn-outline {
    background: transparent;
    color: var(--accent);
    border-color: var(--accent);
}

.btn-outline:hover {
    background: rgba(56, 189, 248, .12);
    color: var(--accent-2);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #f87171;
    color: #fff;
}

.btn-sm {
    padding: .35rem .7rem;
    font-size: .85rem;
}

.btn-block {
    width: 100%;
}

/* ------------------------------------------------------------
   Badges / pills
   ------------------------------------------------------------ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .15rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1.5;
    border: 1px solid transparent;
}

.badge-blue {
    background: rgba(47, 111, 237, .18);
    color: var(--primary-soft);
    border-color: rgba(47, 111, 237, .35);
}

.badge-cyan {
    background: rgba(56, 189, 248, .15);
    color: var(--accent);
    border-color: rgba(56, 189, 248, .35);
}

.badge-green {
    background: rgba(34, 197, 94, .15);
    color: var(--success);
    border-color: rgba(34, 197, 94, .35);
}

.badge-amber {
    background: rgba(245, 158, 11, .15);
    color: var(--warning);
    border-color: rgba(245, 158, 11, .35);
}

.badge-red {
    background: rgba(239, 68, 68, .15);
    color: #f87171;
    border-color: rgba(239, 68, 68, .35);
}

.badge-neutral {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border-color: var(--border);
}

/* Risk-score pills */
.risk-low {
    background: rgba(34, 197, 94, .16);
    color: #4ade80;
}

.risk-medium {
    background: rgba(245, 158, 11, .16);
    color: #fbbf24;
}

.risk-high {
    background: rgba(239, 68, 68, .16);
    color: #f87171;
}

/* ------------------------------------------------------------
   Tables
   ------------------------------------------------------------ */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
    font-size: .93rem;
}

.table th,
.table td {
    padding: .7rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
    white-space: nowrap;
}

.table thead th {
    background: var(--bg-surface-2);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background: var(--bg-elevated);
}

.table td a {
    font-weight: 500;
}

/* ------------------------------------------------------------
   Exception Handlers
   ------------------------------------------------------------ */
.error-page {
    max-width: 600px;
    margin: 4vh auto 0;
    text-align: center;
}

.error-code {
    font-size: clamp(96px, 22vw, 168px);
    font-weight: 900;
    letter-spacing: -0.05em;
    line-height: 1;
    color: var(--purple-100);
    text-shadow: 0 2px 0 #fff, 0 10px 24px rgb(111, 136, 166, 0.12);
    user-select: none;
}

.error-page .page-title {
    margin: 6px 0 10px;
}

.error-message {
    color: var(--color-text-muted);
    font-size: 15px;
    line-height: 1.6;
    margin: 0 auto;
    max-width: 460px;
}

.error-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 26px;
}

/* ------------------------------------------------------------
   Forms
   ------------------------------------------------------------ */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}

.form-group.full {
    grid-column: 1 / -1;
}

label {
    font-size: .88rem;
    font-weight: 600;
    color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: .6rem .8rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: .95rem;
    transition: border-color .15s ease, box-shadow .15s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

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

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238ea6bf' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .8rem center;
    padding-right: 2rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.checkbox-row label {
    font-weight: 500;
    color: var(--text);
}

input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.form-hint {
    font-size: .8rem;
    color: var(--text-muted);
}

/* ------------------------------------------------------------
   Utilities
   ------------------------------------------------------------ */
.grid {
    display: grid;
    gap: 1rem;
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

.flex {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.flex-wrap {
    flex-wrap: wrap;
}

.mt-1 {
    margin-top: .5rem;
}

.mt-2 {
    margin-top: 1rem;
}

.mt-3 {
    margin-top: 1.5rem;
}

.mb-1 {
    margin-bottom: .5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

.text-muted {
    color: var(--text-muted);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-danger {
    color: var(--danger);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.hidden {
    display: none !important;
}

.section-title {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
    border-bottom: 1px solid var(--border-soft);
}

/* ------------------------------------------------------------
   Footer
   ------------------------------------------------------------ */
.footer {
    border-top: 1px solid var(--border);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: .85rem;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ------------------------------------------------------------
   Scrollbar
   ------------------------------------------------------------ */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-page);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ------------------------------------------------------------
   Responsive
   ------------------------------------------------------------ */
@media (max-width: 900px) {

    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }

    .nav {
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--bg-surface);
        border-bottom: 1px solid var(--border);
        padding: .75rem 1.25rem;
        display: none;
    }

    .nav.open {
        display: block;
    }

    .nav-list {
        flex-direction: column;
        align-items: stretch;
        gap: .25rem;
    }

    .nav-link {
        padding: .6rem .85rem;
    }

    .navbar-inner {
        gap: 1rem;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .flash-stack {
        left: 1.25rem;
        right: 1.25rem;
        max-width: none;
    }

    .main {
        padding: 1.25rem 1rem 2rem;
    }
}