/* EUC Ride Data Viewer - Client Side Styles */

:root {
    --primary-color: #0d6efd;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #0dcaf0;
    --dark-color: #212529;
    --light-color: #f8f9fa;
}

/* Custom Toggle Switch Colors - Green instead of Blue */
.form-switch .form-check-input:checked {
    background-color: #28a745;
    border-color: #28a745;
}

.form-switch .form-check-input:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 0.25rem rgba(40, 167, 69, 0.25);
}

body {
    font-family: 'Courier New', Courier, monospace;
    background-color: #f0f2f5;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Dark Mode Styles */
body.dark-mode {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

body.dark-mode .card {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

body.dark-mode .card-body {
    background-color: #2a2a2a;
}

body.dark-mode .navbar-dark {
    background-color: #0a0a0a !important;
}

body.dark-mode .overview-column {
    background: #2a2a2a;
    border-color: #444;
    color: #e0e0e0;
}

body.dark-mode .overview-column-title {
    color: #00ff00;
    border-bottom-color: #00ff00;
}

body.dark-mode .overview-label {
    color: #999;
}

body.dark-mode .overview-value {
    color: #e0e0e0;
}

body.dark-mode .grid-full-width {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
    padding: 20px;
    border-radius: 4px;
}

body.dark-mode .grid-full-width p {
    color: #e0e0e0 !important;
}

body.dark-mode .table-responsive {
    background-color: #2a2a2a !important;
}

body.dark-mode .text-muted {
    color: #999 !important;
}

body.dark-mode .bg-light {
    background-color: #2a2a2a !important;
    color: #e0e0e0;
}

body.dark-mode .table,
body.dark-mode table {
    color: #e0e0e0 !important;
    background-color: #2a2a2a !important;
    border-color: #444 !important;
}

/* Custom hover for file rows - consistent light/dark themes */

/* Unknown format rows - greyed out and non-interactive */
tr.format-unknown {
    opacity: 0.5;
    cursor: default;
}

tr.format-unknown td {
    color: #999 !important;
}

body.dark-mode tr.format-unknown td {
    color: #666 !important;
}

/* Light Mode: Blue theme for file row hover */
body:not(.dark-mode) table tbody tr:not(.table-secondary):not(.format-unknown):hover {
    background-color: #e7f3ff !important;
    outline: 2px solid #007bff !important;
    outline-offset: -2px !important;
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.3) !important;
}

body:not(.dark-mode) table tbody tr:not(.table-secondary):not(.format-unknown):hover td {
    color: #0056b3 !important;
}

/* Dark Mode: Green theme for file row hover */
body.dark-mode table tbody tr:not(.table-secondary):not(.format-unknown):hover {
    background-color: #1a3a1a !important;
    outline: 2px solid #00ff00 !important;
    outline-offset: -2px !important;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3) !important;
}

body.dark-mode table tbody tr:not(.table-secondary):not(.format-unknown):hover td {
    color: #00ff00 !important;
}

body.dark-mode .table-secondary,
body.dark-mode tr.table-secondary {
    background-color: #333 !important;
    color: #e0e0e0 !important;
}

body.dark-mode .table thead th,
body.dark-mode table thead th,
body.dark-mode thead th {
    color: #e0e0e0 !important;
    border-color: #444 !important;
    background-color: #1a1a1a !important;
}

body.dark-mode .table td,
body.dark-mode .table th,
body.dark-mode table td,
body.dark-mode table th,
body.dark-mode td,
body.dark-mode th {
    border-color: #444 !important;
    color: #e0e0e0 !important;
    background-color: #2a2a2a !important;
}

body.dark-mode .table tbody tr,
body.dark-mode table tbody tr,
body.dark-mode tbody tr {
    background-color: #2a2a2a !important;
    color: #e0e0e0 !important;
}

body.dark-mode .bg-light {
    background-color: #1a1a1a !important;
}

body.dark-mode .rounded {
    border: 1px solid #444;
}

body.dark-mode .btn-outline-primary {
    border-color: #00ff00;
    color: #00ff00;
}

body.dark-mode .btn-outline-primary:hover {
    background-color: #00ff00;
    color: #000;
}

body.dark-mode .btn-outline-primary.btn-sm {
    border-color: #00ff00;
    color: #00ff00;
}

body.dark-mode .btn-outline-primary.btn-sm:hover {
    background-color: #00ff00;
    color: #000;
}

body.dark-mode .btn-primary {
    background-color: #00ff00;
    border-color: #00ff00;
    color: #000;
}

body.dark-mode .btn-primary:hover {
    background-color: #00cc00;
    border-color: #00cc00;
}

body.dark-mode h4, body.dark-mode h5 {
    color: #e0e0e0 !important;
}

body.dark-mode code {
    background-color: #1a1a1a !important;
    color: #00ff00 !important;
    padding: 2px 6px;
    border-radius: 3px;
}

body.dark-mode small {
    color: #999 !important;
}

body.dark-mode strong,
body.dark-mode table strong,
body.dark-mode .table strong {
    color: #e0e0e0 !important;
}

body.dark-mode .table-secondary strong,
body.dark-mode tr.table-secondary strong {
    color: #00ff00 !important;
}

/* Dark Mode - Charts */
body.dark-mode canvas {
    filter: invert(1) hue-rotate(180deg);
}

/* Prevent map from being inverted */
body.dark-mode #gps-map canvas {
    filter: none !important;
}

