/**
 * Mosque Finder - Styles
 * Makkah Compass - https://makkahcompass.org
 */

/* ========================================
   CSS VARIABLES
   ======================================== */

:root {
    --mf-primary: #1B5E20;
    --mf-primary-light: #2E7D32;
    --mf-primary-dark: #0D3B12;
    --mf-gold: #D4A941;
    --mf-gold-light: #E8D5A3;

    --mf-bg: #F8F9FA;
    --mf-surface: #FFFFFF;
    --mf-surface-hover: #F5F5F5;
    --mf-border: #E0E0E0;
    --mf-border-light: #EEEEEE;

    --mf-text: #212121;
    --mf-text-secondary: #666666;
    --mf-text-muted: #9E9E9E;

    --mf-success: #4CAF50;
    --mf-warning: #FF9800;
    --mf-error: #F44336;

    --mf-shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --mf-shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --mf-shadow-lg: 0 8px 24px rgba(0,0,0,0.15);

    --mf-radius-sm: 6px;
    --mf-radius-md: 10px;
    --mf-radius-lg: 16px;

    --mf-transition: all 0.2s ease;
}

/* Dark Mode - matches site theme */
html.dark {
    --mf-primary: #2E7D32;
    --mf-primary-light: #4CAF50;
    --mf-primary-dark: #1B5E20;
    --mf-gold: #D4A941;
    --mf-gold-light: #E8D5A3;

    --mf-bg: #0F1D32;
    --mf-surface: #152238;
    --mf-surface-hover: #1E3050;
    --mf-border: rgba(255, 255, 255, 0.1);
    --mf-border-light: rgba(255, 255, 255, 0.05);

    --mf-text: #F5F5F0;
    --mf-text-secondary: #E8E8E3;
    --mf-text-muted: #94A3B8;

    --mf-shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --mf-shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --mf-shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

/* ========================================
   BASE STYLES
   ======================================== */

.mosque-finder-app {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem;
}

/* ========================================
   RAMADAN BANNER
   ======================================== */

.ramadan-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.875rem 1.25rem;
    background: linear-gradient(135deg, var(--mf-primary) 0%, var(--mf-primary-light) 100%);
    color: white;
    border-radius: var(--mf-radius-md);
    margin-bottom: 1.5rem;
    box-shadow: var(--mf-shadow-md);
}

.banner-icon {
    font-size: 1.25rem;
}

.banner-text {
    font-size: 0.95rem;
}

.banner-text strong {
    color: var(--mf-gold-light);
}

.banner-link {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: var(--mf-gold-light);
    text-underline-offset: 2px;
}

.banner-link:hover {
    text-decoration-thickness: 2px;
}

.ramadan-banner,
.ramadan-banner .banner-text,
.ramadan-banner .banner-icon {
    cursor: default;
}

/* ========================================
   SEARCH SECTION
   ======================================== */

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

.search-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

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

.search-input {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--mf-border);
    border-radius: var(--mf-radius-md);
    background: var(--mf-surface);
    color: var(--mf-text);
    transition: var(--mf-transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--mf-primary);
    box-shadow: 0 0 0 3px rgba(27, 94, 32, 0.15);
}

.search-input::placeholder {
    color: var(--mf-text-muted);
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--mf-surface);
    border: 1px solid var(--mf-border);
    border-radius: var(--mf-radius-md);
    margin-top: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--mf-shadow-lg);
    display: none;
}

.search-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--mf-border-light);
    font-size: 0.9rem;
    color: var(--mf-text);
    transition: var(--mf-transition);
}

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

.search-result-item:hover {
    background: var(--mf-surface-hover);
}

/* GPS Button */
.gps-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    white-space: nowrap;
}

.btn {
    border: none;
    border-radius: var(--mf-radius-md);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: var(--mf-transition);
}

.btn-primary {
    background: var(--mf-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--mf-primary-light);
}

.btn-primary:disabled {
    background: var(--mf-text-muted);
    cursor: not-allowed;
}

