/* ═══════════════════════════════════════════════════════
   🎨 POPUP FORMULAIRE CONTACT - DESIGN PREMIUM 2025
   ═══════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────── */
/* OVERLAY AVEC GLASSMORPHISM */
/* ─────────────────────────────────────────────────────── */
.popup-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9998;
    animation: fadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.popup-overlay.active {
    display: block;
}

/* ─────────────────────────────────────────────────────── */
/* CONTENEUR MODAL - TAILLE AUGMENTÉE */
/* ─────────────────────────────────────────────────────── */
.popup-modal {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--white);
    border-radius: 24px;
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(99, 102, 241, 0.1);
    max-width: 900px;
    width: 95%;
    max-height: 110vh;
    overflow: hidden;
    z-index: 9999;
    opacity: 0;
}

.popup-modal.active {
    display: block;
    animation: slideUpScale 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ─────────────────────────────────────────────────────── */
/* HEADER SIMPLIFIÉ (sans sous-titre) */
/* ─────────────────────────────────────────────────────── */
.popup-header {
    padding: 2rem 2.5rem 1.5rem; /* ✅ Réduit le padding-bottom */
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05) 0%, rgba(168, 85, 247, 0.05) 100%);
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
    position: relative;
}

.popup-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient);
}

.popup-header h2 {
    font-size: 1.875rem; /* ✅ On peut garder la taille normale maintenant */
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0; /* ✅ Plus de marge en bas */
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.3;
}

/* ✅ SUPPRIMÉ : .popup-header p { ... } */

/* Bouton fermer amélioré */
.popup-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(99, 102, 241, 0.1);
    border: none;
    font-size: 1.25rem;
    color: var(--primary);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.popup-close:hover {
    background: rgba(99, 102, 241, 0.2);
    transform: rotate(90deg) scale(1.1);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* ─────────────────────────────────────────────────────── */
/* CORPS DU FORMULAIRE - HAUTEUR AUGMENTÉE */
/* ─────────────────────────────────────────────────────── */
.popup-body {
    position: relative;
    padding: 2rem 2.5rem; /* ✅ Augmenté de 1.5rem à 2rem en haut */
    max-height: calc(110vh - 160px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(99, 102, 241, 0.3) transparent;
}

.popup-body::-webkit-scrollbar {
    width: 8px;
}

.popup-body::-webkit-scrollbar-track {
    background: rgba(99, 102, 241, 0.05);
    border-radius: 10px;
}

.popup-body::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.3);
    border-radius: 10px;
    transition: background 0.2s;
}

.popup-body::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.5);
}

/* Espace pour le message quand affiché */
.popup-body.with-message form {
    padding-top: 5rem; /* ✅ Pousse le form vers le bas quand message visible */
    transition: padding-top 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Par défaut : pas d'espace */
.popup-body form {
    padding-top: 0;
    transition: padding-top 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ─────────────────────────────────────────────────────── */
/* LAYOUT 2 COLONNES - DESKTOP */
/* ─────────────────────────────────────────────────────── */
#contactForm {
    display: grid;
    grid-template-columns: 1fr 1fr; /* ✅ 2 colonnes égales */
    gap: 2rem; /* ✅ Espace entre colonnes */
    padding-top: 0;
    transition: padding-top 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.form-column {
    display: flex;
    flex-direction: column;
    gap: 1.25rem; /* ✅ Espace entre éléments */
}

/* ✅ NOUVEAU : form-actions dans la colonne (pas en grid-column span) */
.form-actions {
    margin-top: 0.5rem; /* ✅ Petit espace au-dessus du bouton */
}

/* ✅ Textarea de taille fixe raisonnable */
#contactMessage {
    min-height: 300px; /* ✅ Hauteur confortable */
    max-height: 300px;
    resize: vertical; /* ✅ Permet redimensionnement vertical uniquement */
}

/* ─────────────────────────────────────────────────────── */
/* CHAMPS DE FORMULAIRE - ESPACEMENT OPTIMISÉ */
/* ─────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 0; /* ✅ IMPORTANT : le gap de .form-column gère l'espace */
    position: relative;
}

