/**
 * Modal pour l'ajout/modification d'adresse au checkout
 * Styles inspirés du module ra_inscription_pro
 */

/* Tous les éléments du modal utilisent Poppins */
.address-modal-overlay *,
.address-modal * {
    font-family: 'Poppins', sans-serif !important;
}

.address-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    overflow-y: auto;
}

.address-modal-overlay.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
}

.address-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    max-width: 650px;
    width: 100%;
    position: relative;
    z-index: 9999;
    margin: auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.address-modal-header {
    padding: 40px 40px 20px 40px;
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.address-modal-title {
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    color: #163C5D;
}

.address-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.address-modal-close:hover {
    color: #163C5D;
}

.address-modal-body {
    padding: 0 40px 40px 40px;
    max-height: calc(100vh - 250px);
    overflow-y: auto;
}

/* Styles des formulaires dans le modal */
.address-modal-body input[type="text"],
.address-modal-body input[type="email"],
.address-modal-body input[type="password"],
.address-modal-body input[type="tel"],
.address-modal-body select,
.address-modal-body textarea {
    width: 100%;
    padding: 14px 14px;
    border: 1px solid #163C5D;
    border-radius: 6px;
    font-size: 13px;
    background: white !important;
    transition: all 0.2s ease;
}

/* Cacher les labels générés par PrestaShop */
.address-modal-body .form-control-label,
.address-modal-body label.form-control-label {
    display: none !important;
}

/* Exception: ne pas cacher le label du pays dans select-group */
.address-modal-body .select-group .form-control-label,
.address-modal-body .select-group label {
    display: none !important;
}

/* Assurer que les form-group PrestaShop ont le bon style */
.address-modal-body .form-group {
    margin-bottom: 15px;
}

/* Le select du pays - structure générée par PrestaShop */
.address-modal-body .select-group {
    display: block !important;
}

/* Cacher le label du pays */
.address-modal-body .select-group .form-control-label {
    display: none !important;
}

/* Réinitialiser les colonnes Bootstrap */
.address-modal-body .select-group .row {
    margin: 0 !important;
    display: block !important;
}

.address-modal-body .select-group .col-md-3,
.address-modal-body .select-group .col-md-6,
.address-modal-body .select-group .col-md-9 {
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    flex: none !important;
}

.address-modal-body .select-group .form-control-comment {
    display: none !important;
}

/* Style du select pays */
.address-modal-body .select-group select,
.address-modal-body .select-group .form-control,
.address-modal-body .select-group select.form-control {
    border: 1px solid #163C5D !important;
    border-radius: 6px !important;
    font-size: 13px !important;
    background: white !important;
    transition: all 0.2s ease !important;
    appearance: none !important;
}

.address-modal-body .select-group select:focus {
    outline: none !important;
    border-color: #163C5D !important;
    box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.1) !important;
}

select#field-id_country {
    height: 100%;
}

select#field-id_state {
    height: 49.6px;
    background-image: none !important;
}

.address-modal-body input[type="text"]:focus,
.address-modal-body input[type="email"]:focus,
.address-modal-body input[type="password"]:focus,
.address-modal-body input[type="tel"]:focus,
.address-modal-body select:focus,
.address-modal-body textarea:focus {
    outline: none;
    border-color: #163C5D;
    box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.1);
}

.address-modal-body input::placeholder,
.address-modal-body textarea::placeholder {
    color: rgba(22, 60, 93, 0.9) !important;
    font-size: 13px;
}

/* Select styling */
.address-modal-body select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23666' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

/* Form sections */
.address-modal-body .form-section {
    margin-bottom: 0px;
}

.address-modal-body .form-section h3 {
    color: #163C5D;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 20px;
}


/* Form groups */
.address-modal-body .form-group {
    margin-bottom: 15px;
    position: relative;
}

/* Toggle address2 link */
.address-modal-body .toggle-address2 {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #163C5D;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    font-weight: 500;
    transition: color 0.2s ease;
}

.address-modal-body .toggle-address2:hover {
    color: #103c5c99;
    text-decoration: none;
}

.address-modal-body .toggle-address2 i {
    font-size: 14px;
    font-family: "Font Awesome 5 Free" !important;
}

/* Form rows - champs côte à côte */
.address-modal-body .form-row {
    display: flex;
    gap: 15px;
}

