/**
 * Universal Map Component Styles
 * 
 * Shared styles for all map implementations (Photography, Hiking, Calima)
 * Ensures consistent appearance across all dashboards
 * 
 * @package CanaryConditionsTheme
 */

/* ==========================================================================
   Universal Marker Styles
   ========================================================================== */

.cc-universal-marker {
    background: transparent;
    border: none;
}

.cc-marker-pin {
    width: 40px;
    height: 40px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 3px 4px rgba(0, 0, 0, 0.2);
    border: 2px solid var(--border-dark);
    transition: transform 0.2s ease;
    cursor: pointer;
}

.cc-marker-pin:hover {
    transform: rotate(-45deg) scale(1.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}
.cc-universal-marker span {
    transform: rotate(45deg);
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

/* Inner dot indicator */
.cc-marker-pin::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    bottom: -4px;
    right: 36px;
}

/* Cluster badge */
.cc-cluster-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: var(--bg-light-gray);
    color: var(--text-primary-light);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    border: 2px solid var(--border-dark);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

/* Scale cluster markers slightly */
.cc-is-cluster .cc-marker-pin {
    transform: rotate(-45deg) scale(1.05);
}

.cc-is-cluster .cc-marker-pin:hover {
    transform: rotate(-45deg) scale(1.15);
}

/* Photography marker specific styles */
.cc-marker-photography {
    /* Photography markers use gradient backgrounds */
}

/* Hiking marker specific styles */
.cc-marker-hiking {
    font-size: 18px;
    font-weight: 900;
}

/* Calima marker specific styles */
.cc-marker-calima {
    font-size: 13px;
}

/* color ways for the markers will be defined in the specific dashboard CSS files */

/* AQI Marker Colors */
.cc-marker-aqi-good { background: var(--status-aqi-good); }
.cc-marker-aqi-moderate { background: var(--status-aqi-moderate); }
.cc-marker-aqi-sensitive { background: var(--status-aqi-sensitive); }
.cc-marker-aqi-unhealthy { background: var(--status-aqi-unhealthy); }
.cc-marker-aqi-very-unhealthy { background: var(--status-aqi-very-unhealthy); }
.cc-marker-aqi-hazardous { background: var(--status-aqi-hazardous); }

.cc-marker-exceptional {background: var(--status-excellent);}
.cc-marker-excellent {background: var(--status-safe);}
.cc-marker-good {background: var(--status-caution);}
.cc-marker-fair {background: var(--status-danger);}
.cc-marker-poor {background: var(--status-extreme);}

.cc-safety-green,.cc-marker-safe {background: var(--status-excellent);}

.cc-safety-yellow,.cc-marker-caution {background: var(--status-caution);}

.cc-safety-red,.cc-marker-unsafe {background: var(--status-extreme);}
.cc-marker-unknown {background: var(--status-neutral);}


.cc-last-updated {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-tertiary-dark);
    font-family: var(--font-data);
}

.update-icon {
    font-size: 16px;
}

.cc-refresh-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--gradient-amber);
    color: var(--bg-volcanic);
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-body);
    transition: var(--transition-smooth);
    box-shadow: var(--shadow-amber);
}

.cc-refresh-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-amber-hover);
}

.cc-refresh-btn.spinning .refresh-icon {
    animation: spin 1s linear infinite;
}

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



/* ==========================================================================
   Universal Popup Styles
   ========================================================================== */

.cc-universal-popup {
    min-width: 220px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.cc-universal-popup h4 {
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    font-size: 16px;
    font-weight: 700;
    color: #333;
    border-bottom: 1px solid #e0e0e0;
}

/* Photography Score Header */
.cc-photo-score-header {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
}

.cc-score-icon {
    font-size: 32px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.cc-score-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cc-score-value {
    font-size: 28px;
    font-weight: 800;
    font-family: var(--font-data);
    line-height: 1;
}

.cc-score-value .score-max {
    font-size: 16px;
    font-weight: 600;
    opacity: 0.6;
    margin-left: 2px;
}

.cc-score-label {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

/* Score Color Variations */
.cc-score-value.cc-photo-score-exceptional {
    color: var(--status-excellent);
}

.cc-score-value.cc-photo-score-excellent {
    color: var(--status-safe);
}

.cc-score-value.cc-photo-score-good {
    color: var(--status-caution);
}

.cc-score-value.cc-photo-score-fair {
    color: var(--status-danger);
}

.cc-score-value.cc-photo-score-poor {
    color: var(--status-extreme);
}

.popup-metric {
    margin: 8px 0;
    font-size: 13px;
    color: var(--text-primary-dark);
    font-family: var(--font-body);
    line-height: 1.5;
}

.popup-metric strong {
    color: var(--accent-amber);
    font-weight: 600;
    font-family: var(--font-heading);
    display: inline-block;
    min-width: 100px;
}

.popup-warnings {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
    font-size: 12px;
}

.popup-warnings ul {
    margin: 5px 0 0 0;
    padding-left: 20px;
}

.popup-warnings li {
    margin: 4px 0;
    color: #d32f2f;
}

.popup-time {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
    font-size: 11px;
    color: #999;
    font-style: italic;
    text-align: right;
}
.calima-aemet-widget.compact {
    margin-top: 10px;
    padding: 10px;
    background: var(--bg-glass-light);
    border-radius: var(--border-radius);
}
.aemet-footer a{
    margin: 10px 0;
    display: flex;
}
.aemet-footer .aemet-attribution{
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}
.aemet-footer .aemet-attribution p{
    margin: 0;
}
.aemet-footer .aemet-badge{
    margin: 0;
    font-size: 11px;
    color: var(--text-tertiary-dark);
}
.aemet-footer .aemet-updated{
    margin: 0;
    font-size: 11px;
    color: var(--text-tertiary-dark);
    font-style: italic;
}

.popup-footer {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

.popup-link {
    display: inline-block;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--accent-amber) 0%, var(--accent-amber-hover) 100%);
    color: var(--text-primary-light);
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
    transition: all 0.2s ease;
}
body .leaflet-popup-content .popup-link {
    color: var(--text-primary-light);
}

.popup-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-amber);
}

