/* =====================================================
   GLOBAL MODAL STYLES - Modern & Beautiful Design
   ===================================================== */

/* ===========================================
   MODAL BACKDROP - Effet glassmorphism
   =========================================== */
.modal-backdrop {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.7), rgba(30, 41, 59a, 0.8)) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.modal-backdrop.show {
    opacity: 1 !important;
}

/* ===========================================
   MODAL CONTAINER
   =========================================== */
.modal.fade .modal-dialog {
    transform: scale(0.9) translateY(-50px);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
}

/* ===========================================
   MODAL CONTENT - Carte principale
   =========================================== */
.modal .modal-content {
    border: none !important;
    border-radius: 20px !important;
    box-shadow:
        0 25px 50px -12px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.1) !important;
    overflow: hidden !important;
    background: #ffffff !important;
}

/* ===========================================
   MODAL HEADER - En-tête avec gradient
   =========================================== */
.modal .modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%) !important;
    border: none !important;
    padding: 22px 28px !important;
    position: relative;
    overflow: hidden;
}

/* Effet de brillance sur le header */
.modal .modal-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    animation: headerShine 3s infinite;
}

@keyframes headerShine {
    0% { left: -100%; }
    50%, 100% { left: 100%; }
}

/* Pattern décoratif subtil */
.modal .modal-header::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    transform: translate(30%, -30%);
}

.modal .modal-title {
    font-weight: 700 !important;
    font-size: 1.25rem !important;
    color: #ffffff !important;
    margin: 0 !important;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex !important;
    align-items: center !important;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.modal .modal-title i,
.modal .modal-title .fas,
.modal .modal-title .far,
.modal .modal-title .fa {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Bouton fermer */
.modal .close,
.modal .btn-close {
    color: #ffffff !important;
    opacity: 0.85 !important;
    font-size: 1.6rem !important;
    font-weight: 300 !important;
    text-shadow: none !important;
    transition: all 0.2s ease !important;
    position: relative;
    z-index: 1;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    padding: 0;
    margin: -8px -8px -8px auto;
}

.modal .close:hover,
.modal .btn-close:hover {
    opacity: 1 !important;
    background: rgba(255, 255, 255, 0.25) !important;
    transform: rotate(90deg);
}

/* ===========================================
   MODAL BODY - Corps du modal
   =========================================== */
.modal .modal-body {
    padding: 28px !important;
    background: #ffffff !important;
    color: #1e293b !important;
}

/* ===========================================
   FORM ELEMENTS - Champs de formulaire
   =========================================== */
.modal .form-group {
    margin-bottom: 22px;
}

.modal .form-group label,
.modal label {
    font-weight: 600;
    color: #334155;
    margin-bottom: 10px;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal .form-group label i,
.modal label i {
    color: #667eea;
    font-size: 0.85rem;
}

.modal .form-control,
.modal .form-select,
.modal select.form-control {
    border: 2px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 14px 18px !important;
    font-size: 1rem !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    background: #f8fafc !important;
    color: #1e293b !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

.modal .form-control:focus,
.modal .form-select:focus,
.modal select.form-control:focus {
    border-color: #667eea !important;
    box-shadow:
        0 0 0 4px rgba(102, 126, 234, 0.15),
        0 1px 2px rgba(0, 0, 0, 0.05) !important;
    background: #ffffff !important;
    outline: none !important;
}

.modal .form-control::placeholder {
    color: #94a3b8;
}

/* Input avec icône */
.modal .input-group {
    position: relative;
}

.modal .input-group .form-control {
    padding-left: 48px !important;
}

.modal .input-group-text {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: #667eea;
    z-index: 5;
}

/* ===========================================
   SELECT2 STYLING
   =========================================== */
.modal .select2-container .select2-selection--single,
.modal .select2-container .select2-selection--multiple {
    min-height: 50px !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 8px 14px !important;
    background: #f8fafc !important;
    transition: all 0.3s ease !important;
}

.modal .select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 32px !important;
    color: #1e293b !important;
    padding-left: 0 !important;
}

.modal .select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 48px !important;
    right: 12px !important;
}

.modal .select2-container--default.select2-container--focus .select2-selection--single,
.modal .select2-container--default.select2-container--focus .select2-selection--multiple,
.modal .select2-container--default.select2-container--open .select2-selection--single,
.modal .select2-container--default.select2-container--open .select2-selection--multiple {
    border-color: #667eea !important;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15) !important;
}

/* ===========================================
   BUTTONS - Boutons modernes
   =========================================== */
.modal .btn {
    border-radius: 12px !important;
    padding: 12px 24px !important;
    font-weight: 600 !important;
    font-size: 0.95rem !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    border: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    text-transform: none;
    letter-spacing: 0.3px;
    position: relative;
    overflow: hidden;
}

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

.modal .btn:hover::before {
    left: 100%;
}

/* Primary Button */
.modal .btn-primary,
.modal .btn-info {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4) !important;
}

.modal .btn-primary:hover,
.modal .btn-info:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5) !important;
}

.modal .btn-primary:active,
.modal .btn-info:active {
    transform: translateY(0) !important;
}

/* Success Button */
.modal .btn-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4) !important;
}

.modal .btn-success:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.5) !important;
}

/* Danger Button */
.modal .btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4) !important;
}

.modal .btn-danger:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.5) !important;
}

/* Warning Button */
.modal .btn-warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4) !important;
}

.modal .btn-warning:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.5) !important;
}

/* Secondary/Default Button */
.modal .btn-secondary,
.modal .btn-default,
.modal .btn-light {
    background: #f1f5f9 !important;
    color: #475569 !important;
    border: 2px solid #e2e8f0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05) !important;
}

