/* First-run onboarding wizard (js/onboarding.js). Tokens only (--ds-*). */

body.ob-open {
    overflow: hidden;
}

.ob-overlay {
    position: fixed;
    inset: 0;
    /*
     * --z-overlay (200), deliberately NOT --z-modal (300).
     *
     * It still covers the whole app -- the sidebar is 100 -- but it sits
     * UNDER the shared dialog, so the Skip confirmation can be the app's own
     * Components.confirm rather than a native window.confirm. Both live at
     * z-modal and #modalOverlay is earlier in the document, so at equal
     * z-index this panel would paint on top of the very question it asked.
     */
    z-index: var(--z-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--ds-space-4);
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow-y: auto;
}

.ob-panel {
    width: 100%;
    max-width: 760px;
    max-height: calc(100vh - var(--ds-space-8, 32px));
    display: flex;
    flex-direction: column;
    background: var(--ds-surface);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-xl, 16px);
    box-shadow: var(--ds-shadow-pop, 0 24px 60px rgba(0, 0, 0, 0.28));
    overflow: hidden;
}

.ob-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--ds-space-4);
    padding: var(--ds-space-5) var(--ds-space-6) var(--ds-space-3);
}

.ob-eyebrow {
    margin: 0 0 2px 0;
    font-size: var(--ds-text-xs);
    font-weight: var(--ds-fw-semibold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ds-text-tertiary);
}

.ob-title {
    margin: 0;
    font-size: var(--ds-text-xl, 1.25rem);
    font-weight: var(--ds-fw-semibold);
    color: var(--ds-text-primary);
}

.ob-steps {
    display: flex;
    gap: var(--ds-space-2);
    padding: 0 var(--ds-space-6) var(--ds-space-4);
}

.ob-step {
    flex: 1;
    height: 3px;
    border-radius: 999px;
    background: var(--ds-border);
    transition: background-color var(--ds-motion-hover, 160ms) var(--ds-ease-standard, ease);
}

.ob-step.is-done {
    background: var(--ds-primary);
    opacity: 0.45;
}

.ob-step.is-active {
    background: var(--ds-primary);
    opacity: 1;
}

.ob-body {
    flex: 1;
    /* Same reason as .modal-body: without this the body refuses to shrink
       below its content and pushes the footer off a fixed overlay. */
    min-height: 0;
    overflow-y: auto;
    padding: 0 var(--ds-space-6) var(--ds-space-5);
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-4);
}

.ob-lede {
    margin: 0;
    font-size: var(--ds-text-sm);
    line-height: 1.55;
    color: var(--ds-text-secondary);
}

.ob-hint {
    margin: 0;
    font-size: var(--ds-text-xs);
    line-height: 1.45;
    color: var(--ds-text-tertiary);
}

.ob-count {
    margin: 0;
    font-size: var(--ds-text-xs);
    color: var(--ds-text-tertiary);
}

.ob-foot {
    display: flex;
    justify-content: space-between;
    gap: var(--ds-space-3);
    padding: var(--ds-space-4) var(--ds-space-6);
    border-top: 1px solid var(--ds-border);
    background: var(--ds-bg-inset);
}

.ob-error {
    margin: 0;
    padding: var(--ds-space-3) var(--ds-space-6);
    font-size: var(--ds-text-sm);
    color: var(--ds-danger);
    background: var(--ds-danger-tint, rgba(220, 38, 38, 0.1));
    border-top: 1px solid var(--ds-border);
}

.ob-error[hidden] {
    display: none;
}

/* ── Step 1: business ──────────────────────────────────────────────────── */

.ob-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--ds-space-4);
}

.ob-field-wide {
    grid-column: 1 / -1;
}

/* ── Step 2: sections ──────────────────────────────────────────────────── */

.ob-chips {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: var(--ds-space-2);
}

.ob-chip {
    display: flex;
    align-items: center;
    gap: var(--ds-space-1);
    padding: 4px 4px 4px var(--ds-space-2);
    border: 1px solid var(--ds-border);
    border-radius: var(--ds-radius-lg);
    background: var(--ds-bg-inset);
    transition: border-color var(--ds-motion-hover, 160ms) var(--ds-ease-standard, ease),
                background-color var(--ds-motion-hover, 160ms) var(--ds-ease-standard, ease);
}

