/* Premium Dark Mode CSS for Scanifly Drone Data Analyzer */
:root {
    /* Scanifly Brand & Accents */
    --primary-color: #F97316; /* Vibrant Orange */
    --primary-hover: #EA580C;
    --secondary-color: #3B82F6; /* Electric Blue */
    --secondary-hover: #2563EB;
    
    /* Dark Theme Core Colors */
    --bg-dark: #0f172a; /* Slate 900 */
    --surface-dark: rgba(30, 41, 59, 0.7); /* Slate 800 with transparency */
    --surface-light: rgba(51, 65, 85, 0.8); /* Slate 700 */
    
    /* Text Colors */
    --text-primary: #f8fafc; /* Slate 50 */
    --text-secondary: #cbd5e1; /* Slate 300 */
    --text-muted: #94a3b8; /* Slate 400 */
    
    /* Borders & Utilities */
    --border-color: rgba(255, 255, 255, 0.08);
    --border-color-focus: rgba(249, 115, 22, 0.5);
    --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --border-radius: 12px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    --spacing-unit: 1rem;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Status Colors */
    --status-good-bg: rgba(16, 185, 129, 0.15);
    --status-good-border: #10b981;
    --status-warning-bg: rgba(245, 158, 11, 0.15);
    --status-warning-border: #f59e0b;
    --status-poor-bg: rgba(239, 68, 68, 0.15);
    --status-poor-border: #ef4444;
    --status-info-bg: rgba(59, 130, 246, 0.15);
    --status-info-border: #3b82f6;
}

/* Custom Scrollbar for a premium feel */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    padding: var(--spacing-unit);
    font-size: 16px;
    min-height: 100vh;
    /* Optional: Subtle grid background for high-tech feel */
    background-image: 
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 40px 40px;
}

header {
    text-align: center;
    padding: calc(var(--spacing-unit) * 1.5) 0;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: calc(var(--spacing-unit) * 0.5);
    letter-spacing: -0.5px;
    text-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: calc(var(--spacing-unit));
    border-bottom: 1px solid var(--border-color);
    padding-bottom: calc(var(--spacing-unit) * 0.5);
}

h3 {
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: calc(var(--spacing-unit) * 0.75);
}

/* Main Layout */
.main-container {
    display: grid;
    grid-template-columns: 290px 1fr;
    gap: calc(var(--spacing-unit) * 1.5);
    width: 100%;
    max-width: 100%;
    padding: 0 1rem;
    align-items: start;
}

/* ── Sidebar ── */
.control-panel {
    position: sticky;
    top: var(--spacing-unit);
    height: fit-content;
    display: flex;
    flex-direction: column;
    gap: 0;
    background: var(--surface-dark);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    overflow: hidden;
}

/* Sidebar sections */
.sidebar-section {
    padding: 1.1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.sidebar-section:last-child { border-bottom: none; }

.sidebar-section-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
}

button.sidebar-section-header {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    text-align: left;
    cursor: pointer;
    font-family: inherit;
    color: var(--text-primary);
    border-radius: 0;
}
button.sidebar-section-header:hover {
    background: none;
    transform: none;
    box-shadow: none;
}
button.sidebar-section-header:nth-of-type(2) {
    background: none;
}

.section-icon {
    width: 16px;
    height: 16px;
    color: var(--primary-color);
    flex-shrink: 0;
}

.section-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    flex: 1;
}

.collapse-arrow {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.collapsible[aria-expanded="true"] .collapse-arrow {
    transform: rotate(180deg);
}

.section-body {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Photo count grid */
.photo-count-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.count-item {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem 0.4rem;
    text-align: center;
}

.count-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.2rem;
}

.count-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}
.count-value.kept { color: #10b981; }
.count-value.filtered { color: #f59e0b; }

/* Filter rows */
.filter-row {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 0.5rem;
}
.filter-row label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.filter-row input[type="number"] {
    width: 80px;
    padding: 0.4rem 0.5rem;
    font-size: 0.85rem;
}
.filter-row--check {
    grid-template-columns: 1fr auto;
}
.filter-row--check input[type="checkbox"] {
    margin: 0;
}

.filter-subheader {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-top: 0.25rem;
    border-top: 1px solid var(--border-color);
    margin-top: 0.25rem;
}
.filter-subheader label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
}

#cameraFilterOptions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--border-color);
    margin-top: 0.1rem;
}
.camera-filters:has(#enableCameraFilters:not(:checked)) #cameraFilterOptions,
#enableCameraFilters:not(:checked) ~ #cameraFilterOptions {
    display: none;
}

