:root {
    --primary-color: #f28e1c;
    /* Beer amber color */
    --secondary-color: #2d3436;
    --text-color: #2d3436;
    --bg-color: #f5f6fa;
    --glass-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(255, 255, 255, 0.3);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --radius: 16px;
    --font-family: 'Inter', sans-serif;
}

body,
html {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    font-family: var(--font-family);
    color: var(--text-color);
    overflow: hidden;
    /* Map takes full screen */
    -webkit-tap-highlight-color: transparent;
}

/* App Header */
.app-header {
    position: absolute;
    top: 15px;
    left: 70px;
    z-index: 1000;
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary-color);
    margin: 0;
    text-shadow: 2px 2px 0px #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff;
    pointer-events: none;
    font-family: var(--font-family);
    /* Ensure it stays on top */
}

/* Map Container */
#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

/* Floating Search Bar (Desktop Default) */
.search-container {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: 95%;
    max-width: 800px;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 12px;
    display: flex;
    gap: 8px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    flex-wrap: wrap;
    align-items: center;
}

.search-input {
    flex-grow: 1;
    border: none;
    background: rgba(255, 255, 255, 0.5);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 16px;
    color: var(--text-color);
    font-family: var(--font-family);
    outline: none;
    transition: background 0.2s ease;
    min-width: 150px;
    height: 48px;
    /* Touch target size */
    box-sizing: border-box;
}

.search-select {
    border: none;
    background: rgba(255, 255, 255, 0.5);
    padding: 0 12px;
    border-radius: 12px;
    font-size: 14px;
    color: var(--text-color);
    font-family: var(--font-family);
    outline: none;
    cursor: pointer;
    transition: background 0.2s ease;
    font-weight: 600;
    height: 48px;
    /* Touch target size */
    box-sizing: border-box;
}

.search-select:focus,
.search-input:focus {
    background: #fff;
    box-shadow: 0 0 0 2px var(--primary-color);
}

.search-btn,
.geo-btn {
    border: none;
    background: var(--primary-color);
    color: white;
    padding: 0 20px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    font-size: 16px;
    transition: transform 0.1s ease, background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    /* Touch target size */
    box-sizing: border-box;
}

.geo-btn {
    background: var(--secondary-color);
    width: 48px;
    /* Square */
    padding: 0;
}

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

.search-btn:active {
    transform: scale(0.96);
}

/* Custom Popup Styles */
.leaflet-popup-content-wrapper {
    background: rgba(255, 255, 255, 0.98);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 0;
}

.leaflet-popup-content {
    margin: 16px;
    font-family: var(--font-family);
    line-height: 1.5;
}

.popup-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--secondary-color);
}

.popup-type {
    display: inline-block;
    padding: 4px 8px;
    background: #ffeaa7;
    color: #d35400;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.popup-link {
    display: inline-block;
    margin-top: 8px;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    padding: 8px 0;
    /* Easier to tap */
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.6);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

    100% {
        transform: rotate(360deg);
    }
}

/* Mobile Optimizations (Bottom Sheet) */
@media (max-width: 768px) {
    .app-header {
        font-size: 1.8rem;
        top: 10px;
        left: 15px;
    }

    .search-container {
        top: auto;
        bottom: 20px;
        /* Move to bottom */
        left: 50%;
        transform: translateX(-50%);
        width: 92%;
        flex-direction: row;
        gap: 8px;
        padding: 10px;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        /* Shadow moving up */
    }

    /* Stack elements in the bottom sheet */
    .search-input {
        width: 100%;
        order: 1;
        /* Input first */
        margin-bottom: 0;
    }

    #search-mode {
        order: 2;
        flex: 1;
    }

    #search-type {
        order: 3;
        flex: 1;
    }

    .search-btn {
        order: 4;
        flex: 2;
    }

    .geo-btn {
        order: 5;
    }

    /* Move leaflet controls (zoom) to top right to avoid overlap */
    .leaflet-top.leaflet-left {
        top: 60px;
        /* Push down below header */
        left: 10px;
    }

    .leaflet-bottom.leaflet-right {
        bottom: 160px;
        /* Push attribution up above search bar */
    }
}

/* Legal Disclaimer */
.legal-disclaimer {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 900;
    /* Below search (1000) but above map (1) */
    background: rgba(255, 255, 255, 0.7);
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 11px;
    color: var(--secondary-color);
    backdrop-filter: blur(4px);
    pointer-events: none;
    /* Let clicks pass through to map if needed, though usually links need clicks. */
    max-width: 300px;
    text-align: right;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

.legal-disclaimer a {
    color: var(--primary-color);
    text-decoration: none;
    pointer-events: auto;
    /* Re-enable clicks for links */
}

.legal-disclaimer p {
    margin: 2px 0;
}

/* Mobile check for disclaimer */
@media (max-width: 768px) {
    .legal-disclaimer {
        /* Move up higher to clear the tall search bottom sheet */
        bottom: 180px;
        right: 10px;
        top: auto;
        z-index: 2000;
        /* Ensure it's on top of everything */
    }
}