#wpg-tree-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100000;
    display: flex;
    flex-direction: column;
    padding: 8px;
    box-sizing: border-box;
}
#wpg-tree-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f0f0f0;
    padding: 5px 12px;
    border-radius: 5px 5px 0 0;
    flex-shrink: 0;
    gap: 8px;
    min-height: 44px;   /* cible tactile */
}
#wpg-tree-modal-header h3 {
    margin: 0;
    padding: 0;
    font-size: 1em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* ── Uniformisation + personnalisation des boutons (frontend plugin) ── */
.button,
.button-primary,
.button-secondary,
.button-large,
.button-hero {
    font-size:        var(--wpg-btn-fs,   12px) !important;
    line-height:      var(--wpg-btn-lh,   22px) !important;
    min-height:       var(--wpg-btn-minh, 26px) !important;
    height: auto !important;
    padding:          var(--wpg-btn-pad,  0 8px) !important;
    background-color: var(--wpg-btn-bg,   #f0f0f0) !important;
    color:            var(--wpg-btn-color, #333)   !important;
    font-family:      var(--wpg-font-family, inherit);
}
#wpg-tree-modal-header,
#wpg-pdf-config-inner {
    font-family: var(--wpg-font-family, inherit);
    color:       var(--wpg-text-color,  #1d2327);
}
#wpg-close-tree-modal {
    background: none;
    border: none;
    font-size: 2.2em;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 0 4px;
    flex-shrink: 0;
    min-width: 44px;    /* cible tactile */
    text-align: center;
}
#wpg-close-tree-modal:hover {
    color: #000;
}
#wpg-tree-modal-content {
    flex-grow: 1;
    background: #fff;
    overflow: auto;
    border-radius: 0 0 5px 5px;
    position: relative;
}
#wpg-tree-chart {
    min-height: 100%;
}

/* Centrage sunburst */
.wpg-sunburst-view {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}
.wpg-sunburst-view #wpg-tree-chart {
    flex-shrink: 0;
    min-height: auto;
}

/* ─── Boutons zoom sunburst ─── */
#wpg-sunburst-controls {
    position: fixed;
    bottom: 24px;
    right: 16px;
    z-index: 100001;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#wpg-sunburst-controls .button {
    width: 44px;   /* cible tactile sur mobile */
    height: 44px;
    font-size: 22px;
    line-height: 42px;
    padding: 0;
    text-align: center;
    cursor: pointer;
    background: #fff;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
#wpg-sunburst-controls .button:hover {
    background: #f0f0f1;
}

/* ─── Panneau de configuration PDF ─── */
#wpg-pdf-config {
    position: absolute;
    top: 0;
    right: 0;
    width: min(400px, 100%);    /* ≤ 100% de l'écran */
    height: 100%;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0,0,0,0.3);
    z-index: 10;
    overflow-y: auto;
    animation: wpg-slide-in 0.25s ease-out;
}
@keyframes wpg-slide-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}
#wpg-pdf-config-inner {
    padding: 16px 20px;
}
#wpg-pdf-config-inner h3 {
    margin: 0 0 16px 0;
    font-size: 1.1em;
    border-bottom: 2px solid #2271b1;
    padding-bottom: 8px;
}
.wpg-pdf-row {
    margin-bottom: 14px;
}
.wpg-pdf-row > label:first-child {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    color: #1d2327;
}
.wpg-pdf-row select {
    width: 100%;
    padding: 8px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 16px;   /* empêche zoom iOS */
    box-sizing: border-box;
}
.wpg-pdf-radios {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.wpg-pdf-radios label {
    font-weight: normal;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 36px;  /* cible tactile */
}
.wpg-pdf-grid-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.wpg-pdf-grid-inputs input[type="number"] {
    text-align: center;
    padding: 6px 4px;
    border: 1px solid #8c8f94;
    border-radius: 4px;
    font-size: 16px;
    width: 56px;
}
.wpg-pdf-grid-inputs span {
    font-weight: 600;
    color: #666;
}
.wpg-pdf-grid-total {
    font-size: 12px;
    color: #2271b1;
    font-weight: 600 !important;
}
#wpg-pdf-preview-wrap {
    background: #f0f0f1;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    text-align: center;
}
#wpg-pdf-preview {
    max-width: 100%;
    height: auto;
}
.wpg-pdf-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid #ddd;
    flex-wrap: wrap;
}
.wpg-pdf-actions .button-primary .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* ────────────────────────────────────────────────
   Mobile ≤ 520px : panneau PDF plein écran
   ──────────────────────────────────────────────── */
@media (max-width: 520px) {
    #wpg-tree-modal-overlay {
        padding: 0;
    }
    #wpg-tree-modal-header {
        border-radius: 0;
        padding: 6px 10px;
    }
    #wpg-tree-modal-content {
        border-radius: 0;
    }
    #wpg-pdf-config {
        width: 100%;
        box-shadow: none;
    }
    #wpg-sunburst-controls {
        bottom: 12px;
        right: 10px;
    }
}

/* ────────────────────────────────────────────────
   Desktop ≥ 521px : header h3 taille normale
   ──────────────────────────────────────────────── */
@media (min-width: 521px) {
    #wpg-tree-modal-overlay {
        padding: 15px;
    }
    #wpg-tree-modal-header h3 {
        font-size: 1.2em;
    }
    #wpg-sunburst-controls {
        bottom: 30px;
        right: 30px;
    }
    #wpg-sunburst-controls .button {
        width: 36px;
        height: 36px;
        font-size: 20px;
        line-height: 34px;
    }
}