.btn-icon {
    font-size: 1.1rem;
}

/* Location Status */
.location-status {
    padding: 0.5rem 0;
    font-size: 0.9rem;
    min-height: 1.5rem;
}

.location-status.success {
    color: var(--mf-primary);
}

.location-status.error {
    color: var(--mf-error);
}

/* ========================================
   FILTER SECTION
   ======================================== */

.filter-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.filter-label {
    font-size: 0.9rem;
    color: var(--mf-text);
    font-weight: 500;
}

.filter-buttons {
    display: flex;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 2px solid var(--mf-border);
    border-radius: var(--mf-radius-sm);
    background: var(--mf-surface);
    color: var(--mf-text);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--mf-transition);
}

.filter-btn:hover {
    border-color: var(--mf-primary);
    color: var(--mf-primary);
}

.filter-btn.active {
    background: var(--mf-primary);
    border-color: var(--mf-primary);
    color: white;
}

/* ========================================
   MAIN CONTENT (MAP + LIST)
   ======================================== */

.main-content {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 1.25rem;
    min-height: 500px;
}

/* Map Container */
.map-container {
    position: relative;
    border-radius: var(--mf-radius-lg);
    overflow: hidden;
    box-shadow: var(--mf-shadow-md);
}

.mosque-map {
    width: 100%;
    height: 100%;
    min-height: 500px;
    background: var(--mf-bg);
}

.map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--mf-surface);
    opacity: 0.95;
    z-index: 500;
}

.map-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--mf-border);
    border-top-color: var(--mf-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.map-loading p {
    margin-top: 1rem;
    color: var(--mf-text-secondary);
    font-size: 0.9rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* List Container */
.list-container {
    display: flex;
    flex-direction: column;
    background: var(--mf-surface);
    border-radius: var(--mf-radius-lg);
    box-shadow: var(--mf-shadow-md);
    overflow: hidden;
}

.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--mf-bg);
    border-bottom: 1px solid var(--mf-border);
}

.list-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--mf-text);
}

.mosque-count {
    font-size: 0.85rem;
    color: var(--mf-text-secondary);
    background: var(--mf-surface-hover);
    padding: 0.25rem 0.75rem;
    border-radius: var(--mf-radius-sm);
}

.mosque-list {
    flex: 1;
    overflow-y: auto;
    min-height: 450px;
    max-height: calc(100vh - 300px);
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--mf-text-muted);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.6;
}

.empty-state p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.5;
}

/* ========================================
   MOSQUE CARD
   ======================================== */

.mosque-card {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--mf-border-light);
    cursor: pointer;
    transition: var(--mf-transition);
}

.mosque-card:hover {
    background: var(--mf-surface-hover);
}

.mosque-card.highlighted {
    background: rgba(46, 125, 50, 0.15);
    border-left: 3px solid var(--mf-primary);
}

html.dark .mosque-card.highlighted {
    background: rgba(46, 125, 50, 0.2);
}

.mosque-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.mosque-name {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--mf-text);
    line-height: 1.3;
}

.mosque-distance {
    flex-shrink: 0;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--mf-primary);
    background: rgba(27, 94, 32, 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: var(--mf-radius-sm);
}

.mosque-address,
.mosque-isha {
    font-size: 0.875rem;
    color: var(--mf-text-secondary);
    margin-bottom: 0.4rem;
    line-height: 1.4;
}

.mosque-isha {
    color: var(--mf-gold);
    font-weight: 500;
}

.mosque-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--mf-text-secondary);
    background: var(--mf-bg);
    border: 1px solid var(--mf-border);
    border-radius: var(--mf-radius-sm);
    text-decoration: none;
    transition: var(--mf-transition);
}

.action-btn:hover {
    background: var(--mf-primary);
    border-color: var(--mf-primary);
    color: white;
}

.directions-btn {
    background: var(--mf-primary);
    border-color: var(--mf-primary);
    color: white;
}

.directions-btn:hover {
    background: var(--mf-primary-light);
}

