/* ============================================================
   TestCaseAI — Enterprise Design System
   Clean light theme with professional polish and animations
   ============================================================ */

/* ── Google Fonts Import ─────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Custom Properties (Design Tokens) ────────────────── */
:root {
    /* Typography */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    --text-xs: 0.6875rem;
    --text-sm: 0.8125rem;
    --text-base: 0.875rem;
    --text-md: 0.9375rem;
    --text-lg: 1.0625rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;
    --space-2xl: 32px;
    --space-3xl: 48px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed: 64px;
    --header-height: 56px;
}

/* ── Light Theme (default) ────────────────────────────────── */
:root,
[data-theme="light"] {
    --bg-primary: #f1f5f9;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8fafc;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-elevated: #ffffff;
    --bg-input: #ffffff;
    --bg-overlay: rgba(15, 23, 42, 0.45);
    --loading-overlay-bg: rgba(241, 245, 249, 0.92);

    --border-subtle: #e2e8f0;
    --border-default: #cbd5e1;
    --border-active: rgba(37, 99, 235, 0.45);
    --border-accent: rgba(37, 99, 235, 0.65);

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --text-accent: #2563eb;
    --text-inverse: #ffffff;

    --accent-primary: #2563eb;
    --accent-primary-hover: #1d4ed8;
    --accent-primary-glow: rgba(37, 99, 235, 0.1);
    --accent-secondary: #7c3aed;

    --hover-bg: rgba(0, 0, 0, 0.04);
    --row-hover: rgba(0, 0, 0, 0.03);
    --row-even: rgba(0, 0, 0, 0.02);
    --tag-gray-bg: #f1f5f9;
    --scrollbar-thumb: rgba(0, 0, 0, 0.15);
    --scrollbar-thumb-hover: rgba(0, 0, 0, 0.25);

    --success: #16a34a;
    --success-bg: rgba(22, 163, 74, 0.1);
    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.1);
    --error: #dc2626;
    --error-bg: rgba(220, 38, 38, 0.1);
    --info: #2563eb;
    --info-bg: rgba(37, 99, 235, 0.1);

    --priority-critical: #dc2626;
    --priority-high: #ea580c;
    --priority-medium: #d97706;
    --priority-low: #16a34a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
    --shadow-glow: 0 4px 20px var(--accent-primary-glow);
}

/* ── Dark Theme ───────────────────────────────────────────── */
[data-theme="dark"] {
    --bg-primary: #0a0e17;
    --bg-secondary: #0f1520;
    --bg-tertiary: #151c2c;
    --bg-card: #131a2b;
    --bg-card-hover: #182236;
    --bg-elevated: #1a2236;
    --bg-input: #111827;
    --bg-overlay: rgba(0, 0, 0, 0.6);
    --loading-overlay-bg: rgba(10, 14, 23, 0.85);

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.1);
    --border-active: rgba(99, 179, 237, 0.4);
    --border-accent: rgba(99, 179, 237, 0.6);

    --text-primary: #e8ecf4;
    --text-secondary: #8896ab;
    --text-tertiary: #5a6a80;
    --text-accent: #63b3ed;
    --text-inverse: #0a0e17;

    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --accent-primary-glow: rgba(59, 130, 246, 0.2);
    --accent-secondary: #8b5cf6;

    --hover-bg: rgba(255, 255, 255, 0.05);
    --row-hover: rgba(255, 255, 255, 0.03);
    --row-even: rgba(255, 255, 255, 0.02);
    --tag-gray-bg: rgba(255, 255, 255, 0.06);
    --scrollbar-thumb: rgba(255, 255, 255, 0.12);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.2);

    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);

    --priority-critical: #ef4444;
    --priority-high: #f97316;
    --priority-medium: #f59e0b;
    --priority-low: #22c55e;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px var(--accent-primary-glow);
}

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    overflow: hidden;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

body {
    transition: background-color var(--transition-base), color var(--transition-base);
}

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

/* ── App Layout ───────────────────────────────────────────── */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform var(--transition-base);
}

