/* ============================================================================
   CLARITIQ ADMIN — DESIGN SYSTEM
   ----------------------------------------------------------------------------
   Single source of truth for the admin portal's visual language.

   Every page under admin.claritiq.io includes this file. It owns:
     - design tokens (colors, type scale, spacing, radius)
     - body reset + base typography
     - the dark canvas (background grid + brand-color glow)
     - the page wrapper (.admin-main) and page-head primitives
     - shared components used in two or more pages: stats display,
       filter pills, stat pills, filter sidebar, view switcher

   Page-specific CSS lives inline in the page (e.g. the cards grid on
   the backlog page, the D3 tree styling on the tree page). Anything
   used by 2+ pages should land here instead of being copied.

   See _portal/README.md for the page contract (skeleton + rules).
   ============================================================================ */

/* === DESIGN TOKENS ======================================================== */
:root {
    /* Surface */
    --bg: #0a0a0f;
    --bg-elevated: #12121a;
    --bg-card: #1a1a26;
    --border: #2a2a3a;

    /* Text */
    --text: #e4e4ed;
    --text-muted: #8888a0;
    --text-dim: #5a5a72;

    /* Brand */
    --primary: #6D28D9;
    --primary-light: #A78BFA;
    --primary-glow: rgba(109, 40, 217, 0.15);
    --primary-border: rgba(109, 40, 217, 0.3);
    --accent: #6366F1;
    --gradient: linear-gradient(135deg, #6D28D9, #6366F1);

    /* Status — every status has fg / bg / border / glow so cards, badges
       and pills can all draw from the same set without ad-hoc rgba(). */
    --done: #10b981;
    --done-bg: rgba(16, 185, 129, 0.12);
    --done-border: rgba(16, 185, 129, 0.3);
    --done-glow: rgba(16, 185, 129, 0.2);

    --inprogress: #f59e0b;
    --inprogress-bg: rgba(245, 158, 11, 0.12);
    --inprogress-border: rgba(245, 158, 11, 0.3);
    --inprogress-glow: rgba(245, 158, 11, 0.2);

    --notstarted: #64748b;
    --notstarted-bg: rgba(100, 116, 139, 0.12);
    --notstarted-border: rgba(100, 116, 139, 0.3);

    --parked: #a78bfa;
    --parked-bg: rgba(167, 139, 250, 0.10);
    --parked-border: rgba(167, 139, 250, 0.25);

    /* Parity-specific (not used outside the parity dashboard) */
    --gap-color: #ef4444;
    --partial: #f59e0b;
    --oos: #6b7280;
    --future: #6366F1;

    /* Layout */
    --nav-h: 60px;
    --content-max: 1600px;
    --content-pad: 32px;
    --content-pad-narrow: 20px;
    --section-gap: 40px;

    /* Sidebar (used by backlog cards + tree) */
    --sidebar-w: 260px;
    --sidebar-w-collapsed: 40px;

    /* Type scale */
    --fs-xs: 11px;
    --fs-sm: 12px;
    --fs-base: 13px;
    --fs-md: 14px;
    --fs-lg: 16px;
    --fs-xl: 18px;
    --fs-2xl: 22px;
    --fs-page-title: 32px;

    /* Radius */
    --r-sm: 4px;
    --r-md: 6px;
    --r-lg: 8px;
    --r-xl: 12px;

    /* Animation */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
}


/* === RESET ================================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }


/* === BASE ================================================================= */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    overflow-x: hidden;
}


/* === DARK CANVAS — grid pattern + brand glow ============================== */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(109, 40, 217, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(109, 40, 217, 0.04) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse 80% 60% at 50% 20%, black 10%, transparent 80%);
    -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 20%, black 10%, transparent 80%);
    pointer-events: none;
    z-index: -1;
}
body::after {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 40% at 50% 0%, rgba(109, 40, 217, 0.10), transparent),
        radial-gradient(ellipse 40% 30% at 50% 0%, rgba(99, 102, 241, 0.06), transparent);
    pointer-events: none;
    z-index: -1;
}