/* ========================================
   MAP MARKERS
   ======================================== */

/* User location: pulsing blue dot */
.user-location-marker {
    background: transparent;
}

.user-marker-dot {
    width: 18px;
    height: 18px;
    background: #4285F4;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    position: relative;
}

.user-marker-dot::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    background: rgba(66, 133, 244, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulse-ring 2s ease-out infinite;
}

@keyframes pulse-ring {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.2); opacity: 0; }
}

/* Mosque markers: green SVG pin */
.mosque-marker {
    background: transparent;
}

.mosque-marker-pin {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.mosque-marker-pin svg {
    width: 32px;
    height: 32px;
}

/* Map Popups */
.mosque-popup {
    min-width: 180px;
}

.mosque-popup strong {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
    color: var(--mf-text);
}

.popup-distance {
    font-size: 0.8rem;
    color: var(--mf-primary);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.popup-address {
    font-size: 0.8rem;
    color: var(--mf-text-secondary);
    margin-bottom: 0.25rem;
}

.popup-isha {
    font-size: 0.8rem;
    color: var(--mf-gold);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.popup-directions {
    display: inline-block;
    padding: 0.4rem 0.75rem;
    background: var(--mf-primary);
    color: white;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--mf-radius-sm);
    margin-top: 0.5rem;
}

.popup-directions:hover {
    background: var(--mf-primary-light);
}

/* Marker Cluster Styles */
.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background: rgba(27, 94, 32, 0.2);
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    background: var(--mf-primary);
    color: white;
    font-weight: 600;
}

/* ========================================
   ERROR STATE
   ======================================== */

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    text-align: center;
    background: var(--mf-surface);
    border-radius: var(--mf-radius-lg);
    margin-top: 1rem;
    box-shadow: var(--mf-shadow-md);
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.error-state p {
    margin: 0 0 1rem;
    color: var(--mf-text-secondary);
    font-size: 1rem;
    cursor: default;
}

.error-state .error-hint {
    margin: 0 0 1.5rem;
    color: var(--mf-text-muted);
    font-size: 0.875rem;
}

.error-state .error-hint a {
    color: var(--mf-primary);
    text-decoration: underline;
}

/* No-results state */
.no-results-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.no-results-actions .btn {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* GPS button spinner */
.gps-btn .btn-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.gps-btn.detecting {
    opacity: 0.85;
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 900px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .map-container {
        order: 1;
    }

    .mosque-map {
        min-height: 350px;
    }

    .list-container {
        order: 2;
    }

    .mosque-list {
        min-height: auto;
        max-height: 400px;
    }
}

@media (max-width: 600px) {
    .mosque-finder-app {
        padding: 0.75rem;
    }

    .ramadan-banner {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
    }

    .banner-text {
        font-size: 0.875rem;
    }

    .search-row {
        flex-direction: column;
    }

    .gps-btn {
        width: 100%;
        justify-content: center;
    }

    .filter-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .filter-buttons {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }

    .filter-btn {
        padding: 0.5rem 0.5rem;
        font-size: 0.8rem;
    }

    .mosque-map {
        min-height: 300px;
    }

    .mosque-card {
        padding: 0.875rem 1rem;
    }

    .mosque-name {
        font-size: 0.95rem;
    }

    .mosque-actions {
        gap: 0.375rem;
    }

    .action-btn {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
    }
}

/* ========================================
   LEAFLET OVERRIDES
   ======================================== */

.leaflet-popup-content-wrapper {
    border-radius: var(--mf-radius-md);
    box-shadow: var(--mf-shadow-md);
}

.leaflet-popup-content {
    margin: 0.75rem 1rem;
    font-family: inherit;
}

.leaflet-container a.leaflet-popup-close-button {
    color: var(--mf-text-muted);
}

.leaflet-container a.leaflet-popup-close-button:hover {
    color: var(--mf-text);
}

/* Fix for Leaflet tile loading */
.leaflet-tile-container img {
    width: 256px !important;
    height: 256px !important;
}
