/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body, html {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    height: 100%;
    overflow: hidden;
    color: #333;
}

/* Full screen map */
#map {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Map overlay base styles */
.map-overlay {
    position: absolute;
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Overlay positioning */
.top-left {
    top: 20px;
    left: 20px;
}

.top-right {
    top: 20px;
    right: 20px;
}

.bottom-left {
    bottom: 20px;
    left: 20px;
    max-width: 350px;
}

.bottom-right {
    bottom: 20px;
    right: 20px;
}

/* Search container overlay */
.search-container {
    display: flex;
    gap: 8px;
    padding: 12px;
    min-width: 300px;
    position: relative;
}

.search-container input {
    flex: 1;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    background: rgba(255, 255, 255, 0.9);
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-container input:focus {
    background: rgba(255, 255, 255, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.search-container input::placeholder {
    color: #666;
}

.search-container button {
    padding: 12px 16px;
    background: linear-gradient(135deg, #4a7c59, #2c5530);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-width: 48px;
}

.search-container button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 124, 89, 0.3);
}

/* Autocomplete dropdown */
.autocomplete-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 48px; /* Leave space for search button */
    background: rgba(255, 255, 255, 0.98);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    margin-top: 4px;
}

.autocomplete-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.autocomplete-item:hover,
.autocomplete-item.active {
    background: rgba(74, 124, 89, 0.1);
}

.autocomplete-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.autocomplete-content {
    flex: 1;
    min-width: 0;
}

.autocomplete-text {
    font-weight: 600;
    color: #2c5530;
    font-size: 14px;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.autocomplete-place {
    font-size: 12px;
    color: #666;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.autocomplete-type {
    font-size: 10px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Different styling for mosque vs location suggestions */
.mosque-suggestion {
    border-left: 3px solid #2c5530;
}

.mosque-suggestion .autocomplete-text {
    color: #2c5530;
    font-weight: 700;
}

.mosque-suggestion .autocomplete-type {
    color: #2c5530;
}

.location-suggestion {
    border-left: 3px solid #007cbf;
}

.location-suggestion .autocomplete-text {
    color: #007cbf;
}

.location-suggestion .autocomplete-type {
    color: #007cbf;
}

/* Location button overlay */
.location-btn {
    padding: 12px;
    background: linear-gradient(135deg, #2c5530, #4a7c59);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.location-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 85, 48, 0.3);
}

/* Info panel overlay */
.info-panel {
    padding: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.info-panel h3 {
    color: #2c5530;
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
}

.info-panel p {
    margin: 0 0 8px 0;
    line-height: 1.5;
    font-size: 14px;
    color: #666;
}

.info-panel .mosque-details {
    margin-top: 12px;
}

.info-panel .detail-item {
    padding: 12px;
    background: rgba(248, 249, 250, 0.8);
    border-radius: 6px;
    border-left: 3px solid #4a7c59;
    margin-bottom: 8px;
}

.info-panel .detail-item strong {
    color: #2c5530;
    display: block;
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 600;
}

.info-panel .detail-item a {
    color: #4a7c59;
    text-decoration: none;
    font-weight: 500;
}

.info-panel .detail-item a:hover {
    text-decoration: underline;
}

/* Cache status and controls */
.cache-status {
    margin-top: 12px;
    padding: 8px;
    background: rgba(248, 249, 250, 0.8);
    border-radius: 6px;
    font-size: 11px;
    color: #666;
    border-left: 3px solid #4a7c59;
}

.cache-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
}

.refresh-btn,
.cache-info-btn {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #4a7c59, #2c5530);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-btn:hover,
.cache-info-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74, 124, 89, 0.3);
}

.refresh-btn.loading {
    animation: spin 1s linear infinite;
}

.cache-status.fresh {
    border-left-color: #28a745;
}

.cache-status.stale {
    border-left-color: #ffc107;
}

.cache-status.expired {
    border-left-color: #dc3545;
}

/* Footer */
footer {
    background: #2c5530;
    color: white;
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 3rem;
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #4a7c59;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Responsive design for mobile */
@media (max-width: 768px) {
    .top-left {
        top: 10px;
        left: 10px;
        right: 10px;
    }

    .top-right {
        top: 80px;
        right: 10px;
    }

    .bottom-left {
        bottom: 10px;
        left: 10px;
        right: 10px;
        max-width: none;
    }

    .bottom-right {
        bottom: 10px;
        right: 10px;
    }

    .cache-controls {
        flex-direction: row;
        gap: 6px;
    }

    .refresh-btn,
    .cache-info-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .search-container {
        min-width: auto;
        padding: 10px;
    }

    .search-container input {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    .autocomplete-container {
        right: 8px; /* Adjust for mobile spacing */
    }
}

@media (max-width: 480px) {
    .top-left {
        top: 10px;
        left: 10px;
        right: 60px; /* Make room for location button */
    }

    .top-right {
        top: 10px;
        right: 10px;
    }

    .search-container {
        padding: 8px;
    }

    .search-container input {
        padding: 10px 12px;
        font-size: 16px;
    }

    .autocomplete-container {
        right: 52px; /* Adjust for smaller mobile layout */
    }

    .autocomplete-item {
        padding: 10px 12px;
        gap: 8px;
    }

    .autocomplete-icon {
        font-size: 16px;
        width: 20px;
    }

    .autocomplete-text {
        font-size: 13px;
    }

    .autocomplete-place {
        font-size: 11px;
    }

    .autocomplete-type {
        font-size: 9px;
    }

    .search-container button {
        padding: 10px 12px;
        min-width: 40px;
    }

    .location-btn {
        width: 40px;
        height: 40px;
        padding: 8px;
        font-size: 16px;
    }
}

/* Custom map info window styles */
.custom-info-window {
    max-width: 300px;
    padding: 1rem;
}

.custom-info-window h4 {
    color: #2c5530;
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.custom-info-window p {
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.custom-info-window .mosque-type {
    background: #4a7c59;
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.8rem;
    display: inline-block;
    margin-top: 0.5rem;
}

/* Mapbox popup close button styling */
.mapboxgl-popup-close-button {
    width: 32px !important;
    height: 32px !important;
    font-size: 24px !important;
    line-height: 30px !important;
    text-align: center !important;
    background: rgba(255, 255, 255, 0.95) !important;
    border: 2px solid #e0e0e0 !important;
    border-radius: 50% !important;
    color: #666 !important;
    font-weight: bold !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    top: 8px !important;
    right: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

.mapboxgl-popup-close-button:hover {
    background: #f5f5f5 !important;
    border-color: #ccc !important;
    color: #333 !important;
    transform: scale(1.1) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

.mapboxgl-popup-close-button:active {
    transform: scale(0.95) !important;
}

/* Ensure popup content has proper spacing from close button */
.mapboxgl-popup-content {
    padding: 16px 20px 16px 16px !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    background: rgba(255, 255, 255, 0.98) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    backdrop-filter: blur(10px) !important;
}

/* Mobile responsive close button */
@media (max-width: 768px) {
    .mapboxgl-popup-close-button {
        width: 36px !important;
        height: 36px !important;
        font-size: 26px !important;
        line-height: 34px !important;
        top: 6px !important;
        right: 6px !important;
    }
}
