/**
 * PrestaCraft Demo Manager - barre de demonstration.
 * Elle se superpose au back office comme au front office : les valeurs de
 * z-index sont volontairement tres hautes, PrestaShop ayant ses propres
 * elements fixes.
 */

#dmgr-bar {
    --dmgr-bar-bg: linear-gradient(90deg, #0b0e18 0%, #131832 100%);
    --dmgr-bar-ink: #eef1f8;
    --dmgr-bar-muted: #8b95ad;
    --dmgr-bar-line: rgba(255, 255, 255, 0.1);
    --dmgr-bar-surface: rgba(255, 255, 255, 0.08);
    --dmgr-bar-surface-strong: rgba(255, 255, 255, 0.14);
    --dmgr-bar-panel: #11162a;
    --dmgr-bar-accent-1: #7c4dff;
    --dmgr-bar-accent-2: #2f8fff;
    position: fixed;
    left: 0;
    right: 0;
    z-index: 2147483000;
    display: flex;
    align-items: center;
    gap: 16px;
    height: 48px;
    padding: 0 16px;
    background: var(--dmgr-bar-bg);
    border-bottom: 1px solid var(--dmgr-bar-line);
    color: var(--dmgr-bar-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 13px;
    line-height: 1.2;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
}

#dmgr-bar * {
    box-sizing: border-box;
}

.dmgr-bar-top { top: 0; }
.dmgr-bar-bottom { bottom: 0; box-shadow: 0 -2px 18px rgba(0, 0, 0, 0.35); }

body.dmgr-has-bar-top { padding-top: 48px !important; }
body.dmgr-has-bar-bottom { padding-bottom: 48px !important; }

/* --------------------------------------------------------------- identite */

.dmgr-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 1 auto;
    min-width: 0;
}

#dmgr-bar .dmgr-logo {
    height: 22px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    flex: 0 0 auto;
}