.ob-chip.is-on {
    border-color: var(--ds-primary);
    background: var(--ds-primary-tint);
}

.ob-chip-toggle {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ds-border-strong);
    border-radius: var(--ds-radius-sm);
    background: var(--ds-surface);
    color: var(--ds-text-tertiary);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
}

.ob-chip.is-on .ob-chip-toggle {
    border-color: var(--ds-primary);
    background: var(--ds-primary);
    color: var(--ds-text-on-accent);
}

.ob-chip-input {
    flex: 1 1 auto;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--ds-text-primary);
    font: inherit;
    font-size: var(--ds-text-sm);
    padding: var(--ds-space-2) var(--ds-space-1);
    outline: none;
}

.ob-chip:not(.is-on) .ob-chip-input {
    color: var(--ds-text-tertiary);
    text-decoration: line-through;
}

.ob-chip-input:focus {
    box-shadow: none;
}

.ob-chip-x {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: var(--ds-radius-sm);
    background: transparent;
    color: var(--ds-text-tertiary);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.ob-chip-x:hover {
    background: var(--ds-danger-tint, rgba(220, 38, 38, 0.12));
    color: var(--ds-danger);
}

.ob-add-row {
    display: flex;
    gap: var(--ds-space-2);
}

.ob-add-row .ds-input {
    flex: 1;
    min-width: 0;
}

/* ── Step 3: items ─────────────────────────────────────────────────────── */

.ob-items {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-2);
}

.ob-item-row {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 0.7fr) minmax(0, 1fr) 28px;
    gap: var(--ds-space-2);
    align-items: center;
}

.ob-item-head {
    font-size: var(--ds-text-xs);
    font-weight: var(--ds-fw-semibold);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ds-text-tertiary);
}

.ob-price {
    font-family: var(--ds-font-mono);
    text-align: end;
}

.ob-add-item {
    align-self: flex-start;
}

/* ── Step 4: review ────────────────────────────────────────────────────── */

.ob-review {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-4);
    margin: 0;
}

.ob-review > div {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-2);
    padding-block-end: var(--ds-space-4);
    border-bottom: 1px solid var(--ds-border);
}

.ob-review > div:last-child {
    border-bottom: 0;
    padding-block-end: 0;
}

.ob-review dt {
    font-size: var(--ds-text-xs);
    font-weight: var(--ds-fw-semibold);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ds-text-tertiary);
}

.ob-review dd {
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--ds-space-2);
    font-size: var(--ds-text-sm);
    color: var(--ds-text-primary);
}

.ob-tag {
    display: inline-flex;
    align-items: center;
    padding: 3px var(--ds-space-2);
    border: 1px solid var(--ds-border);
    border-radius: 999px;
    background: var(--ds-bg-inset);
    font-size: var(--ds-text-xs);
}

.ob-muted {
    color: var(--ds-text-tertiary);
    font-size: var(--ds-text-xs);
}

/* ── Narrow ────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
    .ob-overlay {
        padding: 0;
    }

    .ob-panel {
        max-width: none;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        border: 0;
    }

    .ob-head,
    .ob-steps,
    .ob-body,
    .ob-foot,
    .ob-error {
        padding-inline: var(--ds-space-4);
    }

    .ob-field-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    /* The header row labels columns that no longer sit side by side. */
    .ob-item-head {
        display: none;
    }

    .ob-item-row {
        grid-template-columns: minmax(0, 1fr) 28px;
        grid-template-areas:
            "name   x"
            "price  x"
            "cat    x";
        row-gap: var(--ds-space-1);
        padding-block-end: var(--ds-space-3);
        border-bottom: 1px solid var(--ds-border);
    }

    .ob-item-row [data-ob="item-name"]  { grid-area: name; }
    .ob-item-row [data-ob="item-price"] { grid-area: price; text-align: start; }
    .ob-item-row [data-ob="item-cat"]   { grid-area: cat; }
    .ob-item-row .ob-chip-x             { grid-area: x; align-self: start; }
}
