/**
 * Styles frontend pour Myleaflet
 *
 * @package Myleaflet
 * @since 1.0.0
 */

/* Conteneur de carte */
.myleaflet-map-container {
    position: relative;
    width: 100%;
    margin: 20px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* Carte */
.myleaflet-map {
    width: 100%;
    height: 100%;
    min-height: 300px;
}

/* Ratios d'aspect */
.myleaflet-aspect-16-9 {
    aspect-ratio: 16/9;
}

.myleaflet-aspect-4-3 {
    aspect-ratio: 4/3;
}

.myleaflet-aspect-1-1 {
    aspect-ratio: 1/1;
}

.myleaflet-aspect-3-4 {
    aspect-ratio: 3/4;
}

.myleaflet-aspect-7-5 {
    aspect-ratio: 7/5;
}

/* Popup personnalisée */
.myleaflet-popup .leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.2);
    background: #ffffff;
}

.myleaflet-popup .leaflet-popup-content {
    margin: 0;
    padding: 0;
    line-height: 1.4;
}

.myleaflet-popup-content {
    padding: 15px;
    max-width: 320px; /* largeur plus contenue par défaut */
    background: #ffffff; /* fond blanc explicite */
}

.myleaflet-popup-image {
    margin-bottom: 10px;
    text-align: center;
}

.myleaflet-popup-image img {
    border-radius: 4px;
    max-width: 100%;
    height: auto;
}

/* Titre */
.myleaflet-popup-layout {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.myleaflet-popup-img {
    flex: 0 0 110px;
}

.myleaflet-popup-img img {
    width: 110px;
    height: 110px;
    object-fit: cover;
    border-radius: 6px;
}

.myleaflet-popup-details {
    flex: 1 1 auto;
    min-width: 0;
}

.myleaflet-popup-title {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
}

/* Adresse */
.myleaflet-popup-address {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #666;
    line-height: 1.4;
}

/* Contact */
.myleaflet-popup-contact {
    margin: 10px 0;
    padding: 8px 0;
    border-top: 1px solid #eee;
}

.myleaflet-popup-contact p {
    margin: 4px 0;
    font-size: 13px;
    line-height: 1.4;
}

.myleaflet-popup-contact strong {
    color: #333;
    font-weight: 600;
}

.myleaflet-popup-contact a {
    color: #0073aa;
    text-decoration: none;
}

.myleaflet-popup-contact a:hover {
    color: #005177;
    text-decoration: underline;
}

/* Actions */
.myleaflet-popup-actions {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}

.myleaflet-popup-button {
    display: inline-block;
    padding: 8px 16px;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.myleaflet-popup-button:hover {
    background: #005177;
    color: #fff;
    text-decoration: none;
}

/* Modern popover design */
.myleaflet-modern .leaflet-popup-content-wrapper {
    border: 1px solid #eef2f7;
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(16, 24, 40, 0.14);
}

.myleaflet-modern .leaflet-popup-tip {
    display: none; /* look de carte flottante */
}

.myleaflet-modern-card {
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
}

.myleaflet-modern-header {
    position: relative;
    width: 100%;
    height: 140px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.myleaflet-modern-header::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0,0,0,0.00) 25%, rgba(0,0,0,0.45) 100%);
}

.myleaflet-modern-chip {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 4px 10px;
    background: #3388ff;
    color: #fff;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    z-index: 1;
}

.myleaflet-modern-body {
    padding: 12px 14px 14px 14px;
}

.myleaflet-modern-title {
    margin: 0 0 6px 0;
    font-size: 19px!important;
    font-weight: 700;
    color: #101828;
    line-height: 1.3;
}

.myleaflet-modern-address {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: #475467;
    line-height: 1.4;
}

.myleaflet-modern-meta {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    margin: 8px 0 4px 0;
}

.myleaflet-modern-meta-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #344054;
}

.myleaflet-modern-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #667085;
}

.myleaflet-modern-button {
    display: inline-flex;
    text-decoration: none!important;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 10px;
    padding: 9px 12px;
    background: #0ea5e9;
    color: #fff!important;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
    transition: background-color 0.2s ease, transform 0.05s ease;
}

.myleaflet-modern-button:hover {
    background: #0284c7;
    text-decoration: none;
}

.myleaflet-modern-button:active {
    transform: translateY(1px);
}

/* Marqueurs personnalisés */
.myleaflet-marker {
    cursor: pointer;
}

/* S'assurer que tous les éléments de marqueur sont cliquables */
.leaflet-marker-icon {
    cursor: pointer !important;
    pointer-events: auto !important;
}

.leaflet-marker-icon * {
    pointer-events: auto !important;
}

/* Assurer l'empilement correct des calques Leaflet et la cliquabilité */
.myleaflet-map .leaflet-pane.leaflet-overlay-pane {
    z-index: 400 !important;
}

.myleaflet-map .leaflet-pane.leaflet-shadow-pane {
    z-index: 500 !important;
}

.myleaflet-map .leaflet-pane.leaflet-marker-pane {
    z-index: 600 !important;
    pointer-events: auto !important;
}

.myleaflet-map .leaflet-pane.leaflet-popup-pane {
    z-index: 700 !important;
    pointer-events: auto !important;
}

/* Marqueurs colorés */
.myleaflet-colored-marker {
    background: transparent !important;
    border: none !important;
}

.myleaflet-marker-container {
    position: relative;
    display: inline-block;
}

.myleaflet-marker-background {
    position: relative;
    transition: all 0.2s ease;
}

.myleaflet-marker-background:hover {
    transform: rotate(-45deg) scale(1.1);
}

