/**
 * APNI Species Checker - Design System
 * Comprehensive UI with Dark Mode Support
 */

/* =============================================================================
   CSS Custom Properties - Light Theme (Default)
   ============================================================================= */
:root {
    /* Brand Colors */
    --apni-primary: #2e7d32;
    --apni-primary-light: #4caf50;
    --apni-primary-dark: #1b5e20;
    --apni-secondary: #1565c0;
    --apni-secondary-light: #1976d2;
    
    /* Semantic Colors */
    --color-success: #28a745;
    --color-warning: #ffc107;
    --color-danger: #dc3545;
    --color-info: #17a2b8;
    
    /* Status Colors - Species */
    --status-exists: #28a745;
    --status-stub: #f57c00;
    --status-missing: #dc3545;
    
    /* WebSocket Status */
    --ws-connected: #4caf50;
    --ws-disconnected: #9e9e9e;
    --ws-reconnecting: #ff9800;
    
    /* Background Colors */
    --bg-body: #f8f9fa;
    --bg-surface: #ffffff;
    --bg-elevated: #ffffff;
    --bg-muted: #f1f3f5;
    
    /* Text Colors */
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --text-inverse: #ffffff;
    
    /* Border Colors */
    --border-color: #dee2e6;
    --border-color-light: #e9ecef;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.1);
    --shadow-focus: 0 0 0 3px rgba(46, 125, 50, 0.2);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
    
    /* Spacing Scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 1rem;
    --space-4: 1.5rem;
    --space-5: 2rem;
    --space-6: 3rem;
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-full: 50%;
    
    /* Font Sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
}

/* =============================================================================
   Dark Theme - Improved Contrast
   ============================================================================= */
[data-bs-theme="dark"] {
    /* Darker backgrounds for better contrast */
    --bg-body: #0d1117;
    --bg-surface: #161b22;
    --bg-elevated: #21262d;
    --bg-muted: #21262d;
    
    /* Brighter text for readability */
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --text-inverse: #0d1117;
    
    /* Softer borders */
    --border-color: #30363d;
    --border-color-light: #21262d;
    
    /* Adjusted shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.5);
    --shadow-focus: 0 0 0 3px rgba(76, 175, 80, 0.4);
    
    /* Brighter brand colors for dark mode */
    --apni-primary: #3fb950;
    --apni-primary-light: #56d364;
    --apni-primary-dark: #238636;
    --apni-secondary: #58a6ff;
    --apni-secondary-light: #79c0ff;
    
    /* Status colors adjusted for dark bg */
    --status-exists: #3fb950;
    --status-stub: #d29922;
    --status-missing: #f85149;
    
    /* Semantic colors for dark */
    --color-success: #3fb950;
    --color-warning: #d29922;
    --color-danger: #f85149;
    --color-info: #58a6ff;
}

/* Dark mode specific overrides */
[data-bs-theme="dark"] .card {
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .card-header {
    background-color: var(--bg-elevated);
    border-bottom-color: var(--border-color);
}

[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.04);
}

[data-bs-theme="dark"] .table > thead {
    background-color: var(--bg-elevated);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: var(--bg-elevated);
    border-color: var(--apni-primary);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .form-control::placeholder {
    color: var(--text-muted);
}

/* Fix form-floating in dark mode - placeholder must be transparent for label positioning */
[data-bs-theme="dark"] .form-floating > .form-control::placeholder {
    color: transparent;
}

[data-bs-theme="dark"] .input-group-text {
    background-color: var(--bg-elevated);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

[data-bs-theme="dark"] .btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .btn-outline-secondary:hover {
    background-color: var(--bg-elevated);
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .list-group-item {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .modal-content {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: var(--bg-elevated);
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .dropdown-item {
    color: var(--text-primary);
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: var(--bg-muted);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .alert {
    border-width: 1px;
}

[data-bs-theme="dark"] .badge.bg-light {
    background-color: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
}

[data-bs-theme="dark"] code {
    background-color: var(--bg-elevated);
    color: var(--apni-secondary);
}

[data-bs-theme="dark"] .text-muted {
    color: var(--text-secondary) !important;
}

[data-bs-theme="dark"] .settings-section h5 {
    color: var(--apni-primary-light);
}

/* =============================================================================
   Base Styles
   ============================================================================= */
body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* =============================================================================
   Typography
   ============================================================================= */
h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    font-weight: 600;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-base); }
h6 { font-size: var(--text-sm); }

.text-muted {
    color: var(--text-secondary) !important;
}

/* Section Headers */
.section-header {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    padding-bottom: var(--space-2);
    margin-bottom: var(--space-4);
    border-bottom: 2px solid var(--apni-primary);
}

/* =============================================================================
   Cards
   ============================================================================= */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.card-header {
    background-color: var(--bg-muted);
    border-bottom: 1px solid var(--border-color);
}

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

/* Stat Cards */
.stat-card {
    border-left: 4px solid var(--apni-primary);
}

.stat-card .stat-value {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
}

.stat-card .stat-label {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Action Cards */
.action-card {
    cursor: pointer;
    text-align: center;
    padding: var(--space-4);
}

.action-card:hover {
    border-color: var(--apni-primary);
}

.action-card .action-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-3);
    font-size: var(--text-xl);
    background-color: var(--apni-primary);
    color: var(--text-inverse);
    transition: all var(--transition-normal);
}

.action-card:hover .action-icon {
    transform: scale(1.1);
}

/* =============================================================================
   Forms
   ============================================================================= */
.form-control,
.form-select {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
    background-color: var(--bg-surface);
    border-color: var(--apni-primary);
    box-shadow: var(--shadow-focus);
    color: var(--text-primary);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-label {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.input-group-text {
    background-color: var(--bg-muted);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

/* Floating Labels */
.form-floating > .form-control,
.form-floating > .form-select {
    height: calc(3.5rem + 2px);
}

.form-floating > label {
    color: var(--text-secondary);
}

/* =============================================================================
   Buttons
   ============================================================================= */
.btn {
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: all var(--transition-fast);
}

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

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: var(--apni-primary);
    border-color: var(--apni-primary);
}

.btn-primary:hover {
    background-color: var(--apni-primary-dark);
    border-color: var(--apni-primary-dark);
}

.btn-outline-primary {
    color: var(--apni-primary);
    border-color: var(--apni-primary);
}

.btn-outline-primary:hover {
    background-color: var(--apni-primary);
    border-color: var(--apni-primary);
}

/* Button Groups - no transform on hover */
.btn-group .btn:hover {
    transform: none;
}

/* =============================================================================
   Tables
   ============================================================================= */
.table {
    color: var(--text-primary);
}

.table > thead {
    background-color: var(--bg-muted);
}

.table > thead th {
    font-weight: 600;
    text-transform: uppercase;
    font-size: var(--text-xs);
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border-color);
}

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

.table > tbody > tr:hover {
    background-color: var(--bg-muted);
}

.table-bordered {
    border-color: var(--border-color);
}

.table-bordered td,
.table-bordered th {
    border-color: var(--border-color);
}

/* =============================================================================
   Badges
   ============================================================================= */
.badge {
    font-weight: 500;
    border-radius: var(--radius-sm);
}

.badge-status {
    font-size: var(--text-xs);
    padding: 0.25em 0.5em;
}

.badge-exists { background-color: var(--status-exists) !important; }
.badge-stub { background-color: var(--status-stub) !important; }
.badge-missing { background-color: var(--status-missing) !important; }

/* =============================================================================
   Alerts
   ============================================================================= */
.alert {
    border-radius: var(--radius-md);
    border-left-width: 4px;
}

/* =============================================================================
   Modals
   ============================================================================= */
.modal-content {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.modal-header {
    border-bottom-color: var(--border-color);
}

.modal-footer {
    border-top-color: var(--border-color);
}

/* =============================================================================
   Navigation
   ============================================================================= */
.navbar {
    box-shadow: var(--shadow-sm);
}

/* Mobile navbar - keep icons in horizontal row */
.navbar .navbar-nav-icons {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.25rem;
}

/* Mobile adjustments for navbar icons */
@media (max-width: 991.98px) {
    .navbar .navbar-nav-icons {
        margin-left: auto;
    }
    
    .navbar .navbar-nav-icons .nav-link,
    .navbar .navbar-nav-icons .theme-toggle {
        padding: 0.375rem 0.5rem;
    }
    
    .navbar .navbar-toggler {
        padding: 0.25rem 0.5rem;
        font-size: 1rem;
    }
    
    /* Collapsed menu items horizontal on tablet */
    .navbar-collapse .navbar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .navbar-collapse .nav-item {
        flex: 0 0 auto;
    }
    
    .navbar-collapse .nav-link {
        padding: 0.5rem 0.75rem;
        white-space: nowrap;
    }
}

/* Very small screens - stack collapsed menu */
@media (max-width: 575.98px) {
    .navbar-collapse .navbar-nav {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .navbar-collapse .nav-link {
        padding: 0.5rem 0;
        width: 100%;
    }
}

.navbar .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background-color: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--text-sm);
}

.navbar .dropdown-menu {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-md);
    background-color: var(--bg-surface);
}

.navbar .dropdown-item {
    padding: var(--space-2) var(--space-3);
    color: var(--text-primary);
    transition: background-color var(--transition-fast);
}

.navbar .dropdown-item:hover {
    background-color: var(--bg-muted);
}

.navbar .dropdown-item i {
    width: 1.25rem;
    margin-right: var(--space-2);
}

.navbar .dropdown-divider {
    border-color: var(--border-color);
}

.navbar .dropdown-header {
    color: var(--text-secondary);
}



/* =============================================================================
   Authentication Forms
   ============================================================================= */
.auth-container {
    max-width: 420px;
    margin: var(--space-5) auto;
}

.auth-card {
    border: none;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.auth-card .card-header {
    background: linear-gradient(135deg, var(--apni-primary), var(--apni-primary-dark));
    color: var(--text-inverse);
    text-align: center;
    padding: var(--space-4);
    border: none;
}

.auth-card .card-header h4 {
    margin: 0;
    font-weight: 600;
    color: var(--text-inverse);
}

.auth-card .card-body {
    padding: var(--space-5);
    background-color: var(--bg-surface);
}

.auth-card .form-floating {
    margin-bottom: var(--space-3);
}

.auth-card .btn-auth {
    width: 100%;
    padding: var(--space-3);
    font-weight: 600;
    border-radius: var(--radius-md);
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: var(--space-4) 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.auth-divider span {
    padding: 0 var(--space-3);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.auth-footer {
    text-align: center;
    padding: var(--space-3) 0 0;
    border-top: 1px solid var(--border-color-light);
    margin-top: var(--space-4);
}

/* =============================================================================
   Landing Page - Bootstrap-First with Minimal Dark Mode Fixes
   ============================================================================= */

/* Hero Section - gradient background */
.landing-hero {
    background: linear-gradient(135deg, var(--apni-primary) 0%, var(--apni-primary-dark) 100%);
    margin: -1.5rem -12px 0;
    padding: 4rem 0;
}

/* Hero buttons - ensure visibility in both light and dark mode */
.landing-hero .btn-light {
    background-color: #ffffff;
    color: var(--apni-primary-dark);
    border-color: #ffffff;
    font-weight: 600;
}

.landing-hero .btn-light:hover,
.landing-hero .btn-light:focus {
    background-color: rgba(255, 255, 255, 0.9);
    color: var(--apni-primary-dark);
    border-color: rgba(255, 255, 255, 0.9);
}

.landing-hero .btn-outline-light {
    font-weight: 600;
}

.landing-hero .btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

/* Feature icon circles - matches dashboard action-icon pattern */
.landing-feature-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: white;
    margin-bottom: 1rem;
}

/* Step number circles */
.landing-step-number {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--apni-primary), var(--apni-primary-dark));
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

/* Dark mode fixes for bg-light sections */
[data-bs-theme="dark"] .landing-bg-light {
    background-color: var(--bg-muted) !important;
}

/* Dark mode fixes for white cards */
[data-bs-theme="dark"] .landing-card {
    background-color: var(--bg-surface) !important;
    border-color: var(--border-color) !important;
}

[data-bs-theme="dark"] .landing-card strong {
    color: var(--text-primary);
}

/* =============================================================================
   Job Cards with Real-Time Updates
   ============================================================================= */
.product-surface {
    background: linear-gradient(180deg, var(--bg-surface), var(--bg-muted));
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}

.job-card {
    border-left: 4px solid var(--border-color);
    transition: all var(--transition-normal);
    margin-bottom: var(--space-2);
}

.job-card__meta {
    min-width: 260px;
}

.job-card__progress {
    min-width: 260px;
}

.job-card[data-status="running"] {
    border-left-color: var(--apni-secondary);
    background-color: rgba(21, 101, 192, 0.05);
}

.job-card[data-status="completed"] {
    border-left-color: var(--color-success);
}

.job-card[data-status="failed"] {
    border-left-color: var(--color-danger);
}

.job-card[data-status="pending"] {
    border-left-color: var(--text-muted);
}

.job-progress-bar {
    height: 8px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background-color: var(--bg-muted);
    margin-top: var(--space-2);
}

.job-progress-bar .progress-fill {
    height: 100%;
    border-radius: var(--radius-sm);
    transition: width var(--transition-fast);
}

.job-progress-bar .progress-fill.running {
    background: linear-gradient(90deg, var(--apni-secondary), var(--apni-secondary-light));
    animation: progress-pulse 1.5s ease-in-out infinite;
}

.job-progress-bar .progress-fill.completed {
    background-color: var(--color-success);
}

.job-progress-bar .progress-fill.failed {
    background-color: var(--color-danger);
}

/* =============================================================================
   Drafts Workspace
   ============================================================================= */
.drafts-shell {
    overflow: hidden;
}

.drafts-tabs {
    border-bottom: none;
}

.drafts-search-group {
    max-width: 420px;
}

.draft-card {
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.draft-card:hover {
    border-left-color: var(--bs-primary);
    background-color: var(--bg-muted);
}

.draft-card.wikipedia {
    border-left-color: #666;
}

.draft-card.inaturalist {
    border-left-color: #74ac00;
}

.draft-actions {
    opacity: 0.75;
    transition: opacity 0.2s;
}

.draft-card:hover .draft-actions {
    opacity: 1;
}

.tab-content-area {
    min-height: 400px;
}

.preview-content {
    max-height: 60vh;
    overflow-y: auto;
    background: var(--bg-surface);
    color: var(--text-primary);
    padding: 1.5rem;
    border-radius: 0.5rem;
}

.source-content {
    max-height: 60vh;
    overflow-y: auto;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.85rem;
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 1rem;
    border-radius: 0.5rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

@keyframes progress-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* =============================================================================
   Toast Notifications
   ============================================================================= */
.toast-container {
    position: fixed;
    bottom: var(--space-3);
    right: var(--space-3);
    z-index: 1080;
}

.toast {
    background-color: var(--bg-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.toast-header {
    background-color: var(--bg-muted);
    border-bottom-color: var(--border-color);
}

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

/* =============================================================================
   Settings Page
   ============================================================================= */
.settings-section {
    margin-bottom: var(--space-5);
}

.settings-section h5 {
    color: var(--apni-primary-dark);
    border-bottom: 2px solid var(--apni-primary-light);
    padding-bottom: var(--space-2);
    margin-bottom: var(--space-4);
}



.oauth-account-card {
    border-left: 4px solid var(--border-color);
    transition: all var(--transition-normal);
}

.oauth-account-card.linked {
    border-left-color: var(--apni-primary);
}

.oauth-account-card .oauth-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    font-size: var(--text-xl);
    margin-right: var(--space-3);
}

.oauth-icon.wikipedia {
    background-color: var(--bg-muted);
    color: var(--text-primary);
}

.oauth-icon.inaturalist {
    background-color: #74ac00;
    color: var(--text-inverse);
}

/* =============================================================================
   Search Results
   ============================================================================= */
.species-result {
    padding: var(--space-3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-2);
    background-color: var(--bg-surface);
    transition: all var(--transition-fast);
}

.species-result:hover {
    border-color: var(--apni-primary);
    box-shadow: var(--shadow-sm);
}

.species-name {
    font-style: italic;
    font-weight: 500;
}

/* =============================================================================
   Conservation Status
   ============================================================================= */
.conservation-badge {
    font-size: var(--text-sm);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
}

.conservation-badge.lc { background-color: #6fa35e; color: white; }
.conservation-badge.nt { background-color: #8db74a; color: white; }
.conservation-badge.vu { background-color: #f9a825; color: black; }
.conservation-badge.en { background-color: #ff8f00; color: white; }
.conservation-badge.cr { background-color: #d32f2f; color: white; }
.conservation-badge.ew { background-color: #880e4f; color: white; }
.conservation-badge.ex { background-color: #311b92; color: white; }



/* =============================================================================
   Theme Toggle
   ============================================================================= */
.theme-toggle {
    background: transparent;
    border: none;
    color: inherit;
    padding: var(--space-2);
    cursor: pointer;
    border-radius: var(--radius-full);
    transition: background-color var(--transition-fast);
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* =============================================================================
   Empty States
   ============================================================================= */
.empty-state {
    text-align: center;
    padding: var(--space-6);
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: var(--space-3);
    opacity: 0.5;
}

.empty-state h5 {
    color: var(--text-secondary);
}

.empty-state--compact {
    padding: var(--space-4);
}

.empty-state--loading i {
    margin-bottom: 0;
    opacity: 1;
}

/* =============================================================================
   Utility Classes
   ============================================================================= */
.text-apni-green { color: var(--apni-primary) !important; }
.bg-apni-green { background-color: var(--apni-primary) !important; }
.border-apni-green { border-color: var(--apni-primary) !important; }

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* Focus Visible */
:focus-visible {
    outline: 2px solid var(--apni-primary);
    outline-offset: 2px;
}

/* Skip Link */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    padding: var(--space-2) var(--space-4);
    background: var(--apni-primary);
    color: var(--text-inverse);
    z-index: 9999;
    text-decoration: none;
    border-radius: 0 0 var(--radius-md) 0;
}

.skip-link:focus {
    top: 0;
}

/* =============================================================================
   Scrollbar Styling
   ============================================================================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* =============================================================================
   Print Styles
   ============================================================================= */
@media print {
    .navbar,
    .toast-container,
    .btn,
    footer {
        display: none !important;
    }
    
    body {
        background: white;
        color: black;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* =============================================================================
   Responsive Adjustments
   ============================================================================= */
@media (max-width: 768px) {
    :root {
        --text-3xl: 1.5rem;
        --text-2xl: 1.25rem;
        --text-xl: 1.125rem;
    }
    
    .landing-hero {
        padding: var(--space-4) var(--space-3);
    }
    
    .stat-card .stat-value {
        font-size: var(--text-xl);
    }
}

@media (max-width: 575.98px) {
    .product-surface {
        padding: var(--space-3);
    }

    .job-card__meta,
    .job-card__progress {
        min-width: 100%;
    }

    .draft-card .card-body {
        padding: 0.75rem !important;
    }

    .draft-card .draft-row {
        flex-direction: column;
        align-items: stretch !important;
    }

    .draft-card .draft-actions {
        opacity: 1;
        width: 100%;
    }

    .draft-card .draft-actions .btn {
        flex: 1;
    }

    .tab-content-area {
        padding: 0.75rem !important;
    }
}

@media (max-width: 576px) {
    .auth-container {
        margin: var(--space-3);
        max-width: none;
    }
    
    .ws-status-container span {
        display: none;
    }
    
    .toast-container {
        left: var(--space-3);
        right: var(--space-3);
    }
    
    .toast {
        width: 100%;
    }
}

/* =============================================================================
   Species Hub Styles
   ============================================================================= */
.species-hub .filter-sidebar {
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.species-hub .filter-group {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.species-hub .filter-group:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.species-hub .filter-group legend {
    font-size: var(--text-sm);
    float: none;
    width: auto;
    padding: 0;
    margin-bottom: 0.5rem;
}

/* Status indicators */
.status-indicators {
    display: flex;
    gap: 0.5rem;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.875rem;
}

.status-indicator.wiki-status .bi-check-circle-fill { color: var(--status-exists); }
.status-indicator.wiki-status .bi-x-circle-fill { color: var(--status-missing); }
.status-indicator.wiki-status .bi-circle-half { color: var(--status-stub); }

.status-indicator.inat-status .bi-check-circle-fill { color: var(--status-exists); }
.status-indicator.inat-status .bi-x-circle-fill { color: var(--status-missing); }

.status-indicator.cons-status .bi-shield-fill-check { color: var(--status-exists); }
.status-indicator.cons-status .bi-shield-fill-x { color: var(--status-missing); }
.status-indicator.cons-status .bi-shield-fill-exclamation { color: var(--color-warning); }

/* Expandable rows */
.species-row {
    cursor: pointer;
    transition: background-color var(--transition-fast);
}

.species-row:hover {
    background-color: var(--bg-muted);
}

.species-row:focus {
    outline: 2px solid var(--apni-primary);
    outline-offset: -2px;
}

.species-row[aria-expanded="true"] .btn-view-details i {
    transform: rotate(180deg);
}

/* Expand icon rotation for species rows */
.species-row .expand-icon {
    transition: transform 0.2s;
}

.species-row[aria-expanded="true"] .expand-icon,
.species-row.expanded .expand-icon {
    transform: rotate(90deg);
}

.species-details {
    background-color: var(--bg-muted);
    border-top: 1px solid var(--border-color);
}

.species-details-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
}

/* Detail sections in expanded species rows */
.species-details-inner .detail-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    min-width: 0; /* Allow flex items to shrink */
}

.species-details-inner .detail-section h6 {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color-light);
    padding-bottom: 0.5rem;
    white-space: nowrap;
}

/* Photo section - fixed width */
.species-details-inner .detail-photo {
    flex: 0 0 auto;
    min-width: 140px;
    max-width: 160px;
}

/* Platform status section - grows to fill space */
.species-details-inner .detail-platform {
    flex: 1 1 280px;
    min-width: 250px;
}

/* Platform items layout */
.species-details-inner .platform-item {
    white-space: nowrap;
}

/* Conservation status section */
.species-details-inner .detail-conservation {
    flex: 1 1 220px;
    min-width: 200px;
}

/* Discrepancies section */
.species-details-inner .detail-discrepancies {
    flex: 1 1 280px;
    min-width: 250px;
}

/* Legacy support for detail-card class */
.species-details-inner .detail-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
}

.species-details-inner .detail-card h6 {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color-light);
    padding-bottom: 0.5rem;
}

/* Active filter chips */
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.active-filters:empty {
    display: none;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--apni-primary);
    color: white;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
}

.filter-chip button {
    background: none;
    border: none;
    color: white;
    padding: 0;
    cursor: pointer;
    opacity: 0.8;
    line-height: 1;
}

.filter-chip button:hover {
    opacity: 1;
}

/* Search bar container */
.species-hub .search-bar-container {
    max-width: 800px;
}

.species-hub .search-bar-container .input-group-text {
    border-right: none;
}

.species-hub .search-bar-container .form-control {
    border-left: none;
}

.species-hub .search-bar-container .form-control:focus {
    border-color: var(--border-color);
    box-shadow: none;
}

.species-hub .search-bar-container .input-group:focus-within {
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-md);
}

/* Results header */
.species-hub .results-header {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color-light);
}

.species-hub .results-toolbar {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.species-hub .results-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
}

.species-hub #batch-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Tab badge styling */
.species-hub .nav-tabs .badge {
    font-size: 0.65rem;
    vertical-align: middle;
}

/* Selection column */
.species-hub .selection-cell,
.species-hub .selection-header {
    width: 40px;
    text-align: center;
}

/* Species name styling */
.species-hub .species-name {
    font-style: italic;
    font-weight: 500;
}

.species-hub .species-author {
    font-size: var(--text-xs);
}

/* Actions column */
.species-hub .actions-cell {
    white-space: nowrap;
}

.species-hub .actions-cell .btn-group .btn {
    padding: 0.25rem 0.5rem;
}

.species-hub .actions-cell .btn-view-details i {
    transition: transform var(--transition-fast);
}

/* Dark mode adjustments for Species Hub */
[data-bs-theme="dark"] .species-hub .search-bar-container .input-group-text {
    background-color: var(--bg-surface);
}

[data-bs-theme="dark"] .species-hub .filter-sidebar {
    background-color: var(--bg-surface);
}

[data-bs-theme="dark"] .species-details {
    background-color: var(--bg-elevated);
}

[data-bs-theme="dark"] .species-details-inner .detail-card {
    background-color: var(--bg-surface);
}

[data-bs-theme="dark"] .species-details-inner .detail-section {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
}

/* Mobile adjustments for Species Hub */
@media (max-width: 768px) {
    .species-hub .filter-sidebar {
        position: static !important;
        max-height: none;
        margin-bottom: 1rem;
    }
    
    .species-hub .filter-sidebar .card-body {
        display: flex;
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .species-hub .filter-group {
        flex: 1 1 200px;
        border-bottom: none;
        border-right: 1px solid var(--border-color);
        padding-right: 1rem;
        padding-bottom: 0;
    }
    
    .species-hub .filter-group:last-child {
        border-right: none;
        padding-right: 0;
    }
    
    .species-details-inner {
        flex-direction: column;
    }
    
    .species-details-inner .detail-section {
        flex: 1 1 auto;
        min-width: 100%;
        max-width: 100%;
    }
    
    .species-details-inner .detail-photo {
        max-width: 100%;
    }
}

/* =============================================================================
   Job Results Display
   ============================================================================= */
.job-results {
    border-top-color: var(--border-color);
}

.job-results .species-list {
    display: flex;
    flex-wrap: wrap;
}

.job-results .badge {
    font-weight: normal;
}

.job-results .row {
    text-align: center;
}

.job-results .h4,
.job-results .h5 {
    font-weight: 600;
}

/* Collapse button icon rotation */
.job-results [data-bs-toggle="collapse"] .bi-chevron-down {
    transition: transform var(--transition-fast);
}

.job-results [data-bs-toggle="collapse"]:not(.collapsed) .bi-chevron-down {
    transform: rotate(180deg);
}

/* Dark mode adjustments for job results */
[data-bs-theme="dark"] .job-results {
    border-top-color: var(--border-color);
}

[data-bs-theme="dark"] .job-results pre {
    background-color: var(--bg-elevated) !important;
}

/* ════════════════════════════════════════════════════════════════════════════
   SPECIES HUB ENHANCEMENTS
   ════════════════════════════════════════════════════════════════════════════ */

/* Sortable Columns */
th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s ease;
}

th.sortable:hover {
    background-color: var(--bs-gray-100);
}

th.sortable.sorted {
    background-color: var(--bs-primary-bg-subtle);
}

th.sortable .sort-icon {
    opacity: 0.4;
    transition: opacity 0.15s ease;
    font-size: 0.75em;
    margin-left: 0.25rem;
}

th.sortable:hover .sort-icon,
th.sortable.sorted .sort-icon {
    opacity: 1;
}

/* Status Badges */
.status-badge {
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 2rem;
}

/* Platform/Column Toggle */
.platform-toggle + label,
.column-toggle + label {
    cursor: pointer;
}

/* Hidden Columns */
.col-hidden {
    display: none !important;
}

/* ════════════════════════════════════════════════════════════════════════════
   COMPARISON MODAL
   ════════════════════════════════════════════════════════════════════════════ */

#comparisonModal .modal-body {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.comparison-panel {
    min-height: 500px;
}

.comparison-panel .panel-header {
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Source textarea styling */
#wiki-source {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    tab-size: 2;
    background-color: var(--bs-gray-100);
}

#wiki-source:focus {
    background-color: white;
    box-shadow: none;
}

/* Wiki preview styling */
.wiki-preview {
    background-color: #fff;
    line-height: 1.6;
}

.wiki-preview h4,
.wiki-preview h5 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--bs-gray-300);
    padding-bottom: 0.25rem;
}

.wiki-preview a {
    color: var(--bs-link-color);
}

.wiki-preview-content {
    word-wrap: break-word;
}

/* Gaps panel */
#gaps-panel .list-group-item {
    border-left: 3px solid transparent;
}

#gaps-panel .list-group-item:has(.bg-danger) {
    border-left-color: var(--bs-danger);
    background-color: rgba(var(--bs-danger-rgb), 0.05);
}

#gaps-panel .list-group-item:has(.bg-warning) {
    border-left-color: var(--bs-warning);
    background-color: rgba(var(--bs-warning-rgb), 0.05);
}

#gaps-panel .list-group-item:has(.bg-info) {
    border-left-color: var(--bs-info);
    background-color: rgba(var(--bs-info-rgb), 0.05);
}

/* Nav pills in modal */
.nav-pills.nav-sm .nav-link {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

/* Wildnet panel cards */
#wildnet-data .card {
    border-radius: 0.375rem;
}

#wildnet-data .card-header {
    font-size: 0.85rem;
}

/* ════════════════════════════════════════════════════════════════════════════
   TABLE ENHANCEMENTS
   ════════════════════════════════════════════════════════════════════════════ */

/* Compact table cells */
#species-table td {
    vertical-align: middle;
    padding: 0.5rem;
}

#species-table th {
    padding: 0.75rem 0.5rem;
    white-space: nowrap;
}

