/* BRT Route Map Viewer Styles */

/* CSS Variables */
:root {
    --highlight-color: #DAA520;
    --highlight-color-rgb: 218, 165, 32;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    overflow: hidden;
}

/* Map container - full viewport for iframe embedding */
#map-container {
    height: 100%;
    width: 100%;
    position: relative;
    display: flex;
}

#map {
    height: 100%;
    flex: 1;
    min-width: 0;
}

/* Info Panel - collapsible right sidebar */
#info-panel {
    position: relative;
    width: 200px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: row;
    z-index: 1000;
    transition: width 0.3s ease, margin-right 0.3s ease;
}

#info-panel.collapsed {
    width: 28px;
}

#info-toggle {
    width: 28px;
    min-width: 28px;
    background: #fafafa;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 6px 3px;
    cursor: pointer;
    font-size: 12px;
    color: #666;
    transition: background 0.2s;
}

#info-toggle:hover {
    background: #fff;
}

/* Chevron toggle icons - simple styling like elevation drawer */
.toggle-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 16px;
    color: #666;
    transition: transform 0.3s ease, color 0.2s;
    flex-shrink: 0;
}

.toggle-chevron:hover {
    color: #333;
}

/* Collapsed state: chevrons point left (expand action) */
#info-panel.collapsed .toggle-chevron {
    transform: rotate(0deg);
}

/* Expanded state: chevrons point right (collapse action) */
#info-panel:not(.collapsed) .toggle-chevron {
    transform: rotate(180deg);
}

/* Center group - wrapper for route indicators and text */
.toggle-center-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    flex: 1;
    justify-content: center;
}

/* Route indicator styling for collapsed state */
.toggle-route-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

#info-panel:not(.collapsed) .toggle-route-indicator {
    display: none;
}

.toggle-pin {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: white;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.toggle-pin-start {
    background: #e53935;
}

.toggle-pin-end {
    background: #43a047;
}

.toggle-dash {
    width: 2px;
    height: 8px;
    background: #bbb;
    border-radius: 1px;
    margin: 2px 0;
}

.toggle-text {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: #666;
    line-height: 1.25;
    text-align: center;
    padding: 4px 0;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

#info-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 6px;
    display: flex;
    flex-direction: column;
}

/* Labels toggle button */
.labels-toggle {
    display: block;
    width: 100%;
    padding: 6px 10px;
    margin-bottom: 8px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #f0f0f0;
    color: #888;
}

.labels-toggle:hover {
    background: #e8e8e8;
}

.labels-toggle.active {
    background: linear-gradient(to bottom, #4CAF50, #43A047);
    border-color: #388E3C;
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.labels-toggle.active:hover {
    background: linear-gradient(to bottom, #43A047, #388E3C);
}

#info-header {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    text-align: center;
    padding: 4px 0 6px 0;
    margin-bottom: 6px;
    border-bottom: 1px solid #eee;
    letter-spacing: 0.3px;
}

#info-panel.collapsed #info-content {
    display: none;
}

#route-list {
    flex: 1;
    overflow-y: auto;
}

/* Route items with consistent-width boxes */
.route-item {
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    border-radius: 3px;
    margin-bottom: 2px;
}

.route-item:hover {
    background: #f5f5f5;
    border-color: #ddd;
}

.route-item.active {
    background: #fff3cd;
    border-color: #ffc107;
}

/* Trip stage highlight - customizable glow outline */
.route-item.trip-stage-active {
    border: 1px solid var(--highlight-color);
    background: rgba(var(--highlight-color-rgb), 0.15);
    box-shadow: 0 0 6px 1px rgba(var(--highlight-color-rgb), 0.5);
}

.route-point {
    display: flex;
    align-items: flex-start;
    gap: 5px;
    padding: 3px 4px;
}

.route-point-marker {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
    color: white;
    flex-shrink: 0;
    border: 2px solid white;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.route-point-details {
    flex: 1;
    min-width: 0; /* Allow flex item to shrink below content size */
}

.route-point-name {
    font-size: 10px;
    font-weight: 600;
    color: #333;
    word-wrap: break-word;
}

.route-point-location {
    font-size: 9px;
    color: #666;
    word-wrap: break-word;
    margin-top: 1px;
}

.route-segment-info {
    display: flex;
    align-items: center;
    padding: 3px 4px;
    color: #666;
    font-size: 10px;
}

.route-segment-info::before {
    content: '↓';
    margin-right: 5px;
    color: #999;
}

#total-distance {
    margin-top: 6px;
    padding: 6px 4px;
    border-top: 1px solid #ddd;
    font-size: 10px;
    font-weight: 600;
    color: #1565c0;
    text-align: center;
    background: #f8f8f8;
    border-radius: 3px;
    transition: background 0.2s, box-shadow 0.2s;
}

#total-distance:hover {
    background: #e3f2fd;
    box-shadow: 0 0 4px rgba(21, 101, 192, 0.3);
}