.myleaflet-marker-icon {
    user-select: none;
    pointer-events: auto;
}

/* Marqueur par défaut quand l'icône est introuvable */
.myleaflet-default-marker {
    background: transparent !important;
    border: none !important;
}

.myleaflet-marker-pin {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 2px solid #fff;
    position: relative;
}

.myleaflet-marker-text {
    color: #fff;
    font-weight: bold;
    font-size: 14px;
    transform: rotate(45deg);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    line-height: 1;
}

/* Animation pour les marqueurs par défaut */
.myleaflet-marker-pin {
    animation: myleaflet-marker-bounce 0.6s ease-out;
}

@keyframes myleaflet-marker-bounce {
    0% {
        transform: rotate(-45deg) scale(0);
        opacity: 0;
    }
    50% {
        transform: rotate(-45deg) scale(1.2);
        opacity: 0.8;
    }
    100% {
        transform: rotate(-45deg) scale(1);
        opacity: 1;
    }
}

/* Hover effect pour les marqueurs par défaut */
.myleaflet-marker-pin:hover {
    transform: rotate(-45deg) scale(1.1);
    transition: transform 0.2s ease;
}

/* Contrôles de carte */
.myleaflet-map .leaflet-control-zoom {
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
}

.myleaflet-map .leaflet-control-scale {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
    padding: 2px 5px;
    font-size: 11px;
    line-height: 1.2;
}

/* Attribution */
.myleaflet-map .leaflet-control-attribution {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.2;
}

/* Contrôle de filtres Myleaflet */
.myleaflet-filter-control {
    background: rgba(255, 255, 255, 0.97)!important;
    border-radius: 6px!important;
    box-shadow: 0 1px 6px rgba(0,0,0,0.12)!important;
    padding: 4px 8px 6px!important;
    min-width: 140px!important;
    border: 1px solid rgba(0,0,0,0.06)!important;
}

.myleaflet-filter-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 24px;
    padding: 2px 4px 2px 6px;
    margin: 0 0 4px 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    font: inherit;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.2;
    color: #333;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
}

.myleaflet-filter-toggle:hover {
    background: rgba(0,0,0,0.05);
    color: #111;
}

.myleaflet-filter-title {
    font-size: 11px;
    font-weight: 600;
    color: inherit;
    letter-spacing: 0.02em;
}

.myleaflet-filter-toggle-icon {
    font-size: 8px;
    opacity: 0.75;
    margin-left: 4px;
    line-height: 1;
}

.myleaflet-filter-control .myleaflet-filter-list-wrap {
    margin-top: 2px;
}

.myleaflet-filter-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 200px;
    overflow: auto;
    padding-right: 2px;
}

.myleaflet-filter-item {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 11px;
    line-height: 1.25;
    color: #444;
    padding: 2px 0;
}

.myleaflet-filter-item:hover {
    color: #111;
}

.myleaflet-filter-item input[type="checkbox"] {
    cursor: pointer;
    width: 12px;
    height: 12px;
    margin: 0;
    flex-shrink: 0;
}

.myleaflet-filter-bullet {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    border: 1px solid rgba(0,0,0,0.08);
    flex-shrink: 0;
}

.myleaflet-filter-name {
    line-height: 1.25;
}

/* Responsive */
@media (max-width: 768px) {
    .myleaflet-map-container {
        margin: 15px 0;
        border-radius: 4px;
    }
    
    .myleaflet-popup-content {
        max-width: 280px;
        min-width: 240px;
    }
    
    
    .myleaflet-popup-title {
        font-size: 15px;
    }
    
    .myleaflet-popup-address {
        font-size: 13px;
    }
    
    .myleaflet-popup-contact p {
        font-size: 12px;
    }
    
    .myleaflet-popup-button {
        padding: 6px 12px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .myleaflet-map-container {
        margin: 10px 0;
    }
    
    .myleaflet-popup-content {
        max-width: 220px;
        min-width: 200px;
    }
    
    .myleaflet-popup-layout {
        padding: 10px;
        gap: 8px;
    }
    
    .myleaflet-popup-img {
        height: 70px;
        max-width: 150px;
    }
    
    .myleaflet-popup-title {
        font-size: 14px;
    }
    
    .myleaflet-popup-address {
        font-size: 12px;
    }
    
    .myleaflet-popup-contact p {
        font-size: 11px;
    }
    
    .myleaflet-popup-button {
        padding: 5px 10px;
        font-size: 11px;
    }
}

/* États de chargement */
.myleaflet-loading {
    position: relative;
}

.myleaflet-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: myleaflet-spin 1s linear infinite;
    z-index: 1000;
}

@keyframes myleaflet-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Erreurs */
.myleaflet-error {
    padding: 20px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    text-align: center;
    margin: 20px 0;
}

.myleaflet-error h3 {
    margin: 0 0 10px 0;
    font-size: 16px;
}

.myleaflet-error p {
    margin: 0;
    font-size: 14px;
}

/* Améliorations d'accessibilité */
.myleaflet-map:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.myleaflet-popup-button:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Support des thèmes sombres */
@media (prefers-color-scheme: dark) {
    .myleaflet-popup-content {
        background: transparent;
        color: #2d3748;
    }
    
    .myleaflet-popup-title {
        color: #f7fafc;
    }
    
    .myleaflet-popup-address {
        color: #a0aec0;
    }
    
    .myleaflet-popup-contact {
        border-top-color: #4a5568;
    }
    
    .myleaflet-popup-contact strong {
        color: #f7fafc;
    }
    
    .myleaflet-popup-actions {
        border-top-color: #4a5568;
    }
}