/* === MAIN CONTENT WRAPPER =================================================
   Every page wraps its content in <main class="admin-main"> for consistent
   max-width, gutters and top spacing below the portal nav. Pages with a
   sidebar layout (backlog cards/tree) override left padding via a body
   class — see "Filter sidebar" section below. */
.admin-main {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 32px var(--content-pad) 64px;
}

@media (max-width: 768px) {
    .admin-main {
        padding: 20px var(--content-pad-narrow) 40px;
    }
}


/* === PAGE HEAD ============================================================
   Standard page intro: title + optional pill + sub-line. Used at the top of
   every page's <main> so titles align across the portal. */
.admin-page-head {
    margin-bottom: var(--section-gap);
}
.admin-page-title {
    font-size: var(--fs-page-title);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
    display: inline-flex;
    align-items: baseline;
    gap: 14px;
    margin-bottom: 10px;
}
.admin-page-title .page-pill {
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--primary-light);
    background: var(--primary-glow);
    border: 1px solid var(--primary-border);
    padding: 3px 10px;
    border-radius: 999px;
    letter-spacing: 0;
}
.admin-page-sub {
    color: var(--text-muted);
    font-size: var(--fs-md);
    max-width: 720px;
    line-height: 1.6;
}


/* === ADMIN CARD ===========================================================
   Generic elevated container — used for tile-grid tiles, parity summary
   cards, and anywhere else a "framed surface" is appropriate. */
.admin-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 28px;
    transition: all 0.2s var(--ease);
}
.admin-card:hover {
    border-color: var(--text-dim);
}


/* === STATS DISPLAY (used in nav slot) =====================================
   Inline stat columns. Number + label baseline-aligned so the whole row
   fits inside the 60px portal nav band. */
.stats {
    display: flex;
    gap: 18px;
    align-items: center;
}
.stat {
    display: flex;
    align-items: baseline;
    gap: 6px;
}
.stat-num {
    font-size: var(--fs-xl);
    font-weight: 800;
    line-height: 1;
}
.stat-num.done { color: var(--done); }
.stat-num.inprogress { color: var(--inprogress); }
.stat-num.notstarted { color: var(--notstarted); }
.stat-num.parked { color: var(--parked); }
.stat-label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1;
}


/* === FILTER PILL (single-select toggle group) =============================
   The canonical filter button. Used on backlog (cards + tree) sidebar and
   parity dashboard. */
.filter-btn {
    padding: 6px 12px;
    border-radius: var(--r-md);
    font-size: var(--fs-sm);
    font-weight: 600;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s var(--ease);
    font-family: inherit;
    white-space: nowrap;
}
.filter-btn:hover {
    border-color: var(--text-dim);
    color: var(--text);
}
.filter-btn.active {
    background: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary-light);
    box-shadow: 0 0 12px var(--primary-glow);
}


/* === STAT PILL (status indicator pill with optional dot) ==================
   Smaller than .filter-btn — used to show counts on the home tile-grid and
   on parity summary cards. */
.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    font-size: var(--fs-xs);
    color: var(--text-muted);
}
.stat-pill strong { color: var(--text); font-weight: 600; }
.stat-pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}
.stat-pill .dot.done { background: var(--done); }
.stat-pill .dot.partial { background: var(--partial); }
.stat-pill .dot.gap { background: var(--gap-color); }
.stat-pill .dot.oos { background: var(--oos); }
.stat-pill .dot.future { background: var(--future); }
.stat-pill.done { color: var(--done); border-color: var(--done-border); }
.stat-pill.warn,
.stat-pill.inprogress { color: var(--inprogress); border-color: var(--inprogress-border); }


/* === FILTER SIDEBAR =======================================================
   The collapsible left-rail filter UI used by the backlog cards + tree
   pages. Pages that opt in add `body.has-filter-sidebar` so the content
   inside <main class="admin-main"> shifts right by the sidebar width.
   Sidebar collapse state is `body.sidebar-collapsed`. */
