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

:root {
    --royal-blue: #003DA5;
    --royal-blue-dark: #002d7a;
    --royal-blue-light: #0052d9;
    --z-index-header: 1000;
    --z-index-controls: 1001;
    --z-index-search: 1500;
    --z-index-filter: 2000;
    --z-index-modal: 3000;
    --z-index-loading: 9999;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    background-color: #f5f5f5;
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, var(--royal-blue) 0%, var(--royal-blue-dark) 100%);
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: relative;
    z-index: var(--z-index-header);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

h1 {
    font-size: 1.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.store-icon {
    font-size: 1.8rem;
}

/* Font Awesome icon sizing in buttons */
.search-btn i.fa-solid,
.location-btn i.fa-solid,
.reset-btn i.fa-solid {
    font-size: 1.25rem;
    line-height: 1;
}

.footer-button i.fa-solid {
    font-size: 1.5rem;
    line-height: 1;
}

/* Search Container */
.search-container {
    display: flex;
    gap: 0.5rem;
    flex: 1;
    max-width: 600px;
    min-width: 300px;
}

.search-wrapper {
    position: relative;
    flex: 1;
}

#searchInput {
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    height: 48px;
    line-height: 1.5;
}

#searchInput::placeholder {
    color: #999;
}

.search-btn, .reset-btn, .location-btn {
    padding: 0.75rem 1.5rem;
    background: white;
    color: var(--royal-blue);
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    white-space: nowrap;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.search-btn:hover, .reset-btn:hover, .location-btn:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
}

.search-btn:focus, .reset-btn:focus, .location-btn:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

.location-btn.active {
    background: #4CAF50;
    color: white;
}

.location-btn.loading {
    opacity: 0.6;
    cursor: wait;
}

.reset-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
}

.reset-btn:hover {
    background: rgba(255,255,255,0.3);
}

.filter-btn {
    padding: 0.75rem 1rem;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 48px;
    white-space: nowrap;
    font-size: 1rem;
}

.filter-btn:hover {
    background: rgba(255,255,255,0.3);
}

.filter-btn:focus {
    outline: 2px solid white;
    outline-offset: 2px;
}

/* Filter Panel */
.filter-panel {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    padding: 1.5rem;
    min-width: 300px;
    max-width: 400px;
    z-index: var(--z-index-filter);
    display: none;
}

.filter-panel.active {
    display: block;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid #e0e0e0;
}

.filter-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--royal-blue);
}

.close-filter {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close-filter:hover {
    background: #f0f0f0;
}

.close-filter:focus {
    outline: 2px solid var(--royal-blue);
    outline-offset: 2px;
}

.filter-section {
    margin-bottom: 1rem;
}

.filter-section-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
    font-size: 0.9rem;
}

.filter-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.filter-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--royal-blue);
}

.filter-option label {
    cursor: pointer;
    font-size: 0.85rem;
    color: #555;
}

.filter-mode-toggle {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.filter-mode-toggle label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: #333 !important;
    font-weight: 500;
}

.filter-mode-toggle label span {
    user-select: none;
    color: #333 !important;
    white-space: nowrap;
}

.filter-mode-toggle input[type="radio"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--royal-blue);
    flex-shrink: 0;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e0e0e0;
}

.apply-filter, .clear-filter {
    flex: 1;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.apply-filter {
    background: var(--royal-blue);
    color: white;
}

.apply-filter:hover {
    background: var(--royal-blue-dark);
}

.apply-filter:focus, .clear-filter:focus {
    outline: 2px solid var(--royal-blue);
    outline-offset: 2px;
}

.clear-filter {
    background: #f0f0f0;
    color: #666;
}

.clear-filter:hover {
    background: #e0e0e0;
}

/* Search Results */
.search-results {
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    max-height: 400px;
    overflow-y: auto;
    z-index: var(--z-index-search);
    display: none;
}

.search-results.active {
    display: block;
}

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

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

.search-result-item:focus {
    background: #e3f2fd;
    outline: 2px solid var(--royal-blue);
    outline-offset: -2px;
}

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

.result-store-number {
    font-weight: 600;
    color: var(--royal-blue);
    margin-bottom: 0.25rem;
}

.result-address {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 0.25rem;
}

.result-capabilities {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.result-capability-badge {
    background: #e3f2fd;
    color: var(--royal-blue);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.result-distance {
    font-size: 0.85rem;
    color: #4CAF50;
    font-weight: 600;
    margin-top: 0.25rem;
}

.result-hours-status {
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 0.25rem;
}

.result-hours-status.open {
    color: #4CAF50;
}

.result-hours-status.closed {
    color: #d32f2f;
}

.favorite-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    color: #999;
    transition: all 0.2s;
}

.favorite-btn:hover {
    color: var(--royal-blue);
    transform: scale(1.1);
}

.favorite-btn.favorited {
    color: #ff6b00;
}

.favorite-btn:focus {
    outline: 2px solid var(--royal-blue);
    outline-offset: 2px;
    border-radius: 4px;
}

.no-results {
    padding: 2rem;
    text-align: center;
    color: #999;
}

#map {
    width: 100%;
    height: calc(100vh - 90px);
    position: relative;
}

/* Make zoom controls float on top */
.leaflet-control-zoom {
    z-index: var(--z-index-controls) !important;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2) !important;
}