/* Status columns */
.col-nca,
.col-epbc,
.col-wikipedia,
.col-inaturalist {
    text-align: center;
}

/* Status indicator icons */
.status-indicator {
    font-size: 1.1rem;
}

/* Expand icon rotation */
.species-row .expand-icon {
    transition: transform 0.2s ease;
}

.species-row.expanded .expand-icon {
    transform: rotate(90deg);
}

/* Row hover effect */
#species-table tbody tr:hover {
    background-color: var(--bs-gray-50);
}

/* ════════════════════════════════════════════════════════════════════════════
   FILTER SIDEBAR ENHANCEMENTS
   ════════════════════════════════════════════════════════════════════════════ */

.filter-sidebar fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

.filter-sidebar legend {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.filter-sidebar .form-check {
    padding-left: 1.75rem;
    margin-bottom: 0.25rem;
}

.filter-sidebar .form-check-label {
    font-size: 0.875rem;
}

/* Platform selection icons */
.filter-sidebar .bi-globe,
.filter-sidebar .bi-camera,
.filter-sidebar .bi-shield,
.filter-sidebar .bi-shield-check {
    margin-right: 0.25rem;
    opacity: 0.7;
}

/* Dropdown menu for column visibility */
.dropdown-menu .dropdown-item {
    cursor: pointer;
}

.dropdown-menu .dropdown-item:hover {
    background-color: var(--bs-gray-100);
}

.dropdown-menu .form-check-input {
    margin-top: 0;
}

/* ════════════════════════════════════════════════════════════════════════════
   RESPONSIVE ADJUSTMENTS
   ════════════════════════════════════════════════════════════════════════════ */

@media (max-width: 991.98px) {
    #comparisonModal .modal-dialog {
        max-width: 100%;
        margin: 0.5rem;
    }
    
    .comparison-panel {
        min-height: 300px;
    }
    
    #wiki-source {
        min-height: 250px !important;
    }
    
    /* Stack comparison panels vertically on tablet/mobile */
    #comparisonModal .row.g-0 > .col-lg-6 {
        border-right: none !important;
        border-bottom: 1px solid var(--border-color);
    }
    
    #comparisonModal .row.g-0 > .col-lg-6:last-child {
        border-bottom: none;
    }
    
    /* Better touch targets for buttons */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .btn-sm {
        min-height: 36px;
        min-width: 36px;
    }
    
    /* Action button groups more touch-friendly */
    .btn-group-sm .btn {
        padding: 0.5rem 0.75rem;
    }
}