.filter-sidebar {
    position: fixed;
    top: var(--nav-h);
    left: 0;
    bottom: 0;
    width: var(--sidebar-w);
    background: rgba(10, 10, 15, 0.92);
    backdrop-filter: blur(12px);
    border-right: 1px solid var(--border);
    z-index: 80;
    display: flex;
    flex-direction: column;
    transition: width 0.2s var(--ease);
}
.filter-sidebar.collapsed {
    width: var(--sidebar-w-collapsed);
}
.filter-sidebar-toggle {
    position: absolute;
    top: 8px;
    right: 14px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s var(--ease);
    z-index: 2;
    font-size: var(--fs-xs);
}
.filter-sidebar-toggle:hover {
    color: var(--text);
    border-color: var(--text-dim);
}
.filter-sidebar-toggle::before {
    content: '◀';
    line-height: 1;
}
.filter-sidebar.collapsed .filter-sidebar-toggle::before {
    content: '▶';
}
.filters {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.filter-sidebar.collapsed .filters {
    display: none;
}
/* First row of filters (typically the Cards/Tree view-switcher) reserves
   space for the collapse toggle in its top-right corner. */
.filters > :first-child {
    margin-right: 32px;
}
.filter-group {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
}
.filter-label {
    font-size: var(--fs-xs);
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    margin-bottom: 2px;
}
.filter-group-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
/* Inside the sidebar, filter buttons are tighter than the canonical
   .filter-btn — smaller font, less padding, left-aligned text. */
.filters .filter-btn {
    padding: 5px 10px;
    border-radius: 5px;
    font-size: var(--fs-xs);
    text-align: left;
}
.filters .filter-btn.active {
    box-shadow: 0 0 8px var(--primary-glow);
}

.search-input {
    padding: 6px 10px;
    border-radius: 5px;
    font-size: var(--fs-sm);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    width: 100%;
    transition: all 0.2s var(--ease);
}
.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 8px var(--primary-glow);
}
.search-input::placeholder {
    color: var(--text-dim);
}


/* === VIEW SWITCHER (Cards / Tree pill pair, top of sidebar) =============== */
.view-switcher {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin-bottom: 4px;
}
.view-switcher-link {
    flex: 1;
    text-align: center;
    padding: 6px 10px;
    border-radius: var(--r-sm);
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.15s var(--ease);
}
.view-switcher-link:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
}
.view-switcher-link.active {
    color: var(--primary-light);
    background: var(--primary-glow);
    box-shadow: 0 0 8px var(--primary-glow);
}


/* === SIDEBAR-AWARE CONTENT OFFSET =========================================
   On pages with body.has-filter-sidebar, every flow-element below the nav
   shifts right by the sidebar width. Animates in lockstep with the
   sidebar's width transition. */
body.has-filter-sidebar .admin-main,
body.has-filter-sidebar .progress-container,
body.has-filter-sidebar .meta-footer {
    padding-left: calc(var(--content-pad) + var(--sidebar-w));
    transition: padding-left 0.2s var(--ease);
}
body.has-filter-sidebar.sidebar-collapsed .admin-main,
body.has-filter-sidebar.sidebar-collapsed .progress-container,
body.has-filter-sidebar.sidebar-collapsed .meta-footer {
    padding-left: calc(var(--content-pad) + var(--sidebar-w-collapsed));
}


/* === META FOOTER (small "last updated" strip at bottom of page) =========== */
.meta-footer {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 24px var(--content-pad);
    color: var(--text-dim);
    font-size: var(--fs-xs);
    text-align: center;
}


/* === ANIMATIONS =========================================================== */
@keyframes admin-fade-in-up {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}


/* === UTILITY ============================================================== */
.admin-link {
    color: var(--primary-light);
    text-decoration: none;
}
.admin-link:hover {
    text-decoration: underline;
}
