/**
 * Styles pour le drawer Page CPTS (edition WYSIWYG)
 */

/* Drawer cache par defaut */
.projets-drawer-overlay {
    display: none;
    position: fixed;
    inset: 0;
    top: 8vh !important;
    height: 92vh;
    z-index: 9999998;
    opacity: 0;
    transition: opacity .3s ease;
}

/* Quand actif */
.projets-drawer-overlay.active {
    display: flex;
    justify-content: flex-end;
}

/* Quand visible */
.projets-drawer-overlay.show {
    opacity: 1;
}

/* Drawer ferme par defaut (deplace a droite) */
.projets-drawer {
    transform: translateX(100%);
    transition: transform .3s ease;
    width: 100vw;
    max-width: 1000px;
    background-color: white;
    box-shadow: 0px 0px 15px #ececec;
    display: flex;
    flex-direction: column;
}

/* Drawer ouvert */
.projets-drawer-overlay.show .projets-drawer {
    transform: translateX(0);
}

/* ============================================
   FIX : Mediatheque WordPress au-dessus du drawer
   ============================================ */
.media-modal {
    z-index: 9999999999999 !important;
}

.media-modal-backdrop {
    z-index: 999999 !important;
}

/* ============================================
   FIX : Menus TinyMCE au-dessus du drawer
   ============================================ */
.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;
}

/* Overlay derriere le fullscreen */
.mce-fullscreen::before {
    content: '';
    position: fixed;
    top: -50vh;
    left: -50vw;
    width: 200vw;
    height: 200vh;
    background: rgba(0,0,0,0.5);
    z-index: -1;
}

/* ============================================
   Statusbar TinyMCE pour le resize
   ============================================ */
.mce-statusbar {
    background: #f5f5f5 !important;
    border-top: 1px solid #ddd !important;
}
.mce-path {
    display: none !important;
}
.mce-resizehandle {
    cursor: nwse-resize !important;
}

/* Styles pour l'image preview */
.image-preview {
    position: relative;
    margin-top: 10px;
    max-width: 300px;
}

.image-preview img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.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;
}

.remove-image:hover {
    background: #c82333;
}

.form-group {
    margin-bottom: 20px;
    background-color: #4d74b557;
    padding: 15px;
    border-radius: 10px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #1d2327;
    font-family: 'Nexa Light';
}

.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    min-height: 150px;
}

.button-secondary {
    padding: 10px 20px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-family: 'Nexa Light';
}

.button-secondary:hover {
    background: #5a6268;
}

.button-primary {
    padding: 10px 20px;
    background: #00a09a;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: 'Nexa Light';
}

.button-primary:hover {
    background: #008f8a;
}

.button-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.form-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    gap: 12px;
}

/* Onglets */
.drawer-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    background: #f9f9f9;
}

.drawer-tab {
    flex: 1;
    padding: 12px 16px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #686868;
    font-family: 'Nexa Light';
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.drawer-tab:hover {
    background: #e9eef0;
}

.drawer-tab.active {
    color: #4d74b5;
    border-bottom-color: #4d74b5;
}

.drawer-tab-content {
    display: none;
}

.drawer-tab-content.active {
    display: block;
    padding:0
}

.projets-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-radius: 30px 0 0 0;
    border-bottom: 1px solid #ddd;
    background-color: #4d74b5;
}

.projets-drawer-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: white;
    font-family: 'Nexa Light';
}

.projets-drawer-close {
    border: none;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    color: white;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.projets-drawer-close:hover {
    background: white;
    color: #4d74b5;
}

/* TinyMCE styling */
.mce-tinymce {
    border-radius: 6px !important;
}

/* ============================================
   STYLES ONGLET DATES (Branches Arbre)
   ============================================ */
.branches-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

.branches-header h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
    font-family: 'Nexa Light';
}

#branches-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.branche-item {
    background: #4d74b520;
    border: 1px solid #4d74b540;
    border-radius: 10px;
    padding: 15px;
    transition: all 0.2s ease;
}

.branche-item:hover {
    border-color: #4d74b5;
}

.branche-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.branche-number {
    background: #4d74b5;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

.remove-branche-btn {
    background: #dc3545;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.remove-branche-btn:hover {
    background: #c82333;
}

.branche-fields {
    display: grid;
    grid-template-columns: 80px 1fr 2fr;
    gap: 15px;
    align-items: start;
}

.branche-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 5px;
    font-family: 'Nexa Light';
}

.branche-field-picto .branche-upload-picto {
    width: 60px;
    height: 60px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #4d74b5;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    overflow: hidden;
}

.branche-field-picto .branche-upload-picto:hover {
    background: #f0f4ff;
}

.branche-field-picto .branche-upload-picto span {
    font-size: 24px;
    color: #4d74b5;
}

.branche-field-picto .picto-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.branche-field-titre input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
}

.branche-field-texte textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    resize: vertical;
    min-height: 60px;
}

#add-branche-btn {
    background: #4d74b5;
    color: white;
}

#add-branche-btn:hover {
    background: #3d5a8a;
}

/* Responsive branches */
@media (max-width: 600px) {
    .branche-fields {
        grid-template-columns: 1fr;
    }

    .branche-field-picto {
        justify-self: start;
    }
}