@media (max-width: 767.98px) {
    /* Hide less important columns on mobile */
    .col-family,
    .col-inaturalist {
        display: none;
    }
    
    .filter-sidebar {
        position: static !important;
    }
    
    /* More compact table on mobile */
    #species-table th,
    #species-table td {
        padding: 0.4rem 0.25rem;
        font-size: 0.85rem;
    }
    
    /* Smaller action buttons */
    #species-table .btn-group-sm .btn {
        padding: 0.2rem 0.35rem;
        font-size: 0.75rem;
    }
    
    /* Stack species author below name */
    .species-name-cell {
        max-width: 120px;
    }
    
    .species-name {
        font-size: 0.85rem;
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .species-author {
        display: none !important;
    }
    
    /* Compact status badges */
    .status-badge {
        font-size: 0.6rem !important;
        padding: 0.15rem 0.3rem !important;
    }
}

/* Very small screens - more aggressive layout */
@media (max-width: 575.98px) {
    /* Hide even more columns */
    .col-epbc,
    .col-wikipedia {
        display: none;
    }
    
    /* Hide selection column - not practical on mobile */
    .selection-cell,
    .selection-header {
        display: none;
    }
    
    /* Reduce header padding */
    #species-table th {
        padding: 0.35rem 0.2rem;
        font-size: 0.75rem;
    }
    
    #species-table td {
        padding: 0.35rem 0.2rem;
    }
    
    /* Even smaller action buttons - icons only */
    #species-table .actions-cell .btn-group {
        flex-wrap: nowrap;
    }
    
    #species-table .actions-cell .btn {
        padding: 0.15rem 0.25rem;
    }
    
    /* Species name takes priority */
    .species-name-cell {
        max-width: 100px;
    }
    
    /* Single column status indicators */
    .status-indicator {
        font-size: 0.9rem;
    }
    
    /* Search bar adjustments */
    .species-hub .search-bar-container .input-group {
        flex-wrap: nowrap;
    }
    
    .species-hub .search-bar-container .input-group-text {
        padding: 0.5rem;
    }
    
    .species-hub .search-bar-container .form-control {
        font-size: 0.9rem;
    }
    
    .species-hub .search-bar-container .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.9rem;
    }
    
    /* Tabs scrollable on very small screens */
    #hubTabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    #hubTabs::-webkit-scrollbar {
        display: none;
    }
    
    #hubTabs .nav-item {
        flex-shrink: 0;
    }
    
    #hubTabs .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        white-space: nowrap;
    }
    
    .species-hub .results-toolbar {
        width: 100%;
        align-items: flex-start;
    }

    .species-hub .results-toolbar-actions,
    .species-hub #batch-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .species-hub .results-toolbar-actions .btn,
    .species-hub .results-toolbar-actions .dropdown {
        flex: 1 1 auto;
    }
    
    /* Pagination smaller */
    .pagination .page-link {
        padding: 0.3rem 0.5rem;
        font-size: 0.85rem;
    }
}

