/**
 * FOE Maps Module - CSS Styles
 * @package     mod_foe_maps
 * @version     1.0.0
 * @copyright   Copyright (C) 2024 FOE Digital. All rights reserved.
 * @license     GNU General Public License version 2 or later
 */

/* ============================================
   Main Module Container
   ============================================ */
.mod-foe-maps {
    margin-bottom: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ============================================
   Header Section
   ============================================ */
.foe-map-header {
    margin-bottom: 15px;
}

.foe-map-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

/* ============================================
   Map Container
   ============================================ */
.foe-map-container {
    position: relative;
    margin-bottom: 15px;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.foe-map {
    width: 100%;
    min-height: 300px;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

.foe-google-map {
    background-color: #f8f9fa;
}

.foe-openstreetmap-map {
    background-color: #f8f9fa;
}

/* ============================================
   Loading State
   ============================================ */
.foe-map-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: #6c757d;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 6px;
    transition: opacity 0.3s ease;
    font-family: system-ui, -apple-system, sans-serif;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.foe-map-loading-content {
    text-align: center;
}

.foe-map-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 123, 255, 0.1);
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: foe-spin 1s linear infinite;
    margin-bottom: 12px;
}

.foe-map-loading-spinner-inline {
    width: 40px;
    height: 40px;
    border: 4px solid #e9ecef;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes foe-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Additional loading styles for inline loading div */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============================================
   Map Info Section
   ============================================ */
.foe-map-info {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 16px;
    font-size: 0.9rem;
    line-height: 1.6;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.foe-map-description {
    color: #495057;
}

.foe-map-description h1,
.foe-map-description h2,
.foe-map-description h3,
.foe-map-description h4,
.foe-map-description h5,
.foe-map-description h6 {
    margin-top: 0;
    margin-bottom: 12px;
    color: #343a40;
    font-weight: 600;
}

.foe-map-description h1 { font-size: 1.5rem; }
.foe-map-description h2 { font-size: 1.35rem; }
.foe-map-description h3 { font-size: 1.2rem; }
.foe-map-description h4 { font-size: 1.1rem; }
.foe-map-description h5 { font-size: 1rem; }
.foe-map-description h6 { font-size: 0.9rem; }

.foe-map-description p {
    margin-bottom: 12px;
    color: #495057;
}

.foe-map-description p:last-child {
    margin-bottom: 0;
}

.foe-map-description ul,
.foe-map-description ol {
    margin-bottom: 12px;
    padding-left: 20px;
}

.foe-map-description li {
    margin-bottom: 6px;
}

.foe-map-description a {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.foe-map-description a:hover {
    color: #0056b3;
    text-decoration: underline;
}

.foe-map-description a:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* ============================================
   Google Maps Customizations
   ============================================ */
.foe-google-map .gm-style {
    font-family: inherit;
}

.foe-google-map .gm-style .gm-style-iw-c {
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    max-width: 280px;
}

.foe-google-map .gm-style .gm-style-iw-d {
    overflow: hidden !important;
}

.foe-google-map .gm-style .gm-style-iw-t::after {
    background: linear-gradient(45deg, transparent 50%, #ffffff 50%);
}

.foe-google-map .gm-style-iw-chr {
    padding: 0;
}

/* ============================================
   OpenStreetMap/Leaflet Customizations
   ============================================ */
.foe-openstreetmap-map .leaflet-container {
    font-family: inherit;
    background-color: #f8f9fa;
}

.foe-openstreetmap-map .leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 0;
}

.foe-openstreetmap-map .leaflet-popup-content {
    margin: 16px;
    font-family: inherit;
    line-height: 1.5;
    color: #333;
}

.foe-openstreetmap-map .leaflet-popup-tip {
    background: white;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.foe-openstreetmap-map .leaflet-control-attribution {
    background-color: rgba(255, 255, 255, 0.9);
    font-size: 0.7rem;
    padding: 2px 4px;
    border-radius: 3px;
}

.foe-openstreetmap-map .leaflet-control-zoom a {
    color: #333;
    background-color: white;
    border: 1px solid #ccc;
}

.foe-openstreetmap-map .leaflet-control-zoom a:hover {
    background-color: #f8f9fa;
    color: #007bff;
}

/* Custom InfoWindow Styles (applies to both providers) */
.foe-info-window {
    font-family: inherit;
    line-height: 1.5;
    color: #333;
}

.foe-info-window h3 {
    margin: 0 0 8px 0;
    font-size: 1.1rem;
    font-weight: 600;
    color: #007bff;
}

.foe-info-window p {
    margin: 0 0 8px 0;
    font-size: 0.9rem;
}

.foe-info-window p:last-child {
    margin-bottom: 0;
}

/* ============================================
   Error States
   ============================================ */
.foe-map-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    padding: 16px;
    margin: 10px 0;
    font-size: 0.9rem;
}

.foe-map-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 16px;
    margin: 10px 0;
    font-size: 0.9rem;
}

/* ============================================
   Accessibility
   ============================================ */
.foe-google-map:focus {
    outline: 3px solid #007bff;
    outline-offset: 2px;
}

/* Screen reader only content */
.foe-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   Responsive Design
   ============================================ */

/* Tablets */
@media (max-width: 992px) {
    .foe-map-title {
        font-size: 1.15rem;
    }
    
    .foe-google-map {
        min-height: 280px;
    }
}

/* Mobile devices */
@media (max-width: 768px) {
    .mod-foe-maps {
        margin-bottom: 16px;
    }
    
    .foe-map-title {
        font-size: 1.1rem;
    }
    
    .foe-map-header {
        margin-bottom: 12px;
    }
    
    .foe-map-container {
        margin-bottom: 12px;
    }
    
    .foe-google-map {
        min-height: 250px;
    }
    
    .foe-map-info {
        padding: 14px;
        font-size: 0.85rem;
    }
    
    .foe-map-description h1 { font-size: 1.3rem; }
    .foe-map-description h2 { font-size: 1.2rem; }
    .foe-map-description h3 { font-size: 1.1rem; }
    .foe-map-description h4 { font-size: 1rem; }
    .foe-map-description h5 { font-size: 0.95rem; }
    .foe-map-description h6 { font-size: 0.85rem; }
    
    .foe-google-map .gm-style .gm-style-iw-c {
        padding: 12px;
        max-width: 240px;
    }
    
    .foe-map-loading {
        font-size: 0.8rem;
    }
    
    .foe-map-loading-spinner {
        width: 32px;
        height: 32px;
        border-width: 3px;
        margin-bottom: 10px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .foe-google-map {
        min-height: 220px;
    }
    
    .foe-map-info {
        padding: 12px;
        font-size: 0.8rem;
    }
    
    .foe-google-map .gm-style .gm-style-iw-c {
        padding: 10px;
        max-width: 200px;
    }
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .mod-foe-maps {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    .foe-google-map {
        background: #f8f9fa;
        border: 1px solid #dee2e6;
        display: block;
    }
    
    .foe-google-map::after {
        content: "Interactive map not available in print version";
        display: flex;
        align-items: center;
        justify-content: center;
        height: 200px;
        color: #6c757d;
        font-size: 0.9rem;
        text-align: center;
    }
    
    .foe-map-loading {
        display: none;
    }
}

/* ============================================
   High Contrast Mode
   ============================================ */
@media (prefers-contrast: high) {
    .foe-map-container {
        box-shadow: 0 0 0 2px #000;
    }
    
    .foe-map-info {
        border: 2px solid #000;
        background: #fff;
    }
    
    .foe-map-description a {
        color: #00f;
        text-decoration: underline;
    }
}

/* ============================================
   Reduced Motion
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    .foe-map-loading-spinner {
        animation: none;
    }
    
    .foe-map-description a {
        transition: none;
    }
    
    .foe-map-loading {
        transition: none;
    }
}