/* Jarvis Design System tokens — source of truth: docs/design.md */

:root {
    /* Backgrounds */
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-surface: #0f3460;
    --bg-input: #1a1a3e;
    --bg-deep: #0f1629;
    --bg-card: #1e2a4a;

    /* Text */
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b80;

    /* Accent */
    --accent: #4f8ff7;
    --accent-hover: #3a7be0;
    --accent-light: #7eb3ff;
    --accent-subtle: rgba(79, 143, 247, 0.12);

    /* Status */
    --error: #e74c3c;
    --error-bg: rgba(231, 76, 60, 0.15);
    --success: #2ecc71;
    --warning: #e2b71e;
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.15);

    /* Borders & Shadows */
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: #2a3a5e;
    --border-focus: rgba(79, 143, 247, 0.5);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.4);

    /* Radius */
    --radius: 8px;
    --radius-lg: 12px;
    --radius-pill: 24px;

    /* Typography */
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent-light);
    text-decoration: none;
}

a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* Accessibility: keyboard-visible focus ring on every interactive element.
   Mouse users see no outline; keyboard users always do. */
:focus-visible {
    outline: 2px solid var(--border-focus);
    outline-offset: 2px;
    border-radius: var(--radius);
}

/* Visually hidden, available to screen readers. Standard a11y utility. */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Skip link: visually hidden until focused. WCAG 2.4.1. */
.skip-link {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    padding: 0.5rem 0.9rem;
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    z-index: 1100;
    transform: translateY(-200%);
    transition: transform 0.15s ease;
}

.skip-link:focus,
.skip-link:focus-visible {
    transform: translateY(0);
    text-decoration: none;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    line-height: 1.3;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
}

/* Layout shell ============================================================ */

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar__brand {
    color: var(--accent);
    font-size: 1.25rem;
    font-weight: 700;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-deep);
}

.sidebar__nav {
    flex: 1;
    padding: 0.75rem 0;
    overflow-y: auto;
}

.sidebar__link {
    display: block;
    padding: 0.7rem 1.5rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.sidebar__link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    text-decoration: none;
}

.sidebar__link.active {
    background: var(--bg-surface);
    color: var(--text-primary);
    border-left-color: var(--accent);
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    height: 56px;
    padding: 0 1.5rem;
    background: var(--bg-deep);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
}

.topbar__user {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header h1 {
    font-size: 1.5rem;
    margin: 0;
}

/* Cards =================================================================== */

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1rem;
}

.card--auth {
    padding: 2.5rem;
}

/* Forms =================================================================== */

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.4rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(79, 143, 247, 0.2);
}

/* Buttons ================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.btn:hover {
    background: var(--bg-surface);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn--primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn--primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: #fff;
}

.btn--block {
    width: 100%;
}

/* Alerts ================================================================== */

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border: 1px solid transparent;
}

.alert--error {
    background: var(--error-bg);
    color: var(--error);
    border-color: rgba(231, 76, 60, 0.3);
}

.alert--success {
    background: rgba(46, 204, 113, 0.15);
    color: var(--success);
    border-color: rgba(46, 204, 113, 0.3);
}

/* Login layout ============================================================ */

.login-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
}

.login-card h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    color: var(--accent);
}

.login-card .login-card__subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 1.5rem;
}

/* Scrollbars ============================================================== */

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #3a4a6e;
}

/* Blazor error UI ========================================================= */

#blazor-error-ui {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-top: 1px solid var(--border-strong);
    bottom: 0;
    box-shadow: var(--shadow-lg);
    display: none;
    left: 0;
    padding: 0.75rem 1rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
    color: var(--text-secondary);
    padding: 0.15rem 0.5rem;
    font-size: 1rem;
    line-height: 1;
}

#blazor-error-ui .dismiss:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

/* MetricCard hover/focus replaces previous inline JS so keyboard users
   get the same visual cue as mouse users. */
.metric-card {
    display: block;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1rem 1.25rem;
    text-decoration: none;
    transition: background 0.2s ease;
}

.metric-card:hover,
.metric-card:focus-visible {
    background: var(--bg-card);
    text-decoration: none;
}