.sidebar-header {
    padding: var(--space-xl) var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.sidebar-logo {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    object-fit: contain;
}

.brand-name {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.brand-dot {
    color: var(--accent-primary);
}

.brand-tagline {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-weight: 400;
    margin-top: 1px;
}

/* Navigation */
.sidebar-nav {
    padding: var(--space-md) var(--space-sm);
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
    text-align: left;
}

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

.nav-item.active {
    background: var(--accent-primary-glow);
    color: var(--accent-primary);
    font-weight: 600;
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    opacity: 0.7;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
    margin-left: auto;
    background: var(--accent-primary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-full);
    min-width: 18px;
    text-align: center;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}

.footer-credit {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    text-align: center;
}

/* Theme Toggle */
.theme-toggle {
    margin-bottom: var(--space-md);
}

.theme-toggle-label {
    display: block;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--space-sm);
    text-align: center;
}

.theme-toggle-buttons {
    display: flex;
    gap: 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 3px;
}

.theme-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-btn svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.theme-btn:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
}

.theme-btn.active {
    background: var(--accent-primary);
    color: var(--text-inverse);
    box-shadow: var(--shadow-sm);
}

/* ── Main Content ─────────────────────────────────────────── */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* View Panels */
.view-panel {
    display: none;
    flex: 1;
    overflow: hidden;
}

.view-panel.active {
    display: flex;
    flex-direction: column;
}

/* ── Top Bar ──────────────────────────────────────────────── */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-xl);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
    min-height: var(--header-height);
}

.top-bar-title {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.top-bar-title svg {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* ── Stats Cards ──────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--space-lg);
    padding: var(--space-xl);
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    position: relative;
    overflow: hidden;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    opacity: 0;
    transition: opacity var(--transition-base);
}

.stat-card:hover {
    border-color: var(--border-active);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.stat-card:hover::before { opacity: 1; }

.stat-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-md);
    font-size: 20px;
}

.stat-card-icon.blue { background: var(--info-bg); color: var(--info); }
.stat-card-icon.green { background: var(--success-bg); color: var(--success); }
.stat-card-icon.amber { background: var(--warning-bg); color: var(--warning); }
.stat-card-icon.purple { background: rgba(139, 92, 246, 0.1); color: var(--accent-secondary); }

.stat-card-value {
    font-size: var(--text-3xl);
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
    line-height: 1;
    margin-bottom: var(--space-xs);
    font-variant-numeric: tabular-nums;
}

.stat-card-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── Data Table ───────────────────────────────────────────── */
.table-container {
    overflow: auto;
    flex: 1;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.data-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.data-table th {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: var(--text-xs);
    letter-spacing: 0.05em;
    padding: var(--space-md) var(--space-lg);
    text-align: left;
    border-bottom: 1px solid var(--border-default);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
}

.data-table th:hover { color: var(--text-primary); }

.data-table th.sorted { color: var(--accent-primary); }

.data-table td {
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: top;
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--row-hover);
}

.data-table tbody tr:nth-child(even) {
    background: var(--row-even);
}

.data-table tbody tr:nth-child(even):hover {
    background: var(--hover-bg);
}

/* ── Forms & Inputs ───────────────────────────────────────── */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-tertiary);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 12L2 6h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
    cursor: pointer;
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.6;
}

.form-input-password {
    position: relative;
}

.form-input-password input {
    padding-right: 40px;
}

/* Checkbox / Toggle */
.form-checkbox {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.form-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid var(--border-default);
    background: var(--bg-input);
    appearance: none;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast);
}

.form-checkbox input[type="checkbox"]:checked {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.form-checkbox input[type="checkbox"]:checked::after {
    content: '✓';
    position: absolute;
    color: white;
    font-size: 11px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    line-height: 1;
}

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

.btn-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Primary */
.btn-primary {
    background: var(--accent-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-primary-hover);
    box-shadow: var(--shadow-glow);
}

/* Secondary */
.btn-secondary {
    background: transparent;
    border-color: var(--border-default);
    color: var(--text-secondary);
}

.btn-secondary:hover:not(:disabled) {
    border-color: var(--border-active);
    color: var(--text-primary);
    background: var(--hover-bg);
}

/* Ghost */
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--hover-bg);
    color: var(--text-primary);
}

