/* ============================================================
   Greenside AI — Shared Design System
   All new feature pages import this for consistent styling.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --color-primary: #1e293b;
    --color-primary-hover: #334155;
    --color-primary-dark: #0f172a;
    --color-primary-light: #f1f5f9;
    --color-primary-ring: rgba(30, 41, 59, 0.12);
    --color-accent: #2563eb;
    --color-accent-hover: #1d4ed8;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-surface-hover: #f8fafc;
    --color-border: #e2e8f0;
    --color-border-light: #f1f5f9;
    --color-text: #0f172a;
    --color-text-secondary: #334155;
    --color-text-muted: #64748b;
    --color-text-faint: #94a3b8;
    --color-error: #dc2626;
    --color-error-bg: #fef2f2;
    --color-success: #166534;
    --color-success-bg: #f0fdf4;
    --color-warning: #92400e;
    --color-warning-bg: #fef3c7;
    --color-info: #1d4ed8;
    --color-info-bg: #eff6ff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 1px 3px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.04);
    --shadow-lg: 0 2px 6px rgba(0,0,0,0.05), 0 6px 16px rgba(0,0,0,0.06);
    --shadow-xl: 0 4px 12px rgba(0,0,0,0.06), 0 12px 32px rgba(0,0,0,0.08);
    --shadow-modal: 0 16px 48px rgba(0,0,0,0.12);
    --gradient-primary: none;
    --gradient-primary-hover: none;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 10px;
    --transition-fast: 0.1s ease;
    --transition-base: 0.15s ease;
    --transition-slow: 0.2s ease;
}

/* Dark mode */
body.dark-mode, body[data-theme="dark"] {
    --color-primary: #4ade80;
    --color-primary-hover: #22c55e;
    --color-primary-dark: #166534;
    --color-primary-light: #14532d;
    --color-primary-ring: rgba(74, 222, 128, 0.2);
    --color-bg: #0f1210;
    --color-surface: #1a1f1c;
    --color-surface-hover: #252b27;
    --color-border: #2d3630;
    --color-border-light: #232923;
    --color-text: #e5e7eb;
    --color-text-secondary: #d1d5db;
    --color-text-muted: #9ca3af;
    --color-text-faint: #6b7280;
    --color-error: #f87171;
    --color-error-bg: #451a1a;
    --color-success: #4ade80;
    --color-success-bg: #14532d;
    --color-warning: #fbbf24;
    --color-warning-bg: #422006;
    --color-info: #60a5fa;
    --color-info-bg: #1e293b;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 1px 4px rgba(0,0,0,0.4);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.5);
    --shadow-xl: 0 8px 24px rgba(0,0,0,0.6);
    --shadow-modal: 0 20px 60px rgba(0,0,0,0.7);
}
body.dark-mode header, body[data-theme="dark"] header { background: #0f172a; }
body.dark-mode input, body.dark-mode textarea, body.dark-mode select,
body[data-theme="dark"] input, body[data-theme="dark"] textarea, body[data-theme="dark"] select {
    background: var(--color-surface); color: var(--color-text);
    border-color: var(--color-border);
}

/* Reset */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Header */
header {
    background: #0f172a;
    color: white;
    padding: 0 24px;
    height: 48px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
}
.logo {
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -0.5px;
    text-decoration: none;
    color: white;
    white-space: nowrap;
}
.nav-links {
    display: flex;
    gap: 2px;
    align-items: center;
    height: 100%;
}
.nav-links a {
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.nav-links a:hover { color: white; background: rgba(255,255,255,0.12); }
.nav-links a.active { color: white; background: rgba(255,255,255,0.18); font-weight: 600; }
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

/* Nav dropdown component */
.nav-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: 100%;
}
.nav-dropdown-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.75);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.nav-dropdown-btn:hover { color: white; background: rgba(255,255,255,0.12); }
.nav-dropdown.has-active .nav-dropdown-btn { color: white; background: rgba(255,255,255,0.18); font-weight: 600; }
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 200px;
    z-index: 1000;
    padding: 6px;
    animation: slideInDown 0.15s ease;
}
.nav-dropdown:hover .nav-dropdown-menu { display: block; }
.nav-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}
.nav-dropdown-menu a:hover { background: var(--color-primary-light); color: var(--color-primary); }
.nav-dropdown-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--color-text-faint);
    padding: 8px 12px 4px;
}
.nav-dropdown-divider {
    height: 1px;
    background: var(--color-border-light);
    margin: 4px 0;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}
