/* =============================================================
   Boss Station — corporate dark blue + orange accent theme.
   Built on top of Bootstrap 5; overrides only where necessary.
   ============================================================= */

:root {
    --bs-primary: #0b2a4a;
    --bs-primary-rgb: 11, 42, 74;
    --bs-link-color: #0b2a4a;
    --bs-link-hover-color: #ff7a1a;
    --bss-navy: #0b2a4a;
    --bss-navy-deep: #061a30;
    --bss-accent: #ff7a1a;
    --bss-accent-soft: #fff1e3;
}

body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }

/* ---- Buttons ---- */
.btn-primary {
    background-color: var(--bss-navy);
    border-color: var(--bss-navy);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: var(--bss-navy-deep) !important;
    border-color: var(--bss-navy-deep) !important;
}
.btn-outline-primary {
    color: var(--bss-navy);
    border-color: var(--bss-navy);
}
.btn-outline-primary:hover {
    background-color: var(--bss-navy);
    border-color: var(--bss-navy);
}

/* ---- Accent helpers ---- */
.bg-accent          { background-color: var(--bss-accent) !important; color: #fff; }
.bg-accent-subtle   { background-color: var(--bss-accent-soft) !important; }
.text-accent        { color: var(--bss-accent) !important; }
.text-accent-emphasis { color: #c95b00 !important; }

/* ---- Branded top bar ---- */
.navbar-brand-bar {
    background: linear-gradient(90deg, var(--bss-navy) 0%, var(--bss-navy-deep) 100%);
    padding: .6rem 1rem;
}
.brand-square {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bss-accent);
    color: #fff;
    font-weight: 700;
    border-radius: 6px;
    margin-right: .35rem;
}
.avatar-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    color: #fff;
    font-weight: 600;
    font-size: .85rem;
}

/* ---- Sidebar ---- */
.sidebar {
    background: #f5f7fa;
    border-right: 1px solid #e6e9ee;
}
@media (min-width: 768px) {
    .sidebar {
        position: sticky;
        top: 56px;
        height: calc(100vh - 56px);
        overflow-y: auto;
    }
}
/* On mobile the sidebar is an offcanvas drawer (Bootstrap handles the
   slide-in via offcanvas-md); make it look like the brand bar inside. */
