/*
 * Styles pour la sélection des points relais Mondial Relay - VERSION MODERNE
 * Design épuré avec carte intégrée et interface responsive
 */

/* ========================================
   VARIABLES CSS
======================================== */
:root {
    --mr-primary: #CBB390;
    --mr-primary-dark: #B8A082;
    --mr-success: #28a745;
    --mr-error: #dc3545;
    --mr-warning: #ffc107;
    --mr-info: #17a2b8;
    --mr-text: #333333;
    --mr-text-secondary: #666666;
    --mr-text-light: #999999;
    --mr-border: #e5e5e5;
    --mr-background: #f8f9fa;
    --mr-shadow: 0 4px 20px rgba(0,0,0,0.1);
    --mr-shadow-hover: 0 6px 25px rgba(0,0,0,0.15);
    --mr-radius: 12px;
    --mr-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* Empêcher le scroll du body quand le modal est ouvert */
body.ew-modal-open {
    overflow: hidden !important;
}

/* Section Mondial Relay dans le checkout */
.ew-mondial-relay-section {
    margin-top: 20px !important;
}

/* ========================================
   MODAL PRINCIPAL
======================================== */

.ew-relay-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.7) !important;
    backdrop-filter: blur(4px) !important;
    z-index: 999999 !important;
    display: none !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
}

.ew-relay-modal.active {
    display: flex !important;
    opacity: 1 !important;
}

.ew-relay-modal-wrapper {
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 20px !important;
}

.ew-relay-modal-content {
    background: #ffffff !important;
    border-radius: var(--mr-radius) !important;
    max-width: 1400px !important;
    width: 100% !important;
    height: 85vh !important; /* Hauteur fixe pour permettre le scroll */
    max-height: 90vh !important;
    overflow: hidden !important;
    box-shadow: var(--mr-shadow) !important;
    display: flex !important;
    flex-direction: column !important;
    animation: ew-modal-slide-in 0.3s ease-out !important;
}

