/**
 * Western Australia Cycling Routes Visualization
 * Styles for the interactive cycling routes map
 */

/* ============================================
   Reset & Base
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'JetBrains Mono', monospace;
    background: #f5f5f0;
    color: #1a1a1a;
    overflow: hidden;
}

/* ============================================
   Map Container
   ============================================ */

#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ============================================
   Overlay System
   ============================================ */

.overlay {
    position: absolute;
    z-index: 100;
    pointer-events: none;
}

/* ============================================
   Back Link
   ============================================ */

.back-link {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 101;
    font-size: 0.75rem;
    color: rgba(0, 0, 0, 0.5);
    text-decoration: none;
    transition: color 0.2s ease;
}

body.dark-mode .back-link {
    color: rgba(255, 255, 255, 0.7);
}

.back-link:hover {
    color: #d97706;
}

/* ============================================
   Header & Title Card
   ============================================ */

.header {
    top: 50px;
    left: 20px;
    right: 20px;
    z-index: 600;
}

.title-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 20px 24px;
    display: inline-block;
    pointer-events: auto;
}

.title-card h1 {
    font-family: 'Instrument Serif', serif;
    font-size: 1.8rem;
    font-weight: 400;
    margin-bottom: 4px;
    color: #d97706;
}

.title-card .subtitle {
    font-size: 0.75rem;
    color: rgba(0, 0, 0, 0.5);
    font-weight: 300;
}

.title-meta {
    margin-top: 8px;
}

.attribution {
    font-size: 0.65rem;
    color: rgba(0, 0, 0, 0.4);
    margin-right: 12px;
}

.methods-link {
    font-size: 0.65rem;
    color: rgba(0, 0, 0, 0.4);
    text-decoration: none;
    transition: color 0.2s ease;
}

.methods-link:hover {
    color: #d97706;
}

/* ============================================
   Location Button
   ============================================ */

.location-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 601;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0, 0, 0, 0.6);
    transition: all 0.2s ease;
}

.location-btn:hover {
    background: rgba(255, 255, 255, 1);
    color: #d97706;
}

.location-btn.active {
    color: #d97706;
    border-color: rgba(217, 119, 6, 0.3);
}

/* ============================================
   Dark Mode Toggle
   ============================================ */

.dark-mode-toggle {
    position: absolute;
    top: 66px;
    right: 20px;
    z-index: 601;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    margin: 0;
}

.toggle-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: relative;
    width: 36px;
    height: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 2px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle-label input[type="checkbox"]:checked+.toggle-slider {
    background: #d97706;
}

.toggle-label input[type="checkbox"]:checked+.toggle-slider::before {
    transform: translateX(16px);
}

.toggle-text {
    font-size: 0.7rem;
    color: rgba(0, 0, 0, 0.7);
    font-weight: 400;
}

.toggle-label:hover .toggle-text {
    color: #d97706;
}

/* User location marker */
.user-location-marker {
    position: relative;
    width: 24px;
    height: 24px;
}

.location-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    background: #d97706;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* ============================================
   Info Panel
   ============================================ */

.info-panel {
    top: 180px;
    left: 20px;
    z-index: 601;
    pointer-events: none;
}

.info-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0;
    min-width: 200px;
    max-width: 400px;
    pointer-events: auto;
    margin-bottom: 10px;
}

/* Info empty state */
.info-empty {
    padding: 0px 0px;
    text-align: center;
    color: rgba(0, 0, 0, 0.5);
    font-size: 0.7rem;
}

.info-empty.hidden {
    display: none !important;
}

/* Info data grid */
.info-data {
    padding: 16px 20px;
}

.info-data.hidden {
    display: none;
}

/* ============================================
   Filters Panel
   ============================================ */

.filters-panel {
    bottom: 20px;
    left: 20px;
    z-index: 600;
}

.filters-card {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 0;
    pointer-events: auto;
}

/* Panel Headers (collapsible) */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.panel-header:hover {
    background: rgba(217, 119, 6, 0.05);
    border-radius: 12px 12px 0 0;
}

.panel-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #d97706;
}

