/* ============================================
   Map Page Styles - Joe for RTD
   Desktop-first styles for the interactive map
   ============================================ */

/* CSS custom properties for popup configuration */
:root {
    --desktop-popup-offset: 3px;
}

/* Denver street grid background */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('../assets/images/denver-streets.png');
    background-size: contain;
    background-position: top;
    background-repeat: repeat;
    opacity: 0.025;
    pointer-events: none;
    z-index: -1;
}

body {
    position: relative;
}

/* Map-specific styles */
main {
    padding: 0 2rem;
    max-width: 100%;
}

/* Static header - can be scrolled out of view */
header {
    position: relative;
    z-index: 1000;
}

/* Hide the title section on desktop */
.page-title-section {
    display: none;
}

.page-header {
    background-color: white;
    padding: 0.75rem 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.page-header h1 {
    display: none;
}

.page-header p {
    font-size: 1.1rem;
    color: #666;
    max-width: 900px;
    margin: 0 auto;
}

/* Desktop: Map container sized to allow header to scroll out of view */
/* When scrolled, map fills viewport minus footer only */
/* Footer = 0.5rem padding top + 0.5rem padding bottom + ~0.91rem content = ~1.91rem, using 2rem for safety */
.map-container {
    position: relative;
    width: 100%;
    height: calc(100vh - 2rem);
    min-height: calc(100vh - 2rem);
    background-color: #f5f5f5;
    overflow: visible;
}

/* District C boundary watermark on desktop */
.map-watermark {
    display: block;
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: rgba(255, 255, 255, 0.7);
    padding: 0.35rem 0.65rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(246, 135, 31, 0.85);
    z-index: 450;
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

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

.district-info {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    max-width: 350px;
    z-index: 100;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.district-info h3 {
    color: #002F87;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.district-info p {
    color: #444;
    line-height: 1.6;
    margin-bottom: 0.5rem;
}

.district-info .highlight {
    background: linear-gradient(135deg, #41C1EF20 0%, #00948320 100%);
    padding: 0.75rem;
    border-radius: 8px;
    margin-top: 1rem;
    border-left: 3px solid #41C1EF;
}

.district-info .highlight strong {
    color: #002F87;
}

.map-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.map-legend h4 {
    color: #002F87;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.3rem;
}

.legend-color {
    width: 20px;
    height: 12px;
    border-radius: 3px;
    margin-right: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.legend-item span {
    font-size: 0.9rem;
    color: #555;
}

.route-legend {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 0.75rem;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    z-index: 100;
    max-width: 180px;
    transition: all 0.3s ease;
}

.route-legend.minimized {
    padding: 0.5rem;
}

.route-legend.minimized .legend-content {
    display: none;
}

.legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.route-legend.minimized .legend-header {
    margin-bottom: 0;
}

.route-legend h4 {
    color: #002F87;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.legend-toggle {
    background: none;
    border: none;
    color: #002F87;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.legend-toggle:hover {
    opacity: 0.7;
}

.route-legend.minimized .legend-toggle {
    transform: rotate(180deg);
}

.legend-content {
    max-height: 60vh;
    overflow-y: auto;
}

.legend-routes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.legend-section {
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #e0e0e0;
}

.legend-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.legend-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: #002F87;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.legend-route-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.2rem 0.35rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    min-width: 24px;
    text-align: center;
    position: relative;
}

.legend-route-badge.suspended {
    opacity: 0.5;
    background-color: #999999 !important;
}

.legend-route-badge.suspended::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: #333;
    transform: translateY(-50%) rotate(-45deg);
}

.map-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 0.75rem;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    z-index: 100;
    max-width: 200px;
    transition: all 0.3s ease;
}

.map-controls.minimized {
    padding: 0.5rem;
}

.map-controls.minimized .controls-content {
    display: none;
}

.controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.map-controls.minimized .controls-header {
    margin-bottom: 0;
}

.map-controls h4 {
    color: #002F87;
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.controls-toggle {
    background: none;
    border: none;
    color: #002F87;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
}

.controls-toggle:hover {
    opacity: 0.7;
}

.map-controls.minimized .controls-toggle {
    transform: rotate(180deg);
}

.map-controls label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #444;
    cursor: pointer;
}

.map-controls input[type="radio"],
.map-controls input[type="checkbox"] {
    margin-right: 0.5rem;
}

/* Dual range slider styles */
.range-slider-container {
    position: relative;
    height: 30px;
    margin: 0.5rem 0 0.25rem 0;
}

.range-slider-track {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: 6px;
    background: #ddd;
    border-radius: 3px;
}

.range-slider-range {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 6px;
    background: #002F87;
    border-radius: 3px;
}

.range-slider-container input[type="range"] {
    position: absolute;
    width: 100%;
    pointer-events: none;
    -webkit-appearance: none;
    background: transparent;
    top: 50%;
    transform: translateY(-50%);
}

.range-slider-container input[type="range"]::-webkit-slider-thumb {
    pointer-events: auto;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #002F87;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    cursor: pointer;
}

.range-slider-container input[type="range"]::-moz-range-thumb {
    pointer-events: auto;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #002F87;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    cursor: pointer;
}

.range-slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.15rem;
    font-size: 0.8rem;
    color: #666;
}

.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #666;
    z-index: 50;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #41C1EF;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.support-button.back-button {
    background-color: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.support-button.back-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(255, 255, 255, 0.1);
}

/* Mapbox GL controls */
.mapboxgl-ctrl-group {
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

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

.mapboxgl-popup-content {
    border-radius: 12px !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.8) !important;
    padding: 0 !important;
}

