/* ==========================================================================
   Liens Utiles – Grid front
   ========================================================================== */

.liens-utiles-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1em;
    flex-wrap: wrap;
}
.liens-utiles-header h2 {
    color: #121234;
    font-size: 26px;
    padding-bottom: 10px;
    line-height: 1em;
    font-weight: 500;
    margin: 0;
}
.tri-alpha-btn {
    background: #121234;
    color: white;
    border: 1px solid #ccc;
    padding: 8px 16px;
    border-radius: 84px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}
.tri-alpha-btn:hover {
    background: #f48e00;
    color: #fff;
}
.liens-utiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.lien-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    background: #fff;
}
.lien-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transform: translateY(-2px);
    border-color: #f48e00;
}
.lien-item img {
    width: 100%;
    max-width: 150px;
    height: auto;
    margin-bottom: 10px;
    border-radius: 4px;
}
.lien-item span {
    color: #121234;
    font-weight: 500;
    font-size: 14px;
}
.lien-item:hover span {
    color: #f48e00;
}


/* ==========================================================================
   Liens Utiles – Drawer admin CRUD
   ========================================================================== */

/* Drawer principal */
.popup-gestion-liens {
    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-liens.open {
    right: 0;
}
#liens-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999997;
    display: none;
}
#liens-overlay.open {
    display: block;
}

/* Header */
.popup-gestion-liens .popup-header-edit {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #ddd;
    background: #4d74b5;
}
.popup-gestion-liens .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-liens .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-liens .popup-close:hover {
    background: white;
    color: #4d74b5 !important;
}

/* Onglets */
.popup-gestion-liens .drawer-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    background: #f9f9f9;
}
.popup-gestion-liens .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-liens .drawer-tab:hover {
    background: #e9eef0;
}
.popup-gestion-liens .drawer-tab.active {
    color: #4d74b5 !important;
    border-bottom-color: #4d74b5;
}
.popup-gestion-liens .drawer-tab-content {
    display: none;
    padding: 0px;
    overflow-y: auto;
    flex: 1;
}
.popup-gestion-liens .drawer-tab-content.active {
    display: flex;
    flex-direction: column;
}

/* Formulaire intro */
.popup-gestion-liens .drawer-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.popup-gestion-liens .d-flex {
    display: flex;
    gap: 16px;
}
.popup-gestion-liens .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-radius: 10px;
    background-color: #4d74b557;
    padding: 15px;
}
.popup-gestion-liens .form-group.half-flex {
    flex: 1;
}
.popup-gestion-liens .form-group label {
    font-weight: 600;
    font-size: 14px;
    color: #1d2327;
    font-family: 'Nexa Light';
}
.popup-gestion-liens .form-group textarea,
.popup-gestion-liens .form-group input[type="text"],
.popup-gestion-liens .form-group input[type="url"] {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
}
.popup-gestion-liens .form-actions {
    display: flex;
    gap: 12px;
    margin-top: 10px;
}
.popup-gestion-liens .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-liens .button-primary:hover {
    background: #008f8a;
}
.popup-gestion-liens .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-liens .button-secondary:hover {
    background: #3d5a8a;
}

/* Upload image */
.popup-gestion-liens .image-upload-wrapper {
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
}
.popup-gestion-liens .image-preview {
    position: relative;
    max-width: 300px;
}
.popup-gestion-liens .image-preview img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid #ddd;
}
.popup-gestion-liens .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-liens .image-preview .remove-image:hover {
    background: #c82333;
}

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

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

/* Footer avec bouton ajouter */
.popup-gestion-liens .popup-footer {
    padding: 15px 20px;
    border-top: 1px solid #ddd;
}
.popup-gestion-liens .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-liens .btn-add:hover {
    background: #3d5a8a;
}
.popup-gestion-liens .btn-add img {
    width: 18px;
    height: auto;
}

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

/* TinyMCE */
#liens_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-liens .d-flex {
        flex-direction: column;
    }
    .popup-gestion-liens {
        max-width: 100%;
    }
}