body .leaflet-popup-content .popup-link:hover {
    color: var(--text-primary-light);
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.leaflet-popup-content {
    margin: 15px;
}

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

/* ==========================================================================
   Map Container Utilities
   ========================================================================== */

.cc-map-full-width {
    width: 100%;
    height: 100%;
}

.cc-map-with-controls {
    position: relative;
}

.cc-map-overlay {
    position: absolute;
    z-index: 400;
    pointer-events: none;
}

.cc-map-overlay > * {
    pointer-events: auto;
}

/* ==========================================================================
   Legend Component (Universal)
   ========================================================================== */

.cc-map-legend {
    background: var(--bg-glass-darker);
    backdrop-filter: var(--blur-glass-strong);
    padding: 15px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-amber);
    max-width: 300px;
}

.cc-map-legend h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 700;
    font-family: var(--font-heading);
    color: var(--accent-amber);
    border-bottom: 2px solid var(--accent-amber);
    padding-bottom: 6px;
}

.cc-legend-grid {
    display: grid;
    gap: 10px;
}

.cc-legend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 13px;
    font-family: var(--font-body);
    color: var(--text-primary-dark);
}

.cc-legend-item:last-child {
    margin-bottom: 0;
}

.cc-legend-item-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-family: var(--font-body);
    color: var(--text-primary-dark);
}

.cc-legend-marker-sample {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.cc-stat-value {
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font-data);
    color: var(--accent-amber);
}

/* ==========================================================================
   Control Buttons (Universal)
   ========================================================================== */

.cc-map-controls {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cc-map-control-btn {
    background: white;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    padding: 8px;
    cursor: pointer;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    font-size: 16px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cc-map-control-btn:hover {
    background: #f5f5f5;
    border-color: rgba(0, 0, 0, 0.4);
    transform: scale(1.05);
}

.cc-map-control-btn:active {
    transform: scale(0.95);
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.cc-map-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.cc-map-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #e0e0e0;
    border-top-color: #2196f3;
    border-radius: 50%;
    animation: cc-spin 1s linear infinite;
}

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

/* ==========================================================================
   Cluster Markers (if clustering enabled)
   ========================================================================== */

.marker-cluster-small,
.marker-cluster-medium,
.marker-cluster-large {
    background-color: rgba(33, 150, 243, 0.6);
    border-radius: 50%;
}

.marker-cluster-small div,
.marker-cluster-medium div,
.marker-cluster-large div {
    width: 34px;
    height: 34px;
    margin: 3px;
    background-color: rgba(33, 150, 243, 0.8);
    border-radius: 50%;
    text-align: center;
    color: white;
    font-weight: bold;
    line-height: 34px;
}

.marker-cluster-medium {
    background-color: rgba(255, 152, 0, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(255, 152, 0, 0.8);
}

.marker-cluster-large {
    background-color: rgba(244, 67, 54, 0.6);
}

.marker-cluster-large div {
    background-color: rgba(244, 67, 54, 0.8);
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 768px) {
    .cc-marker-pin {
        width: 35px;
        height: 35px;
        font-size: 12px;
        border-width: 2px;
    }
    .cc-marker-pin::after {
        width: 3px;
        height: 3px;
        bottom: -6px;
        right: 34px;
    }

    .cc-universal-popup {
        min-width: 180px;
    }

    .cc-universal-popup h4 {
        font-size: 14px;
    }

    .popup-metric {
        font-size: 12px;
    }

    .cc-map-legend {
        max-width: 250px;
        padding: 12px;
    }

    .cc-map-control-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {

    .popup-metric strong {
        min-width: 80px;
    }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.cc-marker-pin:focus {
    outline: 3px solid #2196f3;
    outline-offset: 2px;
}

.cc-map-control-btn:focus {
    outline: 2px solid #2196f3;
    outline-offset: 2px;
}

/* Screen reader only text */
.cc-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;
}

/* ==========================================================================
   Calima Info Icon
   ========================================================================== */

.calima-info-icon {
    display: inline-block;
    margin-left: 6px;
    font-size: 16px;
    text-decoration: none;
    color: #2196f3;
    transition: transform 0.2s ease, color 0.2s ease;
    cursor: help;
    vertical-align: middle;
}

.calima-info-icon:hover {
    transform: scale(1.2);
    color: #1976d2;
}

.calima-header {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.cc-calima-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.cc-calima-header h5 {
    font-size: 0.9rem;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .cc-map-controls,
    .leaflet-control-zoom,
    .leaflet-control-attribution {
        display: none !important;
    }

    .cc-marker-pin {
        box-shadow: none;
        border-color: #000;
    }
}
