/* Base — reset, body, typography, navbar, page chrome, card */

/* FOUC handling. Until Datastar initialises (body gains .ds-ready via
   data-class), a full-screen loading overlay covers the app — so nothing
   (modals, dropdowns, half-rendered chrome) flashes during the ~0.4s before
   hydration. As belt-and-suspenders we also hard-hide the conditional layers
   underneath. Once .ds-ready is set, the overlay vanishes and each element's
   own reactive display takes over. */
.app-loader { display: none; }
body.chat-page:not(.ds-ready) .app-loader {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}
.app-loader-spin {
    width: 30px;
    height: 30px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: app-loader-spin 0.7s linear infinite;
}
@keyframes app-loader-spin { to { transform: rotate(360deg); } }

body.chat-page:not(.ds-ready) .modal,
body.chat-page:not(.ds-ready) .modal-backdrop,
body.chat-page:not(.ds-ready) [data-show] { display: none !important; }

:root {
    --bg: #ffffff;
    --bg-surface: #f7f6f8;
    --bg-card: #ffffff;
    --bg-hover: rgba(0, 0, 0, 0.02);
    --text: #1a1a2e;
    --text-dim: #838383;
    --text-secondary: #555;
    --primary: hsl(217, 55%, 28%);
    --primary-light: hsl(217, 55%, 95%);
    --primary-muted: hsl(217, 30%, 60%);
    --success: #00b894;
    --success-bg: rgba(0, 184, 148, 0.10);
    --warning: hsl(47.9, 95.8%, 53.1%);
    --warning-bg: rgba(255, 193, 7, 0.10);
    --error: hsl(0, 84.2%, 60.2%);
    --error-bg: rgba(239, 83, 80, 0.08);
    --border: #e2e2e2;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --radius: 7px;
    --radius-lg: 10px;
    --chat-col: 820px;            /* shared content column for header/messages/composer */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Varela Round', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
    line-height: 1.5;
}

/* Chat is a full-viewport layout — nothing should scroll outside the
   message list. Hide body overflow only on the chat page so the dashboard
   and login pages keep their normal page scrolling. */
body.chat-page { overflow: hidden; height: 100vh; min-height: 0; }

/* Lock all interactive form elements to the body font (browser UA stylesheets
   still pick their own defaults otherwise). Inline <code>/<pre> keep monospace. */
button, input, select, textarea, optgroup {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}
::placeholder { font-family: inherit; }

code {
    font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
    font-size: 0.875em;
    background: var(--primary-light);
    color: var(--primary);
    padding: 1px 6px;
    border-radius: 4px;
}

/* Navbar */
.navbar {
    display: flex;
    align-items: center;
    padding: 0 20px;
    height: 56px;
    background: var(--primary);
    gap: 16px;
}

.nav-brand {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    letter-spacing: 0.2px;
}

.nav-spacer { flex: 1; }

.nav-meta {
    color: rgba(255,255,255,0.65);
    font-size: 12px;
}

/* Page */
.page {
    max-width: 880px;
    margin: 0 auto;
    padding: 40px 20px 80px;
}

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.2;
    color: var(--text);
}

.page-lede {
    margin-top: 8px;
    color: var(--text-dim);
    font-size: 15px;
    max-width: 60ch;
}

.page-footer {
    margin-top: 48px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 12.5px;
}

/* Demo section */
.demo {
    margin-bottom: 36px;
}

.demo-head {
    margin-bottom: 14px;
}

.demo-tag {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}

.demo-title {
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.demo-sub {
    color: var(--text-dim);
    font-size: 14px;
    max-width: 62ch;
}

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 22px;
}

/* Buttons */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    min-height: 40px;
    min-width: 44px;
    transition: background 0.18s, box-shadow 0.18s, transform 0.05s;
    line-height: 1;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { box-shadow: var(--shadow-md); }
.btn-primary:disabled, .btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--primary-light); border-color: var(--primary-muted); }

/* Size modifier — pair with any variant (btn-primary/btn-secondary). Keeps
   every compact button (e.g. the tool-approval row) identical in height,
   padding, and corner radius regardless of variant. */
.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    min-height: 32px;
    border-radius: 8px;
}

.btn-ghost {
    background: transparent;
    color: var(--text-dim);
}
.btn-ghost:hover { color: var(--error); }

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}
.btn-icon:hover { background: var(--error-bg); color: var(--error); }

/* ----- Nav extras (links + logout button) ---------------------------- */
.nav-link {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 14px;
    font-family: inherit;
    transition: background 0.15s, color 0.15s;
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.10); }
.nav-link-btn {
    background: transparent;
    border: none;
    cursor: pointer;
}

