/**
 * Base Styles - Consolidated from base.html inline styles
 *
 * WHY: Moved from inline <style> blocks to external file to enable browser caching.
 * Previously, 54KB of CSS was sent with every page load.
 * Now browsers cache this file, reducing egress significantly for repeat visitors.
 *
 * NOTE: CSS variables for background images are set inline in base.html because
 * they use Django's {% static %} template tag.
 */

/* =================================================================
   BOOTSTRAP ICONS - CALENDAR ICON BLOCKING
   Consolidated from 50+ individual rules to single attribute selector
   ================================================================= */
@import url('https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css');

/* Block ALL calendar icon content with single rule */
[class*="bi-calendar"]::before {
    content: "" !important;
    display: none !important;
}

/* Hide calendar icon elements entirely */
[class*="bi-calendar"] {
    display: none !important;
    visibility: hidden !important;
}

/* Hide dropdown toggle arrows */
.dropdown-toggle::after,
.dropdown-toggle::before,
button[data-bs-toggle="dropdown"]::before,
button[data-bs-toggle="dropdown"]::after {
    display: none !important;
    content: none !important;
}

/* =================================================================
   GROK LOGO DARK/LIGHT MODE SWITCHING
   ================================================================= */
.grok-icon-light {
    display: inline-block !important;
}

.grok-icon-dark {
    display: none !important;
}

html[data-bs-theme="dark"] .grok-icon-light {
    display: none !important;
}

html[data-bs-theme="dark"] .grok-icon-dark {
    display: inline-block !important;
}

/* =================================================================
   BODY AND HTML BASE STYLES
   ================================================================= */
body,
html {
    height: 100%;
    margin: 0;
    display: flex;
    flex-direction: column;
    font-family: 'Roboto', sans-serif;
}

body {
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    background-attachment: fixed;
}

/* Mobile background */
@media (max-width: 768px) {
    body {
        background-image: var(--bg-image-mobile) !important;
        background-position: center center !important;
        background-size: cover !important;
        background-attachment: fixed !important;
    }
}

/* WebP support with fallback */
@supports (background-image: url("data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAwA0JaQAA3AA/vuUAAA=")) {
    body {
        background-image: var(--bg-image);
    }
}

@supports not (background-image: url("data:image/webp;base64,UklGRiQAAABXRUJQVlA4IBgAAAAwAQCdASoBAAEAAwA0JaQAA3AA/vuUAAA=")) {
    body {
        background-image: var(--bg-image-fallback);
    }
}

body.bg-loaded {
    transition: background-image 0.3s ease-in-out;
}

/* =================================================================
   PURPLE HERO SECTIONS
   ================================================================= */
.location-hero,
.location-hero *,
.location-hero h1, .location-hero h2, .location-hero h3,
.location-hero h4, .location-hero h5, .location-hero h6,
.location-hero p, .location-hero span, .location-hero a, .location-hero div,
.purple-hero-box,
.purple-hero-box *,
.purple-hero-box h1, .purple-hero-box h2, .purple-hero-box h3,
.purple-hero-box h4, .purple-hero-box h5, .purple-hero-box h6,
.purple-hero-box p, .purple-hero-box span, .purple-hero-box a, .purple-hero-box div {
    color: white !important;
}

/* Disable background images for bots */
.bot-optimized body {
    background-image: none !important;
}

/* =================================================================
   CONTAINER STYLES
   ================================================================= */
.container {
    max-width: 1100px;
    margin: 20px auto;
    background-color: rgba(var(--bs-body-bg-rgb), 0.92);
    padding: 30px;
    border-radius: 8px;
    flex-grow: 1;
    width: 95%;
    color: var(--bs-body-color);
}

.error {
    color: var(--bs-danger);
}

nav ul {
    list-style: none;
    padding: 0;
}

nav ul li {
    display: inline;
    margin-right: 10px;
}

/* =================================================================
   CARD STYLES
   ================================================================= */
.card {
    background-color: var(--bs-card-bg);
    border: var(--bs-border-width) solid var(--bs-border-color);
    padding: 15px;
    margin-bottom: 15px;
    border-radius: var(--bs-card-border-radius);
}

.card-header {
    font-weight: bold;
    margin-bottom: 10px;
}

/* =================================================================
   FOOTER STYLES
   ================================================================= */
.page-footer {
    position: fixed;
    bottom: 10px;
    right: 10px;
    background-color: rgba(var(--bs-tertiary-bg-rgb), 0.8);
    padding: 5px 10px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    display: flex;
    align-items: center;
}

.page-footer ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
}

.page-footer ul li {
    margin-left: 10px;
}

.page-footer ul li:first-child {
    margin-left: 0;
}

/* =================================================================
   THEME SWITCH
   ================================================================= */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    margin-left: 15px;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: #0d6efd;
}

input:focus+.slider {
    box-shadow: 0 0 1px #0d6efd;
}

