/**
 * Valencia Fallas PWA - Main Stylesheet
 * Mobile-first responsive design for fullscreen map experience
 */

/* ===== CSS RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.4;
    color: #fff;
    background: #000;
    overflow: hidden; /* Prevent page scroll */
}

h1, h2, h3, h4, h5, h6 {
    color: #333;
}

/* ===== SECTION COLOR SYSTEM ===== */
/* Text colors for sections */
.section-e { color: #FF0000; }
.section-1 { color: #FF4500; }
.section-2 { color: #FF8C00; }
.section-3 { color: #FFB300; }
.section-4 { color: #FFD700; }
.section-5 { color: #ADFF2F; }
.section-6 { color: #32CD32; }
.section-7 { color: #00CED1; }
.section-8 { color: #4169E1; }
.section-fc { color: #8A2BE2; }

/* Pin colors for map markers */
.pin-e { background-color: #FF0000; }
.pin-1 { background-color: #FF4500; }
.pin-2 { background-color: #FF8C00; }
.pin-3 { background-color: #FFB300; }
.pin-4 { background-color: #FFD700; }
.pin-5 { background-color: #ADFF2F; }
.pin-6 { background-color: #32CD32; }
.pin-7 { background-color: #00CED1; }
.pin-8 { background-color: #4169E1; }
.pin-fc { background-color: #8A2BE2; }

/* ===== HEADER ===== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: #000;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    max-width: 100%;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
    color: #FF6B35;
    display: flex;
    align-items: center;
    gap: 8px;
}

.fallas-icon {
    font-size: 24px;
}

.header-controls {
    display: flex;
    gap: 8px;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

.btn-primary {
    background: #FF6B35;
    color: white;
}

.btn-primary:hover {
    background: #e55a2e;
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: #FF6B35;
    border: 1px solid #FF6B35;
}

.btn-outline:hover {
    background: #FF6B35;
    color: white;
}

.btn-filter, .btn-stats, .btn-experimental {
    background: #333;
    color: #fff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 13px;
    padding: 6px 12px;
}

.btn-filter:hover, .btn-stats:hover, .btn-experimental:hover {
    background: #600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn-experimental.active {
    background: #FF6B35;
    color: white;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

.btn-link {
    background: none;
    border: none;
    color: #FF6B35;
    font-size: 13px;
    cursor: pointer;
    padding: 4px 8px;
}

.stats-count {
    background: #FF6B35;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    text-align: center;
}

/* ===== PANELS - TWO COLUMN FILTER ===== */
.filter-panel, .stats-panel {
    position: fixed;
    top: 70px;
    right: 16px;
    width: 360px; /* Increased for two columns */
    background: #000;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    transform: translateY(-10px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 999;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
}

.filter-panel.active, .stats-panel.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.filter-content, .stats-content {
    padding: 20px;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.filter-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.filter-actions {
    display: flex;
    gap: 8px;
}

/* ===== TWO-COLUMN SECTION FILTERS ===== */
.filter-sections {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two equal columns */
    grid-template-rows: repeat(12, auto); /* Create 6 rows, adjust as needed */
    grid-auto-flow: column; /* Fill columns vertically first */
    gap: 6px 12px; /* Reduced vertical gap, added horizontal gap */
}

.section-filter {
    display: flex;
    align-items: center;
    gap: 8px; /* Reduced from 10px */
    padding: 6px 8px; /* Reduced padding */
    border-radius: 6px; /* Slightly smaller radius */
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.section-filter:hover {
    background: rgba(255, 107, 53, 0.05);
}

.section-filter input[type="checkbox"] {
    width: 14px; /* Slightly smaller checkbox */
    height: 14px;
    accent-color: #FF6B35;
    flex-shrink: 0; /* Prevent checkbox from shrinking */
}

.section-code {
    font-weight: 600;
    font-size: 12px; /* Slightly smaller text */
    padding: 2px 5px; /* Reduced padding */
    border-radius: 4px;
    background: rgba(0, 0, 0, 0);
    min-width: 22px; /* Reduced from 24px */
    text-align: center;
    flex-shrink: 0; /* Prevent from shrinking */
}

.section-count {
    margin-left: auto;
    font-size: 11px; /* Slightly smaller */
    color: #fff;
    background: rgba(255, 255, 255, 0.1); /* More subtle background */
    padding: 1px 5px; /* Reduced padding */
    border-radius: 8px;
    min-width: 18px; /* Reduced from 20px */
    text-align: center;
    flex-shrink: 0; /* Prevent from shrinking */
}

/* ===== STATS PANEL ===== */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stats-content h3 {
    color: #fff;
}

.stat-item {
    text-align: center;
    padding: 12px;
    background: rgba(255, 107, 53, 0.05);
    border-radius: 8px;
}

.stat-number {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #FF6B35;
}

.stat-label {
    font-size: 11px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stats-sections {
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    padding-top: 16px;
    margin-bottom: 20px;
}

.stats-actions {
    text-align: center;
}

/* ===== MAP ===== */
.map-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden; /* Ensure no scrollbars on map */
}

.map {
    width: 100%;
    height: 100%;
    position: relative;
}

/* ===== LOADING ===== */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 500;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255, 107, 53, 0.3);
    border-top: 3px solid #FF6B35;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 12px;
}

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

/* ===== MODAL ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
    padding-right: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #333;
}

.modal-body {
    padding: 20px;
}

.falla-section {
    margin-bottom: 12px;
}

.section-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: white; /* White text for better contrast */
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); /* Add text shadow for readability */
}

/* Section badge background colors using your rainbow scheme */
.section-badge.section-e { background-color: #FF0000; }
.section-badge.section-1 { background-color: #FF4500; }
.section-badge.section-2 { background-color: #FF8C00; }
.section-badge.section-3 { background-color: #FFB300; }
.section-badge.section-4 { background-color: #FFD700; color: #333; } /* Dark text for yellow */
.section-badge.section-5 { background-color: #ADFF2F; color: #333; } /* Dark text for light green */
.section-badge.section-6 { background-color: #32CD32; }
.section-badge.section-7 { background-color: #00CED1; }
.section-badge.section-8 { background-color: #4169E1; }
.section-badge.section-fc { background-color: #8A2BE2; }

.falla-experimental {
    margin-bottom: 12px;
}

.experimental-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    background: linear-gradient(45deg, #FF6B35, #FF8E53);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    box-shadow: 0 2px 4px rgba(255, 107, 53, 0.3);
}

.falla-artist {
    margin-bottom: 20px;
    color: #666;
    font-style: italic;
}

.falla-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.falla-coordinates {
    font-size: 11px;
    color: #999;
    text-align: center;
    padding-top: 12px;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* ===== OVERLAY ===== */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 998;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===== PWA INSTALL PROMPT ===== */
.install-prompt {
    position: fixed;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    z-index: 1500;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.install-content {
    padding: 16px 20px;
    text-align: center;
    color: #333;
}

.install-content p {
    margin-bottom: 12px;
    font-size: 14px;
}

.install-content .btn {
    margin: 0 4px;
}

/* ===== USER LOCATION PULSING ANIMATION ===== */
@keyframes locationPulse {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.4;
    }
    100% {
        transform: scale(1);
        opacity: 0.8;
    }
}

.user-location-marker {
    animation: locationPulse 2s ease-in-out infinite;
    transform-origin: center center;
}

/* ===== ENHANCED MAP CONTROLS ===== */
.gm-style-cc {
    display: none !important;
}

/* Hide specific unwanted controls instead of all gmnoprint elements */
.gm-style .gm-style-cc,
.gm-style [title="Open this area in Google Maps (opens a new window)"],
.gm-style [title="Toggle fullscreen view"],
.gm-style [aria-label="Keyboard shortcuts"] {
    display: none !important;
}

/* Keep the controls we want visible */
.gm-style .gmnoprint .gm-bundled-control {
    display: block !important;
}

/* Style the Google Maps controls */
.gm-style button {
    transition: all 0.2s ease !important;
}

.gm-style button:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,.3) !important;
}

/* Make zoom controls larger and more accessible on mobile */
@media (max-width: 768px) {
    .gm-style .gmnoprint div[title="Zoom in"],
    .gm-style .gmnoprint div[title="Zoom out"] {
        width: 44px !important;
        height: 44px !important;
        font-size: 18px !important;
    }
}

/* Style the custom night mode and location controls */
.gm-style [title="Toggle Night Mode"],
.gm-style [title="Switch to Day Mode"],
.gm-style [title="Switch to Night Mode"],
.gm-style [title="Go to My Location"] {
    transition: all 0.2s ease !important;
    font-size: 18px !important;
}

.gm-style [title="Toggle Night Mode"]:hover,
.gm-style [title="Switch to Day Mode"]:hover,
.gm-style [title="Switch to Night Mode"]:hover,
.gm-style [title="Go to My Location"]:hover {
    background-color: #f5f5f5 !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(0,0,0,.4) !important;
}

/* Improve the visibility of controls on night mode */
.gm-style button {
    backdrop-filter: blur(10px) !important;
}

/* Ensure controls are properly positioned */
.gm-style .gmnoprint {
    z-index: 1000 !important;
}

/* Style fullscreen control */
.gm-style .gm-fullscreen-control {
    right: 12px !important;
    top: 12px !important;
}

/* Add subtle border radius to map controls on larger screens */
@media (min-width: 769px) {
    .gm-style button {
        border-radius: 6px !important;
    }
}

/* Improve marker visibility in night mode */
.gm-style .gm-style-iw {
    background-color: rgba(33, 33, 33, 0.95) !important;
    color: #fff !important;
    border-radius: 8px !important;
}

.gm-style .gm-style-iw-d {
    color: #fff !important;
}

/* Custom positioning for mobile landscape */
@media (orientation: landscape) and (max-height: 500px) {
    .gm-style .gmnoprint {
        margin: 5px !important;
    }

    .gm-style [title="Toggle Night Mode"],
    .gm-style [title="Switch to Day Mode"],
    .gm-style [title="Switch to Night Mode"],
    .gm-style [title="Go to My Location"] {
        width: 36px !important;
        height: 36px !important;
        font-size: 16px !important;
        line-height: 32px !important;
    }
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 480px) {
    .header-content {
        padding: 10px 12px;
    }

    .header-title {
        font-size: 18px;
    }

    .filter-panel, .stats-panel {
        right: 12px;
        left: 12px;
        width: auto; /* Full width on mobile */
    }

    /* Keep two columns even on mobile - they'll just be narrower */
    .filter-sections {
        grid-template-columns: 1fr 1fr;
        gap: 4px 8px; /* Even smaller gaps on mobile */
    }

    .section-filter {
        padding: 5px 6px; /* Even more compact on mobile */
        gap: 6px;
    }

    .section-code {
        font-size: 11px;
        min-width: 20px;
    }

    .section-count {
        font-size: 10px;
        min-width: 16px;
    }

    .falla-actions {
        grid-template-columns: 1fr;
    }

    .stats-summary {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }

    .stat-item {
        padding: 8px;
    }

    .stat-number {
        font-size: 16px;
    }
}

@media (max-width: 360px) {
    .header-controls {
        gap: 4px;
    }

    .btn-filter, .btn-stats {
        padding: 6px 8px;
        font-size: 12px;
    }

    /* On very small screens, stack vertically for readability */
    .filter-sections {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .section-filter {
        gap: 8px; /* More space when single column */
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
button:focus,
input:focus,
.btn:focus {
    outline: 2px solid #FF6B35;
    outline-offset: 2px;
}

/* ===== UTILITIES ===== */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}