.dmgr-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.dmgr-title-name {
    font-weight: 600;
    font-size: 13px;
    max-width: 320px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dmgr-title-module {
    font-size: 11px;
    color: var(--dmgr-bar-muted);
    font-family: monospace;
}

/* ----------------------------------------------------------------- milieu */

.dmgr-middle {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.dmgr-timer {
    padding: 5px 11px;
    border-radius: 999px;
    background: var(--dmgr-bar-surface);
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    white-space: nowrap;
}

.dmgr-timer-warning { background: rgba(247, 184, 74, 0.22); color: #ffd08a; }
.dmgr-timer-critical {
    background: rgba(255, 95, 109, 0.24);
    color: #ffb3b8;
    animation: dmgr-pulse 1s ease-in-out infinite alternate;
}
.dmgr-timer-over { background: rgba(255, 95, 109, 0.32); color: #fff; }

@keyframes dmgr-pulse { from { opacity: 1; } to { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .dmgr-timer-critical { animation: none; } }

/* ----------------------------------------------------------- identifiants */

.dmgr-creds { display: flex; gap: 6px; }

.dmgr-cred {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 3px 10px;
    border: 1px solid var(--dmgr-bar-line);
    border-radius: 8px;
    background: var(--dmgr-bar-surface);
    color: inherit;
    font-family: inherit;
    cursor: pointer;
    line-height: 1.2;
}

.dmgr-cred:hover { background: var(--dmgr-bar-surface-strong); }
.dmgr-cred-label { font-size: 9px; color: var(--dmgr-bar-muted); text-transform: uppercase; letter-spacing: 0.06em; }
.dmgr-cred-value { font-size: 12px; font-family: monospace; }

/* ---------------------------------------------------------------- pages */

.dmgr-pages { display: flex; gap: 6px; overflow: hidden; }

.dmgr-page {
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--dmgr-bar-line);
    color: var(--dmgr-bar-ink);
    text-decoration: none;
    font-size: 12px;
    white-space: nowrap;
}

.dmgr-page:hover { background: var(--dmgr-bar-surface); }
.dmgr-page-current { background: var(--dmgr-bar-surface-strong); font-weight: 600; }

/* --------------------------------------------------------------- actions */

.dmgr-actions-bar { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; margin-left: auto; }

#dmgr-bar .dmgr-btn {
    display: inline-block;
    padding: 6px 13px;
    border: 0;
    border-radius: 9px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    white-space: nowrap;
    color: #fff;
}

#dmgr-bar .dmgr-btn-ghost { background: var(--dmgr-bar-surface); color: var(--dmgr-bar-ink); }
#dmgr-bar .dmgr-btn-ghost:hover { background: var(--dmgr-bar-surface-strong); }
#dmgr-bar .dmgr-btn-buy {
    background: linear-gradient(135deg, var(--dmgr-bar-accent-1), var(--dmgr-bar-accent-2));
    color: #fff;
    box-shadow: 0 6px 16px rgba(80, 90, 255, 0.3);
}
#dmgr-bar .dmgr-btn-buy:hover { filter: brightness(1.08); }
#dmgr-bar .dmgr-btn-small { padding: 5px 10px; font-size: 11px; background: var(--dmgr-bar-surface); color: var(--dmgr-bar-ink); }

.dmgr-close {
    background: none;
    border: 0;
    color: var(--dmgr-bar-muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.dmgr-close:hover { color: var(--dmgr-bar-ink); }

/* ------------------------------------------------------------- catalogue */

.dmgr-catalog { position: relative; }

.dmgr-catalog-toggle::after {
    content: "";
    display: inline-block;
    margin-left: 7px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    vertical-align: middle;
}

.dmgr-catalog-toggle.dmgr-open::after { transform: rotate(180deg); }

.dmgr-catalog-panel {
    position: absolute;
    right: 0;
    width: 380px;
    max-width: 92vw;
    max-height: 60vh;
    overflow-y: auto;
    padding: 12px;
    border-radius: 14px;
    background: var(--dmgr-bar-panel);
    border: 1px solid var(--dmgr-bar-line);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.dmgr-bar-top .dmgr-catalog-panel { top: calc(100% + 10px); }
.dmgr-bar-bottom .dmgr-catalog-panel { bottom: calc(100% + 10px); }

.dmgr-catalog-search {
    width: 100%;
    padding: 9px 11px;
    margin-bottom: 10px;
    border-radius: 9px;
    border: 1px solid var(--dmgr-bar-line);
    background: var(--dmgr-bar-surface);
    color: var(--dmgr-bar-ink);
    font-size: 13px;
    font-family: inherit;
}

.dmgr-catalog-search:focus { outline: none; border-color: rgba(124, 77, 255, 0.6); }

.dmgr-catalog-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 10px;
}

.dmgr-catalog-item:hover { background: var(--dmgr-bar-surface); }
.dmgr-catalog-current { background: rgba(124, 77, 255, 0.16); }

.dmgr-catalog-icon {
    width: 26px;
    height: 26px;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dmgr-catalog-logo { width: 26px; height: 26px; object-fit: contain; flex: 0 0 auto; }

.dmgr-catalog-badge {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    background: var(--dmgr-bar-surface-strong);
    color: var(--dmgr-bar-ink);
}

.dmgr-catalog-badge-ps { background: rgba(124, 77, 255, 0.22); }
.dmgr-catalog-badge-wp { background: rgba(33, 117, 155, 0.28); }
.dmgr-catalog-badge-wh { background: rgba(45, 108, 162, 0.28); }
.dmgr-catalog-badge-other { color: var(--dmgr-bar-muted); }

.dmgr-catalog-info { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.dmgr-catalog-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dmgr-catalog-shop { font-size: 11px; color: var(--dmgr-bar-muted); }
.dmgr-catalog-actions { display: flex; gap: 5px; flex: 0 0 auto; }
.dmgr-catalog-empty { text-align: center; color: var(--dmgr-bar-muted); font-size: 12px; padding: 14px 0; }

/* ------------------------------------------------------------ responsive */

/* Conteneur repliable : sur grand ecran il se comporte comme avant, en ligne
   et occupant la place disponible. */
.dmgr-collapse {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 auto;
    min-width: 0;
    justify-content: space-between;
}

.dmgr-tools { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

/* Bouton « trois barres ». Cache par defaut : il n apparait que sous le point
   de rupture, ou les commandes passent dans le panneau. */
.dmgr-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 38px;
    height: 34px;
    padding: 0 9px;
    cursor: pointer;
    border-radius: 10px;
    border: 1px solid var(--dmgr-bar-line);
    background: var(--dmgr-bar-surface);
}

.dmgr-menu-bar {
    display: block;
    height: 2px;
    width: 100%;
    border-radius: 2px;
    background: var(--dmgr-bar-ink);
    transition: transform 0.18s ease, opacity 0.18s ease;
}

/* Ouvert, les trois barres deviennent une croix : le visiteur voit tout de
   suite comment refermer. */
.dmgr-open-menu .dmgr-menu-bar:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.dmgr-open-menu .dmgr-menu-bar:nth-child(2) { opacity: 0; }
.dmgr-open-menu .dmgr-menu-bar:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

@media (prefers-reduced-motion: reduce) {
    .dmgr-menu-bar { transition: none; }
}

@media (max-width: 900px) {
    #dmgr-bar { gap: 8px; padding: 8px 10px; }

    .dmgr-menu-toggle { display: flex; }

    /* Le panneau se pose SOUS la barre plutot que dans son flux : la hauteur
       de la barre ne bouge pas, donc le decalage applique au contenu de la
       page reste juste, ouvert comme ferme. */
    .dmgr-collapse {
        display: none;
        position: absolute;
        right: 8px;
        left: 8px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px;
        border-radius: 14px;
        background: var(--dmgr-bar-panel);
        border: 1px solid var(--dmgr-bar-line);
        box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
        max-height: 70vh;
        overflow-y: auto;
    }

    .dmgr-bar-top .dmgr-collapse { top: calc(100% + 8px); }

    /* Barre en bas : le panneau s ouvre vers le HAUT, sinon il sortirait de
       l ecran par le bas. */
    .dmgr-bar-bottom .dmgr-collapse { bottom: calc(100% + 8px); }

    .dmgr-open-menu .dmgr-collapse { display: flex; }

    .dmgr-middle,
    .dmgr-actions-bar {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 8px;
    }

    /* Les separateurs verticaux n ont plus de sens en colonne. */
    .dmgr-actions-bar { padding-left: 0; border-left: 0; }
    .dmgr-identity { padding-right: 10px; border-right: 0; }

    /* Les identifiants et les pages compagnons etaient purement et simplement
       MASQUES sur petit ecran : le visiteur n avait plus de quoi se connecter.
       Ils sont maintenant dans le menu, donc on les rend. */
    .dmgr-creds, .dmgr-pages { display: flex; flex-wrap: wrap; gap: 8px; }

    .dmgr-btn, .dmgr-page { width: 100%; text-align: center; justify-content: center; }

    /* Les panneaux du catalogue et des langues sont deja dans le menu : les
       poser en absolu les ferait sortir de l ecran. */
    .dmgr-catalog-panel,
    .dmgr-langs-panel {
        position: static;
        width: 100%;
        min-width: 0;
        box-shadow: none;
    }

    .dmgr-catalog-item { flex-wrap: wrap; }

    body.dmgr-has-bar-top { padding-top: 60px !important; }
    body.dmgr-has-bar-bottom { padding-bottom: 60px !important; }
}

/* ----------------------------------------------------------------- langues */

.dmgr-langs { position: relative; }

.dmgr-langs-toggle { min-width: 46px; text-align: center; }

.dmgr-langs-panel {
    position: absolute;
    right: 0;
    min-width: 160px;
    padding: 6px;
    border-radius: 12px;
    background: var(--dmgr-bar-panel);
    border: 1px solid var(--dmgr-bar-line);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.dmgr-bar-top .dmgr-langs-panel { top: calc(100% + 10px); }
.dmgr-bar-bottom .dmgr-langs-panel { bottom: calc(100% + 10px); }

.dmgr-lang {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--dmgr-bar-ink);
    text-decoration: none;
    font-size: 13px;
}

.dmgr-lang:hover { background: var(--dmgr-bar-surface); }
.dmgr-lang-current { background: rgba(124, 77, 255, 0.2); color: #fff; font-weight: 600; }

/* Apercu dans la page de configuration : la meme barre, mais posee dans le
   flux du document plutot que fixee par dessus la page. */
.dmgr-bar-preview {
    position: relative !important;
    border-radius: 12px;
    margin-top: 12px;
}


/* Un separateur discret entre les groupes, plus lisible qu un simple espace. */
.dmgr-identity { padding-right: 16px; border-right: 1px solid var(--dmgr-bar-line); }
.dmgr-actions-bar { padding-left: 16px; border-left: 1px solid var(--dmgr-bar-line); }

/* Le texte libre du bandeau ne doit jamais pousser le reste hors de l ecran. */
.dmgr-middle .dmgr-title-name { max-width: 40vw; }

/* Entre 900 et 1200 px la barre reste en ligne : les identifiants sont
   masques faute de place, mais restent accessibles en dessous de 900 px via le
   menu. */
@media (max-width: 1200px) and (min-width: 901px) {
    .dmgr-creds { display: none; }
}


/* ---------------------------------------------------------------- socle clair

   La barre suit le mode d affichage : regler les pages publiques sur clair et
   garder une barre noire serait incoherent. */

#dmgr-bar.dmgr-bar-light .dmgr-timer-warning { background: rgba(208, 138, 23, 0.16); color: #8a5a05; }
#dmgr-bar.dmgr-bar-light .dmgr-timer-critical { background: rgba(179, 38, 30, 0.14); color: #9c1f18; }
#dmgr-bar.dmgr-bar-light .dmgr-timer-over { background: rgba(179, 38, 30, 0.9); color: #fff; }

#dmgr-bar.dmgr-bar-light {
    --dmgr-bar-bg: linear-gradient(90deg, #ffffff 0%, #f4f6fb 100%);
    --dmgr-bar-ink: #1b2333;
    --dmgr-bar-muted: #6b7590;
    --dmgr-bar-line: rgba(20, 25, 40, 0.12);
    --dmgr-bar-surface: rgba(20, 25, 40, 0.05);
    --dmgr-bar-surface-strong: rgba(20, 25, 40, 0.1);
    --dmgr-bar-panel: #ffffff;
    box-shadow: 0 4px 20px rgba(20, 25, 40, 0.12);
}

/* Mode automatique : c est le systeme du visiteur qui tranche. */
@media (prefers-color-scheme: light) {
    #dmgr-bar.dmgr-bar-auto .dmgr-timer-warning { background: rgba(208, 138, 23, 0.16); color: #8a5a05; }
    #dmgr-bar.dmgr-bar-auto .dmgr-timer-critical { background: rgba(179, 38, 30, 0.14); color: #9c1f18; }
    #dmgr-bar.dmgr-bar-auto .dmgr-timer-over { background: rgba(179, 38, 30, 0.9); color: #fff; }

    #dmgr-bar.dmgr-bar-auto {
        --dmgr-bar-bg: linear-gradient(90deg, #ffffff 0%, #f4f6fb 100%);
        --dmgr-bar-ink: #1b2333;
        --dmgr-bar-muted: #6b7590;
        --dmgr-bar-line: rgba(20, 25, 40, 0.12);
        --dmgr-bar-surface: rgba(20, 25, 40, 0.05);
        --dmgr-bar-surface-strong: rgba(20, 25, 40, 0.1);
        --dmgr-bar-panel: #ffffff;
        box-shadow: 0 4px 20px rgba(20, 25, 40, 0.12);
    }
}