.leaflet-control-zoom a {
    background-color: white !important;
    color: #333 !important;
}

.leaflet-control-zoom a:hover {
    background-color: #f4f4f4 !important;
}

/* Custom marker styling */
.custom-marker {
    background-color: var(--royal-blue);
    width: 32px;
    height: 32px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    border: 3px solid white;
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: all 0.2s ease;
}

.custom-marker:hover {
    transform: rotate(-45deg) scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.custom-marker.highlighted {
    background-color: #ff6b00;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { transform: rotate(-45deg) scale(1); }
    50% { transform: rotate(-45deg) scale(1.15); }
}

/* Popup styling */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 0;
    overflow: hidden;
}

.leaflet-popup-content {
    margin: 0;
    min-width: 280px;
    max-width: 320px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.leaflet-popup {
    margin-bottom: 24px;
}

.leaflet-popup-tip {
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.1);
}

.store-popup {
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    max-height: 400px;
}

.store-header {
    background: linear-gradient(135deg, var(--royal-blue) 0%, var(--royal-blue-dark) 100%);
    color: white;
    padding: 18px 20px;
    position: sticky;
    top: 0;
    z-index: 1;
    flex-shrink: 0;
}

.store-popup-scroll {
    overflow-y: auto;
    flex: 1;
}

.store-number {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.store-body {
    padding: 16px 20px;
}

.store-address {
    margin-bottom: 12px;
    line-height: 1.5;
    color: #444;
    font-size: 0.9rem;
}

.store-phone {
    color: var(--royal-blue);
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    margin-bottom: 12px;
    font-size: 0.9rem;
    transition: all 0.2s;
    padding: 2px 0;
}

.store-phone:hover {
    color: var(--royal-blue-dark);
    text-decoration: underline;
}

.store-phone:focus {
    outline: 2px solid var(--royal-blue);
    outline-offset: 2px;
    border-radius: 3px;
}

.store-hours {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 10px;
}

.store-status {
    display: inline-block;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 6px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.store-status.open {
    background: #d4edda;
    color: #155724;
}

.store-status.closed {
    background: #f8d7da;
    color: #721c24;
}

.user-location-marker {
    background-color: #4CAF50;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 3px solid white;
    box-shadow: 0 0 0 2px #4CAF50, 0 3px 6px rgba(0,0,0,0.3);
}

.user-location-marker::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}

.capabilities {
    margin: 16px 0 0 0;
    padding-top: 16px;
    border-top: 1px solid #e5e5e5;
}

.capabilities-title {
    font-weight: 600;
    margin-bottom: 12px;
    color: #333;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.capability-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    font-size: 0.85rem;
}

.capability {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    color: #555;
    background: #f8f9fa;
    border-radius: 6px;
    transition: background 0.2s;
}

.capability:hover {
    background: #e9ecef;
}

.capability::before {
    content: '✓';
    color: #28a745;
    font-weight: bold;
    margin-right: 8px;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.navigation-links {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 16px;
    padding: 16px 20px 0;
    border-top: 1px solid #e5e5e5;
}

.nav-button {
    padding: 10px 6px;
    text-align: center;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.2s ease;
    color: white !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nav-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.nav-button:focus {
    outline: 3px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.apple-maps {
    background-color: #000;
}

.apple-maps:hover {
    background-color: #222;
}

.google-maps {
    background-color: #4285F4;
}

.google-maps:hover {
    background-color: #5a95f5;
}

.waze {
    background-color: #33CCFF;
}

.waze:hover {
    background-color: #4dd4ff;
}

/* Gas Prices Table */
.gas-prices {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #e5e5e5;
}

.gas-prices-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 4px;
}

.gas-prices-title {
    font-weight: 600;
    color: #333;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gas-prices-generated {
    font-size: 0.7rem;
    color: #888;
    font-weight: normal;
}

.gas-prices-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.gas-prices-table th {
    text-align: left;
    padding: 8px 6px;
    background: #f8f9fa;
    color: #555;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 2px solid #e5e5e5;
}

.gas-prices-table td {
    padding: 8px 6px;
    border-bottom: 1px solid #eee;
    color: #444;
}

.gas-prices-table tr:last-child td {
    border-bottom: none;
}

.gas-prices-table tr:hover td {
    background: #f8f9fa;
}

.gas-prices-table td:nth-child(2) {
    font-weight: 600;
    color: #2e7d32;
}

.gas-prices-table td:nth-child(3) {
    font-size: 0.75rem;
    color: #888;
}

.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem 3rem;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    z-index: var(--z-index-loading);
    text-align: center;
}

.loading-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--royal-blue);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.error-message {
    color: #d32f2f;
    padding: 1rem;
    background: #ffebee;
    border-radius: 8px;
    margin-top: 1rem;
}

.footer-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: var(--z-index-filter);
    box-shadow: 0 -2px 4px rgba(0,0,0,0.08);
}