/* Mobile filter sidebar */
@media (max-width: 767.98px) {
    /* Filter toggle button styling */
    [data-bs-toggle="collapse"][data-bs-target="#filterCollapse"] .bi-chevron-down {
        transition: transform 0.2s;
    }
    
    [data-bs-toggle="collapse"][data-bs-target="#filterCollapse"]:not(.collapsed) .bi-chevron-down {
        transform: rotate(180deg);
    }
    
    /* Filter sidebar as collapsible card on mobile */
    .filter-sidebar {
        margin-bottom: 1rem;
    }
    
    .filter-sidebar .card-body {
        max-height: 50vh;
        overflow-y: auto;
    }
    
    /* Compact filter groups */
    .filter-sidebar .filter-group {
        margin-bottom: 0.75rem !important;
        padding-bottom: 0.75rem;
    }
    
    .filter-sidebar .form-check {
        margin-bottom: 0.15rem;
    }
    
    .filter-sidebar legend,
    .filter-sidebar .form-label {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }
    
    .filter-sidebar .form-check-label {
        font-size: 0.8rem;
    }
    
    /* Two-column filter layout on tablet */
    .filter-sidebar .card-body {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem 1rem;
    }
    
    .filter-sidebar .active-filters {
        grid-column: 1 / -1;
    }
}