#total-distance .fit-icon {
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-right: 4px;
    opacity: 0.7;
    display: inline-block;
}

#total-distance:hover .fit-icon {
    opacity: 1;
}

/* Custom marker styles */
.route-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    font-weight: bold;
    font-size: 14px;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Sticky label styles - positioned beneath marker */
.route-label {
    background: white;
    border: 1px solid #666;
    border-radius: 4px;
    padding: 3px 6px 3px 8px;
    font-size: 11px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    margin-top: 2px;
    border-left: 3px solid currentColor; /* Color set inline via style */
}

/* Combined marker + label container - label beneath */
.marker-with-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

/* Popup styles */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.leaflet-popup-content {
    margin: 12px 16px;
    line-height: 1.5;
}

.popup-title {
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 8px;
    color: #333;
}

.popup-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    color: white;
    margin-bottom: 8px;
}

.popup-address {
    font-size: 12px;
    color: #666;
}

.popup-elevation {
    font-size: 12px;
    color: #4CAF50;
    font-weight: 500;
    margin-top: 4px;
}

.popup-date {
    font-size: 11px;
    color: #888;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #eee;
}

/* Segment popup - styled point markers */
.popup-segment-title {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
}

.popup-point-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    color: white;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.popup-to-text {
    font-size: 12px;
    font-weight: normal;
    color: #666;
    font-style: italic;
}

/* Multi-segment popup (for overlapping routes) */
.popup-multi-segment {
    min-width: 150px;
}

.popup-multi-header {
    font-size: 11px;
    color: #666;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #eee;
    font-style: italic;
}

.popup-segment-item {
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
}

.popup-segment-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.popup-segment-item:first-child {
    padding-top: 0;
}

.popup-segment-distance {
    font-size: 12px;
    color: #555;
    text-align: center;
    margin-top: 4px;
}

/* Clickable distance labels */
.segment-label-clickable {
    cursor: pointer !important;
}

.segment-label-clickable .segment-distance-label {
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.segment-label-clickable:hover .segment-distance-label {
    transform: scale(1.05);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.25);
}

/* Route line hover effect */
.route-segment:hover {
    stroke-width: 6;
}

/* Active route segment (trip stage: en route) */
.route-segment-active {
    filter: drop-shadow(0 0 6px rgba(var(--highlight-color-rgb), 1))
            drop-shadow(0 0 12px rgba(var(--highlight-color-rgb), 0.6));
    stroke-width: 5;
}

/* Active waypoint marker (trip stage: at location) */
.route-marker-active {
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 0 15px 5px rgba(var(--highlight-color-rgb), 0.7), 0 2px 5px rgba(0, 0, 0, 0.3);
    animation: pulse-glow 2s ease-in-out infinite;
}

