/* ============================================
   MODALS — Design System Antiks
   Source unique de verite pour TOUTES les modales.
   Toutes les modales utilisent Bootstrap 5 modal.fade
   Couleurs : Saphir #0F2347 | Or #C5A059 | Ivoire #F3E5D8
   ============================================ */

/* =============================================
   1. BOOTSTRAP STANDARD — BASE
   ============================================= */

/* Fond de l'overlay Bootstrap */
.modal-backdrop {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    background-color: rgba(0, 0, 0, 0.5) !important;
}

/* ── Contrainte de hauteur globale ──
   Toutes les modales sont limitees a 85vh.
   Le header et le footer restent fixes, le body scrolle. */
.modal-content {
    background: #fff !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2) !important;
    max-height: 85vh !important;
    display: flex !important;
    flex-direction: column !important;
}

.modal-header {
    background: var(--primary-color, #0F2347) !important;
    color: #F3E5D8 !important;
    border-bottom: none !important;
    border-radius: 0 !important;
    padding: 1rem 1.5rem !important;
    flex-shrink: 0;
}

.modal-header .modal-title {
    color: #F3E5D8 !important;
    font-weight: 600;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Icone repere Or dans le titre */
.modal-header .modal-title .modal-icon {
    color: #C5A059;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Bouton fermer dans header sombre */
.modal-header .btn-close {
    filter: invert(1) brightness(2) !important;
    opacity: 0.75;
    transition: opacity 0.2s;
}
.modal-header .btn-close:hover {
    opacity: 1;
}

/* Corps — scrolle automatiquement grace au flex */
.modal-body {
    padding: 1.5rem !important;
    background: #fff !important;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
}

/* Pied de page — colle en bas */
.modal-footer {
    background: #F3E5D8 !important;
    border-top: 1px solid rgba(15, 35, 71, 0.06) !important;
    border-radius: 0 !important;
    padding: 0.75rem 1.5rem !important;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Boutons dans le footer */
.modal-footer .btn {
    border-radius: 0;
    padding: 0.5rem 1.25rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    transition: all 0.2s ease;
}

/* Bouton action principal (Or) */
.modal-footer .btn-primary,
.modal-footer .btn-success,
.modal-footer .btn-warning {
    background: linear-gradient(135deg, #C5A059, #D4AF61) !important;
    border-color: transparent !important;
    color: #0B1A2E !important;
}
.modal-footer .btn-primary:hover,
.modal-footer .btn-success:hover,
.modal-footer .btn-warning:hover {
    background: linear-gradient(135deg, #D4AF61, #C5A059) !important;
    color: #0B1A2E !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(197, 160, 89, 0.35);
}

/* Bouton annuler */
.modal-footer .btn-light,
.modal-footer .btn-secondary,
.modal-footer .btn-outline-secondary {
    background: transparent !important;
    border: 1px solid rgba(15, 35, 71, 0.25) !important;
    color: #0F2347 !important;
}
.modal-footer .btn-light:hover,
.modal-footer .btn-secondary:hover {
    background: rgba(15, 35, 71, 0.06) !important;
    border-color: #0F2347 !important;
}

/* Bouton danger */
.modal-footer .btn-danger {
    background: #8B2332 !important;
    border-color: #8B2332 !important;
    color: #fff !important;
}
.modal-footer .btn-danger:hover {
    background: #a02a3a !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 35, 50, 0.3);
}

/* =============================================
   2. HEADER COLORE selon le contexte
   ============================================= */

/* Succes */
.modal-header.bg-success,
.modal-header.header-success {
    background: linear-gradient(135deg, #C5A059, #D4AF61) !important;
    color: #0B1A2E !important;
}
.modal-header.bg-success .modal-title,
.modal-header.header-success .modal-title {
    color: #0B1A2E !important;
}

/* Danger */
.modal-header.bg-danger,
.modal-header.header-danger {
    background: #8B2332 !important;
    color: #fff !important;
}
.modal-header.bg-danger .modal-title,
.modal-header.header-danger .modal-title {
    color: #fff !important;
}

/* =============================================
   3. COMPOSANTS INTERNES DES MODALES
   ============================================= */

/* Carte selectionnable (option) */
.option-card {
    border: 2px solid rgba(15, 35, 71, 0.06);
    border-radius: 0;
    padding: 1rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
}
.option-card:hover {
    border-color: rgba(15, 35, 71, 0.15);
    background: rgba(243, 229, 216, 0.3);
}
.option-card.selected {
    border-color: #C5A059;
    background: rgba(197, 160, 89, 0.05);
}
.option-card .option-icon {
    width: 40px;
    height: 40px;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    background: rgba(197, 160, 89, 0.1);
    color: #C5A059;
    flex-shrink: 0;
}
.option-icon.icon-success { background: rgba(197, 160, 89, 0.1); color: #C5A059; }
.option-icon.icon-warning { background: rgba(212, 175, 97, 0.15); color: #B08A3E; }
.option-icon.icon-danger  { background: rgba(139, 35, 50, 0.1); color: #8B2332; }
.option-icon.icon-info    { background: rgba(107, 142, 168, 0.1); color: #6B8EA8; }
.option-icon.icon-saphir  { background: rgba(15, 35, 71, 0.1); color: #0F2347; }
.option-card .option-title {
    font-weight: 600;
    color: #0F2347;
    margin-bottom: 0.15rem;
}
.option-card .option-desc {
    font-size: 0.8rem;
    color: rgba(15, 35, 71, 0.5);
    margin: 0;
}

/* Badge titre meuble */
.furniture-title-badge {
    background: linear-gradient(135deg, #F3E5D8 0%, rgba(15, 35, 71, 0.04) 100%);
    border-radius: 0;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    border-left: 4px solid #C5A059;
}
.furniture-title-badge .title-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(15, 35, 71, 0.5);
    margin-bottom: 0.25rem;
}
.furniture-title-badge .title-value {
    font-weight: 600;
    color: #0F2347;
}

/* Conteneurs details */
.modal-details-container,
.sold-details-container,
.schedule-options-container {
    background: #F3E5D8;
    border-radius: 0;
    padding: 1rem;
    margin-top: 0.75rem;
    border: 1px solid rgba(15, 35, 71, 0.06);
}

/* Alertes dans les modales */
.modal-body .alert {
    border-radius: 0;
    border: none;
    padding: 0.875rem 1rem;
}
.modal-body .alert-warning {
    background: rgba(212, 175, 97, 0.12);
    color: #0F2347;
}
.modal-body .alert-info {
    background: rgba(107, 142, 168, 0.1);
    color: #0F2347;
}
.modal-body .alert-danger {
    background: rgba(139, 35, 50, 0.08);
    color: #8B2332;
}
.modal-body .alert-success {
    background: rgba(197, 160, 89, 0.1);
    color: #0F2347;
}

/* Formulaires dans les modales */
.modal-body .form-control,
.modal-body .form-select {
    border-radius: 0;
    border: 1px solid rgba(15, 35, 71, 0.15);
    padding: 0.6rem 0.875rem;
    background: #fff;
}
.modal-body .form-control:focus,
.modal-body .form-select:focus {
    border-color: #C5A059;
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.15);
}

/* Champs invalides — surbrillance rouge */
.modal-body .form-control.is-invalid,
.modal-body .form-select.is-invalid {
    border-color: #8B2332 !important;
    box-shadow: 0 0 0 3px rgba(139, 35, 50, 0.15) !important;
    background-image: none;
}
.modal-body .form-label {
    font-weight: 500;
    font-size: 0.85rem;
    color: #0F2347;
}

/* =============================================
   4. ANIMATION D'ENTREE
   ============================================= */
@keyframes antiks-modal-fadein {
    from { opacity: 0; transform: scale(0.97) translateY(8px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal.show .modal-dialog {
    animation: antiks-modal-fadein 0.2s ease;
}

/* =============================================
   5. RESPONSIVE (tablette + mobile)
   ============================================= */
@media (max-width: 991.98px) {

    /* Aucune modale ne doit depasser le viewport */
    .modal-dialog {
        margin: 0.5rem !important;
        max-width: calc(100% - 1rem) !important;
    }

    .modal-content {
        max-height: 90vh !important;
    }

    .modal-header {
        padding: 0.875rem 1rem !important;
    }

    .modal-header .modal-title {
        font-size: 0.95rem;
    }

    .modal-body {
        padding: 1rem !important;
        font-size: 0.875rem;
    }

    .modal-footer {
        padding: 0.75rem 1rem !important;
        flex-wrap: nowrap;
    }

    .modal-footer .btn {
        font-size: 0.7rem;
        padding: 0.5rem 0.75rem;
        flex: 1;
    }

    .option-card {
        padding: 0.75rem;
    }
}

/* =============================================
   6. SCROLLBAR STYLEE
   ============================================= */
.modal-body::-webkit-scrollbar {
    width: 4px;
}
.modal-body::-webkit-scrollbar-track {
    background: rgba(15, 35, 71, 0.04);
}
.modal-body::-webkit-scrollbar-thumb {
    background: rgba(197, 160, 89, 0.4);
    border-radius: 2px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
    background: #C5A059;
}