input:checked+.slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 28px;
}

.slider.round:before {
    border-radius: 50%;
}

.theme-label {
    margin-left: 8px;
    font-size: 0.9em;
    color: var(--bs-body-color);
}

/* =================================================================
   TOP NAVIGATION
   ================================================================= */
.top-nav-link {
    color: white !important;
    text-decoration: none;
}

.top-nav-link:hover {
    color: #cccccc !important;
}

/* =================================================================
   SEARCH AUTOCOMPLETE STYLING
   ================================================================= */
[data-bs-theme="light"] input::-webkit-autofill,
[data-bs-theme="light"] input::-webkit-autofill:hover,
[data-bs-theme="light"] input::-webkit-autofill:focus,
[data-bs-theme="light"] input::-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px white inset !important;
    -webkit-text-fill-color: #212529 !important;
    box-shadow: 0 0 0 30px white inset !important;
    background-color: white !important;
    color: #212529 !important;
}

[data-bs-theme="light"] .search-suggestions,
[data-bs-theme="light"] .autocomplete-dropdown,
[data-bs-theme="light"] datalist {
    background-color: white !important;
    color: #212529 !important;
}

[data-bs-theme="dark"] input[type="search"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
}

[data-bs-theme="dark"] .search-suggestions,
[data-bs-theme="dark"] .autocomplete-dropdown,
[data-bs-theme="dark"] datalist {
    background-color: var(--bs-dark) !important;
    color: var(--bs-light) !important;
}

[data-bs-theme="dark"] .suggestion-item,
[data-bs-theme="dark"] .autocomplete-item {
    background-color: var(--bs-dark) !important;
    color: var(--bs-light) !important;
    border-color: var(--bs-gray-700) !important;
}

[data-bs-theme="dark"] .suggestion-item:hover,
[data-bs-theme="dark"] .autocomplete-item:hover {
    background-color: var(--bs-gray-800) !important;
    color: var(--bs-white) !important;
}

[data-bs-theme="dark"] [style*="background: white"],
[data-bs-theme="dark"] [style*="background-color: white"] {
    background-color: var(--bs-dark) !important;
    color: var(--bs-light) !important;
}

/* =================================================================
   HELP BUTTON AND MODAL
   ================================================================= */
#helpButton {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

#helpButton:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

#helpModal .list-group-item.active {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
}

.help-section {
    margin-bottom: 2rem;
    padding-top: 1.5rem;
    border-bottom: 1px solid var(--bs-border-color);
    padding-bottom: 1.5rem;
}

.help-section:last-child {
    border-bottom: none;
}

.help-section h4 {
    color: var(--bs-primary);
    margin-bottom: 1rem;
    font-weight: 500;
}

#helpTabContent {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
    position: relative;
}

@keyframes section-highlight {
    0% { background-color: transparent; }
    30% { background-color: rgba(var(--bs-primary-rgb), 0.15); }
    100% { background-color: transparent; }
}

.highlight-section {
    animation: section-highlight 1s ease-in-out;
    border-radius: 0.25rem;
    padding: 0.25rem;
}

/* =================================================================
   MOBILE HAMBURGER MENU
   ================================================================= */
.mobile-hamburger-btn {
    display: flex !important;
    position: fixed;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1050;
    cursor: pointer;
    gap: 4px;
}

body.map-page .mobile-hamburger-btn,
body.map-page .mobile-nav-overlay,
body.map-page .mobile-nav-panel {
    display: none !important;
}

body.map-page .top-nav-container {
    display: none !important;
}

body.map-page {
    background-image: none !important;
    background-color: #f8f9fa !important;
}

.mobile-hamburger-btn span {
    display: block;
    width: 25px;
    height: 3px;
    background: white;
    border: 2px solid #000 !important;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.5) !important;
    transition: all 0.3s ease;
}

button.mobile-hamburger-btn span {
    background: white !important;
    border: 2px solid #333 !important;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.6) !important;
}

html[data-bs-theme="dark"] .mobile-hamburger-btn span {
    background: white !important;
    border: none !important;
    box-shadow: 0 0 2px rgba(255, 255, 255, 0.3) !important;
}

.mobile-hamburger-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.mobile-hamburger-btn.active span:nth-child(2) {
    opacity: 0;
}

.mobile-hamburger-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* =================================================================
   MOBILE NAVIGATION
   ================================================================= */
.mobile-nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-nav-overlay.active {
    opacity: 1;
    visibility: visible;
}

.mobile-nav-panel {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100vh;
    height: 100dvh;
    background: white;
    z-index: 1041;
    transition: right 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.3);
}

.mobile-nav-panel.active {
    right: 0;
}

.mobile-nav-header {
    padding: 20px;
    background: #4285f4;
    color: white;
}

.mobile-nav-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.mobile-nav-content {
    padding: 20px;
    padding-bottom: 60px;
    min-height: calc(100vh - 40px);
}

