/**
 * Air Quality Map Widget Styles
 *
 * @package fhdesignsElementorWidgets
 * @since 1.0.0
 */

/* =============================================
   Widget Container
   ============================================= */
.aqi-map-widget {
    position: relative;
    width: 100%;
}

.aqi-map-title {
    margin: 0 0 20px 0;
    font-weight: 600;
}

/* =============================================
   Map Container
   ============================================= */
.aqi-map-container {
    position: relative;
    width: 100%;
    height: 500px;
    background-color: #e5e7eb;
    overflow: hidden;
    z-index: 1;
}

.aqi-map-container .leaflet-container {
    width: 100%;
    height: 100%;
    font-family: inherit;
}

/* =============================================
   Loading State
   ============================================= */
.aqi-loading,
.aqi-panel-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: rgba(255, 255, 255, 0.9);
    z-index: 1000;
}

.aqi-panel-loading {
    position: relative;
    padding: 40px 20px;
    background: transparent;
}

.aqi-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: aqi-spin 1s linear infinite;
    margin-bottom: 12px;
}

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

.aqi-loading span,
.aqi-panel-loading span {
    color: #6b7280;
    font-size: 14px;
}

/* =============================================
   Search Container
   ============================================= */
.aqi-search-container {
    display: flex;
    gap: 8px;
    margin-bottom: 15px;
}

.aqi-search-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.aqi-search-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.aqi-search-input::placeholder {
    color: #9ca3af;
}

.aqi-search-btn,
.aqi-location-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    padding: 0;
    background-color: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.aqi-search-btn:hover,
.aqi-location-btn:hover {
    background-color: #2563eb;
}

.aqi-search-btn:active,
.aqi-location-btn:active {
    transform: scale(0.95);
}

.aqi-location-btn {
    background-color: #10b981;
}

.aqi-location-btn:hover {
    background-color: #059669;
}

/* =============================================
   Legend
   ============================================= */
.aqi-legend {
    background-color: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 15px 20px;
    margin-top: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.aqi-legend-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 12px;
    color: #1f2937;
}

.aqi-legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
}

.aqi-legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.aqi-legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
}

.aqi-legend-label {
    color: #4b5563;
    white-space: nowrap;
}

/* =============================================
   Notice / Error State
   ============================================= */
.aqi-map-notice {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 20px;
}

