/* SailFrames Analytics Dashboard Styles */

:root {
    --bg-primary: #0f1419;
    --bg-secondary: #1a2332;
    --bg-panel: #222d3d;
    --text-primary: #e7e9ea;
    --text-secondary: #8b98a5;
    --accent: #1d9bf0;
    --accent-hover: #1a8cd8;
    --border: #2f3336;
    --success: #00ba7c;
    --warning: #ffad1f;
    --error: #f4212e;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
}

.session-selector select {
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    min-width: 250px;
    cursor: pointer;
}

.session-selector select:focus {
    outline: none;
    border-color: var(--accent);
}

/* Main layout */
.main {
    flex: 1;
    display: flex;
    overflow: hidden;
    gap: 1px;
    background: var(--border);
}

.panel {
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
}

/* Map panel - collapsible */
.map-panel {
    flex: 0 0 400px;
    min-width: 200px;
    max-width: 60%;
    position: relative;
    transition: flex-basis 0.3s ease, min-width 0.3s ease;
}

.map-panel.collapsed {
    flex-basis: 50px !important;
    min-width: 50px !important;
}

.map-panel.collapsed .map-container {
    display: none;
}

.map-panel.collapsed .stats {
    display: none;
}

.map-panel.collapsed .resize-handle {
    display: none;
}

.btn-collapse {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.btn-collapse:hover {
    background: var(--accent);
    color: white;
}

.map-panel.collapsed .btn-collapse {
    transform: rotate(180deg);
}

.resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    background: transparent;
    transition: background 0.2s;
    z-index: 10;
}

.resize-handle:hover,
.resize-handle.resizing {
    background: var(--accent);
}

.map-container {
    flex: 1;
    background: var(--bg-primary);
}

.stats {
    display: flex;
    gap: 16px;
}

.stat {
    font-size: 0.85rem;
}

.stat label {
    color: var(--text-secondary);
}

.stat span:last-child {
    font-weight: 600;
    color: var(--accent);
}

/* Data panel */
.data-panel {
    flex: 1;
    min-width: 400px;
    overflow-y: auto;
    overflow-x: hidden;
}

.charts-container {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chart-row {
    display: flex;
    gap: 12px;
}

.chart-box {
    flex: 1;
    background: var(--bg-panel);
    border-radius: 8px;
    padding: 12px;
    min-height: 180px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.chart-box:hover {
    box-shadow: 0 0 0 2px var(--accent);
}

.chart-box h3 {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.chart-box canvas {
    width: 100% !important;
    height: 140px !important;
}

/* Fullscreen chart overlay */
.chart-fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.chart-fullscreen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.chart-fullscreen-header h2 {
    font-size: 1.4rem;
    color: var(--text-primary);
}

.chart-fullscreen-close {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
}

.chart-fullscreen-close:hover {
    background: var(--accent);
}

.chart-fullscreen-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    border-radius: 12px;
    padding: 20px;
}

.chart-fullscreen-canvas {
    flex: 1;
    min-height: 0;
}

.chart-fullscreen-stats {
    display: flex;
    gap: 32px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.chart-stat-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chart-stat-group .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.chart-stat-group .value {
    font-size: 1.2rem;
    font-weight: 600;
    font-family: 'SF Mono', 'Menlo', monospace;
}

.chart-stat-group .value.min { color: #f4212e; }
.chart-stat-group .value.max { color: #00ba7c; }
.chart-stat-group .value.avg { color: var(--accent); }
.chart-stat-group .value.current { color: #ffad1f; }

/* Video */
.video-container {
    padding: 12px;
    display: flex;
    gap: 12px;
}

.video-box {
    flex: 1;
    background: var(--bg-panel);
    border-radius: 8px;
    padding: 12px;
}

.video-box h3 {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.video-box video {
    width: 100%;
    border-radius: 4px;
    background: #000;
}

/* Timeline */
.timeline-container {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
}

.playback-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-control {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.btn-control:hover {
    background: var(--accent-hover);
}

.playback-controls select {
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.timeline-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.time-label {
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    min-width: 70px;
}

.time-absolute {
    border-left: 1px solid var(--border);
    padding-left: 16px;
    margin-left: 8px;
}

.time-label-absolute {
    font-family: 'SF Mono', 'Menlo', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent);
    min-width: 120px;
}

.timeline {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--bg-panel);
    border-radius: 3px;
    cursor: pointer;
}

.timeline::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    transition: transform 0.1s;
}

.timeline::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.timeline::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
    border: none;
}

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 20, 25, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 16px;
    color: var(--text-secondary);
}

/* Leaflet overrides */
.leaflet-container {
    background: var(--bg-primary);
}

.leaflet-control-zoom a {
    background: var(--bg-panel) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

.leaflet-control-attribution {
    background: var(--bg-secondary) !important;
    color: var(--text-secondary) !important;
}

/* Responsive */
@media (max-width: 1000px) {
    .main {
        flex-direction: column;
    }

    .map-panel, .data-panel {
        min-width: 100%;
        flex: none;
    }

    .map-panel {
        height: 40vh;
    }

    .chart-row {
        flex-direction: column;
    }
}
