/*
 * Onboarding "Gids" (guide) widget — a fixed right-side rail that walks the user
 * through a page step-by-step, highlighting form fields with contextual tips.
 *
 * Rendered globally from templates/manager/guide_panel.html; only shown on pages
 * that provide a #clms-guide-data JSON block. Driven by static/manager/js/guide.js.
 *
 * Theme-aware: light by default, dark rules under [data-bs-theme="dark"].
 */

:root {
    --guide-primary: #005ea9;
    --guide-accent: #d3983f;
    --guide-accent-soft: #fdf6ec;
    --guide-done: #2e9e3f;
    --guide-panel-bg: #ffffff;
    --guide-panel-border: #e4e8ec;
    --guide-text: #1f2a30;
    --guide-text-soft: #5b6770;
    --guide-text-muted: #9aa6ae;
    --guide-track: #eef1f4;
    --guide-step-hover: #f5f8fb;
}

[data-bs-theme="dark"] {
    --guide-primary: #3a9be0;
    --guide-accent: #e0ac5a;
    --guide-accent-soft: #2c2418;
    --guide-done: #4bb85c;
    --guide-panel-bg: #1c2530;
    --guide-panel-border: #2d3945;
    --guide-text: #e7edf2;
    --guide-text-soft: #aeb9c2;
    --guide-text-muted: #7d8a95;
    --guide-track: #2a3540;
    --guide-step-hover: #232f3b;
}

/* Vertical offset so the panel/tab clear the header + the page's top action bar
   (e.g. "Add produce group"), keeping those top-right buttons visible on any screen. */
:root { --guide-top: 150px; }

/* ---- collapsed tab (right edge) ---- */
.clms-guide__tab {
    position: fixed;
    top: var(--guide-top);
    right: 0;
    z-index: 1035;
    display: none; /* JS shows it when a guide exists for the page */
    align-items: center;
    gap: 8px;
    padding: 10px 13px;
    background: var(--guide-primary);
    color: #fff;
    font-size: 12.5px;
    font-weight: 700;
    border: none;
    border-radius: 10px 0 0 10px;
    box-shadow: -2px 2px 10px rgba(0, 0, 0, .18);
    cursor: pointer;
}
.clms-guide__tab:hover { filter: brightness(1.06); }
.clms-guide__tab.is-hidden { display: none !important; }

/* ---- rail panel ---- */
.clms-guide__panel {
    position: fixed;
    top: var(--guide-top);
    right: 0;
    bottom: 0;
    width: 330px;
    max-width: 90vw;
    z-index: 1035;
    display: none;
    flex-direction: column;
    background: var(--guide-panel-bg);
    border-left: 1px solid var(--guide-panel-border);
    box-shadow: -6px 0 24px rgba(0, 0, 0, .10);
    transform: translateX(100%);
    transition: transform .25s ease;
}
.clms-guide__panel.is-open {
    display: flex;
    transform: translateX(0);
}

.clms-guide__header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--guide-panel-border);
}
.clms-guide__header-icon {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 8px;
    background: var(--guide-accent-soft);
    color: var(--guide-accent);
    display: flex;
    align-items: center;
    justify-content: center;
}
.clms-guide__eyebrow {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--guide-accent);
    text-transform: uppercase;
}
.clms-guide__title {
    font-size: 13.5px;
    font-weight: 700;
    color: var(--guide-text);
}
.clms-guide__close {
    margin-left: auto;
    border: none;
    background: transparent;
    color: var(--guide-text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 4px 6px;
}

/* ---- progress ---- */
.clms-guide__progress {
    padding: 12px 16px;
    border-bottom: 1px solid var(--guide-panel-border);
}
.clms-guide__progress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--guide-text-soft);
}
.clms-guide__progress-count { font-weight: 700; color: var(--guide-text); }
.clms-guide__bar {
    margin-top: 8px;
    height: 8px;
    border-radius: 5px;
    background: var(--guide-track);
    overflow: hidden;
}
.clms-guide__bar-fill {
    height: 100%;
    width: 0%;
    background: var(--guide-done);
    border-radius: 5px;
    transition: width .35s ease;
}

/* ---- steps ---- */
.clms-guide__hint {
    padding: 11px 16px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--guide-text-soft);
    border-bottom: 1px solid var(--guide-panel-border);
}

/* Optional per-guide "Note!" callout (see guide.js note handling). */
.clms-guide__note {
    margin: 10px 14px 2px;
    padding: 10px 12px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--guide-text);
    background: var(--guide-accent-soft);
    border: 1px solid var(--guide-accent);
    border-radius: 9px;
}
.clms-guide__note-label {
    display: block;
    font-weight: 700;
    color: var(--guide-accent);
    margin-bottom: 3px;
}
.clms-guide__steps {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
}
.clms-guide__step {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    width: 100%;
    padding: 10px;
    border: none;
    background: transparent;
    border-radius: 9px;
    text-align: left;
    cursor: pointer;
    color: var(--guide-text);
}
.clms-guide__step:hover { background: var(--guide-step-hover); }
.clms-guide__step.is-active {
    background: var(--guide-accent-soft);
    box-shadow: 0 0 0 1px var(--guide-accent) inset;
}
.clms-guide__step-badge {
    flex: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    background: var(--guide-track);
    color: var(--guide-text-soft);
    border: none;
    cursor: pointer;
}
.clms-guide__step.is-done .clms-guide__step-badge {
    background: var(--guide-done);
    color: #fff;
}
.clms-guide__step-label {
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.35;
}
.clms-guide__step.is-done .clms-guide__step-label {
    color: var(--guide-text-muted);
    text-decoration: line-through;
}

/* ---- contextual field tip (popover) ---- */
.clms-guide__pop {
    position: absolute;
    z-index: 1040;
    width: 260px;
    max-width: 80vw;
    background: var(--guide-panel-bg);
    border: 1px solid var(--guide-panel-border);
    border-radius: 12px;
    box-shadow: 0 14px 40px rgba(0, 0, 0, .22);
    padding: 13px 15px;
}
.clms-guide__pop-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--guide-text);
}
.clms-guide__pop-close {
    margin-left: auto;
    border: none;
    background: transparent;
    color: var(--guide-text-muted);
    cursor: pointer;
    font-size: 12px;
}
.clms-guide__pop-body {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.55;
    color: var(--guide-text-soft);
}
.clms-guide__pop-actions {
    margin-top: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.clms-guide__pop-nav {
    font-size: 11px;
    color: var(--guide-text-muted);
}
.clms-guide__pop-btn {
    border: none;
    border-radius: 7px;
    padding: 6px 12px;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    background: var(--guide-primary);
    color: #fff;
}
.clms-guide__pop-btn--ghost {
    background: transparent;
    color: var(--guide-done);
    border: 1px solid var(--guide-done);
}

/* ---- target highlight ---- */
.clms-guide-highlight {
    outline: 2px solid var(--guide-accent) !important;
    outline-offset: 3px !important;
    border-radius: 6px;
    transition: outline-color .2s ease;
    scroll-margin-top: 90px;
}

@media (max-width: 575.98px) {
    .clms-guide__panel { width: 100%; }
    .clms-guide__tab { top: auto; bottom: 84px; }
}