/* Very small screens - single column filters */
@media (max-width: 480px) {
    .filter-sidebar .card-body {
        grid-template-columns: 1fr;
    }
    
    /* Comparison modal - full width on very small screens */
    #comparisonModal .modal-dialog {
        margin: 0;
        max-width: 100%;
        height: 100%;
    }
    
    #comparisonModal .modal-content {
        height: 100%;
        border-radius: 0;
    }
    
    #comparisonModal .modal-body {
        max-height: calc(100vh - 120px);
    }
}

/* ════════════════════════════════════════════════════════════════════════════
   DARK MODE - COMPREHENSIVE FIXES
   ════════════════════════════════════════════════════════════════════════════ */

/* --- Comparison Modal --- */
[data-bs-theme="dark"] #comparisonModal .modal-content {
    background-color: var(--bg-surface);
}

[data-bs-theme="dark"] #comparisonModal .panel-header,
[data-bs-theme="dark"] #comparisonModal .bg-light {
    background-color: var(--bg-elevated) !important;
    color: var(--text-primary);
}

[data-bs-theme="dark"] #wiki-source {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-bs-theme="dark"] #wiki-source:focus {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

[data-bs-theme="dark"] #wiki-source::placeholder {
    color: var(--text-muted);
}

[data-bs-theme="dark"] .wiki-preview {
    background-color: var(--bg-surface);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .wiki-preview h4,
[data-bs-theme="dark"] .wiki-preview h5 {
    color: var(--text-primary);
    border-bottom-color: var(--border-color);
}

[data-bs-theme="dark"] #wildnet-data .card {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
}