.collapse-icon {
    font-size: 0.8rem;
    color: rgba(0, 0, 0, 0.5);
    transition: transform 0.2s ease;
}

.panel-header.collapsed .collapse-icon {
    transform: rotate(-90deg);
}

/* Panel Content (collapsible) */
.panel-content {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    padding: 16px 20px;
}

.panel-content.collapsed {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    padding: 0 20px;
}

/* Scrollbar styling for panel content */
.panel-content::-webkit-scrollbar {
    width: 6px;
}

.panel-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb {
    background: rgba(217, 119, 6, 0.3);
    border-radius: 3px;
}

.panel-content::-webkit-scrollbar-thumb:hover {
    background: rgba(217, 119, 6, 0.5);
}

.legend-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(0, 0, 0, 0.5);
    margin-top: 0;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
}

.legend-title:first-child {
    border-top: none;
    padding-top: 0;
}

.legend-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 4px;
}

.legend-content.non-interactive .legend-item {
    cursor: default;
}

.legend-content.non-interactive .legend-item:hover {
    background: transparent;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.7rem;
    color: rgba(0, 0, 0, 0.7);
    transition: all 0.2s ease;
}

.legend-item[data-network],
.legend-item[data-hierarchy],
.legend-item[data-linestyle] {
    cursor: pointer;
    padding: 4px 6px;
    margin: -4px -6px;
    border-radius: 6px;
}

.legend-item[data-network]:hover,
.legend-item[data-hierarchy]:hover,
.legend-item[data-linestyle]:hover  {
    background: rgba(217, 119, 6, 0.1);
}

.legend-item[data-network]:not(.active),
.legend-item[data-hierarchy]:not(.active),
.legend-item[data-linestyle]:not(.active) {
    opacity: 0.3;
}

.legend-item[data-network]:not(.active) .legend-line,
.legend-item[data-hierarchy]:not(.active) .legend-line,
.legend-item[data-linestyle]:not(.active) .legend-line-solid,
.legend-item[data-linestyle]:not(.active) .legend-line-dashed {
    opacity: 0.5;
    filter: grayscale(50%);
}

/* Legend Line Samples */
.legend-line {
    width: 30px;
    border-radius: 2px;
    transition: all 0.2s ease;
}

.legend-line-solid {
    width: 30px;
    height: 3px;
    background: linear-gradient(135deg, #d97706, #f59e0b);
    border-radius: 2px;
}

.legend-line-dashed {
    width: 30px;
    height: 3px;
    background-image: repeating-linear-gradient(
        90deg,
        #d97706,
        #d97706 6px,
        transparent 6px,
        transparent 10px
    );
}

/* Legend Checkbox */
.legend-checkbox {
    font-size: 1rem;
    color: #d97706;
    user-select: none;
    transition: all 0.2s ease;
}


.legend-item:not(.active) .legend-checkbox {
    color: rgba(0, 0, 0, 0.3);
}

.legend-item:not(.active) .legend-checkbox::before {
    content: '☐';
}

/* Legend Stats */
.legend-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

/* ============================================
   Geographic Filter
   ============================================ */

/* Geographic Search Container */
.geo-search-container {
    position: relative;
    margin-bottom: 10px;
}

.geo-search-input {
    width: 100%;
    padding: 8px 32px 8px 12px;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 6px;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.5);
    outline: none;
    transition: border-color 0.2s ease, background 0.2s ease;
    font-family: 'JetBrains Mono', monospace;
}

.geo-search-input:focus {
    border-color: #d97706;
    background: rgba(255, 255, 255, 0.9);
}

.search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    opacity: 0.5;
    font-size: 0.9rem;
}

/* Geographic Toggle Buttons */
.geo-toggle-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
}

.geo-toggle-btn {
    flex: 1;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    background: rgba(217, 119, 6, 0.1);
    border: 1px solid rgba(217, 119, 6, 0.3);
    border-radius: 6px;
    color: rgba(0, 0, 0, 0.7);
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

.geo-toggle-btn:hover {
    background: rgba(217, 119, 6, 0.2);
    border-color: rgba(217, 119, 6, 0.5);
    color: #d97706;
}

.geo-toggle-btn:active {
    transform: scale(0.98);
}

/* Geographic Dropdown */
.geo-dropdown {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.5);
    margin-bottom: 10px;
}