/* Danger */
.btn-danger {
    background: transparent;
    border-color: var(--error);
    color: var(--error);
}

.btn-danger:hover:not(:disabled) {
    background: var(--error-bg);
}

/* Success */
.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    filter: brightness(1.1);
}

/* Small */
.btn-sm {
    padding: 6px var(--space-md);
    font-size: var(--text-xs);
}

/* Large */
.btn-lg {
    padding: var(--space-lg) var(--space-xl);
    font-size: var(--text-base);
}

/* ── Tags / Chips ─────────────────────────────────────────── */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.tag-blue { background: var(--info-bg); color: var(--info); }
.tag-green { background: var(--success-bg); color: var(--success); }
.tag-amber { background: var(--warning-bg); color: var(--warning); }
.tag-red { background: var(--error-bg); color: var(--error); }
.tag-purple { background: rgba(124, 58, 237, 0.1); color: #7c3aed; }
[data-theme="dark"] .tag-purple { background: rgba(139, 92, 246, 0.12); color: #a78bfa; }
.tag-gray { background: var(--tag-gray-bg); color: var(--text-secondary); border: 1px solid var(--border-subtle); }

[data-theme="dark"] .tag-gray { border-color: transparent; }

/* Priority tags */
.tag-priority-critical { background: rgba(239, 68, 68, 0.12); color: var(--priority-critical); }
.tag-priority-high { background: rgba(249, 115, 22, 0.12); color: var(--priority-high); }
.tag-priority-medium { background: rgba(245, 158, 11, 0.12); color: var(--priority-medium); }
.tag-priority-low { background: rgba(34, 197, 94, 0.12); color: var(--priority-low); }

/* ── Panels / Cards ───────────────────────────────────────── */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-lg) var(--space-xl);
    border-bottom: 1px solid var(--border-subtle);
}

.panel-title {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.panel-body {
    padding: var(--space-xl);
}

.panel-body.no-pad { padding: 0; }

/* ── Dashboard View ───────────────────────────────────────── */
.dashboard-scroll {
    flex: 1;
    overflow-y: auto;
    padding-bottom: var(--space-xl);
}

.recent-activity-section {
    padding: 0 var(--space-xl) var(--space-xl);
}

/* ── Generator — 3-Panel Layout ───────────────────────────── */
.generator-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.gen-panel-left {
    width: 320px;
    min-width: 280px;
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.gen-panel-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.gen-panel-right {
    width: 300px;
    min-width: 260px;
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-resize-handle {
    width: 5px;
    cursor: col-resize;
    background: transparent;
    transition: background var(--transition-fast);
    flex-shrink: 0;
}

.panel-resize-handle:hover,
.generator-layout.resizing .panel-resize-handle {
    background: var(--accent-primary-glow);
}

.sortable-table th[data-sort]::after {
    content: ' ⇅';
    opacity: 0.3;
    font-size: 0.75em;
}

.sortable-table th.sorted[data-sort] {
    color: var(--accent-primary);
}

.gen-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
}

.gen-section-title {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.gen-section-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
}

/* Filters */
.filter-group {
    margin-bottom: var(--space-md);
}

.filter-group label {
    display: block;
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--space-xs);
}

.filter-group select,
.filter-group input {
    width: 100%;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    outline: none;
    transition: border-color var(--transition-fast);
    appearance: none;
}

.filter-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%2394a3b8' viewBox='0 0 16 16'%3E%3Cpath d='M8 12L2 6h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
    cursor: pointer;
}

.filter-group select:focus,
.filter-group input:focus {
    border-color: var(--accent-primary);
}

/* Story Preview */
.story-preview {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}

.story-preview-label {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--space-sm);
}

.story-preview-key {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--accent-primary);
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.story-preview-summary {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    line-height: 1.4;
}

.story-preview-desc {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.6;
    max-height: 300px;
    overflow-y: auto;
}