body.dark-mode .chart-wrapper {
    background-color: #2a2a2a;
}

/* Drop Zone Styling - entire page is drop zone */
body.drag-over::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 110, 253, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9998;
    pointer-events: none;
}

body.drag-over::before {
    content: '📂 Drop CSV file to load';
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(13, 110, 253, 0.95);
    color: white;
    padding: 30px 60px;
    border-radius: 20px;
    font-size: 24px;
    font-weight: bold;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.05);
    }
}

/* Map Style Buttons - Base styles matching btn-outline-light */
.map-style-btn {
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 400;
    padding: 6px 12px;
    transition: all 0.3s ease;
    white-space: nowrap;
}

/* Light Mode: Dark text with light border */
body:not(.dark-mode) .map-style-btn {
    border: 1px solid #dee2e6;
    background: transparent;
    color: #212529;
}

/* Dark Mode: Light text with light border (matching btn-outline-light) */
body.dark-mode .map-style-btn {
    border: 1px solid #f8f9fa;
    background: transparent;
    color: #f8f9fa;
}

/* Light Mode: Blue theme for button hover */
body:not(.dark-mode) .map-style-btn:hover:not(:disabled) {
    background: #e7f3ff !important;           /* Light blue background */
    border-color: #0056b3 !important;         /* Dark blue border */
    color: #0056b3 !important;                /* Dark blue text */
    outline: 2px solid #007bff !important;    /* Blue outline */
    outline-offset: -2px !important;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.3) !important; /* Blue glow */
}

/* Dark Mode: Green theme for button hover (matches file rows) */
body.dark-mode .map-style-btn:hover:not(:disabled) {
    background: #1a3a1a !important;           /* Dark green background */
    border-color: #00ff00 !important;         /* Bright green border */
    color: #00ff00 !important;                /* Bright green text */
    outline: 2px solid #00ff00 !important;    /* Green outline */
    outline-offset: -2px !important;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3) !important; /* Green glow */
}

.map-style-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed !important;
    filter: grayscale(50%);
}

/* Light Mode: Blue theme for Back to Files button */
body:not(.dark-mode) #back-to-files-btn:hover {
    background: #e7f3ff !important;
    border-color: #0056b3 !important;
    color: #0056b3 !important;
    outline: 2px solid #007bff !important;
    outline-offset: -2px !important;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(0, 123, 255, 0.3) !important;
}

/* Dark Mode: Green theme for Back to Files button (matches file rows) */
body.dark-mode #back-to-files-btn:hover {
    background: #1a3a1a !important;
    border-color: #00ff00 !important;
    color: #00ff00 !important;
    outline: 2px solid #00ff00 !important;
    outline-offset: -2px !important;
    transform: scale(1.05);
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3) !important;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

/* Overview Stats - Column Layout (7 columns) */
#overview-stats {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
}

/* Placeholder content should span all columns */
#overview-stats > .grid-full-width {
    grid-column: 1 / -1;
}

.overview-column {
    background: #ffffff;
    border-radius: 4px;
    padding: 16px;
    box-shadow: none;
    border: 1px solid #dee2e6;
    min-width: 0;
}

.overview-column-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #0d6efd;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #0d6efd;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overview-item {
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.overview-item:last-child {
    border-bottom: none;
}

.overview-label {
    font-size: 0.75rem;
    color: #6c757d;
    font-weight: 600;
    margin-bottom: 3px;
}

.overview-value {
    font-size: 1rem;
    font-weight: bold;
    color: #212529;
}

.overview-value-na {
    color: #dc3545 !important; /* Bootstrap red for zero/N/A values */
}

/* noUiSlider Custom Styling - Dash RangeSlider Theme */
.noUi-target {
    background: #ebebeb;
    border: none;
    box-shadow: none;
    border-radius: 3px;
    height: 5px;
}