/* Section Headers (non-clickable) */
.geo-section-header {
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.05);
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    pointer-events: none;
    user-select: none;
}

.geo-section-header:first-child {
    border-top: none;
}

/* Checkbox List */
.geo-checkbox-list {
    /* Container for checkbox items */
}

/* Checkbox Item */
.geo-checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 0.85rem;
}

.geo-checkbox-item:hover {
    background: rgba(217, 119, 6, 0.1);
}

.geo-checkbox-item.hidden {
    display: none;
}

.geo-checkbox {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: all 0.2s ease;
}

.geo-checkbox-item.active .geo-checkbox {
    background: #d97706;
    border-color: #d97706;
    color: white;
}

.geo-checkbox-item.active .geo-checkbox::before {
    content: '✓';
}

.geo-checkbox-label {
    flex: 1;
    color: rgba(0, 0, 0, 0.8);
}

/* Selection Summary */
.geo-selection-summary {
    padding: 6px 12px;
    font-size: 0.75rem;
    text-align: center;
    color: rgba(0, 0, 0, 0.6);
    background: rgba(217, 119, 6, 0.05);
    border-radius: 4px;
}

/* Scrollbar styling for geo dropdown */
.geo-dropdown::-webkit-scrollbar {
    width: 6px;
}

.geo-dropdown::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.geo-dropdown::-webkit-scrollbar-thumb {
    background: rgba(217, 119, 6, 0.3);
    border-radius: 3px;
}

.geo-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(217, 119, 6, 0.5);
}

.stats-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.stats-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(0, 0, 0, 0.5);
}

.stats-value {
    font-size: 0.9rem;
    font-weight: 300;
    background: linear-gradient(135deg, #d97706, #f59e0b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   Click Marker
   ============================================ */

.click-marker {
    width: 14px;
    height: 14px;
    background: #d97706;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 1000;
}

.click-marker:active {
    transform: scale(0.9);
}

/* ============================================
   MapLibre Popup Styles
   ============================================ */

.maplibregl-popup {
    z-index: 1000 !important;
}

.maplibregl-popup-content {
    background: #ffffff !important;
    border-radius: 8px !important;
    padding: 12px 16px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2) !important;
    font-family: 'JetBrains Mono', monospace;
}

.maplibregl-popup-close-button {
    font-size: 16px;
    color: rgba(0, 0, 0, 0.4);
    padding: 4px 8px;
}

.popup-route-info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    min-width: 200px;
}