@media (max-width: 767.98px) {
    .sidebar.offcanvas-md {
        max-width: 84vw;
        width: 300px;
    }
    .sidebar .offcanvas-header {
        background: linear-gradient(90deg, var(--bss-navy) 0%, var(--bss-navy-deep) 100%);
        color: #fff;
    }
    .sidebar .offcanvas-header .offcanvas-title { color: #fff; display: flex; align-items: center; gap: .5rem; }
    .sidebar .offcanvas-header .btn-close { filter: invert(1) grayscale(1); opacity: .9; }
}
.sidebar-heading {
    color: #6b7785;
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .05em;
    padding: .25rem 1rem;
    margin-top: .75rem;
}
/* Collapsible section toggle (button styled like sidebar-heading). */
.sidebar-section-toggle {
    width: 100%;
    background: transparent;
    border: 0;
    color: #6b7785;
    text-transform: uppercase;
    font-size: .72rem;
    letter-spacing: .05em;
    font-weight: 600;
    padding: .55rem 1rem;
    margin-top: .25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.sidebar-section-toggle:hover { color: var(--bss-navy); }
.sidebar-section-toggle:focus { outline: none; box-shadow: none; }
.sidebar-chevron {
    transition: transform .2s ease;
    font-size: .85rem;
}
.sidebar-section-toggle[aria-expanded="false"] .sidebar-chevron {
    transform: rotate(-90deg);
}
.sidebar .nav-link {
    color: #344050;
    padding: .55rem 1rem;
    border-radius: 0;
    display: flex;
    align-items: center;
    gap: .65rem;
}
.sidebar .nav-link i { color: var(--bss-navy); width: 1.1rem; }
.sidebar .nav-link.active,
.sidebar .nav-link:hover:not(.disabled) {
    background: #fff;
    color: var(--bss-navy);
    border-left: 3px solid var(--bss-accent);
    padding-left: calc(1rem - 3px);
}
.sidebar .nav-link.disabled { color: #aab2bd; }

/* ---- Stat cards ---- */
.stat-card { border: 0; border-radius: 14px; box-shadow: 0 2px 8px rgba(11,42,74,.06); }
.stat-card .stat-label { color: #6b7785; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 1.85rem; font-weight: 700; color: var(--bss-navy); margin-top: .15rem; }
.stat-card.accent { background: linear-gradient(135deg, var(--bss-accent) 0%, #ff9b4a 100%); color: #fff; }
.stat-card.accent .stat-label, .stat-card.accent .stat-value { color: #fff; }

/* ---- Cards ---- */
.card { border: 0; border-radius: 14px; box-shadow: 0 2px 6px rgba(11,42,74,.05); }
.card-header { background: #fff; border-bottom: 1px solid #eef1f5; font-weight: 500; }

/* ---- Auth shell ---- */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #143a64 0%, #061a30 60%, #02080f 100%);
    padding: 2rem 1rem;
}
.auth-card-wrap { width: 100%; max-width: 420px; }
.auth-logo {
    width: 64px; height: 64px;
    background: var(--bss-accent);
    color: #fff;
    font-weight: 800;
    font-size: 1.6rem;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ---- Member avatar (large) ---- */
.member-avatar-lg {
    width: 96px; height: 96px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bss-navy) 0%, var(--bss-navy-deep) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
}
.member-avatar-sm {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--bss-navy) 0%, var(--bss-navy-deep) 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

/* ---- Digital ID card ---- */
.id-card {
    width: 380px;
    border-radius: 18px;
    background: #fff;
    overflow: hidden;
    border: 1px solid #e6e9ee;
}
.id-card-head {
    background: linear-gradient(135deg, var(--bss-navy) 0%, var(--bss-navy-deep) 100%);
    color: #fff;
    padding: 1rem 1.25rem;
}
.id-card-brand { display: flex; align-items: center; gap: .75rem; }
.id-card-body { padding: 1.5rem 1.25rem; text-align: center; }
.id-photo {
    width: 96px; height: 96px;
    margin: 0 auto;
    border-radius: 50%;
    background: var(--bss-accent-soft);
    color: var(--bss-accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 700;
}
.id-qr {
    display: flex; justify-content: center;
    margin-top: 1rem;
}
.id-card-foot {
    border-top: 1px dashed #e6e9ee;
    padding: .75rem 1.25rem;
}

/* ---- Sticky bottom nav (mobile) ---- */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    height: 62px;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom);
    background: #ffffff;
    border-top: 1px solid #e6e9ee;
    box-shadow: 0 -2px 12px rgba(11, 42, 74, .08);
    display: flex;
    align-items: stretch;
}
.bottom-nav a,
.bottom-nav .bottom-nav-more {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: #6b7785;
    text-decoration: none;
    background: transparent;
    border: 0;
    font-size: .68rem;
    line-height: 1;
    font-weight: 500;
    padding: 0 2px;
    min-width: 0;
}
.bottom-nav a i,
.bottom-nav .bottom-nav-more i {
    font-size: 1.35rem;
    line-height: 1;
}
.bottom-nav a.active {
    color: var(--bss-navy);
}
.bottom-nav a.active i {
    color: var(--bss-accent);
}
.bottom-nav a:active,
.bottom-nav .bottom-nav-more:active {
    background: #f5f7fa;
}

/* Reserve room at the bottom of every mobile page for the nav. */
@media (max-width: 767.98px) {
    .has-bottom-nav main {
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }
    .has-bottom-nav .auth-shell,
    .has-bottom-nav.auth-shell { padding-bottom: 0; }
}

/* ---- Mobile-friendly tightening ---- */
@media (max-width: 575.98px) {
    h1.h3 { font-size: 1.35rem; }
    h1.h2 { font-size: 1.55rem; }
    .display-5 { font-size: 2rem; }
    .stat-card .stat-value { font-size: 1.45rem; }
    .stat-card .stat-label { font-size: .7rem; }
    .card { border-radius: 12px; }
    .card-body { padding: .9rem; }
    .navbar-brand-bar { padding: .5rem .75rem; }
    .navbar-brand { font-size: 1rem; }
    .id-card { width: 100%; max-width: 360px; }
    /* Buttons that would otherwise overflow rows shrink on the smallest viewport. */
    .btn { padding-top: .45rem; padding-bottom: .45rem; }
}

/* The container-fluid row collapses to a single column on mobile;
   make sure the main area doesn't have an offset from the sidebar grid. */
@media (max-width: 767.98px) {
    main.col-md-9 { margin-left: 0 !important; }
}

/* ---- AI chat bubbles ---- */
.chat-log { background: #fafbfd; min-height: 320px; max-height: 60vh; overflow-y: auto; }
@media (max-width: 767.98px) {
    .chat-log { max-height: calc(100vh - 280px); }
}
.chat-row { display: flex; }
.chat-row.chat-user { justify-content: flex-end; }
.chat-row.chat-assistant { justify-content: flex-start; }
.chat-bubble {
    max-width: 80%;
    padding: .65rem .9rem;
    border-radius: 14px;
    line-height: 1.45;
    word-wrap: break-word;
}
.chat-row.chat-user .chat-bubble {
    background: var(--bss-navy);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-row.chat-assistant .chat-bubble {
    background: #fff;
    border: 1px solid #e6e9ee;
    border-bottom-left-radius: 4px;
}

/* ---- Markdown surface for AI reports ---- */
.markdown-body { font-size: .95rem; line-height: 1.55; }

@media print {
    body { background: #fff !important; }
    .navbar, .sidebar, .btn, footer { display: none !important; }
    main { padding: 0 !important; }
    .id-card { box-shadow: none; }
}