/* Shared button base */
button {
    font-family: inherit;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    font-weight: 600;
    transition: var(--transition);
}

.btn-full { width: 100%; }

/* Primary CTA */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: var(--primary-color);
    color: #fff;
    padding: 0.75rem 1rem;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(249, 115, 22, 0.4);
}

/* Secondary */
.btn-secondary {
    background: rgba(59, 130, 246, 0.15);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 0.6rem 1rem;
    box-shadow: none;
}
.btn-secondary:hover {
    background: rgba(59, 130, 246, 0.25);
    transform: translateY(-1px);
    box-shadow: none;
}

/* Export buttons */
.btn-export {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255,255,255,0.04);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    padding: 0.6rem 0.75rem;
    font-size: 0.82rem;
    font-weight: 500;
    box-shadow: none;
    text-align: left;
}
.btn-export:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-primary);
    transform: none;
    box-shadow: none;
}

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

/* Processing indicator */
#processingIndicator {
    text-align: center;
    padding: 0.6rem;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid var(--secondary-color);
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--secondary-color);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(59, 130, 246, 0); }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

label {
    font-weight: 500;
    color: var(--text-secondary);
    flex-shrink: 0;
}

input[type="text"],
input[type="number"] {
    font-family: inherit;
    font-size: 0.9rem;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    transition: var(--transition);
}
input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    accent-color: var(--primary-color);
    cursor: pointer;
}

/* ── View Tabs (top of content area) ── */
.view-tabs {
    display: flex;
    gap: 0;
    background: var(--surface-dark);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 4px;
    box-shadow: var(--box-shadow);
}

.view-btn {
    flex: 1;
    text-align: center;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    background: transparent;
    border: none;
    box-shadow: none;
    transition: var(--transition);
    cursor: pointer;
}
.view-btn:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
    transform: none;
    box-shadow: none;
}
.view-btn.active {
    background: var(--secondary-color);
    color: #fff;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

/* Results Panel */
.results-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

/* PDF Style Report Page */
#analysis-summary {
    background-color: transparent;
    padding: 0;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.report-document {
    background: white;
    color: #1e293b;
    padding: 3rem;
    width: 100%;
    max-width: 900px; /* Letter width roughly */
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    font-family: 'Outfit', sans-serif;
    line-height: 1.5;
}

.report-actions {
    display: flex;
    justify-content: center;
    width: 100%;
    max-width: 900px;
    margin-top: 1rem;
    margin-bottom: 2rem;
}

.print-btn {
    background-color: var(--secondary-color);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.print-btn:hover {
    background-color: var(--secondary-hover);
}

/* Report Internal Structure */
.report-header-section {
    text-align: center;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
}

.report-header-section h1 {
    color: #0f172a;
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
    text-shadow: none;
}

.report-header-section p {
    color: #64748b;
    font-size: 1.1rem;
}

.report-category {
    margin-bottom: 2rem;
    page-break-inside: avoid;
}

.report-category h3 {
    color: #334155;
    border-bottom: 1px solid #cbd5e1;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    font-size: 1.3rem;
    font-weight: 600;
}

.report-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.report-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 1rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.report-item-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.report-item-content {
    flex-grow: 1;
}

.report-item-title {
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.25rem;
    display: block;
    font-size: 0.95rem;
}

.report-item-text {
    color: #475569;
    font-size: 0.9rem;
}

/* Print CSS */
@media print {
    body {
        background: white;
        padding: 0;
        margin: 0;
    }
    
    .control-panel,
    header,
    .view-navigation,
    .report-actions {
        display: none !important;
    }

    .main-container {
        display: block;
        padding: 0;
        margin: 0;
        width: 100%;
        max-width: none;
    }

    .results-panel {
        display: block;
    }

    #analysis-summary {
        display: block !important;
    }

    .report-document {
        box-shadow: none;
        border: none;
        margin: 0;
        padding: 0;
        max-width: 100%;
        width: 100%;
    }
    
    .report-item {
        border-color: #cbd5e1;
    }
}

/* Map */
#map {
    height: 600px;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    border: 1px solid var(--border-color);
    z-index: 1; /* Keep map controls below header if sticky */
}