@keyframes ew-modal-slide-in {
    from {
        transform: translateY(30px) scale(0.98);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* ========================================
   HEADER DU MODAL
======================================== */

.ew-relay-modal-header {
    padding: 20px 30px !important;
    border-bottom: 1px solid var(--mr-border) !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    background: linear-gradient(135deg, #ffffff 0%, var(--mr-background) 100%) !important;
    flex-shrink: 0 !important;
}

.ew-header-content {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
}

.ew-header-icon {
    width: 28px !important;
    height: 28px !important;
}

.ew-relay-modal-header h3 {
    margin: 0 !important;
    color: var(--mr-text) !important;
    font-size: 20px !important;
    font-weight: 600 !important;
}

.ew-relay-close {
    background: none !important;
    border: none !important;
    cursor: pointer !important;
    color: var(--mr-text-secondary) !important;
    padding: 8px !important;
    border-radius: 50% !important;
    transition: var(--mr-transition) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.ew-relay-close:hover {
    background: var(--mr-background) !important;
    color: var(--mr-text) !important;
    transform: rotate(90deg) !important;
}

/* ========================================
   ZONE DE RECHERCHE
======================================== */

.ew-relay-search {
    padding: 20px 30px !important;
    background: var(--mr-background) !important;
    border-bottom: 1px solid var(--mr-border) !important;
}

.ew-search-wrapper {
    display: flex !important;
    gap: 12px !important;
    align-items: flex-end !important;
}

.ew-relay-search-field {
    flex: 1 !important;
}

.ew-relay-search-field label {
    display: block !important;
    margin-bottom: 6px !important;
    font-weight: 500 !important;
    color: var(--mr-text) !important;
    font-size: 13px !important;
}

.ew-relay-search-field .optional {
    color: var(--mr-text-light) !important;
    font-weight: normal !important;
}

.ew-relay-search-field input {
    width: 100% !important;
    padding: 10px 14px !important;
    border: 1px solid var(--mr-border) !important;
    border-radius: 8px !important;
    font-size: 14px !important;
    transition: var(--mr-transition) !important;
    background: #ffffff !important;
}

.ew-relay-search-field input:focus {
    outline: none !important;
    border-color: var(--mr-primary) !important;
    box-shadow: 0 0 0 3px rgba(203, 179, 144, 0.1) !important;
}

.ew-relay-search-btn {
    padding: 10px 20px !important;
    background: linear-gradient(135deg, var(--mr-primary), var(--mr-primary-dark)) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 8px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: var(--mr-transition) !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
}

.ew-relay-search-btn:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(203, 179, 144, 0.3) !important;
}

div#ew-mondial-relay-selector {
    padding-top: 15px !important;
}

/* ========================================
   CORPS DU MODAL - LAYOUT SPLIT
======================================== */

.ew-relay-modal-body {
    flex: 1 !important;
    overflow: hidden !important;
    background: #ffffff !important;
}

.ew-body-container {
    display: flex !important;
    height: 100% !important;
}

/* Conteneur de la liste */
.ew-relay-list-container {
    flex: 1 !important;
    min-width: 400px !important;
    display: flex !important;
    flex-direction: column !important;
    border-right: 1px solid var(--mr-border) !important;
}

/* Conteneur de la carte */
.ew-relay-map-container {
    flex: 1 !important;
    min-width: 400px !important;
    background: var(--mr-background) !important;
    position: relative !important;
}

/* ========================================
   LISTE DES POINTS RELAIS
======================================== */

.ew-relay-results {
    height: 100% !important;
    overflow-y: auto !important;
    background: #ffffff !important;
}

.ew-results-header {
    padding: 15px 20px !important;
    background: var(--mr-background) !important;
    border-bottom: 1px solid var(--mr-border) !important;
    position: sticky !important;
    top: 0 !important;
    z-index: 10 !important;
}

.ew-results-count {
    font-weight: 600 !important;
    color: var(--mr-text) !important;
}

.ew-relay-list {
    padding: 10px !important;
}

/* Items de points relais */
.ew-relay-item {
    background: #ffffff !important;
    border: 1px solid var(--mr-border) !important;
    border-radius: 10px !important;
    padding: 15px !important;
    margin-bottom: 10px !important;
    cursor: pointer !important;
    transition: var(--mr-transition) !important;
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    position: relative !important;
}

.ew-relay-item:hover {
    border-color: var(--mr-primary) !important;
    box-shadow: 0 4px 12px rgba(203, 179, 144, 0.15) !important;
    transform: translateX(5px) !important;
}

.ew-relay-item.selected {
    background: linear-gradient(135deg, rgba(203, 179, 144, 0.08), rgba(203, 179, 144, 0.03)) !important;
    border-color: var(--mr-primary) !important;
    box-shadow: 0 4px 15px rgba(203, 179, 144, 0.2) !important;
}

/* Marqueur alphabétique */
.ew-relay-marker {
    width: 32px !important;
    height: 32px !important;
    background: linear-gradient(135deg, var(--mr-primary), var(--mr-primary-dark)) !important;
    color: white !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 600 !important;
    flex-shrink: 0 !important;
}

/* Contenu du point relais */
.ew-relay-content {
    flex: 1 !important;
    min-width: 0 !important;
}

.ew-relay-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    margin-bottom: 8px !important;
}

.ew-relay-header h4 {
    margin: 0 !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--mr-text) !important;
    line-height: 1.3 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

.ew-relay-distance {
    background: var(--mr-background) !important;
    color: var(--mr-text-secondary) !important;
    padding: 4px 8px !important;
    border-radius: 12px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    flex-shrink: 0 !important;
    margin-left: 10px !important;
}

.ew-relay-address {
    display: flex !important;
    gap: 8px !important;
    color: var(--mr-text-secondary) !important;
    font-size: 13px !important;
    line-height: 1.4 !important;
}

.ew-relay-address svg {
    flex-shrink: 0 !important;
    margin-top: 2px !important;
}

/* Indicateur de sélection */
.ew-relay-select {
    position: absolute !important;
    right: 15px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    opacity: 0 !important;
    transition: opacity 0.2s ease !important;
}

.ew-relay-item.selected .ew-relay-select {
    opacity: 1 !important;
}

/* ========================================
   ÉTATS DE CHARGEMENT ET MESSAGES
======================================== */

.ew-initial-state,
.ew-relay-loading,
.ew-relay-error,
.ew-relay-no-results {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 60px 20px !important;
    text-align: center !important;
    height: 100% !important;
    min-height: 400px !important;
}

.ew-initial-state h4,
.ew-relay-error h4,
.ew-relay-no-results h4 {
    margin: 15px 0 10px 0 !important;
    font-size: 18px !important;
    font-weight: 600 !important;
    color: var(--mr-text) !important;
}

.ew-initial-state p,
.ew-relay-error p,
.ew-relay-no-results p {
    margin: 0 !important;
    color: var(--mr-text-secondary) !important;
    font-size: 14px !important;
    max-width: 300px !important;
}

/* Spinner de chargement */
.ew-spinner-wrapper {
    display: flex !important;
    justify-content: center !important;
    margin-bottom: 15px !important;
}

.ew-spinner {
    width: 40px !important;
    height: 40px !important;
    border: 3px solid var(--mr-border) !important;
    border-top-color: var(--mr-primary) !important;
    border-radius: 50% !important;
    animation: ew-spin 1s linear infinite !important;
}

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

/* ========================================
   ZONE DE LA CARTE
======================================== */

.ew-relay-map {
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
}

.ew-map-placeholder {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    height: 100% !important;
    padding: 40px !important;
    color: var(--mr-text-light) !important;
}

.ew-static-map {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: linear-gradient(135deg, #f5f5f5 25%, transparent 25%) -50px 0,
    linear-gradient(225deg, #f5f5f5 25%, transparent 25%) -50px 0,
    linear-gradient(315deg, #f5f5f5 25%, transparent 25%),
    linear-gradient(45deg, #f5f5f5 25%, transparent 25%) !important;
    background-size: 100px 100px !important;
    background-color: #fafafa !important;
}

.ew-map-points {
    position: absolute !important;
    width: 100% !important;
    height: 100% !important;
}

.ew-map-point-marker {
    position: absolute !important;
    width: 30px !important;
    height: 30px !important;
    background: var(--mr-primary) !important;
    color: white !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3) !important;
}

/* Support Leaflet Map si disponible */
#ew-relay-map .leaflet-container {
    height: 100% !important;
    width: 100% !important;
}

/* ========================================
   FOOTER DU MODAL
======================================== */

.ew-relay-modal-footer {
    padding: 15px 30px !important;
    border-top: 1px solid var(--mr-border) !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    background: var(--mr-background) !important;
    flex-shrink: 0 !important;
}

.ew-relay-selected-info {
    flex: 1 !important;
    margin-right: 20px !important;
}

.ew-no-selection {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    color: var(--mr-text-light) !important;
    font-size: 14px !important;
}

.ew-selected-info {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

.ew-selected-info strong {
    color: var(--mr-text) !important;
    font-size: 14px !important;
}

.ew-selected-info span {
    color: var(--mr-text-secondary) !important;
    font-size: 13px !important;
}

/* Actions du footer */
.ew-relay-actions {
    display: flex !important;
    gap: 10px !important;
}

.ew-relay-btn-cancel {
    padding: 10px 20px !important;
    background: #ffffff !important;
    color: var(--mr-text-secondary) !important;
    border: 1px solid var(--mr-border) !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    transition: var(--mr-transition) !important;
    font-weight: 500 !important;
}

.ew-relay-btn-cancel:hover {
    background: var(--mr-background) !important;
    border-color: var(--mr-text-secondary) !important;
}

.ew-relay-btn-confirm {
    padding: 10px 24px !important;
    background: linear-gradient(135deg, var(--mr-primary), var(--mr-primary-dark)) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    font-weight: 600 !important;
    transition: var(--mr-transition) !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
}

.ew-relay-btn-confirm:hover:not(:disabled) {
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(203, 179, 144, 0.4) !important;
}

.ew-relay-btn-confirm:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

/* ========================================
   SCROLLBAR PERSONNALISÉE
======================================== */

.ew-relay-results::-webkit-scrollbar {
    width: 6px !important;
}

.ew-relay-results::-webkit-scrollbar-track {
    background: var(--mr-background) !important;
}

.ew-relay-results::-webkit-scrollbar-thumb {
    background: var(--mr-primary) !important;
    border-radius: 3px !important;
}

.ew-relay-results::-webkit-scrollbar-thumb:hover {
    background: var(--mr-primary-dark) !important;
}

/* ========================================
   MESSAGES FLASH
======================================== */

.ew-flash-message {
    animation: ew-flash-slide-in 0.3s ease-out !important;
}

@keyframes ew-flash-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========================================
   RESPONSIVE DESIGN
======================================== */

/* Tablettes (max-width: 1024px) */
@media (max-width: 1024px) {
    .ew-relay-modal-content {
        max-width: 95vw !important;
    }

    .ew-body-container {
        flex-direction: column !important;
    }

    .ew-relay-list-container {
        min-width: unset !important;
        border-right: none !important;
        border-bottom: 1px solid var(--mr-border) !important;
        max-height: 50vh !important;
    }

    .ew-relay-map-container {
        min-width: unset !important;
        height: 300px !important;
        display: none !important; /* Cache la carte sur tablette */
    }
}

/* Mobile (max-width: 768px) */
@media (max-width: 768px) {
    .ew-relay-modal-wrapper {
        padding: 0 !important;
    }

    .ew-relay-modal-content {
        max-width: 100% !important;
        max-height: 100vh !important;
        height: 100vh !important;
        border-radius: 0 !important;
    }

    .ew-relay-modal-header {
        padding: 15px 20px !important;
    }

    .ew-relay-modal-header h3 {
        font-size: 18px !important;
    }

    .ew-relay-search {
        padding: 15px 20px !important;
    }

    .ew-search-wrapper {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .ew-relay-search-field {
        width: 100% !important;
    }

    .ew-relay-search-btn {
        width: 100% !important;
        justify-content: center !important;
    }

    .ew-body-container {
        flex-direction: column !important;
    }

    .ew-relay-list-container {
        border-right: none !important;
        height: auto !important;
        flex: 1 !important;
    }

    .ew-relay-map-container {
        display: none !important; /* Cache complètement la carte sur mobile */
    }

    .ew-relay-item {
        padding: 12px !important;
    }

    .ew-relay-marker {
        width: 28px !important;
        height: 28px !important;
        font-size: 12px !important;
    }

    .ew-relay-header h4 {
        font-size: 13px !important;
    }

    .ew-relay-address {
        font-size: 12px !important;
    }

    .ew-relay-modal-footer {
        padding: 12px 15px !important;
        flex-direction: column !important;
        gap: 10px !important;
    }

    .ew-relay-selected-info {
        width: 100% !important;
        margin-right: 0 !important;
        margin-bottom: 10px !important;
    }

    .ew-relay-actions {
        width: 100% !important;
        justify-content: space-between !important;
    }

    .ew-relay-actions button {
        flex: 1 !important;
    }
}

/* Très petit mobile (max-width: 400px) */
@media (max-width: 400px) {
    .ew-relay-header {
        flex-direction: column !important;
        align-items: flex-start !important;
    }

    .ew-relay-distance {
        margin-left: 0 !important;
        margin-top: 5px !important;
    }

    .ew-relay-item {
        padding: 10px !important;
    }

    .ew-relay-marker {
        width: 24px !important;
        height: 24px !important;
        font-size: 11px !important;
    }
}

/* ========================================
   ANIMATIONS SUPPLÉMENTAIRES
======================================== */

.ew-relay-item {
    animation: ew-fade-in 0.3s ease-out backwards !important;
}

.ew-relay-item:nth-child(1) { animation-delay: 0.05s !important; }
.ew-relay-item:nth-child(2) { animation-delay: 0.1s !important; }
.ew-relay-item:nth-child(3) { animation-delay: 0.15s !important; }
.ew-relay-item:nth-child(4) { animation-delay: 0.2s !important; }
.ew-relay-item:nth-child(5) { animation-delay: 0.25s !important; }

@keyframes ew-fade-in {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========================================
   AMÉLIORATION ACCESSIBILITÉ
======================================== */

.ew-relay-item:focus-visible {
    outline: 2px solid var(--mr-primary) !important;
    outline-offset: 2px !important;
}

.ew-relay-btn-confirm:focus-visible,
.ew-relay-btn-cancel:focus-visible,
.ew-relay-search-btn:focus-visible {
    outline: 2px solid var(--mr-primary) !important;
    outline-offset: 2px !important;
}

/* Mode sombre (optionnel) */
@media (prefers-color-scheme: dark) {
    /* Vous pouvez ajouter des styles pour le mode sombre ici si nécessaire */
}