[data-bs-theme="dark"] #wildnet-data .card-header {
    background-color: var(--bg-elevated) !important;
    color: var(--text-primary);
    border-bottom-color: var(--border-color);
}

[data-bs-theme="dark"] #wildnet-data .card-body {
    color: var(--text-primary);
}

[data-bs-theme="dark"] #gaps-panel .bg-warning-subtle {
    background-color: rgba(var(--bs-warning-rgb), 0.15) !important;
    color: var(--text-primary);
}

[data-bs-theme="dark"] #gaps-panel .list-group-item {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-bs-theme="dark"] #comparisonModal .nav-pills .nav-link {
    color: var(--text-secondary);
}

[data-bs-theme="dark"] #comparisonModal .nav-pills .nav-link.active {
    background-color: var(--apni-primary);
    color: white;
}

[data-bs-theme="dark"] #comparisonModal .border-end {
    border-color: var(--border-color) !important;
}

/* --- Drafts Page --- */
[data-bs-theme="dark"] .preview-content {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary);
}

[data-bs-theme="dark"] .draft-card:hover {
    background-color: var(--bg-elevated) !important;
}

[data-bs-theme="dark"] .draft-card .bg-light {
    background-color: var(--bg-elevated) !important;
}

/* --- General Bootstrap bg-light/bg-white Dark Mode Override --- */
[data-bs-theme="dark"] .bg-light {
    background-color: var(--bg-elevated) !important;
    color: var(--text-primary);
}

[data-bs-theme="dark"] .bg-light.text-dark {
    color: var(--text-primary) !important;
}

[data-bs-theme="dark"] .bg-white {
    background-color: var(--bg-surface) !important;
    color: var(--text-primary);
}

/* --- Table Sortable Headers --- */
[data-bs-theme="dark"] th.sortable:hover {
    background-color: var(--bg-elevated);
}

[data-bs-theme="dark"] th.sortable.sorted {
    background-color: rgba(var(--bs-primary-rgb), 0.2);
}

/* --- Table Row Hover --- */
[data-bs-theme="dark"] #species-table tbody tr:hover {
    background-color: var(--bg-elevated);
}

/* --- Dropdown Menu --- */
[data-bs-theme="dark"] .dropdown-menu .dropdown-item:hover {
    background-color: var(--bg-muted);
}

/* --- Badge Fixes --- */
[data-bs-theme="dark"] .badge.bg-light {
    background-color: var(--bg-elevated) !important;
    color: var(--text-primary) !important;
}

[data-bs-theme="dark"] .badge.bg-light.text-dark {
    color: var(--text-primary) !important;
}

/* --- Form Labels in Dark Panels --- */
[data-bs-theme="dark"] .form-label.text-muted {
    color: var(--text-secondary) !important;
}

/* --- Card Header Strong Text --- */
[data-bs-theme="dark"] .card-header strong {
    color: var(--text-primary);
}

/* --- Modal Footer/Header Borders --- */
[data-bs-theme="dark"] .modal-header,
[data-bs-theme="dark"] .modal-footer {
    border-color: var(--border-color);
}