/* Chart Container */
.chart-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: calc(var(--spacing-unit) * 1.5);
}

.chart-container > div {
    background-color: var(--surface-dark);
    backdrop-filter: blur(12px);
    padding: calc(var(--spacing-unit) * 1.5);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    box-shadow: var(--box-shadow);
    height: 380px; /* Force minimum height for spacious charts */
    display: flex;
    flex-direction: column;
}

.chart-container canvas {
    flex-grow: 1;
}

/* Table */
.table-container {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: auto;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    background-color: var(--surface-dark);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(12px);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 1400px;
}

th, td {
    padding: calc(var(--spacing-unit) * 0.85);
    text-align: left;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    white-space: nowrap;
    color: var(--text-secondary);
}

th {
    background-color: rgba(15, 23, 42, 0.95);
    color: var(--text-primary);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(4px);
    letter-spacing: 0.5px;
}

tbody tr {
    transition: var(--transition);
}

tbody tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.02);
}

tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.1); /* Subtle blue hover highlight */
}

tr.filtered-out td {
    background-color: rgba(239, 68, 68, 0.1) !important;
    color: #fca5a5;
}

/* Map specific tweaks for dark mode Leaflet (Optional, filtering tiles) */
.leaflet-layer,
.leaflet-control-zoom-in,
.leaflet-control-zoom-out,
.leaflet-control-attribution {
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

.heading-arrow {
    background: transparent !important;
    border: none !important;
    text-align: center;
    line-height: 20px;
    filter: none; /* Keep arrows original color */
}

/* Map wrapper and 2D/3D toggle */
.map-wrapper {
    position: relative;
}

#cesium-container {
    height: 600px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.map-mode-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    display: flex;
    gap: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.mode-btn {
    padding: 6px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

.mode-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.mode-btn.active {
    background: var(--primary-color);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Cesium loading spinner */
.cesium-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-md);
    z-index: 999;
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-size: 0.95rem;
}

.cesium-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: cesium-spin 0.8s linear infinite;
}

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

/* Cesium widget theme overrides */
#cesium-container .cesium-viewer-bottom {
    display: none !important;
}

#cesium-container .cesium-toolbar-button {
    background: rgba(15, 23, 42, 0.85) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

#cesium-container .cesium-toolbar-button:hover {
    background: rgba(30, 41, 59, 0.9) !important;
}

#cesium-container .cesium-infoBox {
    background: rgba(15, 23, 42, 0.95) !important;
    border-color: var(--border-color) !important;
}

#cesium-container .cesium-sceneModePicker-wrapper {
    position: absolute;
    top: 8px;
    left: 8px;
}

/* Review panel */
.review-panel {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.review-info {
    color: var(--text-primary);
    font-family: 'Outfit', sans-serif;
    font-size: 0.85rem;
    min-width: 140px;
    text-align: center;
    white-space: nowrap;
}

.review-nav-btn {
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.review-nav-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.review-stop-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    border: 1px solid rgba(239, 68, 68, 0.4);
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.review-stop-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* Responsive */
@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 300px 1fr;
    }
}

@media (max-width: 900px) {
    .main-container {
        grid-template-columns: 1fr;
    }
    .control-panel {
        position: static;
    }
    #analysis-results {
        grid-template-columns: 1fr;
    }
    .chart-container {
        grid-template-columns: 1fr; /* Stack charts on small screens */
    }
}