.noUi-connect {
    background: #119dff;
    box-shadow: none;
    pointer-events: none !important; /* Disable dragging the middle bar */
}

.noUi-handle {
    background: #fff !important;
    border: 2px solid #119dff !important;
    border-radius: 50% !important;
    box-shadow: 0 0 0 0 rgba(17, 157, 255, 0) !important;
    cursor: pointer !important;
    width: 20px !important;
    height: 20px !important;
    top: -7.5px !important; /* Center 20px handle on 5px track: (5 - 20) / 2 */
    right: -10px !important; /* Center handle horizontally: 20px / 2 */
    transition: box-shadow 0.15s ease !important;
}

.noUi-handle:before,
.noUi-handle:after {
    display: none; /* Remove default handle bars */
}

.noUi-handle:hover {
    box-shadow: 0 0 0 8px rgba(17, 157, 255, 0.15) !important;
}

.noUi-handle:active {
    box-shadow: 0 0 0 12px rgba(17, 157, 255, 0.25) !important;
}

.noUi-handle:focus {
    outline: none !important;
    box-shadow: 0 0 0 8px rgba(17, 157, 255, 0.2) !important;
}

/* Tooltip styling */
.noUi-tooltip {
    background: #212529;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Pips (time marks) - Dash RangeSlider style */
.noUi-pips {
    color: #506784;
    font-size: 0.65rem;
    pointer-events: none; /* Allow clicks to pass through to buttons below */
}

.noUi-marker-horizontal {
    background: #aaa;
    width: 1px;
    height: 5px;
}

.noUi-marker-large {
    height: 8px;
    background: #888;
}

.noUi-value {
    color: #506784;
    font-size: 0.65rem;
    padding-top: 12px; /* Increased spacing to avoid overlap with markers */
    font-weight: 400;
}

.noUi-value-horizontal {
    transform: translateX(-50%);
}

/* Responsive adjustments for 7 columns */
@media (max-width: 1400px) {
    .overview-column-title {
        font-size: 0.85rem;
    }
    .overview-value {
        font-size: 0.95rem;
    }
}

@media (max-width: 992px) {
    #overview-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .overview-column {
        padding: 14px;
    }
}

@media (max-width: 576px) {
    #overview-stats {
        grid-template-columns: 1fr;
    }
}

/* Legacy stat-item styles (for backward compatibility) */
.stat-item {
    padding: 15px;
    border-right: 1px solid #dee2e6;
}

.stat-item:last-child {
    border-right: none;
}

.stat-label {
    font-size: 0.875rem;
    color: #6c757d;
    font-weight: 600;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: bold;
    color: #212529;
}

/* Chart Containers */
.chart-wrapper {
    margin-bottom: 5px;
    position: relative;
}

.chart-title {
    display: none; /* Hide chart titles */
}

/* GPS Map */
#gps-map {
    position: relative;
    z-index: 1;
}

/* Leaflet custom controls (matching DASHAPP) */
.custom-map-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-control-btn {
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255,255,255,1.0);
    background: rgba(0, 0, 0, 0.8);
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    color: white;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.map-control-btn:hover {
    background: rgba(255, 255, 255, 0.8);
    border-color: rgba(0,0,0,1.0);
    color: black;
    transform: scale(1.05);
}

/* Time Range Slider */
#time-range-slider {
    width: calc(100% - 40px); /* Add padding on edges */
    margin: 0 20px 55px 20px; /* Edge padding and bottom space for pips */
}

/* Responsive Design */
@media (max-width: 768px) {
    .stat-item {
        border-right: none;
        border-bottom: 1px solid #dee2e6;
    }

    .stat-item:last-child {
        border-bottom: none;
    }

    #gps-map {
        height: 80vh !important;
    }
}

/* Card Shadows */
.card {
    border: none;
}

/* Smooth Transitions */
/* Exclude Leaflet map elements for better performance */
*:not(#gps-map):not(#gps-map *):not(.leaflet-container):not(.leaflet-container *):not(.tooltip):not(.tooltip *):not(.popover):not(.popover *) {
    transition: all 0.2s ease;
}

/* Format Icons */
.format-icon {
    height: 48px;
    width: auto;
    margin-right: 12px;
    vertical-align: middle;
    float: left;
}

/* Format Icons in File List */
.file-list-icon {
    height: 24px;
    width: auto;
    vertical-align: middle;
    display: inline-block;
}

/* Format Icons in Summary Header */
.summary-icon {
    height: 20px;
    width: auto;
    vertical-align: middle;
    display: inline-block;
    margin: 0 4px;
}