/* Desktop-only popup sizing */
@media (min-width: 769px) {
    .mapboxgl-popup-content {
        max-width: 350px !important;
        min-width: 320px !important;
    }
}

.mapboxgl-popup-close-button {
    font-size: 20px !important;
    padding: 8px !important;
    color: #002F87 !important;
}

.popup-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #f5f5f5;
    border-top: 1px solid #ddd;
    gap: 0.5rem;
    border-radius: 0 0 12px 12px;
}

.popup-nav-button {
    background: #002F87;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.2s;
    min-width: 32px;
}

.popup-nav-button:hover:not(:disabled) {
    background: #001f5c;
}

.popup-nav-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.5;
}

.popup-nav-info {
    font-size: 0.85rem;
    color: #666;
    font-weight: 500;
}

.popup-content {
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.routes-list {
    max-height: 300px;
    overflow-y: auto;
    flex: 1;
    margin-top: 0.75rem;
}

.popup-content h3 {
    color: #002F87;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    font-size: 1.1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #FF6900;
}

.popup-content .stop-type {
    display: inline-block;
    background: #41C1EF;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.popup-content .stop-type.rail {
    background: #DC143C;
}

.popup-content p {
    color: #555;
    font-size: 0.9rem;
    margin: 0.3rem 0;
}

.popup-content .stop-code {
    color: #888;
    font-size: 0.85rem;
    margin-top: 0.5rem;
}

.popup-loading {
    padding: 1rem;
    text-align: center;
    color: #888;
    font-size: 0.9rem;
}

.routes-list .label {
    font-weight: 600;
    color: #002F87;
    margin-bottom: 0.75rem;
    display: block;
}

.route-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.route-item:last-child {
    margin-bottom: 0;
}

.route-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #002F87;
    color: white;
    padding: 0.3rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 700;
    min-width: 28px;
    min-height: 28px;
    text-align: center;
    width: fit-content;
    flex-shrink: 0;
}

.route-badge.rail {
    background: #DC143C;
}

.route-directions {
    font-size: 0.8rem;
    color: #666;
    line-height: 1.3;
    flex: 1;
}

.route-directions-label {
    font-weight: 600;
    color: #444;
    margin-right: 0.25rem;
}

/* Compact footer for map page */
footer {
    background-color: #002F87;
    color: white;
    padding: 0.5rem 0;
    text-align: center;
    margin-top: 0;
}

.footer-content {
    padding: 0 1rem;
}

.footer-legal {
    font-size: 0.7rem;
    line-height: 1.3;
    text-align: center;
}

.footer-legal p {
    display: inline;
    margin: 0;
}

.footer-legal p::after {
    content: "•";
    margin: 0 0.5rem;
}

.footer-legal p:last-child::after {
    content: "";
    margin: 0 0;
}

/* Schedule button styles */
.schedule-button {
    display: inline-block;
    background: #002F87;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.schedule-button:hover {
    background: #001f5c;
}

.schedule-button-small {
    display: inline-block;
    background: #666;
    color: white;
    padding: 0.35rem 0.75rem;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.schedule-button-small:hover {
    background: #444;
}

/* Mobile Tabbed Bottom Panel - hidden on desktop */
.mobile-tab-container {
    display: none;
}

/* Route detail popup styles */
.route-detail-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.route-detail-header .route-badge {
    font-size: 1.2rem;
    min-width: 40px;
    min-height: 40px;
    padding: 0.5rem;
}

.route-detail-header h3 {
    margin: 0;
    flex: 1;
}

.route-detail-directions {
    margin-bottom: 0.75rem;
}

.route-detail-schedule {
    margin-top: 0.75rem;
}

.direction-group {
    margin-bottom: 0.5rem;
}

.direction-label {
    font-weight: 600;
    color: #002F87;
    margin-bottom: 0.25rem;
}

.direction-headsign {
    font-size: 0.85rem;
    color: #555;
    margin-left: 1rem;
}

.direction-unavailable {
    color: #888;
    font-style: italic;
}

.stop-schedule-link {
    margin-top: 0.25rem;
}

/* Search box styles */
.map-search-container {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 500px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 500;
    border: 1px solid rgba(255, 255, 255, 0.8);
    overflow: hidden;
}

.search-mode-toggle {
    display: flex;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

.search-mode-btn {
    flex: 1;
    padding: 0.75rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    font-size: 0.9rem;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-mode-btn:hover {
    background: rgba(0, 47, 135, 0.05);
}

.search-mode-btn.active {
    color: #002F87;
    background: white;
    border-bottom-color: #41C1EF;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 1rem 3rem 1rem 1rem;
    border: none;
    font-size: 1rem;
    outline: none;
    background: white;
}

.search-input::placeholder {
    color: #999;
}

.search-clear-btn {
    position: absolute;
    right: 0.75rem;
    background: none;
    border: none;
    color: #666;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
    transition: color 0.2s;
}

.search-clear-btn:hover {
    color: #002F87;
}

.search-results {
    max-height: 400px;
    overflow-y: auto;
    border-top: 1px solid #ddd;
    background: white;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.search-result-item:hover {
    background: #f8f9fa;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-title {
    font-weight: 600;
    color: #002F87;
    margin-bottom: 0.25rem;
}

.search-result-subtitle {
    font-size: 0.85rem;
    color: #666;
}

.search-result-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #002F87;
    color: white;
    padding: 0.2rem 0.4rem;
    border-radius: 3px;
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 24px;
    margin-right: 0.5rem;
}

.search-no-results {
    padding: 1.5rem;
    text-align: center;
    color: #888;
    font-style: italic;
}