.mobile-nav-item {
    display: block;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    font-size: 1.1rem;
}

.mobile-nav-item:hover {
    color: #4285f4;
    text-decoration: none;
}

.mobile-nav-item i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

.mobile-nav-item.theme-toggle.active {
    background-color: #e3f2fd;
    color: #0d6efd;
    font-weight: bold;
}

html[data-bs-theme="dark"] .mobile-nav-item.theme-toggle.active {
    background-color: #1a3a52;
    color: #4dabf7;
}

/* =================================================================
   MAP PAGE FLOATING MENU
   ================================================================= */
.map-page-floating-menu-btn {
    position: fixed;
    top: 15px;
    right: 15px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid #333;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 1050;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #333;
    transition: all 0.3s ease;
}

body.map-page .map-page-floating-menu-btn {
    display: flex !important;
}

.map-page-floating-menu-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    background: rgba(255, 255, 255, 1);
}

html[data-bs-theme="dark"] .map-page-floating-menu-btn {
    background: rgba(33, 37, 41, 0.95);
    color: white;
    border-color: #666;
}

.map-page-floating-nav-panel {
    position: fixed;
    top: 0;
    right: -300px;
    width: 300px;
    height: 100vh;
    background: white;
    z-index: 1040;
    transition: right 0.3s ease;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.3);
    display: none;
}

.map-page-floating-nav-panel.active {
    right: 0;
    display: block;
}

body.map-page .map-page-floating-nav-panel {
    display: block;
}

.map-page-floating-nav-content {
    height: 100%;
    overflow-y: auto;
}

.map-page-floating-nav-header {
    padding: 20px;
    background: #4285f4;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.map-page-floating-nav-header h5 {
    margin: 0;
    font-size: 1.2rem;
}

.map-page-floating-nav-header .btn-close {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    opacity: 1;
}

.map-page-floating-nav-body {
    padding: 20px;
}

.map-page-nav-item {
    display: block;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    font-size: 1.1rem;
    transition: color 0.2s ease;
}

.map-page-nav-item:hover {
    color: #4285f4;
    text-decoration: none;
}

.map-page-nav-item i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
}

html[data-bs-theme="dark"] .map-page-floating-nav-panel {
    background: #2d3748;
}

html[data-bs-theme="dark"] .map-page-nav-item {
    color: #e2e8f0;
    border-bottom-color: #4a5568;
}

html[data-bs-theme="dark"] .map-page-nav-item:hover {
    color: #4dabf7;
}

/* =================================================================
   MOBILE RESPONSIVE
   ================================================================= */
@media (max-width: 768px) {
    .map-view-btn .btn-text,
    .list-view-btn .btn-text {
        display: none;
    }

    .map-view-btn .bi-map-fill.me-2,
    .map-view-btn .bi-map.me-2,
    .list-view-btn .bi-list.me-2,
    .list-view-btn .bi-list-ul.me-2 {
        margin-right: 0 !important;
    }

    .map-view-btn:has(.btn-text),
    .list-view-btn:has(.btn-text) {
        padding: 0.5rem 0.75rem;
    }
}

/* =================================================================
   DARK MODE MOBILE NAV
   ================================================================= */
html[data-bs-theme="dark"] .mobile-nav-panel {
    background: #2d3748;
}

html[data-bs-theme="dark"] .mobile-nav-item {
    color: #e2e8f0;
    border-bottom-color: #4a5568;
}

html[data-bs-theme="dark"] .mobile-nav-item:hover {
    color: #4dabf7;
}

/* =================================================================
   UNIVERSAL NAVBAR SPACING
   ================================================================= */
body:has(.universal-navbar) .container {
    margin-top: 70px !important;
}

@media (max-width: 768px) {
    body:has(.universal-navbar) .container {
        margin-top: 60px !important;
    }
}

/* =================================================================
   SORT INFO POPOVER
   ================================================================= */
.sort-info-popover {
    z-index: 10000 !important;
    max-width: 400px;
}

.popover {
    z-index: 10000 !important;
}

/* =================================================================
   YELLOW DROPDOWN TEXT IN DARK MODE
   ================================================================= */
body[data-bs-theme="dark"] .form-select,
body[data-bs-theme="dark"] select.form-select,
body[data-bs-theme="dark"] select,
html[data-bs-theme="dark"] body .form-select,
html[data-bs-theme="dark"] body select.form-select,
html[data-bs-theme="dark"] body select {
    color: #ffc107 !important;
    background-color: #212529 !important;
    border-color: #495057 !important;
}

body[data-bs-theme="dark"] .form-select option,
body[data-bs-theme="dark"] select option,
html[data-bs-theme="dark"] body .form-select option,
html[data-bs-theme="dark"] body select option {
    color: #ffc107 !important;
    background-color: #212529 !important;
}