.aqi-notice-content {
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

.aqi-notice-icon {
    font-size: 28px;
    line-height: 1;
    color: #d97706;
}

.aqi-notice-text strong {
    display: block;
    color: #92400e;
    font-size: 16px;
    margin-bottom: 8px;
}

.aqi-notice-text p {
    margin: 0 0 10px 0;
    color: #78350f;
    font-size: 14px;
}

.aqi-notice-text a {
    color: #d97706;
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
}

.aqi-notice-text a:hover {
    text-decoration: underline;
}

.aqi-panel-error {
    padding: 20px;
    text-align: center;
    color: #dc2626;
}

/* =============================================
   Info Panel (Enhanced Station Details)
   ============================================= */
.aqi-info-panel {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 380px;
    max-width: calc(100% - 20px);
    max-height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 1001;
    overflow: hidden;
}

.aqi-info-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 20px;
    line-height: 1;
    color: #6b7280;
    transition: background-color 0.2s;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aqi-info-close:hover {
    background: rgba(0, 0, 0, 0.2);
    color: #374151;
}

.aqi-info-content {
    max-height: calc(500px - 20px);
    overflow-y: auto;
    overflow-x: hidden;
}

/* =============================================
   Detail Panel Structure
   ============================================= */
.aqi-detail-panel {
    padding: 0 0 20px 0;
}

.aqi-detail-header {
    padding: 15px 50px 10px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.aqi-detail-station {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
    line-height: 1.3;
}

/* Main AQI Display */
.aqi-detail-main {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px;
    margin: 0;
}

.aqi-detail-face {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
}

.aqi-emoji {
    width: 100%;
    height: 100%;
}

.aqi-detail-value-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.aqi-detail-value {
    font-size: 42px;
    font-weight: 700;
    line-height: 1;
}

.aqi-detail-label {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
}

/* Update Time */
.aqi-detail-updated {
    padding: 10px 20px 15px;
    font-size: 13px;
    color: #6b7280;
    border-bottom: 1px solid #e5e7eb;
}

.aqi-update-label {
    color: #9ca3af;
}

.aqi-update-time {
    font-weight: 600;
    color: #374151;
}

.aqi-update-exact {
    color: #9ca3af;
    font-size: 12px;
}

/* Detail Sections */
.aqi-detail-section {
    padding: 15px 20px;
    border-bottom: 1px solid #e5e7eb;
}

.aqi-detail-section:last-child {
    border-bottom: none;
}

/* =============================================
   Hourly Chart
   ============================================= */
.aqi-chart-header {
    margin-bottom: 8px;
}

.aqi-chart-time-labels {
    display: flex;
    justify-content: space-between;
    padding-left: 55px;
    font-size: 11px;
    color: #9ca3af;
}

.aqi-chart-row {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.aqi-chart-label {
    width: 45px;
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    flex-shrink: 0;
}

.aqi-hourly-chart {
    flex: 1;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    height: 50px;
    background: #f9fafb;
    border-radius: 4px;
    padding: 4px;
}

.aqi-bar {
    flex: 1;
    min-width: 3px;
    max-width: 8px;
    border-radius: 2px 2px 0 0;
    transition: height 0.2s;
}

.aqi-bar-good {
    background-color: #8cb26c;
}

.aqi-bar-moderate {
    background-color: #ecc4a5;
}

.aqi-bar-unhealthy-sensitive {
    background-color: #c45224;
}

.aqi-bar-unhealthy {
    background-color: #821a08;
}

.aqi-bar-very-unhealthy {
    background-color: #500a04;
}

.aqi-bar-hazardous {
    background-color: #2d0602;
}

/* =============================================
   5-Day Forecast
   ============================================= */
.aqi-forecast {
    display: flex;
    justify-content: space-between;
    gap: 8px;
}

.aqi-forecast-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
}

.aqi-forecast-label {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 500;
}

.aqi-forecast-face {
    width: 44px;
    height: 44px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

.aqi-forecast-face .aqi-emoji {
    width: 100%;
    height: 100%;
}

.aqi-forecast-range {
    font-size: 11px;
    color: #6b7280;
    font-weight: 500;
}

/* =============================================
   Pollutants Grid
   ============================================= */
.aqi-pollutants-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
}

.aqi-pollutant-item {
    background: #f9fafb;
    border-radius: 8px;
    padding: 10px 8px;
    text-align: center;
}

.aqi-pollutant-label {
    display: block;
    font-size: 11px;
    color: #9ca3af;
    margin-bottom: 4px;
    font-weight: 500;
}

.aqi-pollutant-value {
    font-size: 14px;
    font-weight: 600;
    color: #374151;
}

.aqi-no-pollutants {
    font-size: 13px;
    color: #9ca3af;
    text-align: center;
    margin: 0;
}

/* =============================================
   More Info Button
   ============================================= */
.aqi-more-info-btn {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    text-decoration: none;
    transition: background-color 0.2s, border-color 0.2s;
}

.aqi-more-info-btn:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
    color: #1f2937;
    text-decoration: none;
}

/* =============================================
   Source Attribution
   ============================================= */
.aqi-detail-source {
    padding: 12px 20px;
    background: #f9fafb;
    font-size: 12px;
    color: #6b7280;
    display: flex;
    align-items: center;
    gap: 8px;
}

.aqi-source-icon {
    font-size: 16px;
}

/* =============================================
   AQI Level Colors
   ============================================= */
.aqi-level-good {
    background-color: #e4f0d0;
    color: #3d6b2e;
}

.aqi-level-moderate {
    background-color: #f7e4d2;
    color: #7a3b1e;
}

.aqi-level-unhealthy-sensitive {
    background-color: #f0d0be;
    color: #7a2e0e;
}

.aqi-level-unhealthy {
    background-color: #d4a090;
    color: #2d0602;
}

.aqi-level-very-unhealthy {
    background-color: #500a04;
    color: #f2edd0;
}

.aqi-level-hazardous {
    background-color: #2d0602;
    color: #f2edd0;
}

/* =============================================
   Map Markers
   ============================================= */
.aqi-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 700;
    color: white;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.aqi-marker:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 1000 !important;
}

