/* ==========================================================================
   WMEP CI Assessment Tool — design system
   Brand: dark teal #013C4D / light teal #69AFC4
   Type: Archivo (display/headings) + Public Sans (body), loaded in base.html
   ========================================================================== */

:root {
    --teal-900: #013C4D;
    --teal-800: #06485C;
    --teal-700: #0A566B;
    --teal-500: #2E7D96;
    --teal-400: #69AFC4;
    --teal-100: #D7E9EF;
    --teal-050: #EFF6F8;

    --paper: #F7F9FA;
    --surface: #FFFFFF;
    --ink: #152229;
    --ink-2: #51646D;
    --line: #DDE6EA;

    --ok: #2E7D32;
    --ok-bg: #E8F3E9;
    --warn: #B7791F;
    --warn-bg: #FBF3E4;
    --bad: #B3352C;
    --bad-bg: #FBEAE8;
    --amber: #E9A13B;

    --radius: 8px;
    --shadow: 0 1px 3px rgba(1, 60, 77, 0.08);
    --font-display: 'Archivo', 'Segoe UI', sans-serif;
    --font-body: 'Public Sans', 'Segoe UI', sans-serif;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
body {
    background: var(--paper);
    font-family: var(--font-body);
    color: var(--ink);
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--ink);
}

.text-muted { color: var(--ink-2) !important; }

.num, .score, .currency {
    font-variant-numeric: tabular-nums;
}

a { color: var(--teal-700); }
a:hover { color: var(--teal-900); }

/* --------------------------------------------------------------------------
   Navbar
   -------------------------------------------------------------------------- */
