/* ==========================================================================
   Boite a outils – Drawer admin CRUD
   ========================================================================== */

/* Drawer principal - Boite a outils */
.popup-gestion-boite {
    position: fixed;
    top: 9vh;
    right: -900px;
    width: 100%;
    max-width: 850px;
    height: 91vh;
    background: #fff;
    z-index: 9999998;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    border-radius: 20px 0 0 0;
    box-shadow: -2px 0 20px rgba(0,0,0,0.25);
}
.popup-gestion-boite.open {
    right: 0;
}
#boite-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999997;
    display: none;
}
#boite-overlay.open {
    display: block;
}

/* Header */
.popup-gestion-boite .popup-header-edit {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #ddd;
    background: #4d74b5;
}
.popup-gestion-boite .popup-header-edit h4 {
    margin: 0;
    padding: 0 !important;
    font-size: 20px !important;
    color: white !important;
    font-weight: 600 !important;
    font-family: 'Nexa Light' !important;
}
.popup-gestion-boite .popup-close {
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    color: white !important;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.popup-gestion-boite .popup-close:hover {
    background: white;
    color: #4d74b5 !important;
}

/* Onglets */
.popup-gestion-boite .drawer-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    background: #f9f9f9;
}
.popup-gestion-boite .drawer-tab {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    font-family: "Nexa Light" !important;
    color: #686868 !important;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}
.popup-gestion-boite .drawer-tab:hover {
    background: #e9eef0;
}
.popup-gestion-boite .drawer-tab.active {
    color: #4d74b5 !important;
    border-bottom-color: #4d74b5;
}
.popup-gestion-boite .drawer-tab-content {
    display: none;
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}
.popup-gestion-boite .drawer-tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Formulaire intro */
.popup-gestion-boite .drawer-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.popup-gestion-boite .d-flex {
    display: flex;
    gap: 16px;
}
.popup-gestion-boite .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-radius: 10px;
    background-color: #4d74b557;
    padding: 15px;
}
.popup-gestion-boite .form-group.half-flex {
    flex: 1;
}
.popup-gestion-boite .form-group label {
    font-weight: 600;
    font-size: 14px;
    color: #1d2327;
    font-family: 'Nexa Light';
}
.popup-gestion-boite .form-group textarea,
.popup-gestion-boite .form-group input[type="text"],
.popup-gestion-boite .form-group input[type="url"] {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
}
.popup-gestion-boite .form-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}
.popup-gestion-boite .button-primary {
    background: #00a09a;
    color: white;
    padding: 10px 20px;
    min-width: 30%;
    border: none;
    border-radius: 6px;
    font-family: 'Nexa Light';
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}
.popup-gestion-boite .button-primary:hover {
    background: #008f8a;
}
.popup-gestion-boite .button-secondary {
    background: #4d74b5;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-family: 'Nexa Light';
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}
.popup-gestion-boite .button-secondary:hover {
    background: #3d5a8a;
}

/* Upload image */
.popup-gestion-boite .image-upload-wrapper {
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
}
.popup-gestion-boite .image-preview {
    position: relative;
    max-width: 300px;
}
.popup-gestion-boite .image-preview img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid #ddd;
}
.popup-gestion-boite .image-preview .remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #dc3545;
    color: white;
    border: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.popup-gestion-boite .image-preview .remove-image:hover {
    background: #c82333;
}

/* Liste des liens */
.popup-gestion-boite .liste-liens {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    max-height: 50vh;
    flex: 1;
}
.popup-gestion-boite .ligne-lien {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #ddd;
    transition: all 0.2s ease;
}
.popup-gestion-boite .ligne-lien:hover {
    background: #f0f0f0;
}
.popup-gestion-boite .titre-lien {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    color: #1d2327;
}
.popup-gestion-boite .btn-view-lien,
.popup-gestion-boite .btn-edit-lien-boite,
.popup-gestion-boite .btn-delete-lien-boite {
    padding: 8px;
    border: none !important;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.popup-gestion-boite .btn-view-lien img,
.popup-gestion-boite .btn-edit-lien-boite img,
.popup-gestion-boite .btn-delete-lien-boite img {
    width: 20px;
    height: auto;
}
.popup-gestion-boite .compteur-liens {
    padding: 15px;
    text-align: center;
    color: #666;
    font-size: 14px;
}

/* Formulaire lien utile */
.popup-gestion-boite .form-lien-utile {
    padding: 20px;
    background: #f9f9f9;
    border-radius: 10px;
    margin-top: 15px;
}
.popup-gestion-boite .form-lien-utile.hidden-form {
    display: none !important;
}

/* Footer avec bouton ajouter */
.popup-gestion-boite .popup-footer {
    padding: 15px 20px;
    border-top: 1px solid #ddd;
}
.popup-gestion-boite .btn-add {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #4d74b5;
    font-family: 'Nexa Light';
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}
.popup-gestion-boite .btn-add:hover {
    background: #3d5a8a;
}
.popup-gestion-boite .btn-add img {
    width: 18px;
    height: auto;
}

/* Iframe container */
.popup-gestion-boite .iframe-container {
    flex: 1;
    display: flex;
}
.popup-gestion-boite .iframe-container iframe {
    width: 100%;
    height: 100%;
    min-height: 500px;
    border: none;
}

/* TinyMCE */
#boite_intro_text {
    width: 100%;
    min-height: 200px;
}
.tox-tinymce,
.mce-tinymce {
    border-radius: 6px !important;
}

/* IMPORTANT: Z-index pour les menus TinyMCE */
.mce-menu,
.mce-floatpanel,
.mce-panel.mce-floatpanel,
.mce-container.mce-panel.mce-floatpanel,
.mce-container.mce-panel.mce-floatpanel.mce-menu,
body > .mce-menu,
body > .mce-floatpanel {
    z-index: 99999999999 !important;
}
.mce-menu .mce-menu-item,
.mce-menu-item {
    display: block !important;
}
.mce-listbox .mce-menu {
    max-height: 300px !important;
    overflow-y: auto !important;
    background: #fff !important;
}

/* Media Library au-dessus */
.media-modal {
    z-index: 9999999999999 !important;
}
.media-modal-backdrop {
    z-index: 99999 !important;
}

@media (max-width: 768px) {
    .popup-gestion-boite .d-flex {
        flex-direction: column;
    }
    .popup-gestion-boite {
        max-width: 100%;
    }
}