.aqi-marker-good {
    background-color: #8cb26c;
    color: #2c4a1e;
}

.aqi-marker-moderate {
    background-color: #ecc4a5;
    color: #7a3b1e;
}

.aqi-marker-unhealthy-sensitive {
    background-color: #c45224;
    color: white;
}

.aqi-marker-unhealthy {
    background-color: #821a08;
    color: white;
}

.aqi-marker-very-unhealthy {
    background-color: #500a04;
    color: #f2edd0;
}

.aqi-marker-hazardous {
    background-color: #2d0602;
    color: #f2edd0;
}

/* =============================================
   Editor Preview
   ============================================= */
.aqi-editor-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    color: #0369a1;
}

.aqi-preview-icon {
    margin-bottom: 15px;
    opacity: 0.6;
}

.aqi-editor-preview p {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 5px 0;
}

.aqi-editor-preview span {
    font-size: 14px;
    opacity: 0.7;
}

/* =============================================
   Responsive Styles
   ============================================= */
@media (max-width: 768px) {
    .aqi-legend-items {
        flex-direction: column;
        gap: 8px;
    }

    .aqi-info-panel {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 70vh;
    }

    .aqi-info-content {
        max-height: calc(70vh - 20px);
    }

    .aqi-pollutants-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .aqi-search-container {
        flex-wrap: wrap;
    }

    .aqi-search-input {
        flex: 1 1 100%;
        order: 1;
    }

    .aqi-search-btn,
    .aqi-location-btn {
        flex: 1;
        order: 2;
    }

    .aqi-forecast-face {
        width: 38px;
        height: 38px;
    }

    .aqi-detail-value {
        font-size: 36px;
    }

    .aqi-detail-label {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .aqi-marker {
        width: 30px;
        height: 30px;
        font-size: 10px;
    }

    .aqi-pollutants-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .aqi-forecast {
        flex-wrap: wrap;
        justify-content: center;
    }

    .aqi-forecast-day {
        flex: 0 0 auto;
        width: calc(20% - 6px);
        min-width: 55px;
    }

    .aqi-detail-face {
        width: 50px;
        height: 50px;
    }

    .aqi-detail-value {
        font-size: 32px;
    }
}

/* =============================================
   Animation for station pulse
   ============================================= */
.aqi-marker-pulse {
    animation: aqi-pulse 2s ease-in-out infinite;
}

@keyframes aqi-pulse {
    0%, 100% {
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 0 0 8px rgba(59, 130, 246, 0.2);
    }
}

/* =============================================
   Leaflet Control Customization
   ============================================= */
.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
}

.leaflet-control-zoom a {
    background-color: white !important;
    color: #374151 !important;
    border-radius: 0 !important;
    width: 34px !important;
    height: 34px !important;
    line-height: 34px !important;
    font-size: 18px !important;
}

.leaflet-control-zoom a:first-child {
    border-radius: 8px 8px 0 0 !important;
}

.leaflet-control-zoom a:last-child {
    border-radius: 0 0 8px 8px !important;
}

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

.leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.8) !important;
    padding: 3px 8px !important;
    font-size: 11px !important;
}

/* =============================================
   Scrollbar Styling for Info Panel
   ============================================= */
.aqi-info-content::-webkit-scrollbar {
    width: 6px;
}

.aqi-info-content::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.aqi-info-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.aqi-info-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
