/* Settings page - page-scoped, --ds-* tokens only */

.settings-page {
    padding: 0;
    max-width: none;
}

.settings-shell {
    display: flex;
    align-items: flex-start;
    gap: var(--ds-space-5);
    min-height: 0;
    width: 100%;
}

/*
 * The rail scrolls inside itself instead of spilling out of its card.
 *
 * `design-system.css` sets `align-items: stretch` on `.settings-page >
 * .settings-shell`, so this rail is sized to the height of the CONTENT PANEL
 * beside it. With 15 nav entries the rail's own content is taller than a short
 * panel -- measured 728px of buttons in a 645px box -- and the default
 * `overflow: visible` neither clipped nor scrolled it. The surplus simply
 * spilled: the last entries rendered below the card's border, and on an
 * 802px-tall window "Data" landed at y=860, off-screen and unclickable. There
 * was no scrollbar because nothing was scrollable, and the settings page does
 * not scroll either, so those entries were unreachable. The 768px POS screens
 * this cafe runs make it worse.
 *
 * The stretch is deliberately left alone -- it is what gives the rail its
 * full-height card next to the panel. Only the overflow behaviour changes.
 * `max-height: 100%` is belt and braces for any layout where the stretch does
 * not apply; it resolves against the shell's definite height, which is exactly
 * the visible area.
 */
.settings-tab-rail {
    flex: 0 0 220px;
    position: sticky;
    top: var(--ds-space-4);
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-1);
    padding: var(--ds-space-3);
    background: var(--ds-bg-surface);
    border: 1px solid var(--ds-border-default);
    border-radius: var(--ds-radius-lg);
}

/* A nav entry must never shrink to fit; the rail scrolls instead. Without
   this, flex would compress the buttons and clip their labels. */
.settings-tab-rail > * {
    flex-shrink: 0;
}

.settings-tab-strip {
    display: none;
    gap: var(--ds-space-1);
    overflow-x: auto;
    padding: var(--ds-space-2);
    margin-block-end: var(--ds-space-4);
    background: var(--ds-bg-surface);
    border: 1px solid var(--ds-border-default);
    border-radius: var(--ds-radius-lg);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.settings-tab-btn {
    display: block;
    width: 100%;
    min-height: var(--ds-touch-target);
    padding: var(--ds-space-2) var(--ds-space-3);
    border: 1px solid transparent;
    border-radius: var(--ds-radius-md);
    background: transparent;
    color: var(--ds-text-secondary);
    font-size: var(--ds-text-sm);
    font-weight: var(--ds-fw-medium);
    text-align: start;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--ds-motion-hover) var(--ds-ease-standard),
                color var(--ds-motion-hover) var(--ds-ease-standard);
}

.settings-tab-strip .settings-tab-btn {
    width: auto;
    flex: 0 0 auto;
}

.settings-tab-btn:hover {
    background: var(--ds-bg-inset);
    color: var(--ds-text-primary);
}

.settings-tab-btn.is-active {
    background: var(--ds-primary-tint);
    color: var(--ds-primary);
    border-color: color-mix(in srgb, var(--ds-primary) 25%, transparent);
}

.settings-main {
    flex: 1;
    min-width: 0;
}

.settings-panel-stack {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-4);
}

.settings-section {
    margin-block-end: 0;
}

.settings-section-title {
    margin: 0 0 var(--ds-space-1) 0;
}

.settings-section-desc {
    margin: 0 0 var(--ds-space-4) 0;
    font-size: var(--ds-text-sm);
    color: var(--ds-text-secondary);
}

.settings-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--ds-space-3);
}

.settings-form-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--ds-space-3);
}

@media (max-width: 640px) {
    .settings-form-row,
    .settings-form-row-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .settings-shell {
        flex-direction: column;
    }

    .settings-tab-rail {
        display: none;
    }

    .settings-tab-strip {
        display: flex;
    }
}

.settings-logo-row {
    display: flex;
    align-items: center;
    gap: var(--ds-space-3);
    flex-wrap: wrap;
}

.settings-logo-preview {
    width: 64px;
    height: 64px;
    object-fit: contain;
    border: 1px solid var(--ds-border-default);
    border-radius: var(--ds-radius-md);
    background: var(--ds-bg-inset);
}

.settings-cat-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--ds-space-3);
    flex-wrap: wrap;
    margin-block-end: var(--ds-space-3);
}

.settings-cat-hint {
    font-size: var(--ds-text-sm);
    color: var(--ds-text-secondary);
    margin: 0 0 var(--ds-space-3) 0;
}

.settings-cat-swatch {
    width: 24px;
    height: 24px;
    border-radius: var(--ds-radius-sm);
    border: 1px solid var(--ds-border-default);
}

.settings-data-actions {
    display: flex;
    gap: var(--ds-space-2);
    flex-wrap: wrap;
}

.settings-day-chips {
    display: flex;
    gap: var(--ds-space-2);
    flex-wrap: wrap;
    margin-block-start: var(--ds-space-1);
}

.settings-day-chip {
    display: flex;
    align-items: center;
    gap: var(--ds-space-1);
    cursor: pointer;
    font-size: var(--ds-text-sm);
    color: var(--ds-text-primary);
}

.settings-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--ds-border-default);
    border-radius: var(--ds-radius-lg);
}

.settings-toggle-row {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
    cursor: pointer;
}

.settings-toggle-row .ds-label {
    margin: 0;
    font-weight: var(--ds-fw-regular);
}

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

.settings-method-item {
    display: flex;
    align-items: center;
    gap: var(--ds-space-2);
    padding: var(--ds-space-2) var(--ds-space-3);
    border: 1px solid var(--ds-border-default);
    border-radius: var(--ds-radius-md);
    background: var(--ds-bg-inset);
    cursor: pointer;
}

.settings-hours-grid {
    display: flex;
    flex-direction: column;
    gap: var(--ds-space-2);
}

.settings-hours-row {
    display: grid;
    grid-template-columns: 80px 1fr 1fr auto;
    gap: var(--ds-space-2);
    align-items: center;
}

@media (max-width: 640px) {
    .settings-hours-row {
        grid-template-columns: 1fr;
    }
}

.settings-kds-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: var(--ds-space-2);
    align-items: center;
    padding-block: var(--ds-space-2);
    border-block-start: 1px solid var(--ds-border-default);
}

.settings-kds-row:first-child {
    border-block-start: none;
    padding-block-start: 0;
}

.settings-readonly-note {
    font-size: var(--ds-text-sm);
    color: var(--ds-text-secondary);
    padding: var(--ds-space-3);
    background: var(--ds-bg-inset);
    border-radius: var(--ds-radius-md);
    border: 1px solid var(--ds-border-default);
}

.settings-link-row {
    margin-block-start: var(--ds-space-3);
}
