/* Pulse — Base styles: variables, reset, layout, header, navigation, typography, utilities */

:root {
    /* Unitary palette — light theme */
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: rgba(0, 0, 0, 0.02);
    --bg-muted: #f4f5f7;
    --text-primary: #222222;
    --text-secondary: #6B7280;
    --accent: #61CA6B;
    --accent-hover: #6AF392;
    --success: #61CA6B;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #3b82f6;
    --border: #e5e7eb;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --overlay-bg: rgba(0, 0, 0, 0.5);

    /* Raw colours */
    --color-blue: #3b82f6;
    --color-green: #16a34a;
    --color-red: #dc2626;
    --color-amber: #d97706;
    --color-purple: #7c3aed;

    /* Tinted backgrounds */
    --info-bg: rgba(59, 130, 246, 0.12);
    --warning-bg: rgba(217, 119, 6, 0.12);
    --danger-bg: rgba(220, 38, 38, 0.12);
    --success-bg: rgba(97, 202, 107, 0.12);

    /* Typography scale */
    --text-xs: 0.65rem;
    --text-sm: 0.75rem;
    --text-base: 0.85rem;
    --text-md: 1rem;
    --text-lg: 1.25rem;
    --text-xl: 1.5rem;
    --text-2xl: 2rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;

    /* Radii */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px var(--shadow-color);
    --shadow-md: 0 4px 12px var(--shadow-color);
    --shadow-lg: 0 8px 24px var(--shadow-color);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;

    color-scheme: light;
}

/* Dark theme */
[data-theme="dark"] {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #1e2a47;
    --bg-hover: rgba(255, 255, 255, 0.04);
    --bg-muted: #243352;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent: #6AF392;
    --accent-hover: #61CA6B;
    --success: #6AF392;
    --warning: #fbbf24;
    --danger: #f87171;
    --info: #60a5fa;
    --border: #334155;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --overlay-bg: rgba(0, 0, 0, 0.7);
    --color-blue: #60a5fa;
    --color-green: #4ade80;
    --color-red: #f87171;
    --color-amber: #fbbf24;
    --color-purple: #a78bfa;
    --info-bg: rgba(96, 165, 250, 0.12);
    --warning-bg: rgba(251, 191, 36, 0.12);
    --danger-bg: rgba(248, 113, 113, 0.12);
    --success-bg: rgba(106, 243, 146, 0.12);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-primary: #1a1a2e;
        --bg-secondary: #16213e;
        --bg-card: #1e2a47;
        --bg-hover: rgba(255, 255, 255, 0.04);
        --bg-muted: #243352;
        --text-primary: #e2e8f0;
        --text-secondary: #94a3b8;
        --accent: #6AF392;
        --accent-hover: #61CA6B;
        --success: #6AF392;
        --warning: #fbbf24;
        --danger: #f87171;
        --info: #60a5fa;
        --border: #334155;
        --shadow-color: rgba(0, 0, 0, 0.3);
        --overlay-bg: rgba(0, 0, 0, 0.7);
        --color-blue: #60a5fa;
        --color-green: #4ade80;
        --color-red: #f87171;
        --color-amber: #fbbf24;
        --color-purple: #a78bfa;
        --info-bg: rgba(96, 165, 250, 0.12);
        --warning-bg: rgba(251, 191, 36, 0.12);
        --danger-bg: rgba(248, 113, 113, 0.12);
        --success-bg: rgba(106, 243, 146, 0.12);
        color-scheme: dark;
    }
}

/* Skip link — visible only on focus for keyboard users */
.skip-link {
    position: absolute;
    top: -100%;
    left: 1rem;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    border-radius: 0 0 4px 4px;
    z-index: 10000;
    font-weight: 600;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
    color: #fff;
}

/* Screen-reader only text */
.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; }

/* Focus-visible outlines for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* Layout */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
    margin-bottom: 2rem;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0;
    padding-bottom: 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}
.logo-pulse { flex-shrink: 0; }

/* Navigation */
nav {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-base);
    transition: color var(--transition-base), background var(--transition-base);
}

nav a:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

nav a.active {
    background: var(--success-bg);
    color: var(--accent);
}

.nav-separator {
    display: inline-block;
    width: 1px;
    height: 1rem;
    background: var(--border);
    margin: 0 var(--space-1);
    vertical-align: middle;
}

.nav-logout {
    color: var(--text-secondary);
}

.nav-logout:hover {
    color: var(--danger);
}

/* Theme toggle */
.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    margin-left: 0.75rem;
    font-size: 1rem;
    line-height: 1;
    color: var(--text-secondary);
    transition: color 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

/* Show moon in light, sun in dark */
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-icon-light { display: none; }
    :root:not([data-theme="light"]) .theme-icon-dark { display: inline; }
}

/* Typography */
h1, h2, h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

h1 {
    font-size: 2rem;
}

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

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

/* Utility classes */
.text-muted {
    color: var(--text-secondary);
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 2rem;
}

.hidden {
    display: none !important;
}

/* Command Palette */
.cmd-palette-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 15vh;
    background: var(--overlay-bg);
}

.cmd-palette {
    width: 100%;
    max-width: 560px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: 0 16px 48px var(--shadow-color);
    overflow: hidden;
}

.cmd-palette-input-row {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    gap: 0.5rem;
}

.cmd-palette-icon {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.cmd-palette-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
}

.cmd-palette-input::placeholder { color: var(--text-secondary); }

.cmd-palette-kbd {
    font-size: 0.65rem;
    padding: 0.125rem 0.375rem;
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    color: var(--text-secondary);
    background: var(--bg-primary);
    font-family: inherit;
}

.cmd-palette-results {
    max-height: 360px;
    overflow-y: auto;
}

.cmd-result-group {
    padding: 0.375rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--bg-muted);
}

.cmd-result-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: background 0.1s;
}

.cmd-result-item:hover,
.cmd-result-selected {
    background: var(--bg-hover);
}

.cmd-result-icon { font-size: 1rem; flex-shrink: 0; }

.cmd-result-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.cmd-result-title {
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmd-result-sub {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cmd-result-empty {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Alert banners — theme-aware */
.alert-info    { background: var(--bg-muted); border: 1px solid var(--accent); padding: 16px; border-radius: 4px; color: var(--text-primary); }
.alert-success { background: var(--bg-muted); border: 1px solid var(--success); padding: 16px; border-radius: 4px; color: var(--text-primary); }
.alert-error   { background: var(--bg-muted); border: 1px solid var(--danger); padding: 16px; border-radius: 4px; color: var(--text-primary); }

/* Alert badge in header nav */
.nav-alerts { position: relative; }
.alert-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; font-size: var(--text-xs); font-weight: 700; color: #fff; background: var(--danger); border-radius: var(--radius-full); margin-left: 4px; vertical-align: middle; }

/* Responsive breakpoints */
@media (max-width: 1024px) {
    nav { gap: var(--space-1); }
    nav a { padding: var(--space-1); font-size: var(--text-sm); }
    .nav-separator { display: none; }
}

@media (max-width: 768px) {
    .container { padding: 1rem; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .board-container { flex-direction: column; }
    .board-column { min-width: auto; max-width: none; }
    .stage-tabs-global { overflow-x: auto; flex-wrap: nowrap; }
    header .container { flex-direction: column; gap: 0.5rem; }
}