/* --- Panel Body Text --- */
[data-bs-theme="dark"] .panel-body {
    color: var(--text-primary);
}

[data-bs-theme="dark"] .panel-body p {
    color: var(--text-primary);
}

/* --- Tab Content in Dark Mode --- */
[data-bs-theme="dark"] .tab-content {
    background-color: var(--bg-surface);
}

[data-bs-theme="dark"] .nav-tabs .nav-link {
    color: var(--text-secondary);
}

[data-bs-theme="dark"] .nav-tabs .nav-link.active {
    background-color: var(--bg-surface);
    border-color: var(--border-color) var(--border-color) var(--bg-surface);
    color: var(--text-primary);
}

[data-bs-theme="dark"] .nav-tabs {
    border-bottom-color: var(--border-color);
}

/* --- Species Details Expanded Row --- */
[data-bs-theme="dark"] .species-details {
    background-color: var(--bg-elevated);
}

[data-bs-theme="dark"] .species-details .detail-section h6 {
    color: var(--text-secondary);
}

/* --- Input Group Dark Mode --- */
[data-bs-theme="dark"] .input-group-text.bg-white {
    background-color: var(--bg-surface) !important;
    border-color: var(--border-color);
}

/* --- Conservation/Discrepancies Page Cards --- */
[data-bs-theme="dark"] .stat-card {
    background-color: var(--bg-surface);
}

/* --- Collapsed Filter Dark Mode Toggle Button --- */
[data-bs-theme="dark"] .btn-outline-secondary {
    border-color: var(--border-color);
    color: var(--text-secondary);
}

[data-bs-theme="dark"] .btn-outline-secondary:hover {
    background-color: var(--bg-elevated);
    color: var(--text-primary);
}

/* ════════════════════════════════════════════════════════════════════════════
   SEARCH AUTOCOMPLETE SUGGESTIONS
   ════════════════════════════════════════════════════════════════════════════ */

.search-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1050;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
}

.search-suggestions .suggestion-item {
    padding: 0.625rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--bs-border-color);
    transition: background-color 0.15s ease;
}

.search-suggestions .suggestion-item:last-child {
    border-bottom: none;
}

.search-suggestions .suggestion-item:hover,
.search-suggestions .suggestion-item.selected {
    background-color: var(--bs-primary);
    color: white;
}

.search-suggestions .suggestion-item:hover .text-muted,
.search-suggestions .suggestion-item.selected .text-muted {
    color: rgba(255, 255, 255, 0.8) !important;
}

.search-suggestions .suggestion-item .species-name {
    font-style: italic;
}

/* Position container relative for dropdown */
.search-bar-container {
    position: relative;
}

.search-bar-container .input-group {
    position: relative;
}

/* Dark mode suggestions */
[data-bs-theme="dark"] .search-suggestions {
    background: var(--bg-surface);
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .search-suggestions .suggestion-item {
    border-color: var(--border-color);
}

/* ════════════════════════════════════════════════════════════════════════════
   PROGRESS NOTIFICATION
   ════════════════════════════════════════════════════════════════════════════ */

.toast-container .toast.bg-primary {
    background-color: var(--bs-primary) !important;
}

.toast-container .toast .progress {
    background-color: rgba(255, 255, 255, 0.3);
}

.toast-container .toast .progress-bar.bg-light {
    background-color: rgba(255, 255, 255, 0.9) !important;
}

.toast-container .toast .progress-step {
    color: rgba(255, 255, 255, 0.9);
}

/* ════════════════════════════════════════════════════════════════════════════
   CHECK STATUS BADGE
   ════════════════════════════════════════════════════════════════════════════ */

.badge i.bi {
    font-size: 0.75rem;
    margin-right: 0.25rem;
}

/* Checked column styling */
td:has(.badge.bg-success) {
    background-color: rgba(var(--bs-success-rgb), 0.05);
}

td:has(.badge.bg-warning) {
    background-color: rgba(var(--bs-warning-rgb), 0.05);
}

td:has(.badge.bg-secondary) {
    background-color: rgba(var(--bs-secondary-rgb), 0.05);
}

/* ════════════════════════════════════════════════════════════════════════════
   SPECIES PHOTOS
   ════════════════════════════════════════════════════════════════════════════ */

.species-photo {
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    cursor: pointer;
    border-radius: var(--radius-md);
}

.species-photo:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.species-photo-link {
    display: inline-block;
    text-decoration: none;
}

.species-photo-placeholder {
    border: 2px dashed var(--border-color);
}

/* Dark mode adjustments for photos */
[data-bs-theme="dark"] .species-photo {
    border-color: var(--border-color);
}

[data-bs-theme="dark"] .species-photo-placeholder {
    border-color: var(--border-color);
    background-color: var(--bg-muted) !important;
}

[data-bs-theme="dark"] .species-photo-placeholder i {
    color: var(--text-muted);
}

/* =============================================================================
   Slice A Refresh - Shared shell, landing, dashboard
   ============================================================================= */

.shell-header {
    background: color-mix(in srgb, var(--bg-surface) 94%, var(--apni-primary) 6%);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
}

.shell-nav {
    padding: 0.65rem 0;
}

.shell-brand {
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
}

.shell-brand:hover {
    color: var(--text-primary);
}

.shell-brand-mark {
    display: inline-flex;
    width: 2rem;
    height: 2rem;
    border-radius: 0.625rem;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--apni-primary), var(--apni-primary-dark));
    color: #fff;
}

.shell-brand-subtitle {
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
}

.shell-user-menu {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-muted);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.shell-user-menu:hover,
.shell-user-menu:focus {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.shell-nav-links .nav-link {
    color: var(--text-secondary);
    font-weight: 500;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
}

.shell-nav-links .nav-link:hover,
.shell-nav-links .nav-link.active {
    color: var(--text-primary);
    background: var(--bg-muted);
}

.shell-main {
    min-height: calc(100vh - 220px);
}

.shell-frame {
    max-width: 1480px;
}

.workbench-container {
    width: min(100% - 2rem, 1240px);
    margin: 0 auto;
    padding-top: 1.25rem;
}

.workbench-container--wide {
    width: min(100% - 2rem, 1380px);
}

.workbench-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.workbench-toolbar .btn-group {
    flex-wrap: wrap;
    gap: 0.5rem;
}

.workbench-toolbar .btn-group > .btn {
    border-radius: 0.5rem !important;
}

.settings-nav-card {
    position: sticky;
    top: 5.5rem;
}

.settings-layout {
    margin-left: 0;
    margin-right: 0;
}

.settings-layout > * {
    min-width: 0;
}

.shell-footer {
    margin-top: 3rem;
    padding: 2rem 0;
    background: var(--bg-muted);
    border-top: 1px solid var(--border-color);
}

.landing-hero-v2 {
    padding: 4.5rem 0 2rem;
}

.landing-kicker,
.dashboard-kicker {
    display: inline-block;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--apni-primary);
}