.container-wide {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* Page header */
.page-header { margin-bottom: 20px; }
.page-header h1 {
    font-size: 20px;
    color: var(--color-text);
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.3;
}
.page-header p {
    color: var(--color-text-muted);
    font-size: 13px;
    margin-top: 2px;
    font-weight: 400;
}

/* Tabs */
.tabs {
    display: inline-flex;
    gap: 2px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    padding: 3px;
    margin-bottom: 24px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--color-border);
}
.tab {
    padding: 8px 18px;
    min-height: 36px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    white-space: nowrap;
}
.tab:hover { color: var(--color-text); background: var(--color-surface-hover); }
.tab.active {
    color: var(--color-primary);
    background: var(--color-surface);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}
.tab-panel { display: none; animation: fadeIn 0.2s ease; }
.tab-panel.active { display: block; }

/* Cards */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: var(--color-primary);
    border-radius: 0 2px 2px 0;
    opacity: 0;
    transition: opacity var(--transition-fast);
}
.stat-card:hover::before { opacity: 1; }
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-card .stat-label {
    font-size: 11px;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.stat-card .stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
    margin-top: 2px;
    letter-spacing: -0.3px;
}
.stat-card .stat-sub {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
input, select, textarea {
    width: 100%;
    padding: 6px 10px;
    min-height: 34px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-ring);
}
textarea { resize: vertical; min-height: 80px; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    min-height: 34px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1.4;
}
.btn-primary {
    background: var(--color-primary);
    color: white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.btn-primary:hover { background: var(--color-primary-hover); box-shadow: 0 1px 4px rgba(0,0,0,0.15); }
.btn-primary:active { box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-surface-hover); }
.btn-danger {
    background: var(--color-error);
    color: white;
}
.btn-danger:hover { opacity: 0.9; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}
.btn-icon:hover { color: var(--color-text); background: var(--color-surface-hover); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-green { background: var(--color-success-bg); color: var(--color-success); }
.badge-red { background: var(--color-error-bg); color: var(--color-error); }
.badge-yellow { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-blue { background: var(--color-info-bg); color: var(--color-info); }
.badge-gray { background: var(--color-border-light); color: var(--color-text-muted); }

/* Priority badges */
.priority-low { background: var(--color-success-bg); color: var(--color-success); }
.priority-medium { background: var(--color-warning-bg); color: var(--color-warning); }
.priority-high { background: #fff7ed; color: #c2410c; }
.priority-critical { background: var(--color-error-bg); color: var(--color-error); }
.priority-urgent { background: var(--color-error-bg); color: var(--color-error); }

/* Status badges */
.status-active, .status-open { background: var(--color-success-bg); color: var(--color-success); }
.status-pending { background: var(--color-warning-bg); color: var(--color-warning); }
.status-completed, .status-resolved { background: var(--color-success-bg); color: var(--color-success); }
.status-cancelled, .status-retired { background: var(--color-border-light); color: var(--color-text-muted); }
.status-in_progress, .status-assigned { background: var(--color-info-bg); color: var(--color-info); }
.status-maintenance, .status-repair { background: #fff7ed; color: #c2410c; }
.status-monitoring, .status-treated { background: #fefce8; color: #854d0e; }

body.dark-mode .priority-low, body[data-theme="dark"] .priority-low { background: #14532d; color: #4ade80; }
body.dark-mode .priority-medium, body[data-theme="dark"] .priority-medium { background: #422006; color: #fbbf24; }
body.dark-mode .priority-high, body[data-theme="dark"] .priority-high { background: #431407; color: #fb923c; }
body.dark-mode .priority-critical, body[data-theme="dark"] .priority-critical,
body.dark-mode .priority-urgent, body[data-theme="dark"] .priority-urgent { background: #450a0a; color: #f87171; }
body.dark-mode .status-active, body[data-theme="dark"] .status-active,
body.dark-mode .status-open, body[data-theme="dark"] .status-open { background: #14532d; color: #4ade80; }
body.dark-mode .status-pending, body[data-theme="dark"] .status-pending { background: #422006; color: #fbbf24; }
body.dark-mode .status-completed, body[data-theme="dark"] .status-completed,
body.dark-mode .status-resolved, body[data-theme="dark"] .status-resolved { background: #14532d; color: #4ade80; }
body.dark-mode .status-in_progress, body[data-theme="dark"] .status-in_progress,
body.dark-mode .status-assigned, body[data-theme="dark"] .status-assigned { background: #1e3a5f; color: #93c5fd; }
body.dark-mode .status-maintenance, body[data-theme="dark"] .status-maintenance,
body.dark-mode .status-repair, body[data-theme="dark"] .status-repair { background: #431407; color: #fb923c; }
body.dark-mode .status-monitoring, body[data-theme="dark"] .status-monitoring,
body.dark-mode .status-treated, body[data-theme="dark"] .status-treated { background: #422006; color: #fbbf24; }

/* Tables */
.table-wrapper { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
th {
    text-align: left;
    padding: 10px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--color-border);
    background: var(--color-surface);
}
td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text);
}
tr:hover td { background: var(--color-surface-hover); }

/* Modals */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.modal-overlay.active, .modal-overlay.open { display: flex; }
.modal {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 24px;
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-modal);
    animation: slideUp 0.2s ease;
}
.modal-lg { max-width: 800px; }
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--color-surface-hover); }
.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

/* Section dividers */
.section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.section h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--color-text);
    letter-spacing: -0.2px;
}

/* Filters bar */
.filters-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.filters-bar select, .filters-bar input {
    width: auto;
    min-width: 140px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty-state h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; color: var(--color-text-secondary); }
.empty-state p { font-size: 14px; }

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--color-border-light);
    border-radius: 100px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 100px;
    transition: width var(--transition-slow);
}
.progress-green { background: #22c55e; }
.progress-yellow { background: #eab308; }
.progress-red { background: #ef4444; }

/* Quick action buttons grid */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}
.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    text-decoration: none;
    color: var(--color-text);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-fast);
}
.quick-action:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
    background: var(--color-primary-light);
}
.quick-action .qa-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--color-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all var(--transition-fast);
}
.quick-action .qa-icon svg { width: 20px; height: 20px; color: var(--color-primary); }
.quick-action:hover .qa-icon { background: var(--color-primary); }
.quick-action:hover .qa-icon svg { color: white; }

/* Severity colors */
.severity-1 { color: #22c55e; }
.severity-2 { color: #3b82f6; }
.severity-3 { color: #eab308; }
.severity-4 { color: #f97316; }
.severity-5 { color: #ef4444; }
.severity-bg-1 { background: var(--color-success-bg); border-left: 3px solid #22c55e; }
.severity-bg-2 { background: var(--color-info-bg); border-left: 3px solid #3b82f6; }
.severity-bg-3 { background: #fefce8; border-left: 3px solid #eab308; }
.severity-bg-4 { background: #fff7ed; border-left: 3px solid #f97316; }
.severity-bg-5 { background: var(--color-error-bg); border-left: 3px solid #ef4444; }

body.dark-mode .severity-bg-1, body[data-theme="dark"] .severity-bg-1 { background: #14532d; border-left-color: #4ade80; }
body.dark-mode .severity-bg-2, body[data-theme="dark"] .severity-bg-2 { background: #1e3a5f; border-left-color: #60a5fa; }
body.dark-mode .severity-bg-3, body[data-theme="dark"] .severity-bg-3 { background: #422006; border-left-color: #facc15; }
body.dark-mode .severity-bg-4, body[data-theme="dark"] .severity-bg-4 { background: #431407; border-left-color: #fb923c; }
body.dark-mode .severity-bg-5, body[data-theme="dark"] .severity-bg-5 { background: #450a0a; border-left-color: #f87171; }

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Notification bell */
.notification-bell {
    position: relative;
    cursor: pointer;
}
.notification-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--color-error);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 100px;
    min-width: 16px;
    text-align: center;
}

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile menu */
.mobile-nav {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
}
.mobile-nav.open { display: block; }
.mobile-nav-content {
    background: var(--color-surface);
    width: 280px;
    height: 100%;
    padding: 20px;
    box-shadow: var(--shadow-xl);
    overflow-y: auto;
}
.mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.mobile-nav-header .logo { color: var(--color-primary); }
.mobile-nav-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--color-text-muted);
}
.mobile-nav-links {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.mobile-nav-links a {
    display: block;
    padding: 10px 12px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}
.mobile-nav-links a:hover { background: var(--color-surface-hover); }
.mobile-nav-links a.active { background: var(--color-primary-light); color: var(--color-primary); font-weight: 600; }
.mobile-nav-links a.nav-logout { color: var(--color-error); }
.mobile-nav-links a.nav-logout:hover { background: var(--color-error-bg); }
.mobile-nav-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--color-text-faint);
    padding: 16px 12px 4px;
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideInDown 0.2s ease;
    max-width: 360px;
}
.toast-success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid #bbf7d0; }
.toast-error { background: var(--color-error-bg); color: var(--color-error); border: 1px solid #fecaca; }
.toast-warning { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid #fde68a; }
.toast-info { background: var(--color-info-bg); color: var(--color-info); border: 1px solid #bfdbfe; }

/* Responsive */
@media (max-width: 1024px) {
    .nav-links { display: none; }
    .mobile-menu-btn { display: block; }
    .form-row, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
    .stat-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .container, .container-wide { padding: 16px; }
    .stat-cards { grid-template-columns: 1fr; }
    .card-grid { grid-template-columns: 1fr; }
    .quick-actions { grid-template-columns: repeat(2, 1fr); }
    .tabs { gap: 0; }
    .tab { padding: 8px 12px; font-size: 13px; }
    .modal { padding: 16px; max-width: calc(100vw - 16px); margin: 8px; border-radius: var(--radius-lg); }
    .btn, button, [role="button"] { min-height: 36px; }
    .gs-toast-container { left: 12px; right: 12px; top: 12px; }
    .gs-toast { max-width: 100%; }
    .empty-state { padding: 32px 16px; }
}

/* --- iOS Safe Area Insets (Capacitor / notch / Dynamic Island) --- */
body {
    padding-top: env(safe-area-inset-top);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}
header {
    padding-top: env(safe-area-inset-top);
    height: calc(56px + env(safe-area-inset-top));
}

/* --- Tab scroll fade indicator --- */
.tabs {
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.tabs::-webkit-scrollbar { display: none; }

/* --- Mobile card view for data tables --- */
.mobile-cards { display: none; }
@media (max-width: 768px) {
    .table-wrapper.has-card-view table { display: none; }
    .table-wrapper.has-card-view .mobile-cards { display: block; }

    .mobile-card {
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        padding: 14px;
        margin-bottom: 10px;
    }
    .mobile-card-header {
        font-weight: 600;
        font-size: 14px;
        margin-bottom: 8px;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--color-border-light);
    }
    .mobile-card-row {
        display: flex;
        justify-content: space-between;
        padding: 4px 0;
        font-size: 13px;
    }
    .mobile-card-label {
        color: var(--color-text-muted);
        font-size: 11px;
        text-transform: uppercase;
        font-weight: 600;
    }
    .mobile-card-actions {
        display: flex;
        gap: 8px;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--color-border-light);
    }

    /* Tab scroll fade */
    .tabs {
        -webkit-mask-image: linear-gradient(to right, black calc(100% - 24px), transparent);
        mask-image: linear-gradient(to right, black calc(100% - 24px), transparent);
    }
}

/* --- Landscape orientation (phone held sideways) --- */
@media (max-height: 500px) and (orientation: landscape) {
    header { padding: 6px 16px; padding-top: calc(6px + env(safe-area-inset-top)); }
    .header-content { min-height: 36px; }
    .container, .container-wide { padding: 8px 16px; }
    .modal { max-height: 90vh; }
    .stat-cards { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

/* --- Modal action buttons (shared across all tools) --- */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}
.submit-btn {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.submit-btn:hover { background: var(--color-primary-hover); box-shadow: var(--shadow-md); }
.submit-btn:active { transform: scale(0.98); }
.submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.cancel-btn {
    background: var(--color-border-light);
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}
.cancel-btn:hover { background: var(--color-border); }
.cancel-btn:active { transform: scale(0.98); }
.chart-placeholder {
    background: var(--color-bg-secondary);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: 40px 20px;
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 14px;
}

/* ============================================================
   Premium UI Polish — Code Blocks, Toasts, Skeletons, Animations
   ============================================================ */

/* --- Code blocks with copy button --- */
.code-block-wrapper {
    position: relative;
    margin: 12px 0;
}
.code-block-wrapper pre {
    margin: 0;
    border-radius: var(--radius-md);
    overflow-x: auto;
}
.code-block-wrapper code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
}
.code-copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--transition-fast), background var(--transition-fast);
    color: var(--color-text-muted);
    z-index: 2;
}
.code-block-wrapper:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { background: var(--color-surface-hover); color: var(--color-text); }
.code-copy-btn.copied { color: var(--color-success); border-color: var(--color-success); }

/* --- Inline code --- */
:not(pre) > code {
    background: var(--color-border-light);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
}

/* --- Toast notifications (enhanced) --- */
.toast {
    display: flex;
    align-items: center;
    gap: 8px;
    pointer-events: auto;
}
.toast-exit {
    animation: toastExit 0.2s ease forwards;
}
@keyframes toastExit {
    to { opacity: 0; transform: translateY(-8px); }
}

/* --- Skeleton loaders --- */
.skeleton {
    background: linear-gradient(90deg, var(--color-border-light) 25%, var(--color-surface-hover) 50%, var(--color-border-light) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}
.skeleton-text { height: 14px; margin-bottom: 8px; width: 80%; }
.skeleton-text-short { height: 14px; margin-bottom: 8px; width: 50%; }
.skeleton-card { height: 80px; margin-bottom: 12px; }
.skeleton-circle { width: 40px; height: 40px; border-radius: 50%; }
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* --- GS Toast Container --- */
.gs-toast-container {
    position: fixed;
    top: 72px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

/* --- GS Toast Notifications --- */
.gs-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    opacity: 0;
    transform: translateX(20px);
    transition: opacity var(--transition-base), transform var(--transition-base);
    cursor: pointer;
}
.gs-toast-visible { opacity: 1; transform: translateX(0); }
.gs-toast-exit { opacity: 0; transform: translateX(20px); transition: opacity var(--transition-fast), transform var(--transition-fast); }
.gs-toast-success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid var(--color-success); }
.gs-toast-error { background: var(--color-error-bg); color: var(--color-error); border: 1px solid var(--color-error); }
.gs-toast-warning { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid var(--color-warning); }
.gs-toast-info { background: var(--color-info-bg); color: var(--color-info); border: 1px solid var(--color-info); }

/* --- Button Loading Spinner --- */
.gs-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: gs-spin 0.6s linear infinite;
    margin-right: 6px;
    vertical-align: middle;
}
.gs-btn-loading { opacity: 0.8; cursor: wait; }
@keyframes gs-spin { to { transform: rotate(360deg); } }

/* --- Danger Button (for confirm dialogs) --- */
.btn-danger { background: var(--color-error); color: #fff; border-color: var(--color-error); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

/* --- Additional Skeleton Variants --- */
.skeleton-row { height: 48px; margin-bottom: 8px; border-radius: var(--radius-sm); }
.skeleton-stat { height: 100px; border-radius: var(--radius-lg); }
.skeleton-list { display: flex; flex-direction: column; gap: 8px; }

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--color-text-muted);
}
.empty-state-icon { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.5; color: var(--color-text-faint); }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--color-text-secondary); margin-bottom: 4px; }
.empty-state p { font-size: 14px; max-width: 300px; margin-bottom: 16px; }

/* --- Focus Visible Global --- */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* --- Active Button Press --- */
.btn:active, button.btn-primary:active, button.btn-secondary:active { transform: scale(0.98); }

/* --- Input Focus Ring --- */
input:focus-visible, select:focus-visible, textarea:focus-visible {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-ring);
}

/* --- Fade In Utility --- */
.gs-fade-in { animation: gsFadeIn var(--transition-base) ease forwards; }
@keyframes gsFadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- Message enter animation (slide up) --- */
.message-enter {
    animation: messageSlideUp 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes messageSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Message timestamps --- */
.message-time {
    font-size: 11px;
    color: var(--color-text-faint);
    margin-top: 4px;
    opacity: 0;
    transition: opacity var(--transition-fast);
    user-select: none;
}
.message-bubble:hover + .message-time,
.message-content:hover .message-time {
    opacity: 1;
}

/* --- Follow-up suggestions --- */
.follow-ups {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--color-border-light);
}
.follow-up-btn {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 100px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: inherit;
    line-height: 1.4;
}
.follow-up-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
    background: var(--color-primary-light);
    box-shadow: var(--shadow-sm);
}

/* --- Inline citations (Perplexity style) --- */
.citation-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: var(--color-primary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: 4px;
    cursor: pointer;
    vertical-align: super;
    margin: 0 1px;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1;
}
.citation-badge:hover {
    background: var(--color-primary-hover);
    transform: scale(1.15);
}
.source-chip.citation-highlight {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-ring);
}

/* --- Conversation search --- */
.conv-search-wrapper {
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border-light);
}
.conv-search-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    min-height: 32px;
    background: var(--color-surface);
    color: var(--color-text);
}
.conv-search-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-ring);
}
.conv-item-title-input {
    width: 100%;
    border: 1px solid var(--color-primary);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    outline: none;
    min-height: auto;
}

/* --- Keyboard shortcuts modal --- */
.shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.shortcut-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 4px;
    border-bottom: 1px solid var(--color-border-light);
}
.shortcut-row:last-child { border-bottom: none; }
.shortcut-desc { font-size: 14px; color: var(--color-text); }
.shortcut-keys { display: flex; gap: 4px; }
kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 5px;
    font-size: 12px;
    font-family: inherit;
    font-weight: 600;
    color: var(--color-text-secondary);
    box-shadow: 0 1px 0 var(--color-border);
}
.shortcut-hint {
    cursor: pointer;
    color: var(--color-text-faint);
    transition: color var(--transition-fast);
}
.shortcut-hint:hover { color: var(--color-primary); }

/* --- Textarea auto-resize for chat input --- */
#question-input {
    resize: none;
    max-height: 150px;
    overflow-y: auto;
    line-height: 1.5;
    min-height: 36px;
}
