/* ═══════════════════════════════════════════════════════════
   Cite8.ai — Brand Design System
   Primary:  #2AB5A5  (teal)
   Dark:     #192038  (navy)
   BG:       #F0F2F6  (light gray-blue)
   ═══════════════════════════════════════════════════════════ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── CSS Design Tokens ─────────────────────────────────────── */
:root {
    /* Brand colours */
    --c8-teal:          #2AB5A5;
    --c8-teal-dark:     #1F8F82;
    --c8-teal-light:    #5FCFC3;
    --c8-teal-subtle:   #EAF7F6;
    --c8-navy:          #192038;
    --c8-navy-mid:      #2A3558;
    --c8-navy-light:    #3D4F7A;

    /* Neutrals */
    --c8-bg:            #F0F2F6;
    --c8-bg-alt:        #E6E9F0;
    --c8-white:         #FFFFFF;
    --c8-border:        #E2E8F0;
    --c8-text:          #192038;
    --c8-text-muted:    #4A5568;
    --c8-text-faint:    #A0AEC0;

    /* Semantic */
    --c8-success:       #38A169;
    --c8-warning:       #D69E2E;
    --c8-error:         #E53E3E;
    --c8-info:          #3182CE;

    /* Sizing */
    --c8-radius:        10px;
    --c8-radius-lg:     16px;
    --c8-radius-xl:     24px;
    --c8-shadow-sm:     0 1px 3px rgba(25,32,56,0.08), 0 1px 2px rgba(25,32,56,0.05);
    --c8-shadow:        0 4px 12px rgba(25,32,56,0.10), 0 2px 4px rgba(25,32,56,0.06);
    --c8-shadow-lg:     0 10px 28px rgba(25,32,56,0.12), 0 4px 8px rgba(25,32,56,0.08);
}

/* ── Base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background-color: var(--c8-bg);
    color: var(--c8-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ── MudBlazor overrides ───────────────────────────────────── */

/* Headings — keep Inter, drop old Playfair Display */
h1, h2, h3, h4, h5, h6,
.mud-typography-h1, .mud-typography-h2, .mud-typography-h3,
.mud-typography-h4, .mud-typography-h5, .mud-typography-h6 {
    font-family: 'Inter', sans-serif;
    color: var(--c8-navy);
}

