/* ============================================================
   Professional Services Hub — "Midnight Desk"
   A dark technical cockpit built on the Mortgage Automator brand
   Navy #112434  ·  Teal #14B8A6  ·  Blue #094A73
   ============================================================ */

/* ---- Design tokens ---------------------------------------- */
:root {
    /* Light theme — "cool concrete" */
    --bg:            #f1f5f6;
    --bg-2:          #e7edef;
    --surface:       #ffffff;
    --surface-2:     #ebf1f3;
    --surface-inset: #e7eef0;
    --sidebar-bg:    #e3ebee;   /* tinted cool panel, distinct from white cards */
    --border:        #d3dde1;
    --border-strong: #b7c6cc;
    --text:          #112434;
    --text-muted:    #516b75;
    --text-faint:    #8aa0a8;
    --accent:        #0c7e72;   /* teal, deepened for contrast on light */
    --accent-bright: #0f9b8c;
    --accent-soft:   rgba(20,184,166,.12);
    --accent-2:      #094a73;   /* brand blue */
    /* Primary button: bright brand teal, brightens further on hover */
    --btn-bg:        #14b8a6;   /* brand teal */
    --btn-bg-hover:  #2dd4bf;   /* brighter teal */
    --btn-fg:        #04140f;
    --btn-fg-hover:  #04140f;
    --danger:        #c0432e;
    --danger-soft:   rgba(192,67,46,.10);
    --ring:          rgba(12,126,114,.30);
    --radius:        9px;
    --radius-sm:     6px;
    --shadow:        0 1px 2px rgba(17,36,52,.06), 0 8px 24px -12px rgba(17,36,52,.18);
    --grid-line:     rgba(17,36,52,.035);
    --grain:         .015;
    --font-sans: 'Hanken Grotesk', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

.dark {
    /* Dark theme — the cockpit. Foundations are brand navy. */
    --bg:            #08121a;
    --bg-2:          #0b1a25;
    --surface:       #112434;   /* brand primary navy */
    --sidebar-bg:    #112434;
    --surface-2:     #152c3e;
    --surface-inset: #0c1d2a;
    --border:        #1e3a4a;
    --border-strong: #28505f;
    --text:          #e7eff1;
    --text-muted:    #8aa6b0;
    --text-faint:    #5a7682;
    --accent:        #19c6af;   /* brand teal, nudged brighter to glow on navy */
    --accent-bright: #38e6cd;
    --accent-soft:   rgba(25,198,175,.14);
    --accent-2:      #2f87c0;   /* brand blue, lifted for dark visibility */
    /* Dark mode keeps its brighten-on-hover behavior */
    --btn-bg:        #19c6af;
    --btn-bg-hover:  #38e6cd;
    --btn-fg:        #04140f;
    --btn-fg-hover:  #04140f;
    --danger:        #e8604c;
    --danger-soft:   rgba(232,96,76,.14);
    --ring:          rgba(25,198,175,.40);
    --shadow:        0 1px 0 rgba(255,255,255,.03) inset, 0 18px 40px -22px rgba(0,0,0,.8);
    --grid-line:     rgba(120,200,210,.04);
    --grain:         .03;
}

/* ---- Base ------------------------------------------------- */
* { font-family: var(--font-sans); }

html { scroll-behavior: smooth; }

body {
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    background-image:
        linear-gradient(var(--grid-line) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
    background-size: 46px 46px, 46px 46px;
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
.dark body { background-color: var(--bg); }

/* Fine film grain for cockpit depth */
body::before {
    content: "";
    position: fixed; inset: 0; z-index: 0; pointer-events: none;
    opacity: var(--grain);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* Keep page content above the fixed grain layer. Do NOT include #sidebar
   here — it must stay position:fixed (it already sits above the grain via z-40). */
main { position: relative; z-index: 1; }

::selection { background: var(--accent); color: #06141a; }

/* ---- Typographic accents ---------------------------------- */
h1, h2, h3, .stat-value { letter-spacing: -.015em; }

/* Uppercase mono micro-label — the cockpit signature.
   Use class="eyebrow" anywhere you want a labelled readout. */
.eyebrow,
.data-table th {
    font-family: var(--font-mono);
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--text-faint);
}

/* ---- Sidebar (cockpit rail) ------------------------------- */
#sidebar {
    background: var(--sidebar-bg) !important;
    border-color: var(--border) !important;
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
}
#sidebar > div:first-child { border-color: var(--border) !important; }

/* nav links — added via sidebar.php */
.nav-link {
    position: relative;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.is-active {
    color: var(--accent);
    background: var(--accent-soft);
}
.nav-link.is-active::before {
    content: "";
    position: absolute; left: -11px; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px; border-radius: 0 3px 3px 0;
    background: var(--accent);
}
.brand-mark {
    background: var(--accent) !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.18);
}

/* Sidebar brand logo — full wordmark when expanded, mark when collapsed,
   colour in light theme, white in dark theme. */
.sidebar-logo { display: flex; align-items: center; min-height: 34px; }
.sidebar-logo .logo-img { display: none; height: 28px; width: auto; max-width: 100%; }
.sidebar-logo .logo-mark { height: 26px; }
/* expanded */
html:not(.dark) .sidebar-logo .logo-full.logo-light { display: block; }
html.dark       .sidebar-logo .logo-full.logo-dark  { display: block; }
/* collapsed → mark only, centered, no side padding */
.sidebar-collapsed .sidebar-logo { padding-left: 0; padding-right: 0; justify-content: center; }
.sidebar-collapsed .sidebar-logo .logo-full { display: none !important; }
html:not(.dark) .sidebar-collapsed .sidebar-logo .logo-mark.logo-light { display: block; }
html.dark       .sidebar-collapsed .sidebar-logo .logo-mark.logo-dark  { display: block; }

.sidebar-collapsed #sidebar { width: 68px; }
.sidebar-collapsed #sidebar .sidebar-text { display: none; }
.sidebar-collapsed main { margin-left: 68px; }

/* Top bar */
header.sticky {
    background: color-mix(in srgb, var(--bg) 78%, transparent) !important;
    border-color: var(--border) !important;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

/* ---- Cards ------------------------------------------------ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: border-color .2s, transform .2s, box-shadow .2s;
    animation: rise .5s cubic-bezier(.2,.7,.2,1) both;
}
.card:hover { border-color: var(--border-strong); }

/* Stat cards read like instrument gauges */
.stat-card { display: flex; align-items: center; gap: 1rem; }
.stat-icon {
    width: 3rem; height: 3rem; border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
    /* Force the cohesive teal treatment, overriding any per-page colour utilities */
    background: var(--accent-soft) !important; color: var(--accent) !important;
    border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.stat-value {
    font-family: var(--font-mono);
    font-size: 1.85rem; font-weight: 700; line-height: 1;
    font-variant-numeric: tabular-nums; color: var(--text);
}
.stat-label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* ---- Tables (data grid) ----------------------------------- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    text-align: left; padding: .7rem 1rem;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: .8rem 1rem; font-size: .875rem; vertical-align: middle;
    border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
    color: var(--text);
}
.data-table tbody tr { transition: background .12s; }
.data-table tbody tr:hover { background: var(--accent-soft); }
.data-table tbody tr:last-child td { border-bottom: none; }
/* tabular figures everywhere in tables */
.data-table td { font-variant-numeric: tabular-nums; }

/* ---- Table search box ------------------------------------- */
.table-search { display: flex; align-items: center; gap: .65rem; margin-bottom: .85rem; }
.table-search-input { max-width: 340px; }
.table-search-count {
    font-size: .75rem; color: var(--text-muted); white-space: nowrap;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

/* ---- Badges (status chips) -------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .15rem .55rem; border-radius: 5px;
    font-family: var(--font-mono);
    font-size: .68rem; font-weight: 600; letter-spacing: .04em;
    text-transform: uppercase; line-height: 1.5;
    border: 1px solid transparent;
}
/* Re-skin the Tailwind status utilities for the dark cockpit so chips
   glow instead of sitting as pale pastel pills. */
.dark .badge.bg-green-100  { background: rgba(34,197,94,.14);  color: #54d98c; border-color: rgba(34,197,94,.28); }
.dark .badge.bg-blue-100   { background: rgba(47,135,192,.16); color: #6cc0f0; border-color: rgba(47,135,192,.30); }
.dark .badge.bg-red-100    { background: rgba(232,96,76,.15);  color: #f6886f; border-color: rgba(232,96,76,.30); }
.dark .badge.bg-yellow-100 { background: rgba(212,165,60,.15); color: #e7c266; border-color: rgba(212,165,60,.30); }
.dark .badge.bg-orange-100 { background: rgba(212,140,60,.15); color: #ecb066; border-color: rgba(212,140,60,.30); }
.dark .badge.bg-gray-100   { background: rgba(138,166,176,.13);color: #a7c0c9; border-color: rgba(138,166,176,.24); }
.dark .badge.bg-purple-100 { background: rgba(139,124,246,.16);color: #b3a6fb; border-color: rgba(139,124,246,.30); }

/* ---- Buttons ---------------------------------------------- */
.btn {
    display: inline-flex; align-items: center; gap: .5rem;
    padding: .5rem 1rem; border-radius: var(--radius-sm);
    font-size: .8125rem; font-weight: 600; letter-spacing: .01em;
    transition: all .15s; cursor: pointer; border: 1px solid transparent;
    text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--btn-bg); color: var(--btn-fg); }
.btn-primary:hover { background: var(--btn-bg-hover); color: var(--btn-fg-hover); }
.btn-secondary {
    background: var(--surface-2); color: var(--text);
    border-color: var(--border-strong);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-sm { padding: .375rem .7rem; font-size: .78rem; }
.btn-icon { padding: .5rem; }
.btn-icon.btn-sm { padding: .4rem; }

/* ---- Forms ------------------------------------------------ */
.form-group { margin-bottom: 1rem; }
.form-label {
    display: block; font-size: .8rem; font-weight: 600;
    margin-bottom: .4rem; color: var(--text-muted);
}
.form-input {
    width: 100%; padding: .55rem .8rem;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    font-size: .875rem; background: var(--surface-inset); color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.form-input::placeholder { color: var(--text-faint); }
.form-input:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--ring);
}
.form-select { appearance: auto; }
.form-textarea { min-height: 100px; resize: vertical; }

/* ---- Progress --------------------------------------------- */
.progress-bar {
    height: .5rem; background: var(--surface-inset);
    border: 1px solid var(--border); border-radius: 9999px; overflow: hidden;
}
.progress-fill {
    height: 100%; border-radius: 9999px;
    background: var(--accent);
    transition: width .6s cubic-bezier(.2,.7,.2,1);
}
.circular-progress { position: relative; width: 120px; height: 120px; }
.circular-progress svg { transform: rotate(-90deg); }
.circular-progress .progress-text {
    position: absolute; inset: 0; display: flex;
    flex-direction: column; align-items: center; justify-content: center;
}

/* ---- Modal ------------------------------------------------ */
.modal-overlay {
    position: fixed; inset: 0; z-index: 50;
    background: rgba(4, 11, 16, .66);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; padding: 1rem;
    animation: fade .2s ease both;
}
.modal-content {
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 1.5rem; max-width: 32rem; width: 100%;
    max-height: 90vh; overflow-y: auto;
    box-shadow: 0 30px 80px -20px rgba(0,0,0,.6);
    animation: rise .28s cubic-bezier(.2,.7,.2,1) both;
}
.modal-lg { max-width: 48rem; }

/* ---- Empty state ------------------------------------------ */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-faint); }
.empty-state i { margin-bottom: 1rem; opacity: .7; }

/* ---- Tabs ------------------------------------------------- */
.tabs {
    display: flex; gap: .25rem;
    border-bottom: 1px solid var(--border); margin-bottom: 1.5rem;
}
.tab {
    padding: .65rem 1rem; font-size: .85rem; font-weight: 600;
    color: var(--text-muted); border-bottom: 2px solid transparent;
    margin-bottom: -1px; transition: all .15s; cursor: pointer; text-decoration: none;
}
.tab:hover { color: var(--text); }
.tab.active {
    color: var(--accent); border-bottom-color: var(--accent);
}

/* ---- Timeline / Gantt (brand-coded) ----------------------- */
.gantt-bar { height: 28px; border-radius: 4px; position: relative; min-width: 20px; }
.gantt-bar-session     { background: #16b6a1; }
.gantt-bar-project     { background: #5e7e91; }  /* muted steel — calmer than vivid blue */
.gantt-bar-deliverable { background: #c79545; }
.gantt-bar-task        { background: #7d72c9; }

/* ---- Tooltip ---------------------------------------------- */
[data-tooltip] { position: relative; }
[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
    background: var(--surface-2); color: var(--text);
    border: 1px solid var(--border-strong);
    padding: .3rem .55rem; border-radius: var(--radius-sm);
    font-size: .72rem; white-space: nowrap; margin-bottom: .35rem; z-index: 10;
    box-shadow: var(--shadow);
}

/* ---- Scrollbar -------------------------------------------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong); border-radius: 9px;
    border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--accent); background-clip: padding-box; }

/* ---- Focus visibility ------------------------------------- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- Motion ----------------------------------------------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* Stagger the first run of cards/rows on a page for a cockpit "boot up" */
.card:nth-of-type(1) { animation-delay: .02s; }
.card:nth-of-type(2) { animation-delay: .08s; }
.card:nth-of-type(3) { animation-delay: .14s; }
.card:nth-of-type(4) { animation-delay: .20s; }
.card:nth-of-type(5) { animation-delay: .26s; }

@media (prefers-reduced-motion: reduce) {
    *, ::before, ::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---- Responsive ------------------------------------------- */
@media (max-width: 768px) {
    #sidebar { transform: translateX(-100%); }
    .sidebar-open #sidebar { transform: translateX(0); }
    main { margin-left: 0 !important; }
}
