/* ==========================================================================
   Gas Contextual Help — CSS partagé
   Couvre : toggle d'aide, blocs de section, bulles de champ,
            tour guidé (spotlight + popover), modal tutoriel + pill flottant.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Barre d'aide sticky — positionnée AVANT le header, colle en haut lors du scroll.
   --gas-uh-nav-sticky-top est calculée en JS (ResizeObserver sur le header APH fixe).
   -------------------------------------------------------------------------- */
.gas-uh-help-slot {
    position: sticky;
    top: var(--gas-uh-nav-sticky-top, 0px);
    z-index: 500;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-height: 0;
}

/* --------------------------------------------------------------------------
   Barre d'aide (help toggle + tutoriel + tour)
   Rendue dans .gas-uh-help-slot (via props McNav ou Teleport de profile-edit).
   -------------------------------------------------------------------------- */
.gas-uh-help-bar {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

/* --------------------------------------------------------------------------
   Toggle "Aide"
   -------------------------------------------------------------------------- */
.gas-help-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--gas-color-border, #d1d5db);
    border-radius: 999px;
    background: var(--gas-color-surface-card, var(--gas-bg-surface));
    color: var(--gas-color-text-muted, #6b7280);
    font-size: 0.88em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.gas-help-toggle:hover {
    border-color: var(--gas-color-primary, #3b82f6);
    color: var(--gas-color-primary, #3b82f6);
}

/* Fond = primary BRUT (mode-stable) et non l'alias --gas-color-primary qui vire
   au primary-light en dark-mode → texte blanc illisible sur fond pâle. */
.gas-help-toggle--active {
    background: var(--gas-primary, #2563eb);
    border-color: var(--gas-primary, #2563eb);
    color: var(--gas-text-color-inverse, #fff);
}

.gas-help-toggle--active:hover {
    background: color-mix(in srgb, var(--gas-primary, #2563eb) 82%, #000);
    border-color: color-mix(in srgb, var(--gas-primary, #2563eb) 82%, #000);
    color: var(--gas-text-color-inverse, #fff);
}

.gas-help-toggle .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 1;
}

.gas-help-toggle__label {
    line-height: 1;
}

.gas-admin-help-shell[hidden] {
    display: none;
}

.gas-admin-help-toggle__icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.gas-admin-help-shell .gas-help-drawer__overlay {
    z-index: 9900;
}

.gas-admin-help-shell .gas-help-drawer {
    z-index: 9910;
}

.gas-help-drawer__section-body p {
    margin: 0 0 0.75em;
}

.gas-help-drawer__section-body p:last-child {
    margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   Bloc d'aide de section (sous les headers de card)
   -------------------------------------------------------------------------- */
.gas-help-block {
    margin: 0;
    padding: 10px 18px;
    background: linear-gradient(90deg, var(--gas-color-info-bg) 0%, var(--gas-color-surface-alt) 100%);
    border-left: 3px solid var(--gas-color-info, #3b82f6);
    color: var(--gas-color-text, #374151);
    font-size: 0.88em;
    line-height: 1.5;
    font-style: italic;
}

.gas-help-block::before {
    content: "\f223"; /* dashicons-info */
    font-family: dashicons;
    font-style: normal;
    margin-right: 6px;
    color: var(--gas-color-info, #3b82f6);
    vertical-align: -2px;
}

.gas-help-block--inline {
    margin-top: 6px;
    padding: 6px 10px;
    border-left-width: 2px;
    font-size: 0.82em;
}

/* --------------------------------------------------------------------------
   Bulle "?" de champ (GasHelpTip)
   Deux implémentations partageant le même bouton .gas-help-tip :
   - Vue  : tooltip via ::after + --tip-x/--tip-y (classe --open gérée en JS)
   - React: GasHelpTip = composition de GasTooltip (primitive Radix
            qui rend .gas-tooltip__content via Portal)
   -------------------------------------------------------------------------- */
.gas-help-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--gas-info-dark, var(--gas-color-info, #3b82f6));
    color: var(--gas-color-surface-card, var(--gas-text-color-inverse));
    font-size: 0.72em;
    font-weight: 700;
    font-style: normal;
    font-family: inherit;
    cursor: help;
    vertical-align: middle;
    line-height: 1;
    flex-shrink: 0;
}

.gas-help-tip:hover,
.gas-help-tip:focus {
    background: var(--gas-color-primary-dark, #2563eb);
    outline: 2px solid var(--gas-color-primary-ring);
    outline-offset: 1px;
}

.gas-help-tip::after {
    content: attr(title);
    position: fixed;
    top:  var(--tip-y, 0);
    left: var(--tip-x, 0);
    width: 300px;
    max-width: calc(100vw - 24px);
    padding: 10px 12px;
    background: var(--gas-topbar-bg);
    color: var(--gas-text-color-inverse);
    font-size: 12px;
    font-weight: 400;
    font-style: normal;
    text-align: left;
    line-height: 1.45;
    white-space: normal;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    opacity: 0;
    pointer-events: none;
    z-index: 100000;
    letter-spacing: normal;
    display: none;
}

.gas-help-tip--open::after {
    opacity: 1;
    pointer-events: auto;
    display: block;
}

/* --------------------------------------------------------------------------
   GasTooltip React — primitive générique (Radix Tooltip + Portal)
   Utilisé directement (icon buttons, raccourcis, etc.) ou composé par
   GasHelpTip pour les bulles d'aide.
   -------------------------------------------------------------------------- */
.gas-tooltip__content {
    background: var(--gas-topbar-bg);
    color: var(--gas-text-color-inverse);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 400;
    font-style: normal;
    line-height: 1.5;
    max-width: 280px;
    white-space: normal;
    letter-spacing: normal;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    z-index: 100000;
    animation-duration: 0.12s;
    animation-timing-function: ease-out;
    will-change: transform, opacity;
}

.gas-tooltip__content[data-state="delayed-open"][data-side="bottom"] {
    animation-name: gas-tip-slide-down;
}
.gas-tooltip__content[data-state="delayed-open"][data-side="top"] {
    animation-name: gas-tip-slide-up;
}

@keyframes gas-tip-slide-down {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes gas-tip-slide-up {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.gas-tooltip__arrow {
    fill: var(--gas-topbar-bg);
}

/* --------------------------------------------------------------------------
   GasHelpDrawer — panneau latéral d'aide React (Radix Dialog)
   -------------------------------------------------------------------------- */
.gas-help-drawer__overlay {
    position: fixed;
    inset: 0;
    background: var(--gas-bg-overlay);
    z-index: 9500;
    animation: gas-help-drawer-fade-in 0.15s ease-out;
}

@keyframes gas-help-drawer-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.gas-help-drawer {
    position: fixed;
    inset: 0 0 0 auto;
    width: min(100%, 360px);
    background: var(--gas-bg-surface, #fff);
    border-left: 1px solid var(--gas-border-color, #e5e7eb);
    display: flex;
    flex-direction: column;
    z-index: 9600;
    box-shadow: -4px 0 32px rgba(0, 0, 0, 0.12);
    animation: gas-help-drawer-slide-in 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes gas-help-drawer-slide-in {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.gas-help-drawer__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gas-border-color, #e5e7eb);
    flex-shrink: 0;
    background: var(--gas-color-primary-light, #eff6ff);
}

.gas-help-drawer__header-text {
    min-width: 0;
}

.gas-help-drawer__title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
    font-weight: 700;
    color: var(--gas-color-text, #111827);
    margin: 0 0 4px;
}

.gas-help-drawer__title-icon {
    font-size: 1.1em;
    flex-shrink: 0;
}

.gas-help-drawer__intro {
    font-size: 0.8em;
    color: var(--gas-color-text-muted, #6b7280);
    line-height: 1.45;
    margin: 0;
}

.gas-help-drawer__close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gas-color-text-muted, #6b7280);
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 20px;
    line-height: 1;
    transition: background 0.1s, color 0.1s;
}

.gas-help-drawer__close:hover {
    background: color-mix(in srgb, var(--gas-color-text-default) 6%, transparent);
    color: var(--gas-color-text, #111827);
}

.gas-help-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.gas-help-drawer__section {
    padding: 14px 20px;
    border-bottom: 1px solid var(--gas-color-border, #f3f4f6);
    transition: background 0.1s;
}

.gas-help-drawer__section:last-child {
    border-bottom: none;
}

.gas-help-drawer__section:hover {
    background: var(--gas-color-surface, #f9fafb);
}

.gas-help-drawer__section-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
}

.gas-help-drawer__section-icon {
    font-size: 1em;
    flex-shrink: 0;
}

.gas-help-drawer__section-title {
    font-size: 0.88em;
    font-weight: 600;
    color: var(--gas-color-text, #111827);
    margin: 0;
}

.gas-help-drawer__section-body {
    font-size: 0.82em;
    color: var(--gas-color-text-muted, #6b7280);
    line-height: 1.55;
    margin: 0;
}

.gas-help-drawer__empty {
    padding: 24px 20px;
    font-size: 0.85em;
    color: var(--gas-color-text-muted, #9ca3af);
    margin: 0;
}

@media (max-width: 480px) {
    .gas-help-drawer {
        width: 100%;
    }
}

/* --------------------------------------------------------------------------
   Tour guidé — spotlight + popover
   -------------------------------------------------------------------------- */

/* Fond semi-transparent généré par box-shadow autour du spotlight */
.gas-tour-spotlight {
    position: fixed;
    border-radius: 6px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    z-index: 99990;
    pointer-events: none;
    transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
}

/* Anneau de mise en évidence */
.gas-tour-spotlight::after {
    content: '';
    position: absolute;
    inset: -3px;
    border: 2px solid var(--gas-color-primary, #3b82f6);
    border-radius: 8px;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* Popover du tour */
.gas-tour-popover {
    position: fixed;
    z-index: 99995;
    background: var(--gas-color-surface-card, var(--gas-bg-surface));
    border: 1px solid var(--gas-color-border-default, var(--gas-border-color));
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
    padding: 16px 18px;
    transition: top 0.25s ease, left 0.25s ease;
}

.gas-tour-popover__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.gas-tour-popover__title {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--gas-color-text, #111827);
    margin: 0;
}

.gas-tour-popover__close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gas-color-text-muted, #6b7280);
    padding: 0;
    line-height: 1;
    font-size: 18px;
}

.gas-tour-popover__close:hover {
    color: var(--gas-color-text, #111827);
}

.gas-tour-popover__body {
    font-size: 0.88em;
    color: var(--gas-color-text-muted, #4b5563);
    line-height: 1.5;
    margin: 0 0 12px;
}

.gas-tour-popover__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.gas-tour-popover__progress {
    font-size: 0.8em;
    color: var(--gas-color-text-muted, #9ca3af);
}

.gas-tour-popover__nav {
    display: flex;
    gap: 6px;
}

/* Flèche de direction sur le popover */
.gas-tour-popover--up::before {
    content: '';
    position: absolute;
    bottom: -7px;
    left: 20px;
    width: 14px;
    height: 14px;
    background: var(--gas-color-surface-card, var(--gas-bg-surface));
    transform: rotate(45deg);
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.08);
}

.gas-tour-popover--down::before {
    content: '';
    position: absolute;
    top: -7px;
    left: 20px;
    width: 14px;
    height: 14px;
    background: var(--gas-color-surface-card, var(--gas-bg-surface));
    transform: rotate(45deg);
    box-shadow: -2px -2px 4px rgba(0, 0, 0, 0.08);
}

/* --------------------------------------------------------------------------
   Modal tutoriel
   -------------------------------------------------------------------------- */
.gas-tutorial-overlay {
    position: fixed;
    inset: 0;
    background: var(--gas-bg-overlay);
    z-index: 99980;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.gas-tutorial-modal {
    position: relative;
    width: 420px;
    max-width: 95vw;
    height: 100%;
    max-height: 100vh;
    background: var(--gas-color-surface-card, var(--gas-bg-surface));
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.gas-tutorial-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--gas-color-border, #e5e7eb);
    flex-shrink: 0;
}

.gas-tutorial-modal__title {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--gas-color-text, #111827);
    margin: 0 0 4px;
}

.gas-tutorial-modal__intro {
    font-size: 0.85em;
    color: var(--gas-color-text-muted, #6b7280);
    line-height: 1.5;
    margin: 0;
}

.gas-tutorial-modal__close {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--gas-color-text-muted, #6b7280);
    padding: 4px;
    border-radius: 4px;
    font-size: 20px;
    line-height: 1;
}

.gas-tutorial-modal__close:hover {
    background: var(--gas-color-surface, #f3f4f6);
    color: var(--gas-color-text, #111827);
}

/* Mode paginé : sidebar + contenu */
.gas-tutorial-modal__layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.gas-tutorial-modal__sidebar {
    width: 148px;
    min-width: 140px;
    flex-shrink: 0;
    border-right: 1px solid var(--gas-color-border, #e5e7eb);
    background: var(--gas-color-surface, #f9fafb);
    overflow-y: auto;
    padding: 6px 0;
}

.gas-tutorial-modal__page-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-left: 3px solid transparent;
    background: transparent;
    text-align: left;
    font-size: 0.82em;
    color: var(--gas-color-text-muted, #6b7280);
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    line-height: 1.3;
}

.gas-tutorial-modal__page-btn:hover {
    background: var(--gas-color-bg-hover, #f3f4f6);
    color: var(--gas-color-text, #111827);
}

.gas-tutorial-modal__page-btn--active {
    background: var(--gas-color-primary-light, #eff6ff);
    color: var(--gas-color-primary, #3b82f6);
    border-left-color: var(--gas-color-primary, #3b82f6);
    font-weight: 600;
}

.gas-tutorial-modal__page-btn .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.gas-tutorial-modal__body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
    min-height: 0;
}

.gas-tutorial-empty {
    padding: 24px 20px;
    font-size: 0.85em;
    color: var(--gas-color-text-muted, #9ca3af);
}

@media (max-width: 480px) {
    .gas-tutorial-modal__layout { flex-direction: column; }
    .gas-tutorial-modal__sidebar {
        width: 100%;
        min-width: 0;
        border-right: none;
        border-bottom: 1px solid var(--gas-color-border, #e5e7eb);
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0;
    }
    .gas-tutorial-modal__page-btn {
        flex-direction: column;
        gap: 3px;
        padding: 8px 12px;
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
        font-size: 0.78em;
    }
    .gas-tutorial-modal__page-btn--active {
        border-bottom-color: var(--gas-color-primary, #3b82f6);
        border-left-color: transparent;
    }
}

/* Section individuelle dans le tutoriel */
.gas-tutorial-section {
    display: grid;
    grid-template-columns: 32px 1fr auto;
    align-items: start;
    gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--gas-color-border, #f3f4f6);
    cursor: default;
    transition: background 0.1s;
}

.gas-tutorial-section:hover {
    background: var(--gas-color-surface, #f9fafb);
}

.gas-tutorial-section__icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--gas-color-primary-light, #eff6ff);
    color: var(--gas-color-primary, #3b82f6);
    flex-shrink: 0;
}

.gas-tutorial-section__icon .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.gas-tutorial-section__content {
    min-width: 0;
}

.gas-tutorial-section__title {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--gas-color-text, #111827);
    margin: 0 0 4px;
}

.gas-tutorial-section__body {
    font-size: 0.83em;
    color: var(--gas-color-text-muted, #6b7280);
    line-height: 1.5;
    margin: 0;
}

.gas-tutorial-section__action {
    flex-shrink: 0;
    align-self: center;
}

.gas-tutorial-section__btn-show {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border: 1px solid var(--gas-color-border, #d1d5db);
    border-radius: 6px;
    background: var(--gas-color-surface-card, var(--gas-bg-surface));
    color: var(--gas-color-text-muted, #6b7280);
    font-size: 0.8em;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}

.gas-tutorial-section__btn-show:hover {
    border-color: var(--gas-color-primary, #3b82f6);
    color: var(--gas-color-primary, #3b82f6);
    background: var(--gas-color-primary-light, #eff6ff);
}

/* --------------------------------------------------------------------------
   Pill flottant (modal minimisée)
   -------------------------------------------------------------------------- */
.gas-tutorial-pill {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99985;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--gas-color-surface-card, var(--gas-bg-surface));
    border: 1px solid var(--gas-color-border, #d1d5db);
    border-radius: 999px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-size: 0.88em;
    cursor: pointer;
    transition: box-shadow 0.15s;
}

.gas-tutorial-pill:hover {
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.2);
}

.gas-tutorial-pill__icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gas-color-primary-light, #eff6ff);
    color: var(--gas-color-primary, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gas-tutorial-pill__icon .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

.gas-tutorial-pill__label {
    font-weight: 500;
    color: var(--gas-color-text, #374151);
}

.gas-tutorial-pill__back {
    color: var(--gas-color-primary, #3b82f6);
    font-weight: 500;
    font-size: 0.9em;
}

/* --------------------------------------------------------------------------
   Aide contextuelle pilotée par la classe racine .gas-help-enabled
   Masque les blocs d'aide par défaut ; les affiche quand le toggle est actif.
   S'applique aussi à .gas-help-block (sections) et .gas-help-block--inline (champs).
   -------------------------------------------------------------------------- */
:not(.gas-help-enabled) .gas-help-block {
    display: none;
}

.gas-help-enabled .gas-help-block {
    display: block;
}

/* Spotlight partagé tour + tutoriel */
.gas-spotlight {
    position: fixed;
    border-radius: 6px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    z-index: 99990;
    pointer-events: none;
    transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
}

.gas-spotlight::after {
    content: '';
    position: absolute;
    inset: -3px;
    border: 2px solid var(--gas-color-primary, #3b82f6);
    border-radius: 8px;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}