.landing-preview-card {
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    background: var(--bg-surface);
    box-shadow: var(--shadow-md);
    padding: 1.25rem;
}

.landing-workflow {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.75rem;
}

.landing-workflow li {
    border: 1px solid var(--border-color-light);
    border-radius: 0.75rem;
    padding: 0.65rem 0.8rem;
    display: grid;
    gap: 0.2rem;
}

.landing-workflow li span {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.landing-section {
    padding: 2rem 0;
}

.landing-section-muted {
    background: var(--bg-muted);
}

.landing-info-card,
.landing-usecase-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1.25rem;
}

.landing-usecase-card i {
    display: inline-flex;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.75rem;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--apni-primary) 15%, var(--bg-surface));
    color: var(--apni-primary);
}

.landing-source-chip {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    min-height: 3rem;
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    color: var(--text-primary);
    text-decoration: none;
    background: var(--bg-surface);
    font-weight: 600;
}

.landing-source-chip:hover {
    border-color: var(--apni-primary);
    color: var(--apni-primary);
}

.landing-cta-panel {
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 2rem 1.25rem;
    background: var(--bg-surface);
}

.dashboard-shell .section-head {
    border-bottom: 1px solid var(--border-color-light);
    padding-bottom: 0.5rem;
}

.dashboard-search {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 1rem;
}

.dashboard-op-row {
    border: 1px solid var(--border-color);
    border-radius: 0.75rem;
    padding: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    background: var(--bg-muted);
}

.dashboard-op-row .btn {
    flex-shrink: 0;
}

.dashboard-onboarding {
    border: 1px solid color-mix(in srgb, var(--apni-primary) 40%, var(--border-color));
    background: color-mix(in srgb, var(--apni-primary) 8%, var(--bg-surface));
}

@media (min-width: 1200px) {
    .landing-hero-v2 {
        padding: 5rem 0 2.75rem;
    }

    .landing-hero-v2 .row,
    .dashboard-hero .row {
        min-height: clamp(24rem, 52vh, 34rem);
    }

    .landing-hero-v2 h1,
    .landing-hero-v2 .lead,
    .landing-cta-panel,
    .dashboard-hero p,
    .dashboard-search {
        max-width: 40rem;
    }

    .dashboard-search {
        margin-left: auto;
    }

    .landing-preview-card {
        max-width: 28rem;
        margin-left: auto;
    }

    .landing-section {
        padding: 2.5rem 0;
    }
}

@media (max-width: 991.98px) {
    .shell-nav {
        padding: 0.55rem 0;
    }

    .shell-brand-subtitle {
        display: none;
    }

    .shell-header .container {
        row-gap: 0.75rem;
    }

    .shell-header-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }

    .shell-nav .navbar-collapse {
        flex-basis: 100%;
        order: 4;
        margin-top: 0.5rem;
        padding-top: 0.75rem;
        border-top: 1px solid var(--border-color-light);
    }

    .shell-nav-links {
        gap: 0.35rem;
    }

    .shell-nav-links .nav-link {
        font-size: 0.95rem;
    }

    .landing-hero-v2 {
        padding: 3.5rem 0 1.75rem;
    }

    .landing-preview-card {
        max-width: none;
    }

    .dashboard-shell {
        padding-top: 1.25rem !important;
    }

    .workbench-container,
    .workbench-container--wide {
        width: min(100% - 1.5rem, 100%);
        padding-top: 1rem;
    }

    .settings-nav-card {
        position: static;
    }

    .workbench-toolbar .btn-group {
        width: 100%;
    }

    .workbench-toolbar .btn-group > .btn,
    .workbench-toolbar .btn-group > a.btn {
        flex: 1 1 calc(50% - 0.25rem);
    }

    .dashboard-search {
        padding: 0.85rem;
    }

    .dashboard-op-row {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 767.98px) {
    .shell-nav .container {
        align-items: flex-start;
    }

    .shell-brand {
        gap: 0.6rem;
        max-width: calc(100% - 7rem);
    }

    .shell-brand > span:last-child {
        min-width: 0;
    }

    .shell-brand .d-block {
        font-size: 0.98rem;
        line-height: 1.15;
        overflow-wrap: anywhere;
    }

    .shell-header-actions {
        gap: 0.5rem !important;
    }

    .shell-header-cta {
        padding-left: 0.7rem;
        padding-right: 0.7rem;
    }

    .landing-hero-v2 h1 {
        font-size: clamp(2rem, 8vw, 2.7rem);
    }

    .landing-section {
        padding: 1.5rem 0;
    }

    .landing-info-card,
    .landing-usecase-card,
    .landing-cta-panel,
    .dashboard-search,
    .dashboard-op-row {
        padding: 1rem;
    }

    .section-head {
        gap: 0.75rem;
        flex-wrap: wrap;
        align-items: flex-start !important;
    }

    .section-head > * {
        width: 100%;
    }

    .section-head .btn {
        width: 100%;
    }

    .dashboard-search .input-group {
        flex-wrap: wrap;
    }

    .dashboard-search .input-group > .input-group-text,
    .dashboard-search .input-group > .form-control,
    .dashboard-search .input-group > .btn {
        width: 100%;
        border-radius: var(--radius-md) !important;
    }

    .dashboard-search .input-group > .input-group-text {
        justify-content: center;
        border-bottom: 0;
    }

    .dashboard-search .input-group > .form-control {
        border-top: 0;
    }

    .dashboard-search .input-group > .btn {
        margin-top: 0.5rem;
    }

    .stat-card .card-body,
    .action-card {
        padding: 0.95rem;
    }

    .action-card {
        text-align: left;
    }

    .action-card .action-icon {
        margin: 0 0 var(--space-3);
    }

    .search-suggestions {
        max-height: min(18rem, 55vh);
    }

    .toast-container {
        left: var(--space-2);
        right: var(--space-2);
        bottom: var(--space-2);
    }
}

@media (max-width: 575.98px) {
    .shell-header .container {
        align-items: flex-start;
    }

    .shell-header-actions {
        width: 100%;
        justify-content: space-between;
        margin-left: 0 !important;
    }

    .shell-header-cta {
        flex: 1 1 calc(50% - 0.5rem);
        text-align: center;
    }

    .shell-header-cta:last-child {
        flex-basis: 100%;
    }

    .landing-hero-v2 .btn-lg,
    .landing-cta-panel .btn-lg {
        width: 100%;
    }

    .dashboard-shell {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .workbench-container,
    .workbench-container--wide {
        width: calc(100% - 1rem);
        padding-top: 0.85rem;
    }

    .workbench-toolbar .btn-group > .btn,
    .workbench-toolbar .btn-group > a.btn {
        flex: 1 1 100%;
    }

    .dashboard-op-row .btn {
        width: 100%;
    }
}