/* ─────────────────────────────────────────────────────── */
/* PLACEHOLDERS AS LABELS (amélioration UX) */
/* ─────────────────────────────────────────────────────── */
#contactForm input::placeholder,
#contactForm textarea::placeholder {
    color: var(--gray);
    opacity: 0.7;
    font-size: 0.95rem;
    transition: opacity 0.2s ease;
}

#contactForm input:focus::placeholder,
#contactForm textarea:focus::placeholder {
    opacity: 0.4; /* ✅ Plus discret au focus */
}

/* ✅ Astérisque rouge pour champs requis */
#contactForm input:required,
#contactForm textarea:required {
    border-left: 3px solid var(--primary);
}

#contactForm input:invalid:not(:placeholder-shown),
#contactForm textarea:invalid:not(:placeholder-shown) {
    border-color: var(--error);
}

#contactForm input:valid:not(:placeholder-shown),
#contactForm textarea:valid:not(:placeholder-shown) {
    border-color: var(--success);
}

/* Inputs avec effet flottant */
.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid rgba(99, 102, 241, 0.15);
    border-radius: 12px;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(99, 102, 241, 0.02);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 
        0 0 0 4px rgba(99, 102, 241, 0.1),
        0 4px 12px rgba(99, 102, 241, 0.15);
    transform: translateY(-2px);
}

.form-group textarea {
    resize: vertical;
    min-height: 130px;
    line-height: 1.6;
}

.form-group small {
    display: block;
    margin-top: 0.375rem;
    color: var(--gray);
    font-size: 0.8125rem;
    font-style: italic;
}

/* ─────────────────────────────────────────────────────── */
/* SELECT DROPDOWN STYLING */
/* ─────────────────────────────────────────────────────── */
select {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    font-size: 0.9375rem;
    color: var(--text);
    background: white;
    transition: all 0.3s ease;
    cursor: pointer;
    appearance: none; /* Retire le style natif */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236366f1' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 16px;
    padding-right: 3rem; /* Espace pour la flèche */
}

select:hover {
    border-color: rgba(99, 102, 241, 0.4);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.05);
}

select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Style des options groupées */
select optgroup {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.875rem;
    padding: 0.5rem 0;
}

select option {
    padding: 0.75rem 1rem;
    color: var(--text);
}

/* État invalide */
select.is-invalid {
    border-color: #ef4444;
    background-color: rgba(239, 68, 68, 0.05);
}

/* État valide */
select.is-valid {
    border-color: #10b981;
    background-color: rgba(16, 185, 129, 0.05);
}

/* Placeholder personnalisé (option disabled selected) */
select option[disabled] {
    color: var(--gray);
}

/* Validation visuelle - Plus subtile */
.form-group input.is-valid,
.form-group textarea.is-valid {
    border-color: #10b981;
    background: rgba(16, 185, 129, 0.03);
}

.form-group input.is-invalid,
.form-group textarea.is-invalid {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.03);
}

/* ─────────────────────────────────────────────────────── */
/* MESSAGES DE STATUT - POSITION ABSOLUE POUR ZERO ESPACE */
/* ─────────────────────────────────────────────────────── */
.form-message {
    position: absolute; /* ✅ SOLUTION : position absolue = hors du flux */
    top: 0;
    left: 2.5rem;
    right: 2.5rem;
    padding: 0;
    border-radius: 12px;
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 500;
    display: none;
    align-items: center;
    gap: 0.75rem;
    opacity: 0;
    transform: translateY(-20px);
    z-index: 10;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.form-message.show {
    display: flex;
    padding: 1.125rem 1.25rem;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.form-message i {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.form-message.success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    color: #155724;
    border: 2px solid #10b981;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.25);
}

.form-message.error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    color: #721c24;
    border: 2px solid #ef4444;
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.25);
}

/* ─────────────────────────────────────────────────────── */
/* BOUTON SUBMIT PREMIUM */
/* ─────────────────────────────────────────────────────── */
.form-actions {
    margin-top: 0.5rem;
}

.btn-submit {
    width: 100%;
    padding: 0.875rem 1.5rem; /* ✅ Légèrement réduit */
    background: var(--gradient);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
    position: relative;
    overflow: hidden;
}

.btn-submit::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
}

.btn-submit:hover:not(:disabled)::before {
    left: 100%;
}

.btn-submit:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5);
}