/* Cards */
.mud-card {
    border-radius: var(--c8-radius-lg) !important;
    box-shadow: var(--c8-shadow-sm) !important;
    border: 1px solid var(--c8-border);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.mud-card:hover {
    box-shadow: var(--c8-shadow) !important;
    transform: translateY(-2px);
}

/* Paper / Surface */
.mud-paper {
    border-radius: var(--c8-radius-lg) !important;
}

/* Buttons */
.mud-button-root {
    border-radius: var(--c8-radius-xl) !important;
    font-weight: 600 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
}
.mud-button-filled-primary {
    background-color: var(--c8-teal) !important;
    color: #fff !important;
    box-shadow: 0 2px 8px rgba(42,181,165,0.30) !important;
}
.mud-button-filled-primary:hover {
    background-color: var(--c8-teal-dark) !important;
    box-shadow: 0 4px 14px rgba(42,181,165,0.40) !important;
}
.mud-button-outlined-primary {
    border-color: var(--c8-teal) !important;
    color: var(--c8-teal) !important;
}
.mud-button-outlined-primary:hover {
    background-color: var(--c8-teal-subtle) !important;
}

/* Input fields */
.mud-input-outlined .mud-input-outlined-border {
    border-color: var(--c8-border) !important;
    border-radius: var(--c8-radius) !important;
}
.mud-input-outlined:hover .mud-input-outlined-border {
    border-color: #CBD5E0 !important;
}

/* Chips */
.mud-chip {
    border-radius: var(--c8-radius-xl) !important;
    font-weight: 500 !important;
}

/* AppBar */
.mud-appbar { border-bottom: 1px solid rgba(255,255,255,0.08) !important; }

/* Inline appbar nav buttons */
.appbar-nav-btn {
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    text-transform: none !important;
    letter-spacing: 0 !important;
    padding: 6px 14px !important;
    border-radius: 8px !important;
    color: rgba(255,255,255,0.80) !important;
    transition: color 0.15s ease, background-color 0.15s ease !important;
}
.appbar-nav-btn:hover {
    color: #ffffff !important;
    background-color: rgba(255,255,255,0.10) !important;
}
/* Active page highlight — matches any Blazor NavLink active class */
.appbar-nav-btn.active,
.appbar-nav-btn[aria-current="page"] {
    color: #2AB5A5 !important;
    background-color: rgba(42,181,165,0.12) !important;
}

/* Badges / status chips */
.mud-chip-color-success { background-color: #C6F6D5 !important; color: #22543D !important; }
.mud-chip-color-warning { background-color: #FEFCBF !important; color: #744210 !important; }
.mud-chip-color-error   { background-color: #FED7D7 !important; color: #742A2A !important; }
.mud-chip-color-info    { background-color: #BEE3F8 !important; color: #2A4365 !important; }

/* Tables */
.mud-table-head .mud-table-cell {
    background-color: var(--c8-bg) !important;
    font-weight: 600 !important;
    color: var(--c8-text-muted) !important;
    font-size: 0.75rem !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    border-bottom: 2px solid var(--c8-border) !important;
}
.mud-table-row:hover { background-color: var(--c8-teal-subtle) !important; }

/* Progress bars */
.mud-progress-linear-bar { background-color: var(--c8-teal) !important; }

/* ── Utility Classes ───────────────────────────────────────── */

/* Teal CTA button (direct class) */
.c8-btn-teal {
    background-color: var(--c8-teal) !important;
    color: #fff !important;
    border-radius: var(--c8-radius-xl) !important;
    font-weight: 600 !important;
    box-shadow: 0 2px 8px rgba(42,181,165,0.30) !important;
    transition: background-color 0.18s ease, box-shadow 0.18s ease !important;
}
.c8-btn-teal:hover {
    background-color: var(--c8-teal-dark) !important;
    box-shadow: 0 4px 14px rgba(42,181,165,0.40) !important;
}

/* Outline secondary button */
.c8-btn-outline {
    background-color: var(--c8-white) !important;
    color: var(--c8-navy) !important;
    border: 1.5px solid var(--c8-border) !important;
    border-radius: var(--c8-radius-xl) !important;
    font-weight: 500 !important;
}
.c8-btn-outline:hover { border-color: var(--c8-teal) !important; color: var(--c8-teal) !important; }

/* Hero section */
.c8-hero {
    background: linear-gradient(135deg, var(--c8-navy) 0%, #253050 60%, #2A3D60 100%);
    padding: 100px 24px 110px;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.c8-hero::before {
    content: '';
    position: absolute;
    top: -80px; right: -80px;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(42,181,165,0.18) 0%, transparent 70%);
    pointer-events: none;
}
.c8-hero-title {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    line-height: 1.1;
}
@media (max-width: 600px) { .c8-hero-title { font-size: 2rem; } .c8-hero { padding: 48px 16px; } }

/* Teal accent card top border */
.c8-card-accent { border-top: 3px solid var(--c8-teal) !important; }

/* Practice area clickable cards */
.c8-practice-card:hover {
    border-color: var(--c8-teal) !important;
    box-shadow: 0 4px 20px rgba(42,181,165,0.15) !important;
    transform: translateY(-2px);
}
.c8-practice-card:hover .mud-typography { color: var(--c8-teal) !important; }

/* Stat / KPI card */
.c8-stat-card {
    background: var(--c8-white);
    border-radius: var(--c8-radius-lg);
    padding: 24px;
    box-shadow: var(--c8-shadow-sm);
    border: 1px solid var(--c8-border);
}
.c8-stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--c8-teal);
    line-height: 1;
}
.c8-stat-label {
    font-size: 0.8125rem;
    color: var(--c8-text-muted);
    font-weight: 500;
    margin-top: 4px;
}

/* Section label / eyebrow */
.c8-eyebrow {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--c8-teal);
}

/* Gradient text for headings */
.c8-gradient-text {
    background: linear-gradient(135deg, var(--c8-teal) 0%, #5FCFC3 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Sidebar sticky */
.c8-sidebar-sticky { position: sticky; top: 80px; }

/* Legal disclaimer */
.c8-legal {
    font-size: 11px;
    color: var(--c8-text-faint);
    line-height: 1.5;
}

/* Skeleton loading */
.mud-skeleton { border-radius: var(--c8-radius) !important; }

/* ── Focus rings ────────────────────────────────────────────────────────────
   Kill ALL outlines by default — no boxes on text, cards, containers, etc.
   Restore a clean ring ONLY on elements the user can actually interact with
   via keyboard (buttons, links, inputs, selects, textareas, checkboxes).
   ────────────────────────────────────────────────────────────────────────── */
*, *:focus, *:focus-visible, *:focus-within {
    outline: none !important;
    box-shadow: none !important;
}

/* Re-enable for genuinely interactive elements (buttons, links) — not raw inputs
   since MudBlazor wraps inputs in its own styled containers */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
[role="link"]:focus-visible,
[role="menuitem"]:focus-visible,
[role="tab"]:focus-visible {
    outline: 2px solid var(--c8-teal) !important;
    outline-offset: 2px !important;
    box-shadow: none !important;
}

/* MudBlazor inputs — no focus border change; consistent 1px border at all times */
.mud-input-outlined:focus-within .mud-input-outlined-border,
.mud-input-outlined.mud-focused .mud-input-outlined-border {
    border-color: var(--c8-border) !important;
    border-width: 1px !important;
}

/* Scrollbar (Webkit) */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--c8-bg); }
::-webkit-scrollbar-thumb { background: var(--c8-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--c8-teal-light); }

/* ── Backward-compat aliases (old ca- classes) ─────────────── */
.ca-hero       { @extend .c8-hero; }      /* graceful fallback in old razor pages */
.btn-cta       { background: var(--c8-teal) !important; color: #fff !important; font-weight: 700 !important; }
.card-gold-accent { border-top: 3px solid var(--c8-teal) !important; }
.sidebar-sticky   { position: sticky; top: 80px; }
.legal-disclaimer { font-size: 11px; color: var(--c8-text-faint); line-height: 1.5; }

/* ── Collaborative editor layout ──────────────────────────────── */

/*
 * editor-page-root
 * Fills exactly the visible viewport below the 72 px app bar.
 * Uses `dvh` (dynamic viewport height) so mobile browser chrome is
 * excluded automatically; falls back to `vh` for older engines.
 * All direct children default to flex-shrink:0 (fixed height);
 * only .editor-layout stretches to fill the remaining space.
 */
.editor-page-root {
    height: calc(100vh  - 72px);   /* vh fallback */
    height: calc(100dvh - 72px);   /* dvh = excludes mobile browser chrome */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /*
     * The MudContainer wrapping @Body has mb-8 (32 px bottom margin) and
     * the MudMainContent uses overflow-y:auto, which can produce a tiny
     * scrollbar even when our content fits exactly.  A negative bottom margin
     * of 32 px cancels the container's mb-8 so the scroll never appears.
     */
    margin-bottom: -32px;
}
/* Every direct child is fixed-height by default … */
.editor-page-root > * {
    flex-shrink: 0;
}
/* … except the editor grid, which fills whatever is left */
.editor-page-root > .editor-layout {
    flex: 1 1 0;
    min-height: 0;        /* allow shrink below intrinsic size */
    flex-shrink: 1;       /* override the > * rule above */
}

.editor-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    /* height comes from flex parent — do NOT set a fixed height here */
}
.editor-layout.with-chat {
    grid-template-columns: 1fr 320px;
}
.editor-pane {
    height: 100%;
    overflow: hidden;
    min-height: 0;
}
.chat-pane {
    height: 100%;
    overflow: hidden;
    min-height: 0;
}
/* Quill toolbar override */
.ql-toolbar.ql-snow {
    border: none !important;
    border-bottom: 1px solid #E5E7EB !important;
    background: #FAFAFA;
    flex-shrink: 0;
}
.ql-container.ql-snow {
    border: none !important;
}

/* Quill host paper — flex column so Quill's toolbar sibling + container fill height naturally.
   Quill inserts .ql-toolbar BEFORE #quill-editor (which becomes .ql-container) in the parent.
   Making the parent flex-column lets the toolbar size naturally while the container fills the rest. */
.quill-host-paper {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
}
.quill-host-paper > .ql-container {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: auto !important;   /* override Quill's height:100% so flex sizing wins */
}
.quill-host-paper > .ql-editor,
.quill-host-paper .ql-editor {
    height: 100%;
    overflow-y: auto;
}

/* ── Responsive utilities ───────────────────────────────────── */
@media (max-width: 960px) {
    .mud-typography-h2 { font-size: 2rem !important; }
    .mud-typography-h3 { font-size: 1.5rem !important; }
}
@media (max-width: 600px) {
    .mud-typography-h1 { font-size: 1.875rem !important; }
    .mud-typography-h2 { font-size: 1.625rem !important; }
}