.modal .btn-secondary:hover,
.modal .btn-default:hover,
.modal .btn-light:hover {
    background: #e2e8f0 !important;
    color: #334155 !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

/* ===========================================
   MODAL FOOTER
   =========================================== */
.modal .modal-footer {
    background: linear-gradient(to top, #f8fafc, #ffffff) !important;
    border: none !important;
    border-top: 1px solid #f1f5f9 !important;
    padding: 20px 28px !important;
    display: flex !important;
    justify-content: flex-end !important;
    gap: 12px !important;
}

/* ===========================================
   TABLES INSIDE MODALS
   =========================================== */
.modal .table {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}

.modal .table thead th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #ffffff;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    padding: 14px 16px;
    border: none;
}

.modal .table tbody td {
    padding: 14px 16px;
    vertical-align: middle;
    border-color: #f1f5f9;
}

.modal .table tbody tr:hover {
    background: #f8fafc;
}

/* ===========================================
   ALERTS INSIDE MODALS
   =========================================== */
.modal .alert {
    border: none;
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal .alert-info {
    background: linear-gradient(135deg, #e0f2fe, #bae6fd);
    color: #0369a1;
}

.modal .alert-success {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #047857;
}

.modal .alert-warning {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #b45309;
}

.modal .alert-danger {
    background: linear-gradient(135deg, #fee2e2, #fecaca);
    color: #b91c1c;
}

/* ===========================================
   LOADING STATE
   =========================================== */
.modal .spinner-border {
    width: 1.2rem;
    height: 1.2rem;
    border-width: 2px;
}

.modal .btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

/* ===========================================
   CHECKBOX & RADIO CUSTOM
   =========================================== */
.modal .custom-control-input:checked ~ .custom-control-label::before {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
}

.modal .custom-checkbox .custom-control-label::before {
    border-radius: 6px;
}

/* ===========================================
   TEXTAREA
   =========================================== */
.modal textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

/* ===========================================
   FILE INPUT
   =========================================== */
.modal .custom-file-label {
    border: 2px dashed #e2e8f0 !important;
    border-radius: 12px !important;
    padding: 20px !important;
    background: #f8fafc !important;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal .custom-file-label:hover {
    border-color: #667eea !important;
    background: #f0f4ff !important;
}

.modal .custom-file-label::after {
    display: none;
}

/* ===========================================
   RESPONSIVE DESIGN
   =========================================== */
@media (max-width: 768px) {
    .modal .modal-dialog {
        margin: 15px !important;
    }

    .modal .modal-header {
        padding: 18px 20px !important;
    }

    .modal .modal-body {
        padding: 20px !important;
    }

    .modal .modal-footer {
        padding: 16px 20px !important;
        flex-direction: column;
    }

    .modal .modal-footer .btn {
        width: 100%;
    }

    .modal .modal-title {
        font-size: 1.1rem !important;
    }
}

@media (max-width: 576px) {
    .modal .modal-dialog {
        margin: 10px !important;
    }

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

    .modal .modal-body {
        padding: 15px !important;
    }

    .modal .modal-footer {
        padding: 12px 15px !important;
    }
}

/* ===========================================
   MODAL SIZE VARIANTS
   =========================================== */
.modal .modal-lg {
    max-width: 900px;
}

.modal .modal-xl {
    max-width: 1140px;
}

.modal .modal-sm {
    max-width: 400px;
}

/* ===========================================
   DARK MODE SUPPORT
   =========================================== */
.dark-mode .modal .modal-content,
body.dark-mode .modal .modal-content {
    background: #1e293b !important;
}

.dark-mode .modal .modal-body,
body.dark-mode .modal .modal-body {
    background: #1e293b !important;
    color: #e2e8f0 !important;
}

.dark-mode .modal .form-control,
body.dark-mode .modal .form-control {
    background: #334155 !important;
    border-color: #475569 !important;
    color: #e2e8f0 !important;
}

.dark-mode .modal .form-control:focus,
body.dark-mode .modal .form-control:focus {
    background: #3b4a5f !important;
    border-color: #667eea !important;
}

.dark-mode .modal .form-group label,
.dark-mode .modal label,
body.dark-mode .modal .form-group label,
body.dark-mode .modal label {
    color: #cbd5e1 !important;
}

.dark-mode .modal .modal-footer,
body.dark-mode .modal .modal-footer {
    background: linear-gradient(to top, #0f172a, #1e293b) !important;
    border-top-color: #334155 !important;
}

.dark-mode .modal .btn-secondary,
.dark-mode .modal .btn-default,
.dark-mode .modal .btn-light,
body.dark-mode .modal .btn-secondary,
body.dark-mode .modal .btn-default,
body.dark-mode .modal .btn-light {
    background: #334155 !important;
    color: #e2e8f0 !important;
    border-color: #475569 !important;
}

/* ===========================================
   SPECIAL EFFECTS
   =========================================== */

/* Effet de glow sur focus */
.modal .form-control:focus {
    animation: inputGlow 0.3s ease;
}

@keyframes inputGlow {
    0% { box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4); }
    100% { box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.15); }
}

/* Smooth scrollbar pour modal body */
.modal .modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal .modal-body::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.modal .modal-body::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 3px;
}

.modal .modal-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd6, #6a4190);
}

/* ===========================================
   COMPATIBILITY - Remove old conflicting styles
   =========================================== */
.modal-enhanced .modal-content,
.modal-enhanced .modal-header,
.modal-enhanced .modal-body,
.modal-enhanced .modal-footer {
    /* Ces styles sont maintenant gérés globalement */
}