/* Active waypoint label */
.route-label-active {
    background: linear-gradient(rgba(var(--highlight-color-rgb), 0.25), rgba(var(--highlight-color-rgb), 0.25)), white;
    font-weight: 600;
    box-shadow: 0 0 10px rgba(var(--highlight-color-rgb), 0.5), 0 2px 4px rgba(0, 0, 0, 0.2);
    -webkit-text-stroke: 1px white;
    paint-order: stroke fill;
}

/* Pulse animation for active markers */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.9), 0 0 15px 5px rgba(var(--highlight-color-rgb), 0.7), 0 2px 5px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.9), 0 0 20px 8px rgba(var(--highlight-color-rgb), 0.9), 0 2px 5px rgba(0, 0, 0, 0.3);
    }
}

/* Zoom controls styling */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
}

.leaflet-control-zoom a {
    width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
    font-size: 18px !important;
}

/* Fullscreen control - matches zoom controls */
.leaflet-control-fullscreen {
    border: none !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
}

.leaflet-control-fullscreen-button {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 32px !important;
    height: 32px !important;
    background: white !important;
    color: #333 !important;
    text-decoration: none;
    border-radius: 4px;
}

.leaflet-control-fullscreen-button:hover {
    background: #f4f4f4 !important;
    color: #000 !important;
}

.leaflet-control-fullscreen-button svg {
    display: block;
}

/* Attribution - smaller for cleaner look */
.leaflet-control-attribution {
    font-size: 10px;
    background: rgba(255, 255, 255, 0.8) !important;
}

/* Loading indicator */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    font-size: 16px;
    color: #666;
}

.loading-overlay.hidden {
    display: none;
}

/* Error message */
.error-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fee;
    border: 1px solid #c00;
    border-radius: 8px;
    padding: 20px;
    color: #900;
    text-align: center;
    z-index: 1000;
}

/* Total distance info bar */
.distance-info-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    border-top: 1px solid #ccc;
    padding: 8px 15px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    z-index: 1000;
    text-align: center;
}

.distance-info-bar strong {
    color: #1565c0;
}

/* Segment distance labels - compact with directional arrow */
.segment-distance-label {
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #666;
    border-radius: 8px;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 500;
    color: #333;
    text-align: center;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    line-height: 1.2;
}

.segment-direction-arrow {
    font-size: 14px;
    font-weight: bold;
    color: #555;
}