.story-preview-section {
    margin-top: var(--space-md);
}

.story-preview-section-title {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--space-xs);
}

/* Center Panel — Results Grid */
.gen-results-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-lg);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-tertiary);
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.gen-results-filter {
    flex: 1;
    min-width: 160px;
    max-width: 280px;
}

.gen-results-filter input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--text-sm);
}

.gen-results-filter input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.gen-results-count {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-weight: 600;
}

.gen-results-count span { color: var(--accent-primary); }

.gen-results-actions {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.gen-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-3xl);
    text-align: center;
}

.gen-empty-icon {
    font-size: 48px;
    margin-bottom: var(--space-lg);
    opacity: 0.3;
}

.gen-empty-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.gen-empty-desc {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    max-width: 400px;
}

/* Right Panel — AI Refinement */
.refine-prompt-area {
    margin-bottom: var(--space-lg);
}

.refine-prompt-area textarea {
    width: 100%;
    min-height: 100px;
    padding: var(--space-md);
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    resize: vertical;
    outline: none;
    line-height: 1.5;
    transition: border-color var(--transition-fast);
}

.refine-prompt-area textarea:focus {
    border-color: var(--accent-primary);
}

.quick-actions-label {
    font-size: var(--text-xs);
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: var(--space-sm);
}

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: var(--space-lg);
}

.quick-action-chip {
    padding: 5px 10px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-default);
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.quick-action-chip:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--accent-primary-glow);
}

/* Coverage Checkboxes */
.coverage-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    margin-bottom: var(--space-lg);
}

/* ── Jira Explorer — Tree View ────────────────────────────── */
.explorer-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.explorer-tree {
    width: 360px;
    min-width: 300px;
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.explorer-detail {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tree-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
}

.tree-node {
    user-select: none;
}

.tree-node-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px var(--space-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition-fast);
    font-size: var(--text-sm);
}

.tree-node-row:hover {
    background: var(--hover-bg);
}

.tree-node-row.selected {
    background: var(--accent-primary-glow);
    color: var(--accent-primary);
}

.tree-toggle {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: var(--text-tertiary);
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.tree-toggle.expanded { transform: rotate(90deg); }
.tree-toggle.empty { visibility: hidden; }

.tree-node-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.tree-node-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-node-key {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.tree-children {
    padding-left: 20px;
}

.tree-children.collapsed { display: none; }

/* ── Templates — Card Grid ────────────────────────────────── */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-lg);
    padding: var(--space-xl);
}

.template-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    transition: all var(--transition-base);
    display: flex;
    flex-direction: column;
    cursor: default;
}

.template-card:hover {
    border-color: var(--border-active);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.template-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.template-card-name {
    font-size: var(--text-base);
    font-weight: 700;
    color: var(--text-primary);
}

.template-card-category {
    margin-top: var(--space-xs);
}

.template-card-body {
    flex: 1;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: var(--space-lg);
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.template-card-actions {
    display: flex;
    gap: var(--space-sm);
}

.template-card-default-badge {
    font-size: var(--text-xs);
    color: var(--accent-primary);
    font-weight: 600;
    opacity: 0.7;
}

/* New Template Card */
.template-card-new {
    border-style: dashed;
    border-color: var(--border-default);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: var(--space-md);
    cursor: pointer;
    min-height: 180px;
}

.template-card-new:hover {
    border-color: var(--accent-primary);
    background: var(--accent-primary-glow);
}

.template-card-new-icon {
    font-size: 32px;
    opacity: 0.3;
}

.template-card-new-label {
    font-size: var(--text-sm);
    color: var(--text-tertiary);
    font-weight: 600;
}

/* ── History View ─────────────────────────────────────────── */
.history-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-xl);
    border-bottom: 1px solid var(--border-subtle);
}

.history-search {
    flex: 1;
    max-width: 400px;
    position: relative;
}

.history-search input {
    width: 100%;
    padding: 8px 12px 8px 36px;
    background: var(--bg-input);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: var(--text-sm);
    font-family: var(--font-body);
    outline: none;
    transition: border-color var(--transition-fast);
}