/* Version Badge - Retro Console Style */
.version-badge {
    font-family: 'Courier New', Courier, monospace;
    background: #1a1a1a;
    color: #00ff00;
    padding: 4px 12px;
    border-radius: 4px;
    border: 1px solid #333;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    font-weight: normal;
}

/* Bootstrap Tooltips - Overview Stats */
.tooltip {
    pointer-events: none;
}

.tooltip .tooltip-inner {
    max-width: 400px;
    text-align: left;
    padding: 10px 14px;
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Dark Mode Tooltip Styling */
body.dark-mode .tooltip .tooltip-inner {
    background-color: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #00ff00;
    box-shadow: 0 4px 12px rgba(0, 255, 0, 0.15);
}

body.dark-mode .tooltip .tooltip-arrow::before {
    border-top-color: #00ff00 !important;
    border-bottom-color: #00ff00 !important;
    border-left-color: #00ff00 !important;
    border-right-color: #00ff00 !important;
}

/* Light Mode Tooltip Styling */
body:not(.dark-mode) .tooltip .tooltip-inner {
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
}

/* Tooltip hover hint */
.overview-item[data-bs-toggle="tooltip"] {
    cursor: help;
}

/* File Info - Retro Console Style */
#file-info {
    font-family: 'Courier New', Courier, monospace;
    background: #1a1a1a;
    color: #00ff00;
    padding: 8px 16px;
    border-radius: 4px;
    border: 1px solid #333;
    font-size: 0.9rem;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    min-height: 64px;
}

#file-info .badge {
    font-family: 'Courier New', Courier, monospace;
    background: transparent !important;
    color: #00ff00 !important;
    border: none;
    font-weight: normal;
    letter-spacing: 0.5px;
    padding: 0;
}

#file-info .text-muted {
    color: #666 !important;
}

/* Progress Indicator */
.progress-thin {
    height: 3px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ==================== Footer Styles ==================== */
.page-footer {
    position: relative;
    bottom: 0;
    width: 100%;
    background-color: #2a2a2a;
    color: #e0e0e0;
    padding: 16px 0;
    margin-top: 32px;
    border-top: 2px solid #444;
    font-size: 0.875rem;
}

.page-footer .footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.page-footer .footer-left,
.page-footer .footer-center,
.page-footer .footer-right {
    flex: 1;
}

.page-footer .footer-left {
    text-align: left;
    font-family: 'Courier New', Courier, monospace;
    color: #00ff00;
    font-weight: 500;
}

.page-footer .footer-center {
    text-align: center;
}

.page-footer .footer-right {
    text-align: right;
}

.page-footer a {
    color: #0d6efd;
    text-decoration: none;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.page-footer a:hover {
    color: #0a58ca;
    text-decoration: underline;
}

.page-footer .footer-right a {
    display: inline-flex;
    align-items: center;
    opacity: 0.8;
}

.page-footer .footer-right a:hover {
    opacity: 1;
    text-decoration: none;
}

.page-footer .footer-right svg {
    transition: transform 0.2s ease;
}

.page-footer .footer-right a:hover svg {
    transform: scale(1.1);
}

/* Dark Mode Footer */
body.dark-mode .page-footer {
    background-color: #0a0a0a;
    border-top-color: #333;
}

body.dark-mode .page-footer a {
    color: #4dabf7;
}

body.dark-mode .page-footer a:hover {
    color: #74c0fc;
}

/* Light Mode Footer */
body:not(.dark-mode) .page-footer {
    background-color: #e9ecef;
    color: #212529;
    border-top-color: #dee2e6;
}

body:not(.dark-mode) .page-footer .footer-left {
    color: #198754;
}

body:not(.dark-mode) .page-footer a {
    color: #0d6efd;
}

body:not(.dark-mode) .page-footer a:hover {
    color: #0a58ca;
}

/* Responsive Footer */
@media (max-width: 768px) {
    .page-footer .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .page-footer .footer-left,
    .page-footer .footer-center,
    .page-footer .footer-right {
        text-align: center;
    }
}

/* ==================== Marker Animation Control ==================== */
/* By default, disable all marker animations for performance */
.leaflet-marker-icon > div {
    animation: none !important;
}

/* Only enable animations when marker-animations-enabled class is on body */
/* Uses CSS custom properties set in marker HTML (--animation-name, --animation-duration) */
body.marker-animations-enabled .leaflet-marker-icon > div {
    animation: var(--animation-name) var(--animation-duration) ease-in-out infinite !important;
}