.address-modal-body .form-row .form-group {
    flex: 1;
}

/* Select group avec flèche personnalisée */
.address-modal-body .select-group {
    position: relative;
}

.address-modal-body .select-group::before {
    content: "";
    position: absolute;
    transform: rotate(45deg);
    display: block;
    z-index: 4;
    width: 10px;
    height: 10px;
    border-color: #003d60;
    border-style: solid;
    border-width: 0 1px 1px 0;
    pointer-events: none;
}

.address-modal-footer {
    padding: 20px 40px;
    border-top: none;
    background-color: white;
    border-radius: 0 0 12px 12px;
}

/* Question Oui/Non pour "Utiliser aussi pour facturation" */
.use-same-address-question {
    margin-top: 10px;
}

.use-same-address-question-label {
    display: block;
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 12px;
    color: #163C5D;
}

.use-same-address-options {
    display: flex;
    gap: 20px;
    align-items: center;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 8px;
}

.radio-option input[type="radio"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #163C5D;
    border-radius: 50%;
    margin: 0;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
}

.radio-option input[type="radio"]:checked {
    border-color: #163C5D;
}

.radio-option input[type="radio"]:checked::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #163C5D;
}

.radio-option label {
    font-size: 14px;
    color: #163C5D;
    cursor: pointer;
    margin: 0;
    font-weight: 500;
}

/* Boutons de la modal */
.address-modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: flex-start;
    margin-top: 20px;
}

.address-modal-button {
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: initial;
}

.address-modal-button.full-width {
    width: 100%;
}

.address-modal-button.primary {
    background: #163C5D;
    color: white;
}

.address-modal-button.primary:hover {
    background: #336480;
}

.address-modal-button.primary:disabled {
    background-color: #cbd5e0;
    cursor: not-allowed;
    opacity: 0.6;
}

.address-modal-button.secondary {
    background-color: transparent;
    color: #4a5568;
    border: 1px solid #163C5D;
}

.address-modal-button.secondary:hover {
    background-color: #f7fafc;
}

/* Checkbox groups */
.address-modal-body .checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 15px;
}

.address-modal-body .checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
    margin-top: 2px;
}

.address-modal-body .checkbox-group label {
    font-size: 0.79rem;
    color: #4a5568;
    line-height: 1.5;
    cursor: pointer;
}

.address-modal-body .checkbox-group label a {
    color: #163C5D;
    text-decoration: underline;
}

.address-modal-body .checkbox-group label a:hover {
    color: #1a365d;
}

/* Message d'erreur global dans le formulaire */
.address-form-error {
    background-color: #fdf0f0;
    color: #dc3545;
    border: 1px solid #dc3545;
    border-radius: 6px;
    padding: 12px 15px;
    margin-top: 15px;
    margin-bottom: 15px;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.4;
}

/* Labels et messages d'erreur */
.address-modal-body label.error {
    color: #dc3545 !important;
    font-size: 13px;
    margin-top: 5px;
    display: block;
    font-weight: normal;
}

.address-modal-body input.error,
.address-modal-body select.error {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 0.2rem rgba(220, 53, 69, 0.25) !important;
}

/* Responsive */
@media (max-width: 768px) {
    .address-modal {
        max-width: 95%;
        margin: 20px auto;
    }

    .address-modal-header {
        padding: 30px 20px 20px 20px;
    }

    .address-modal-title {
        font-size: 2rem;
    }

    .address-modal-body {
        padding: 0 20px 30px 20px;
        max-height: calc(100vh - 200px);
    }

    .address-modal-footer {
        padding: 20px;
    }

    .address-modal-body input[type="text"],
    .address-modal-body input[type="email"],
    .address-modal-body input[type="password"],
    .address-modal-body input[type="tel"],
    .address-modal-body select {
        padding: 12px;
    }

    .address-modal-button {
        width: 100%;
        padding: 15px;
        font-size: 1rem;
    }

    /* Form-row en colonne sur mobile */
    .address-modal-body .form-row {
        flex-direction: column;
        gap: 0;
    }
}

@media (max-width: 480px) {
    .address-modal-header {
        padding: 20px 15px;
    }

    .address-modal-title {
        line-height: 1.5;
        font-size: 18px;
    }

    .address-modal-body {
        padding: 0 15px 20px 15px;
    }

    .address-modal-footer {
        padding: 15px;
    }
}