.segment-distance-label .dist-values {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.segment-distance-label .dist-mi {
    font-weight: 600;
}

.segment-distance-label .dist-km {
    color: #666;
    font-size: 9px;
}

/* ============================================
   Layer Switcher Control - Google Maps style
   ============================================ */

.layer-switcher {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow 0.2s;
}

.layer-switcher:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

/* Collapsed state - shows current layer thumbnail */
.layer-switcher-current {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px;
}

.layer-switcher.expanded .layer-switcher-current {
    display: none;
}

/* Thumbnail preview boxes */
.layer-thumb {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    border: 2px solid #ccc;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}

.layer-switcher-current .layer-thumb {
    border-color: #1976d2;
}

/* CSS-based thumbnail patterns */
.layer-thumb-standard {
    background:
        linear-gradient(#f5f5dc 1px, transparent 1px),
        linear-gradient(90deg, #f5f5dc 1px, transparent 1px),
        linear-gradient(#e8e8d0 2px, transparent 2px),
        linear-gradient(90deg, #e8e8d0 2px, transparent 2px),
        #fafaf5;
    background-size: 12px 12px, 12px 12px, 48px 48px, 48px 48px;
}

.layer-thumb-standard::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 3px;
    background: #ffcc00;
    transform: rotate(-15deg);
}

.layer-thumb-terrain {
    background: linear-gradient(180deg, #e8d4b8 0%, #c9b896 50%, #a8c4a0 100%);
}

.layer-thumb-terrain::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        /* Contour lines - wavy horizontal */
        repeating-linear-gradient(
            180deg,
            transparent 0px,
            transparent 6px,
            rgba(139, 90, 43, 0.4) 6px,
            rgba(139, 90, 43, 0.4) 7px
        );
}

.layer-thumb-terrain::after {
    content: '';
    position: absolute;
    inset: 0;
    /* Wavy contour effect */
    background:
        radial-gradient(ellipse 80% 20% at 20% 25%, transparent 0%, transparent 50%, rgba(139, 90, 43, 0.2) 50%, rgba(139, 90, 43, 0.2) 52%, transparent 52%),
        radial-gradient(ellipse 60% 15% at 70% 55%, transparent 0%, transparent 50%, rgba(139, 90, 43, 0.25) 50%, rgba(139, 90, 43, 0.25) 53%, transparent 53%),
        radial-gradient(ellipse 90% 25% at 40% 80%, transparent 0%, transparent 50%, rgba(139, 90, 43, 0.2) 50%, rgba(139, 90, 43, 0.2) 52%, transparent 52%);
}

.layer-thumb-satellite {
    background:
        /* Base dark green/brown earth tones */
        linear-gradient(135deg, #2a3d2a 0%, #3d4a35 30%, #4a5540 60%, #3a4535 100%);
}

.layer-thumb-satellite::before {
    content: '';
    position: absolute;
    inset: 0;
    /* Grid pattern suggesting roads/fields */
    background:
        linear-gradient(0deg, transparent 0%, transparent 45%, rgba(200, 200, 180, 0.3) 46%, rgba(200, 200, 180, 0.3) 48%, transparent 49%, transparent 100%),
        linear-gradient(90deg, transparent 0%, transparent 30%, rgba(200, 200, 180, 0.25) 31%, rgba(200, 200, 180, 0.25) 33%, transparent 34%, transparent 65%, rgba(200, 200, 180, 0.2) 66%, rgba(200, 200, 180, 0.2) 68%, transparent 69%, transparent 100%);
}

.layer-thumb-satellite::after {
    content: '';
    position: absolute;
    inset: 0;
    /* Field patches and variation */
    background:
        radial-gradient(ellipse 40% 30% at 15% 25%, rgba(60, 80, 50, 0.6) 0%, transparent 100%),
        radial-gradient(ellipse 35% 40% at 75% 70%, rgba(70, 90, 55, 0.5) 0%, transparent 100%),
        radial-gradient(ellipse 25% 20% at 50% 45%, rgba(80, 100, 65, 0.4) 0%, transparent 100%);
}

/* Layer name text - collapsed state shows below thumbnail */
.layer-name {
    font-size: 10px;
    font-weight: 500;
    color: #333;
    text-align: center;
    line-height: 1.2;
}

/* Expand indicator - sits next to thumbnail in collapsed state */
.layer-expand-icon {
    width: 12px;
    height: 12px;
    color: #666;
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 2px;
}

/* Row with thumbnail and arrow */
.layer-thumb-row {
    position: relative;
    display: flex;
    align-items: center;
}

/* Dropdown options panel */
.layer-options {
    display: none;
    padding: 4px;
}

.layer-switcher.expanded .layer-options {
    display: block;
}

/* Individual layer option */
.layer-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.layer-option:hover {
    background: #f0f0f0;
}

.layer-option.active {
    background: #e3f2fd;
}

.layer-option .layer-thumb {
    width: 40px;
    height: 40px;
}

.layer-option-info {
    flex: 1;
}

.layer-option-name {
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.layer-option-desc {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

/* Radio indicator */
.layer-option-radio {
    width: 18px;
    height: 18px;
    border: 2px solid #999;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.layer-option.active .layer-option-radio {
    border-color: #1976d2;
}

.layer-option.active .layer-option-radio::after {
    content: '';
    width: 10px;
    height: 10px;
    background: #1976d2;
    border-radius: 50%;
}

/* ============================================
   Elevation Profile Drawer
   ============================================ */

.elevation-drawer {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.97);
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    margin-left: 40px; /* Offset to right of layer switcher */
    overflow: hidden;
}

.elevation-drawer.collapsed {
    width: auto;
}

.elevation-drawer:not(.collapsed) {
    width: 500px;
}

/* Toggle button (always visible) */
.elevation-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    user-select: none;
    background: linear-gradient(to bottom, #fafafa, #f0f0f0);
}

/* When expanded, add bottom border to separate from chart */
.elevation-drawer:not(.collapsed) .elevation-toggle {
    justify-content: center;
    border-bottom: 1px solid #ddd;
    border-radius: 8px 8px 0 0;
    margin-bottom: 4px;
}

.elevation-toggle:hover {
    background: linear-gradient(to bottom, #fff, #f5f5f5);
}

.elevation-icon {
    color: #666;
    flex-shrink: 0;
}

.elevation-label {
    font-size: 12px;
    font-weight: 500;
    color: #333;
}

.elevation-chevron {
    color: #666;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

/* Chevron rotates when expanded */
.elevation-drawer:not(.collapsed) .elevation-chevron {
    transform: rotate(180deg);
}

/* Content area (hidden when collapsed) */
.elevation-content {
    display: none;
    padding: 0 0 4px 0;
    position: relative;
}

.elevation-drawer:not(.collapsed) .elevation-content {
    display: block;
}

/* Canvas container */
#elevation-canvas {
    width: 100%;
    height: 160px;
    display: block;
    border-radius: 4px;
}

/* Hover tooltip */
.elevation-hover {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    white-space: nowrap;
    z-index: 10;
}

.elevation-hover.visible {
    opacity: 1;
}

/* ============================================
   TOP POSITION VARIANT
   ============================================ */
.elevation-drawer.position-top {
    bottom: auto;
    top: 10px;
    margin-left: 0; /* Center when at top - no layer switcher conflict */
}

/* Reverse gradient for top position */
.elevation-drawer.position-top .elevation-toggle {
    background: linear-gradient(to top, #fafafa, #f0f0f0);
}

.elevation-drawer.position-top .elevation-toggle:hover {
    background: linear-gradient(to top, #fff, #f5f5f5);
}

/* When expanded at top, border goes on top of content */
.elevation-drawer.position-top:not(.collapsed) .elevation-toggle {
    border-bottom: none;
    border-top: 1px solid #ddd;
    border-radius: 0 0 8px 8px;
    margin-bottom: 0;
    margin-top: 4px;
    order: 2; /* Move toggle below content */
}

/* Reorder content to appear above toggle when at top */
.elevation-drawer.position-top:not(.collapsed) {
    display: flex;
    flex-direction: column;
}

.elevation-drawer.position-top:not(.collapsed) .elevation-content {
    order: 1;
    padding: 4px 0 0 0;
}

/* Chevron: points down by default when at top, up when expanded */
.elevation-drawer.position-top .elevation-chevron {
    transform: rotate(180deg);
}

.elevation-drawer.position-top:not(.collapsed) .elevation-chevron {
    transform: rotate(0deg);
}

/* Hide elevation drawer on mobile (JS adds .is-mobile class) */
body.is-mobile .elevation-drawer {
    display: none;
}

/* Narrower drawer for medium viewports (600px iframes) */
@media screen and (min-width: 501px) and (max-width: 700px) {
    .elevation-drawer:not(.collapsed) {
        width: 420px;
        margin-left: 20px;
    }
}

/* Adjust position when sidebar is expanded (desktop) */
@media screen and (min-width: 769px) {
    .elevation-drawer {
        max-width: calc(100vw - 300px);
    }
}

/* ============================================
   TRUCK LOCATION CONTROL & MARKER
   ============================================ */

/* Truck control button - matches zoom/fullscreen styling */
.leaflet-control-truck {
    border: none !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2) !important;
    border-radius: 4px;
    overflow: visible; /* Allow tooltip to show outside container */
}

.leaflet-control-truck-button {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 32px !important;
    height: 32px !important;
    background: white !important;
    text-decoration: none;
    border-radius: 4px;
    padding: 2px;
    transition: background 0.2s;
}

.leaflet-control-truck-button:hover {
    background: #f4f4f4 !important;
}

.truck-control-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    transition: filter 0.2s, opacity 0.2s;
}

/* Offline state - grayed out */
.leaflet-control-truck-button.truck-offline .truck-control-icon {
    filter: grayscale(100%);
    opacity: 0.5;
}

/* Custom tooltip for truck control button */
.truck-control-tooltip {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    z-index: 1000;
}

.truck-control-tooltip.visible {
    opacity: 1;
}

/* Arrow pointing left toward button */
.truck-control-tooltip::before {
    content: '';
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: rgba(0, 0, 0, 0.8);
}

/* Truck marker on map */
.truck-marker-container {
    background: transparent !important;
    border: none !important;
}

.truck-marker-icon {
    width: 48px;
    height: 48px;
    object-fit: contain;
    /* Shadow around icon for contrast against map */
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5))
            drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
    transition: filter 0.3s, opacity 0.3s, transform 0.3s;
}

/* Offline state - grayed out (same filter approach as privacy mode, no opacity) */
.truck-marker-icon.truck-offline {
    filter: grayscale(100%) brightness(1.1) contrast(0.85)
            drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4))
            drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
}

/* Truck tooltip styling */
.truck-tooltip {
    background: rgba(0, 0, 0, 0.8);
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    padding: 6px 10px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.truck-tooltip::before {
    border-top-color: rgba(0, 0, 0, 0.8) !important;
}

.truck-tooltip small {
    display: block;
    opacity: 0.8;
    margin-top: 2px;
}

/* Privacy mode - button styling */
.leaflet-control-truck-button.truck-privacy-mode {
    border: 2px dashed #888 !important;
    position: relative;
    overflow: visible !important;
}

/* Allow asterisk to overflow outside the control container */
.leaflet-control-truck:has(.truck-privacy-mode) {
    overflow: visible !important;
}

.leaflet-control-truck-button.truck-privacy-mode .truck-control-icon {
    /* Gray overlay effect using brightness + saturation reduction */
    filter: grayscale(40%) brightness(1.1) contrast(0.9);
}

/* Asterisk indicator for privacy mode */
.leaflet-control-truck-button.truck-privacy-mode::after {
    content: '*';
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 14px;
    font-weight: bold;
    color: #000;
    line-height: 1;
    /* White outline + red glow */
    text-shadow:
        /* White outline */
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff,
        1px 1px 0 #fff,
        0 -1px 0 #fff,
        0 1px 0 #fff,
        -1px 0 0 #fff,
        1px 0 0 #fff,
        /* Red glow */
        0 0 4px #e53935,
        0 0 8px #e53935;
}

/* Privacy mode - marker icon styling */
.truck-marker-icon.truck-privacy {
    /* Gray overlay effect - 65% desaturation */
    filter: grayscale(65%) brightness(1.1) contrast(0.9)
            drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4))
            drop-shadow(0 2px 6px rgba(0, 0, 0, 0.25));
}

/* Privacy message popup at bottom of screen */
.privacy-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.3s ease;
    max-width: 90%;
}

.privacy-message span {
    display: block;
}

.privacy-message span:first-child {
    font-weight: 500;
}

.privacy-message span:last-child {
    font-size: 11px;
    opacity: 0.9;
    margin-top: 4px;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Offline message popup (same styling as privacy message) */
.offline-message {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(80, 80, 80, 0.9);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: fadeInUp 0.3s ease;
    max-width: 90%;
}

.offline-message span {
    display: block;
}

.offline-message span:first-child {
    font-weight: 500;
}

.offline-message span:last-child {
    font-size: 11px;
    opacity: 0.9;
    margin-top: 4px;
}