.popup-label {
    font-size: 0.7rem;
    color: rgba(0, 0, 0, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.popup-value {
    font-size: 0.75rem;
    color: #d97706;
    font-weight: 400;
}

/* ============================================
   Loading Status
   ============================================ */

.loading-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
    pointer-events: none;
}

.loading-overlay.hidden {
    opacity: 0;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(217, 119, 6, 0.2);
    border-top-color: #d97706;
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.55, 0.055, 0.675, 0.19) infinite;
    margin-bottom: 16px;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.loading-text {
    font-family: 'Instrument Serif', serif;
    font-style: italic;
    font-size: 1.5rem;
    font-weight: 400;
    color: #d97706;
    text-shadow:
        0 0 20px rgba(255, 255, 255, 0.9),
        0 0 10px rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    letter-spacing: 0.02em;
}

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

/* ============================================
   Dark Mode Styles
   ============================================ */

body.dark-mode .title-card,
body.dark-mode .info-card,
body.dark-mode .filters-card,
body.dark-mode .dark-mode-toggle,
body.dark-mode .location-btn {
    background: rgba(30, 30, 30, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .info-empty {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .title-card h1 {
    color: #f59e0b;
}

body.dark-mode .title-card .subtitle,
body.dark-mode .attribution,
body.dark-mode .methods-link,
body.dark-mode .legend-title,
body.dark-mode .legend-item span,
body.dark-mode .stats-label {
    color: rgba(255, 255, 255, 0.7);
}

body.dark-mode .methods-link:hover {
    color: #f59e0b;
}

body.dark-mode .toggle-text {
    color: rgba(255, 255, 255, 0.7);
}

body.dark-mode .toggle-label:hover .toggle-text {
    color: #f59e0b;
}

body.dark-mode .location-btn {
    color: rgba(255, 255, 255, 0.6);
}

body.dark-mode .location-btn:hover {
    background: rgba(50, 50, 50, 0.95);
    color: #f59e0b;
}

body.dark-mode .legend-checkbox {
    color: #f59e0b;
}

body.dark-mode .legend-item:not(.active) .legend-checkbox {
    color: rgba(255, 255, 255, 0.3);
}

body.dark-mode .maplibregl-popup-content {
    background: #2a2a2a !important;
}

body.dark-mode .popup-label {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .popup-value {
    color: #f59e0b;
}

body.dark-mode .maplibregl-popup-close-button {
    color: rgba(255, 255, 255, 0.6);
}

body.dark-mode .panel-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .panel-header h3 {
    color: #f59e0b;
}

body.dark-mode .collapse-icon {
    color: rgba(255, 255, 255, 0.5);
}

body.dark-mode .geo-search-input {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

body.dark-mode .geo-search-input:focus {
    border-color: #f59e0b;
    background: rgba(0, 0, 0, 0.5);
}

body.dark-mode .geo-dropdown {
    background: rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .geo-section-header {
    color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.05);
    border-top-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .geo-checkbox {
    border-color: rgba(255, 255, 255, 0.3);
}

body.dark-mode .geo-checkbox-item.active .geo-checkbox {
    background: #f59e0b;
    border-color: #f59e0b;
}

body.dark-mode .geo-checkbox-label {
    color: rgba(255, 255, 255, 0.8);
}

body.dark-mode .geo-selection-summary {
    color: rgba(255, 255, 255, 0.6);
    background: rgba(245, 158, 11, 0.1);
}

body.dark-mode .geo-toggle-btn {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.3);
    color: rgba(255, 255, 255, 0.7);
}

body.dark-mode .geo-toggle-btn:hover {
    background: rgba(245, 158, 11, 0.2);
    border-color: rgba(245, 158, 11, 0.5);
    color: #f59e0b;
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 768px) {
    .maplibregl-ctrl-attrib.maplibregl-compact {
        display: block;
    }

    .maplibregl-ctrl-attrib.maplibregl-compact::after {
        content: '';
        display: block;
    }

    .maplibregl-ctrl-attrib-inner {
        display: none;
    }

    .maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner {
        display: block;
    }

    .title-card h1 {
        font-size: 1.2rem;
    }

    .title-card {
        padding: 14px 18px;
    }

    .legend-title {
        margin-top: 0;
        padding-top: 12px;
        cursor: pointer;
        user-select: none;
    }

    .legend-title:first-child {
        padding-top: 0;
    }

    .legend-title::after {
        content: ' ▼';
        font-size: 0.6rem;
        opacity: 0.5;
    }

    .legend-title.collapsed::after {
        content: ' ▶';
    }

    .legend-content {
        max-height: 500px;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .legend-content.collapsed {
        max-height: 0;
    }

    .filters-card {
        padding: 0;
    }

    .filters-card .panel-content {
        padding: 12px 16px;
    }

    /* Make dark mode toggle vertical on mobile */
    .dark-mode-toggle {
        padding: 10px 8px;
        width: fit-content;
    }

    .toggle-label {
        flex-direction: column;
        gap: 6px;
        align-items: center;
    }

    .toggle-text {
        font-size: 0.65rem;
        text-align: center;
        max-width: 40px;
        line-height: 1.2;
        word-spacing: 100vw;
    }
}

/* ============================================
   MapLibre Attribution - Force Compact
   ============================================ */

.maplibregl-ctrl-attrib {
    display: none !important;
}

.maplibregl-ctrl-attrib.maplibregl-compact {
    display: block !important;
    min-height: 20px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 12px;
}

.maplibregl-ctrl-attrib-button {
    display: block !important;
}

.maplibregl-ctrl-attrib:not(.maplibregl-compact-show) .maplibregl-ctrl-attrib-inner {
    display: none;
}