.footer-button {
    border: none;
    background: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #003DA5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s;
    position: relative;
}

.footer-button:hover {
    color: #0052d9;
    background: #f0f0f0;
}

.footer-button:focus {
    outline: 2px solid var(--royal-blue);
    outline-offset: 2px;
}

.favorite-count {
    position: absolute;
    top: 0;
    right: 0;
    background: #ff6b00;
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

.release-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: var(--z-index-modal);
}

.release-modal.open {
    display: flex;
}

.release-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.4);
}

.release-modal-content {
    position: relative;
    background: #ffffff;
    max-width: 600px;
    width: 90%;
    max-height: 70vh;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    padding: 16px 16px 8px 16px;
    display: flex;
    flex-direction: column;
}

.release-modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    border: none;
    background: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.release-modal-close:hover {
    background: #f0f0f0;
}

.release-modal-close:focus {
    outline: 2px solid var(--royal-blue);
    outline-offset: 2px;
    border-radius: 50%;
}

.release-modal-body {
    margin-top: 24px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Basic markdown-ish styling */
.release-modal-body h1,
.release-modal-body h2,
.release-modal-body h3 {
    margin: 0.5rem 0;
    font-weight: 600;
}

.release-modal-body p {
    margin: 0.4rem 0;
}

.release-modal-body ul {
    padding-left: 1.2rem;
    margin: 0.4rem 0;
}

/* Responsive design */
@media (max-width: 1024px) {
    .search-container {
        max-width: 500px;
    }
}

@media (max-width: 768px) {
    header {
        padding: 0.5rem 0.75rem;
    }

    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    h1 {
        font-size: 1.2rem;
        text-align: center;
    }

    .store-icon {
        font-size: 1.2rem;
    }

    .search-container {
        max-width: 100%;
        min-width: 100%;
        flex-wrap: wrap;
        gap: 0.4rem;
    }

    .search-wrapper {
        flex: 1 1 100%;
        min-width: 100%;
    }

    .search-btn, .location-btn, .reset-btn {
        flex: 1;
        min-width: 0;
        padding: 0.75rem 0.5rem;
    }

    .filter-btn {
        flex: 1;
        min-width: 0;
    }

    .search-results {
        position: fixed;
        left: 0;
        right: 0;
        top: auto;
        width: 80%;
        max-width: 100vw;
    }

    #map {
        height: calc(100vh - 180px);
    }

    .leaflet-popup-content {
        min-width: 260px;
        max-width: 280px;
    }

    .store-popup .navigation-links {
        margin: 0;
        padding: 12px;
        border-bottom: 1px solid #e0e0e0;
        background: #f8f9fa;
    }

    .filter-panel {
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        right: auto;
        margin: 0;
        max-width: 90vw;
    }

    .leaflet-popup-content {
        min-width: 280px;
    }

    .capability-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1rem;
    }

    .store-icon {
        font-size: 1rem;
    }

    .search-btn, .location-btn, .reset-btn, .filter-btn {
        font-size: 0.9rem;
        padding: 0.65rem 0.4rem;
    }

    .store-header {
        padding: 12px;
    }

    .store-body {
        padding: 12px;
    }

    .filter-options {
        grid-template-columns: 1fr;
    }

    .navigation-links {
        grid-template-columns: 1fr;
    }
}

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