/* Generic Popup Styles */

/*
   Tokens de composant (thémables). Les défauts ci-dessous reproduisent
   EXACTEMENT le rendu DARK historique du Workshop (aucune régression) : ils ne
   font que router les couleurs vers des variables que le domaine MRP peut
   remapper en thème clair via `body.mrp-theme` (cf. utils/mrp-base.css).
*/
:root {
    --popup-surface: var(--bg-dark-secondary);
    --popup-text: var(--text-primary);
    --popup-title: var(--text-primary);
    --popup-title-size: 24px;                    /* thémable par domaine */
    --popup-control: var(--text-primary);       /* boutons retour + fermer */
    --popup-control-hover: var(--primary);
    --popup-overlay-bg: var(--black-alpha-85);  /* voile derrière la popup */
}

/* Bloque le scroll de la page sous-jacente tant qu'une popup est ouverte. */
body.popup-open {
    overflow: hidden;
}

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--popup-overlay-bg);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(2px);
    padding: 20px;
    box-sizing: border-box;
    /* Sur tablette/mobile, `overflow:hidden` sur body ne suffit pas à bloquer le
       scroll tactile : le geste "remonte" vers la page (scroll chaining).
       `overscroll-behavior: contain` arrête ce chaînage tout en laissant intact le
       scroll interne des popups (porté par leurs propres conteneurs). */
    overscroll-behavior: contain;
}

.popup-overlay:not(.hidden) {
    display: flex;
}

.popup-container {
    background-color: var(--popup-surface);
    border-radius: var(--radius);
    box-shadow: var(--toast-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 25px 30px;
    color: var(--popup-text);
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
}

.popup-header h2 {
    margin: 0;
    font-size: var(--popup-title-size);
    font-weight: 800;
    text-transform: uppercase;
    color: var(--popup-title);
    letter-spacing: 0;
    flex: 1;
    min-width: 0;
}

.title-20 {
    font-size: 20px !important;
}

.title-22 {
    font-size: 22px !important;
}

.title-24 {
    font-size: 24px !important;
}

.popup-header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.popup-back-btn {
    background: none;
    border: none;
    color: var(--popup-control);
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    opacity: 0.8;
    transition: all 0.2s ease;
}

.popup-back-btn:hover {
    opacity: 1;
    color: var(--popup-control-hover);
}

.popup-close-btn {
    background: none;
    border: none;
    color: var(--popup-control);
    font-size: 35px;
    cursor: pointer;
    padding: 0;
    opacity: 0.8;
    transition: all 0.2s ease;
}

.popup-close-btn:hover {
    opacity: 1;
    color: var(--popup-control-hover);
}

.popup-body {
    flex: 1;
    overflow-y: auto;
    font-size: 18px;
    line-height: 1.4;
    /* Le scroll interne ne remonte pas à la page quand on atteint le bord. */
    overscroll-behavior: contain;
}

.popup-footer {
    display: flex;
    flex-direction: row;
}

.popup-footer-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    justify-content: flex-end;
}

/* Action Buttons in Popups */
.popup-footer button {
    flex: 1;
    min-height: 54px;
    /* Slightly smaller for better fit */
    height: auto;
    border-radius: var(--radius);
    padding: 10px 15px;
    font-size: 18px;
    /* Slightly smaller */
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.popup-footer button:hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
}

.popup-footer button:active {
    transform: translateY(0);
}

.popup-footer button:disabled,
.popup-footer button.is-disabled {
    background-color: var(--neo-text-disabled);
    color: var(--text-muted);
    border-color: var(--line-disabled);
    cursor: not-allowed;
    opacity: 0.6;
    pointer-events: none;
    filter: none;
    transform: none;
}


.popup-footer .btn-solid-green {
    background-color: var(--success-green);
    color: var(--bg-dark);
    border: none;
}

.popup-footer .btn-solid-cyan {
    background-color: var(--primary);
    color: var(--bg-dark);
    border: none;
}

.popup-footer .btn-outline-red {
    background-color: var(--transparent);
    border: 2px solid var(--error-red);
    color: var(--error-red);
}

.popup-footer .btn-outline-red:hover {
    background-color: var(--error-red-alpha-10);
}

/* Contour bleu marque MRP (--border), ex. bouton Annuler de la popin de
   déconnexion — même gabarit que btn-outline-red/cyan. */
.popup-footer .btn-outline-blue {
    background-color: var(--transparent);
    border: 2px solid var(--border);
    color: var(--border);
}

.popup-footer .btn-outline-blue:hover {
    background-color: var(--border-alpha-10);
}

.popup-footer .btn-solid-red {
    background-color: var(--error-red);
    color: var(--white);
    border: none;
}

.popup-footer .btn-solid-red:hover {
    background-color: var(--error-red);
    filter: brightness(1.1);
}

/* Contour rouge-corail dédié aux actions destructives spécifiques (ex.
   déconnexion), distinct de --error-red pour ne pas modifier btn-outline-red
   (partagé Workshop) — même gabarit que btn-outline-red/blue. */
.popup-footer .btn-outline-danger {
    background-color: var(--transparent);
    border: 2px solid var(--button-danger);
    color: var(--button-danger);
}

.popup-footer .btn-outline-danger:hover {
    background-color: var(--button-danger-alpha-10);
}

.popup-footer .btn-solid-white {
    background-color: var(--white);
    color: var(--bg-dark);
    border: none;
}

.popup-footer .btn-solid-white:hover {
    background-color: var(--white);
    filter: brightness(0.95);
}

.popup-footer .btn-outline-cyan {
    background-color: var(--transparent);
    border: 2px solid var(--primary);
    color: var(--primary);
}

.popup-footer .btn-outline-cyan:hover {
    background-color: var(--primary-alpha-10);
}