/* Location Modal Styles */
.loc-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.loc-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loc-modal-content {
    background: #fff;
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
    animation: loc-modal-slide-up 0.3s ease;
}

@keyframes loc-modal-slide-up {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.loc-modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.loc-modal-header h2 {
    margin: 0;
    font-size: 1.2rem;
    font-family: sagonamedium, "Open Sans", serif;
    color: #4e3027;
    line-height: 1.3;
}

.loc-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

.loc-modal-body {
    padding: 20px;
    padding-bottom: 30px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.loc-modal-body p {
    font-family: focoregular, "Segoe UI", Arial, sans-serif;
    font-size: 0.95rem;
    color: #666;
    margin: 0 0 15px 0;
    line-height: 1.4;
}

.loc-state-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
}

.loc-state-btn {
    padding: 10px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-family: focoregular, "Segoe UI", Arial, sans-serif;
    font-size: 0.9rem;
    color: #444;
    transition: all 0.2s ease;
    text-align: center;
    line-height: 1.2;
    min-height: 54px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loc-state-btn:hover,
.loc-state-btn.selected {
    border-color: #4e3027;
    background: #fdfaf8;
    color: #4e3027;
    font-weight: bold;
}

.loc-modal-back {
    background: none;
    border: none;
    color: #4e3027;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    margin-bottom: 5px;
    padding: 0;
}

.loc-city-search {
    color: #333333 !important;
    background-color: #ffffff !important;
    -webkit-text-fill-color: #333333 !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    opacity: 1 !important;
    width: 100% !important;
    height: 46px !important;
    min-height: 46px !important;
    line-height: normal !important;
    padding: 0 12px !important;
    font-size: 16px !important; /* Prevents iOS zoom and sets explicit size */
    text-indent: 0 !important;
    text-shadow: none !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    margin: 0 0 10px 0 !important;
    font-family: focoregular, "Segoe UI", Arial, sans-serif !important;
    outline: none !important;
    box-sizing: border-box !important;
    display: block !important;
}

.loc-city-search::placeholder {
    color: #999999 !important;
    -webkit-text-fill-color: #999999 !important;
    opacity: 1 !important;
}

.loc-city-search:focus {
    border-color: #4e3027;
}

.loc-city-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 250px;
    overflow-y: auto;
    width: 100%;
    scrollbar-width: thin;
    margin-top: 10px;
    padding-bottom: 20px;
    -webkit-overflow-scrolling: touch;
}

.loc-city-btn {
    text-align: left;
    padding: 12px 15px;
    background: #fcfcfc;
    border: 1px solid #eee;
    border-radius: 4px;
    cursor: pointer;
    font-family: focoregular, "Segoe UI", Arial, sans-serif;
    color: #444 !important;
    transition: background 0.2s;
    font-size: 0.95rem;
    line-height: 1.3;
}

.loc-city-btn:hover {
    background: #f0f0f0;
    border-color: #ddd;
}

/* Mobile optimizations */
@media (max-width: 480px) {
    .loc-modal-content {
        width: 95%;
        max-height: 85vh; /* Safer max-height for mobile Safari */
        margin-bottom: env(safe-area-inset-bottom, 20px);
    }

    .loc-modal-header {
        padding: 15px;
    }

    .loc-modal-body {
        padding: 15px;
        padding-bottom: 60px; /* Ensure last items are clickable above iOS bottom bar */
    }

    .loc-state-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 8px;
    }

    .loc-state-btn {
        padding: 10px;
        font-size: 0.85rem;
    }

    .loc-city-search {
    color: #333 !important;
    background-color: #fff !important;
        padding: 10px;
    }

    .loc-city-btn {
        padding: 8px 12px;
    }
}