/* ===============================
   BASE - MOBILE FIRST APPROACH
   =============================== */

.political-map-container, #political-form-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 15px;
    box-sizing: border-box;
}

/* ===============================
   LÉGENDE RESPONSIVE
   =============================== */

.legend {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    overflow-x: auto;
}

.legend-items {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    min-width: max-content;
}

.legend-items div {
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    font-size: 0.9rem;
    min-width: 0;
    flex-shrink: 0;
}

/* ===============================
   ONGLETS RESPONSIVE
   =============================== */

.admin-tabs {
    border-bottom: 1px solid #ccc;
    margin-bottom: 15px;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 2px;
}

.tab-button {
    background: #f1f1f1;
    border: none;
    padding: 8px 15px;
    cursor: pointer;
    margin-right: 3px;
    border-radius: 5px 5px 0 0;
    font-size: 0.9rem;
    display: inline-block;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 0;
}

.tab-button.active {
    background: #e67e22;
    color: white;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===============================
   FORMULAIRES RESPONSIVE
   =============================== */

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    box-sizing: border-box;
    font-size: 16px; /* Évite le zoom sur iOS */
    line-height: 1.4;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.form-group input[type="file"] {
    padding: 8px 0;
    background: transparent;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

/* ===============================
   CARTE RESPONSIVE
   =============================== */

.map-selector {
    height: 250px;
    width: 100%;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    position: relative;
}

.custom-marker {
    background: transparent !important;
    border: none !important;
}

/* ===============================
   BOUTONS RESPONSIVE
   =============================== */

.button-primary,
.button-secondary {
    display: inline-block;
    width: 100%;
    padding: 12px 20px;
    background: #e67e22;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    text-align: center;
    box-sizing: border-box;
    text-decoration: none;
    transition: background 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.button-primary:hover,
.button-secondary:hover {
    background: #cf6d1c;
}

.button-primary:active,
.button-secondary:active {
    transform: translateY(1px);
}

.form-group.commune-field button,
button#localiser {
    background: #e67e22 !important;
    color: #fff !important;
    border: none;
    border-radius: 6px;
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.form-group.commune-field button:hover,
button#localiser:hover {
    background: #cf6d1c !important;
}

/* ===============================
   MODAL RESPONSIVE
   =============================== */

#contact-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    background: #ffffff;
    padding: 20px;
    border-radius: 8px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: relative;
}

#form-message {
    margin-top: 15px;
}

/* ===============================
   TABLETTE - 576px et plus
   =============================== */

@media screen and (min-width: 576px) {
    .political-map-container, #political-form-container {
        padding: 20px;
    }
    
    .form-grid {
        grid-template-columns: 1fr 1fr;
        gap: 20px;
    }
    
    .legend {
        padding: 20px;
    }
    
    .legend-items {
        gap: 15px;
        justify-content: flex-start;
    }
    
    .legend-items div {
        font-size: 1rem;
    }
    
    .map-selector {
        height: 300px;
        margin-bottom: 20px;
    }
    
    .tab-button {
        padding: 10px 20px;
        margin-right: 5px;
        font-size: 1rem;
    }
    
    .button-primary,
    .button-secondary {
        width: auto;
        display: inline-block;
        min-width: 120px;
    }
    
    .form-group.commune-field button,
    button#localiser {
        width: auto;
        min-width: 120px;
    }
}

/* ===============================
   DESKTOP - 768px et plus
   =============================== */

@media screen and (min-width: 768px) {
    .political-map-container, #political-form-container {
        max-width: 1200px;
        padding: 30px;
    }
    
    .form-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .map-selector {
        height: 400px;
    }
    
    .admin-tabs {
        overflow-x: visible;
        white-space: normal;
    }
    
    .modal-content {
        max-height: 80vh;
    }
}

/* ===============================
   GRAND ÉCRAN - 992px et plus
   =============================== */

@media screen and (min-width: 992px) {
    .form-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .legend-items {
        justify-content: space-between;
    }
}

/* ===============================
   TRÈS GRAND ÉCRAN - 1200px et plus
   =============================== */

@media screen and (min-width: 1200px) {
    .political-map-container, #political-form-container {
        padding: 40px;
    }
    
    .map-selector {
        height: 500px;
    }
}


/* ===============================
   SURCHARGE WORDPRESS RESPONSIVE
   =============================== */

.wp-core-ui .button,
.wp-core-ui .button-primary {
    background: #e67e22 !important;
    border-color: #cf6d1c !important;
    color: #fff !important;
    text-shadow: none !important;
    box-shadow: none !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
}

.wp-core-ui .button:hover,
.wp-core-ui .button-primary:hover {
    background: #cf6d1c !important;
    border-color: #b85c17 !important;
}

/* ===============================
   AMÉLIORATIONS TACTILES
   =============================== */

@media (pointer: coarse) {
    .button-primary,
    .button-secondary,
    .tab-button,
    .form-group.commune-field button,
    button#localiser {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        min-height: 44px;
        padding: 12px 16px;
    }
}

/* ===============================
   ANIMATIONS ET TRANSITIONS
   =============================== */

.button-primary,
.button-secondary,
.tab-button,
.form-group input,
.form-group select,
.form-group textarea {
    transition: all 0.2s ease;
}

.modal-content {
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-50px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ===============================
   ACCESSIBILITÉ
   =============================== */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible pour l'accessibilité */
.button-primary:focus-visible,
.button-secondary:focus-visible,
.tab-button:focus-visible,
.form-group input:focus-visible,
.form-group select:focus-visible,
.form-group textarea:focus-visible {
    outline: 2px solid #e67e22;
    outline-offset: 2px;
}

/* ===============================
   PRINT STYLES
   =============================== */

@media print {
    .button-primary,
    .button-secondary,
    .tab-button,
    #contact-modal {
        display: none !important;
    }
    
    .political-map-container,
    #political-form-container {
        max-width: 100% !important;
        padding: 0 !important;
        box-shadow: none !important;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        border: 1px solid #000 !important;
        background: transparent !important;
    }
}