.history-search input:focus { border-color: var(--accent-primary); }

.history-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 14px;
}

/* ── Settings View ────────────────────────────────────────── */
.settings-scroll {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xl);
}

.settings-tabs {
    display: flex;
    gap: 2px;
    padding: 0 var(--space-xl);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
}

.settings-tab {
    padding: var(--space-md) var(--space-lg);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: color var(--transition-fast);
}

.settings-tab:hover { color: var(--text-primary); }

.settings-tab.active {
    color: var(--accent-primary);
}

.settings-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent-primary);
    border-radius: 1px 1px 0 0;
}

.settings-section {
    display: none;
}

.settings-section.active { display: block; }

.settings-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
}

.settings-card-title {
    font-size: var(--text-md);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.settings-card-title svg {
    width: 18px;
    height: 18px;
    color: var(--accent-primary);
}

.settings-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

.settings-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}

.connection-status {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
}

.connection-status.connected {
    background: var(--success-bg);
    color: var(--success);
}

.connection-status.disconnected {
    background: var(--error-bg);
    color: var(--error);
}

.connection-status.testing {
    background: var(--warning-bg);
    color: var(--warning);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 200ms ease;
}

.modal-backdrop.active { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 540px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: slideUp 300ms ease;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-xl);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: 700;
}

.modal-close {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-xl);
    overflow-y: auto;
    max-height: 50vh;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-lg) var(--space-xl);
    border-top: 1px solid var(--border-subtle);
}

/* ── Toast Notifications ──────────────────────────────────── */
.toast-container {
    position: fixed;
    top: var(--space-xl);
    right: var(--space-xl);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: var(--text-sm);
    color: var(--text-primary);
    min-width: 300px;
    max-width: 440px;
    animation: slideInRight 300ms ease;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--error); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.info { border-left: 3px solid var(--info); }

.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-message { flex: 1; }

.toast-close {
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 14px;
    padding: 2px;
}

/* ── Loading / Spinner ────────────────────────────────────── */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-default);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

.loading-overlay {
    position: absolute;
    inset: 0;
    background: var(--loading-overlay-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-md);
    z-index: 10;
}

.loading-text {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    animation: pulse 2s ease-in-out infinite;
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-elevated) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: 12px; }
.skeleton-card { height: 100px; }

/* ── Animations ───────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(60px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes countUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Mobile Header ────────────────────────────────────────── */
.mobile-header {
    display: none;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
}

.hamburger {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 4px;
}

.hamburger span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-secondary);
    border-radius: 1px;
    transition: all var(--transition-fast);
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.mobile-logo { width: 24px; height: 24px; border-radius: 4px; }
.mobile-title { font-weight: 700; font-size: var(--text-base); }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1200px) {
    .gen-panel-right { width: 260px; min-width: 240px; }
    .gen-panel-left { width: 280px; min-width: 260px; }
}

@media (max-width: 1024px) {
    .gen-panel-right { display: none; }
    .explorer-tree { width: 280px; }
    .settings-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        z-index: 200;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open { transform: translateX(0); }

    .mobile-header { display: flex; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .generator-layout { flex-direction: column; }
    .gen-panel-left { width: 100%; border-right: none; border-bottom: 1px solid var(--border-subtle); max-height: 40vh; }
    .gen-panel-center { min-height: 50vh; }

    .explorer-layout { flex-direction: column; }
    .explorer-tree { width: 100%; border-right: none; border-bottom: 1px solid var(--border-subtle); max-height: 40vh; }

    .templates-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .top-bar { padding: var(--space-sm) var(--space-md); }
    .top-bar-title { font-size: var(--text-base); }
}

/* ── Utility Classes ──────────────────────────────────────── */
.text-mono { font-family: var(--font-mono); }
.text-accent { color: var(--text-accent); }
.text-muted { color: var(--text-secondary); }
.text-center { text-align: center; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.ml-auto { margin-left: auto; }
.w-full { width: 100%; }
.overflow-hidden { overflow: hidden; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