.btn-submit:active:not(:disabled) {
    transform: translateY(-1px);
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-submit i {
    font-size: 1.25rem;
}

/* ─────────────────────────────────────────────────────── */
/* FOOTER COMPACT */
/* ─────────────────────────────────────────────────────── */
.popup-footer {
    padding: 1.5rem 2.5rem; /* ✅ Réduit de 2rem */
    background: rgba(99, 102, 241, 0.03);
    border-top: 1px solid rgba(99, 102, 241, 0.1);
    text-align: center;
}

.popup-footer p {
    color: var(--gray);
    font-size: 0.875rem; /* ✅ Réduit de 0.9375rem */
    margin-bottom: 0.875rem; /* ✅ Réduit de 1.125rem */
    font-weight: 500;
}

.popup-footer .btn-outline {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem; /* ✅ Réduit de 0.625rem */
    padding: 0.75rem 1.5rem; /* ✅ Réduit de 0.875rem 1.75rem */
    border: 2px solid var(--primary);
    background: white;
    color: var(--primary);
    border-radius: 10px; /* ✅ Réduit de 12px */
    text-decoration: none;
    font-size: 0.9375rem; /* ✅ Ajouté */
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.popup-footer .btn-outline:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px); /* ✅ Réduit de -3px */
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.3); /* ✅ Réduit */
}

/* ─────────────────────────────────────────────────────── */
/* ANIMATIONS PERSONNALISÉES */
/* ─────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUpScale {
    0% {
        opacity: 0;
        transform: translate(-50%, -45%) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ─────────────────────────────────────────────────────── */
/* LARGE SCREENS - Optimiser l'espace */
/* ─────────────────────────────────────────────────────── */
@media (min-width: 1200px) {
    .popup-modal {
        max-width: 950px; /* ✅ Encore plus large sur grands écrans */
    }

    #contactForm {
        gap: 2.5rem; /* ✅ Plus d'espace entre colonnes */
    }

    .popup-body {
        padding: 1.75rem 3rem 2rem; /* ✅ Plus de padding latéral */
        max-height: calc(90vh - 200px); /* ✅ Encore plus d'espace */
    }

    .popup-header {
        padding: 2rem 3rem 1.5rem;
    }

    .popup-footer {
        padding: 1.75rem 3rem;
    }
}

/* ─────────────────────────────────────────────────────── */
/* RESPONSIVE MOBILE (≤768px) */
/* ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .popup-modal {
        width: 96%;
        max-height: 110vh;
        border-radius: 20px;
        max-width: 600px;
    }

    /* ✅ 1 colonne sur mobile */
    #contactForm {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .form-column {
        gap: 1.25rem;
    }

    /* ✅ Textarea adapté mobile */
    #contactMessage {
        min-height: 200px !important;
        max-height: 200px !important;
    }

    .form-actions {
        margin-top: 1rem;
    }

    .popup-header {
        padding: 1.5rem 1.5rem 1.25rem;
    }

    .popup-header h2 {
        font-size: 1.5rem;
    }

    .popup-body {
        padding: 1.5rem;
        max-height: calc(110vh - 140px);
    }

    .popup-footer {
        padding: 1.25rem 1.5rem;
    }

    .btn-submit {
        padding: 0.875rem 1.5rem;
        font-size: 1rem;
    }

    .form-message {
        left: 1.5rem;
        right: 1.5rem;
        font-size: 0.875rem;
    }

    .popup-body.with-message form {
        padding-top: 4.5rem;
    }
}

@media (max-width: 480px) {
    .popup-header h2 {
        font-size: 1.375rem;
    }

    .popup-body {
        padding: 1rem 1.25rem;
        max-height: calc(110vh - 130px);
    }

    .popup-footer {
        padding: 1rem 1.25rem;
    }
}



@media (max-height: 700px) {
    /* ✅ NOUVEAU : Pour petits écrans en hauteur */
    .popup-modal {
        max-height: 110vh;
    }

    .popup-body {
        padding: 1rem 2.5rem 1.5rem; /* ✅ Réduit top */
        max-height: calc(110vh - 200px);
    }

    .popup-header {
        padding: 1.5rem 2.5rem 1rem; /* ✅ Réduit bottom */
    }

    .popup-footer {
        padding: 1.25rem 2.5rem;
    }
}