.navbar {
    background: linear-gradient(120deg, var(--teal-900) 0%, var(--teal-700) 100%);
    box-shadow: var(--shadow);
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

.navbar .logo {
    max-width: 120px;
    height: auto;
}

.navbar .navbar-text {
    color: rgba(255, 255, 255, 0.85);
    font-family: var(--font-display);
    letter-spacing: 0.02em;
}

.navbar .nav-link {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
}

.navbar .nav-link:hover,
.navbar .nav-link.active {
    color: #fff;
}

.navbar .btn-outline-light {
    border-color: rgba(255, 255, 255, 0.45);
}

/* --------------------------------------------------------------------------
   Cards & containers — quiet: white, 1px line, one shadow level
   -------------------------------------------------------------------------- */
.card,
.chart-container,
.dashboard-header,
.search-container,
.assessment-header,
.rating-scale {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card { overflow: hidden; transition: box-shadow 0.15s ease; }
.card:hover { box-shadow: 0 3px 10px rgba(1, 60, 77, 0.12); transform: none; }

.card-header {
    background: var(--teal-050);
    color: var(--teal-900);
    border-bottom: 1px solid var(--line);
    font-family: var(--font-display);
    font-weight: 600;
    padding: 0.85rem 1.25rem;
}

.card-header.brand {
    background: var(--teal-900);
    color: #fff;
    border-bottom: none;
}

.chart-container { padding: 20px; margin-bottom: 24px; }
.dashboard-header { padding: 24px 30px; margin-bottom: 24px; }
.search-container { padding: 20px; margin-bottom: 24px; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn { border-radius: 6px; font-weight: 500; }

.btn-primary {
    background: var(--teal-800);
    border: 1px solid var(--teal-900);
    padding: 0.5rem 1.1rem;
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--teal-900);
    border-color: var(--teal-900);
    transform: none;
    box-shadow: 0 2px 6px rgba(1, 60, 77, 0.25);
}

.btn-outline-primary {
    color: var(--teal-800);
    border-color: var(--teal-400);
}

.btn-outline-primary:hover {
    background: var(--teal-050);
    color: var(--teal-900);
    border-color: var(--teal-700);
}

.btn-success { background: var(--ok); border-color: var(--ok); }
.btn-success:hover { background: #256B29; border-color: #256B29; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-control, .form-select {
    border-radius: 6px;
    border: 1px solid var(--line);
    padding: 0.55rem 0.85rem;
}

.form-control:focus, .form-select:focus {
    border-color: var(--teal-400);
    box-shadow: 0 0 0 0.2rem rgba(105, 175, 196, 0.25);
}

.form-label { font-weight: 500; color: var(--ink); }

/* --------------------------------------------------------------------------
   Progress
   -------------------------------------------------------------------------- */
.progress { height: 8px; border-radius: 4px; background: var(--teal-050); }
.progress-bar { background-color: var(--teal-500); }

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal-content { border-radius: var(--radius); border: 1px solid var(--line); }

.modal-header {
    background: var(--teal-900);
    color: white;
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: none;
}

.modal-header .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
.modal-body { padding: 24px; }

/* --------------------------------------------------------------------------
   Engagement rail — the 8-station process stepper
   -------------------------------------------------------------------------- */
.rail {
    display: flex;
    align-items: flex-start;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 12px 10px;
    margin-bottom: 24px;
    overflow-x: auto;
}

.rail-station {
    flex: 1 1 0;
    min-width: 76px;
    position: relative;
    text-align: center;
    text-decoration: none;
    color: var(--ink-2);
}

/* track segment to the left of each station (skip the first) */
.rail-station + .rail-station::before {
    content: "";
    position: absolute;
    top: 14px;
    right: 50%;
    width: 100%;
    height: 2px;
    background: var(--line);
    z-index: 0;
}

.rail-station.done + .rail-station.done::before,
.rail-station.done + .rail-station.current::before {
    background: var(--teal-400);
}

.rail-dot {
    position: relative;
    z-index: 1;
    width: 28px;
    height: 28px;
    margin: 0 auto 6px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.8rem;
    background: var(--surface);
    border: 2px solid var(--line);
    color: var(--ink-2);
}

.rail-station.done .rail-dot {
    background: var(--teal-800);
    border-color: var(--teal-800);
    color: #fff;
}

.rail-station.current .rail-dot {
    background: var(--surface);
    border-color: var(--teal-800);
    color: var(--teal-900);
    box-shadow: 0 0 0 4px var(--teal-100);
}

.rail-label {
    display: block;
    font-size: 0.72rem;
    line-height: 1.25;
    padding: 0 4px;
}

.rail-station.current .rail-label { color: var(--teal-900); font-weight: 600; }
a.rail-station.done:hover .rail-label { color: var(--teal-700); text-decoration: underline; }
.rail-station.locked { opacity: 0.55; cursor: default; }

.rail-details-link {
    flex: 0 0 auto;
    align-self: flex-start;
    margin-top: 4px;
    padding: 4px 8px;
    color: var(--ink-2);
    border-left: 1px solid var(--line);
}

.rail-details-link:hover { color: var(--teal-700); }

/* mini rail for dashboard cards */
.rail-mini {
    display: flex;
    gap: 4px;
    align-items: center;
}

.rail-mini .seg {
    flex: 1 1 0;
    height: 6px;
    border-radius: 3px;
    background: var(--teal-050);
    border: 1px solid var(--line);
}

.rail-mini .seg.done { background: var(--teal-500); border-color: var(--teal-500); }
.rail-mini .seg.current { background: var(--amber); border-color: var(--amber); }

/* --------------------------------------------------------------------------
   Back / Next footer bar
   -------------------------------------------------------------------------- */
.flow-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 18px;
    margin: 28px 0 40px;
}

/* --------------------------------------------------------------------------
   Auth (split panel)
   -------------------------------------------------------------------------- */
.auth-wrap {
    min-height: 100vh;
    display: flex;
}

.auth-brand {
    flex: 1 1 45%;
    background: linear-gradient(160deg, var(--teal-900) 0%, var(--teal-700) 70%, var(--teal-500) 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 56px;
}

.auth-brand .logo { max-width: 180px; margin-bottom: 28px; }

.auth-brand h1 {
    color: #fff;
    font-size: 1.9rem;
    line-height: 1.3;
    margin-bottom: 12px;
}

.auth-brand p { color: rgba(255, 255, 255, 0.8); max-width: 420px; }

.auth-form {
    flex: 1 1 55%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
}

.auth-card { width: 100%; max-width: 420px; }

@media (max-width: 860px) {
    .auth-wrap { flex-direction: column; }
    .auth-brand { padding: 36px 28px; flex: none; }
}

/* --------------------------------------------------------------------------
   KPI capture — live preview stays visible on tablet (sticky strip above form)
   -------------------------------------------------------------------------- */
.kpi-preview-card { position: sticky; top: 16px; }

@media (max-width: 991.98px) {
    .kpi-preview-card {
        position: sticky;
        top: 0;
        z-index: 100;
        box-shadow: 0 3px 10px rgba(1, 60, 77, 0.15);
    }
}

/* --------------------------------------------------------------------------
   Status badges
   -------------------------------------------------------------------------- */
.badge-status { font-weight: 600; border-radius: 4px; padding: 4px 10px; }
.badge-status.draft { background: var(--teal-050); color: var(--teal-800); border: 1px solid var(--teal-100); }
.badge-status.progress { background: var(--warn-bg); color: var(--warn); }
.badge-status.complete { background: var(--ok-bg); color: var(--ok); }

/* --------------------------------------------------------------------------
   Legacy flow-page classes (restyled with tokens; pages rewritten in Phase 4)
   -------------------------------------------------------------------------- */
.assessment-container { max-width: 1100px; margin: 0 auto; }
.assessment-header { text-align: center; margin-bottom: 28px; padding: 24px; }
.rating-scale { padding: 24px; margin-bottom: 28px; }

.scale-item {
    text-align: center;
    padding: 16px;
    margin-bottom: 16px;
    border-radius: var(--radius);
    background: var(--teal-050);
    border: 1px solid var(--line);
}

.scale-number {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--teal-900);
    margin-bottom: 8px;
}

.scale-desc { font-size: 0.85rem; color: var(--ink-2); }

.category-section {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}

.category-header {
    color: white;
    background: var(--teal-800);
    padding: 14px 22px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.category-title { margin: 0; font-weight: 600; color: #fff; }

.category-count {
    background: rgba(255, 255, 255, 0.18);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85rem;
}

.toggle-icon { transition: transform 0.2s ease; }
.category-section .collapse.show .toggle-icon { transform: rotate(180deg); }
.category-content { background: var(--surface); padding: 22px; }

.principle-card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    margin-bottom: 16px;
}

.principle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.principle-header h5 { margin: 0; color: var(--teal-900); }

.rating-group { display: flex; gap: 10px; }
.rating-label { cursor: pointer; position: relative; }

.rating-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    border: 3px solid transparent;
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.rating-circle.rating-1 { background: var(--bad); }
.rating-circle.rating-2 { background: var(--amber); }
.rating-circle.rating-3 { background: var(--teal-400); color: var(--teal-900); }
.rating-circle.rating-4 { background: var(--ok); }

.rating-label input { position: absolute; opacity: 0; }
.rating-label input:checked + .rating-circle {
    border-color: var(--teal-900);
    transform: scale(1.12);
}

/* Keyboard accessibility: visible focus on the styled rating circles and rail */
.rating-label input:focus-visible + .rating-circle {
    outline: 3px solid var(--teal-400);
    outline-offset: 2px;
}

a.rail-station:focus-visible,
.rail-details-link:focus-visible {
    outline: 2px solid var(--teal-400);
    outline-offset: 2px;
    border-radius: 4px;
}

.principle-content p { margin-bottom: 12px; color: var(--ink-2); }
.next-steps .form-control { border-radius: 6px; }

.mini-chart { width: 80px; height: 80px; margin: 0 auto; }

.animate-fade-in { animation: fadeIn 0.4s ease-in; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   Floating bug reporter (every authenticated page)
   -------------------------------------------------------------------------- */
.bug-fab {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 1035;  /* under modals (1055) and toasts (1080) */
    display: inline-flex;
    align-items: center;
    gap: 0;
    padding: 12px;
    border: 1px solid var(--teal-900);
    border-radius: 999px;
    background: var(--teal-800);
    color: #fff;
    box-shadow: 0 3px 10px rgba(1, 60, 77, 0.3);
    transition: gap 0.15s ease, padding 0.15s ease, background 0.15s ease;
}

.bug-fab:hover,
.bug-fab:focus-visible {
    background: var(--teal-900);
    color: #fff;
    gap: 8px;
    padding: 12px 18px;
}

.bug-fab:focus-visible {
    outline: 3px solid var(--teal-400);
    outline-offset: 2px;
}

/* Label reveals on hover/focus; the icon alone keeps the resting footprint small. */
.bug-fab-label {
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0.85rem;
    font-weight: 500;
    transition: max-width 0.15s ease;
}

.bug-fab:hover .bug-fab-label,
.bug-fab:focus-visible .bug-fab-label {
    max-width: 140px;
}

/* Never overlay a client-facing document. */
body.presenting .bug-fab { display: none !important; }

@media print {
    .bug-fab { display: none !important; }
}

/* --------------------------------------------------------------------------
   Case-study references inside AI narratives
   -------------------------------------------------------------------------- */
.case-ref {
    font-weight: 600;
    background: rgba(233, 161, 59, 0.16);
    border-bottom: 1px dotted var(--amber);
    border-radius: 2px;
    padding: 0 2px;
    cursor: help;
}

/* --------------------------------------------------------------------------
   Signature pad
   -------------------------------------------------------------------------- */
#signaturePad {
    width: 100%;
    height: 180px;
    border: 2px dashed var(--teal-400);
    border-radius: var(--radius);
    background: var(--surface);
    touch-action: none;
    cursor: crosshair;
}

.signature-render {
    max-width: 320px;
    border-bottom: 1px solid var(--ink);
}

/* --------------------------------------------------------------------------
   Presentation mode (proposal fullscreen)
   -------------------------------------------------------------------------- */
body.presenting .navbar,
body.presenting .rail,
body.presenting .flow-nav,
body.presenting .no-print,
body.presenting .alert.no-print {
    display: none !important;
}

body.presenting {
    background: var(--surface);
    font-size: 1.12rem;
}

body.presenting main.container {
    max-width: 920px;
}

body.presenting .proposal-headline {
    font-size: 2.6rem;
}

body.presenting .proposal-section {
    scroll-margin-top: 24px;
}

/* --------------------------------------------------------------------------
   Admin
   -------------------------------------------------------------------------- */
.admin-subnav .nav-link {
    color: var(--ink-2);
    border-radius: 6px;
    font-weight: 500;
}

.admin-subnav .nav-link.active {
    background: var(--teal-050);
    color: var(--teal-900);
}

.table > :not(caption) > * > * { border-bottom-color: var(--line); }
.table thead th {
    font-family: var(--font-display);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-2);
}
