/* Beauty workspace — iOS look (owner 06/11: «restyle ios look and feel»).
   Loaded only on the beauty pages (base_admin + the public salon booking
   page) with html.bty-ios set. The pages keep their own markup and colour
   variables; this re-points the variables at iOS values, swaps the editorial
   serif for the system font, and adds the iPhone basics: 16px inputs (no
   focus zoom), dvh heights, home-indicator space, a phone tab bar. Layout
   rules for phones live inside max-width queries; nothing here widens a
   desktop layout. */

html.bty-ios {
    --ios-bg: #f2f2f7;
    --ios-card: #ffffff;
    --ios-ink: #1c1c1e;
    --ios-sub: #8e8e93;
    --ios-sep: rgba(60, 60, 67, .14);
    --ios-fill: rgba(118, 118, 128, .12);
    --ios-green: #34c759;
    --ios-red: #ff3b30;
    --ios-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    --ios-tab-h: 56px;

    /* salon pages (hours, wizard, settings, public booking) */
    --salon-cream: var(--ios-bg);
    --salon-cream-deep: #e5e5ea;
    --salon-paper: var(--ios-card);
    --salon-ink: var(--ios-ink);
    --salon-ink-soft: var(--ios-sub);
    --salon-line: var(--ios-sep);
    --salon-line-soft: rgba(60, 60, 67, .08);
    --w-serif: var(--ios-font);
    --serif: var(--ios-font);

    /* beauty dashboard */
    --vd-bg: var(--ios-bg);
    --vd-paper: var(--ios-card);
    --vd-ink: var(--ios-ink);
    --vd-ink-soft: var(--ios-sub);
    --vd-line: var(--ios-sep);
}

/* ── type ─────────────────────────────────────────────────────────── */
html.bty-ios .admin-main,
html.bty-ios .sbk-wrap,
html.bty-ios body.bty-public {
    font-family: var(--ios-font);
    -webkit-font-smoothing: antialiased;
}
html.bty-ios .admin-main { background: var(--ios-bg); }
html.bty-ios .vd-kpi-value,
html.bty-ios .vd-alert-n,
html.bty-ios .vd-stat > strong,
html.bty-ios .vd-date,
html.bty-ios .vd-row-time { font-family: var(--ios-font); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }

html.bty-ios .sh-masthead h1,
html.bty-ios .ss-masthead h1,
html.bty-ios .wiz-wrap h1,
html.bty-ios .vd-title {
    font-family: var(--ios-font);
    font-weight: 800;
    letter-spacing: -.02em;
}

/* ── cards: rounded, flat, iOS grouped ────────────────────────────── */
html.bty-ios .vd-panel,
html.bty-ios .vd-kpi,
html.bty-ios .sh-card,
html.bty-ios .salon-set-card,
html.bty-ios .wiz-step,
html.bty-ios .sbk-card {
    border-radius: 16px;
    border-color: transparent;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

/* ── buttons ──────────────────────────────────────────────────────── */
html.bty-ios .sh-actions button,
html.bty-ios .wiz-actions button,
html.bty-ios .wiz-actions a,
html.bty-ios .salon-actions button,
html.bty-ios .sbk-sticky-bar button {
    border-radius: 12px;
    font-family: var(--ios-font);
    font-weight: 600;
}

/* ── switches instead of checkboxes (settings, wizard, hours «Off») ─ */
html.bty-ios .ss-wrap input[type="checkbox"],
html.bty-ios .wiz-wrap input[type="checkbox"],
html.bty-ios .sh-day-cell .off-toggle input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 42px; height: 26px; flex: none;
    border-radius: 13px;
    background: #e9e9eb;
    position: relative;
    cursor: pointer;
    transition: background .2s;
    vertical-align: middle;
    margin: 0;
}
html.bty-ios .ss-wrap input[type="checkbox"]::after,
html.bty-ios .wiz-wrap input[type="checkbox"]::after,
html.bty-ios .sh-day-cell .off-toggle input[type="checkbox"]::after {
    content: "";
    position: absolute; top: 2px; left: 2px;
    width: 22px; height: 22px; border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, .2);
    transition: transform .2s;
}
html.bty-ios .ss-wrap input[type="checkbox"]:checked,
html.bty-ios .wiz-wrap input[type="checkbox"]:checked { background: var(--ios-green); }
html.bty-ios .sh-day-cell .off-toggle input[type="checkbox"]:checked { background: var(--ios-red); }
html.bty-ios .ss-wrap input[type="checkbox"]:checked::after,
html.bty-ios .wiz-wrap input[type="checkbox"]:checked::after,
html.bty-ios .sh-day-cell .off-toggle input[type="checkbox"]:checked::after { transform: translateX(16px); }
html.bty-ios .ss-wrap input[type="checkbox"]:focus-visible,
html.bty-ios .wiz-wrap input[type="checkbox"]:focus-visible,
html.bty-ios .sh-day-cell .off-toggle input[type="checkbox"]:focus-visible { outline: 2px solid var(--salon-accent, #0a84ff); outline-offset: 2px; }

/* ── heights: dvh, not vh (the Safari toolbar) ───────────────────── */
@supports (height: 100dvh) {
    html.bty-ios .admin-container { min-height: 100dvh; }
    html.bty-ios body { min-height: 100dvh; }
    html.bty-ios .ai-panel { height: min(540px, calc(100dvh - 130px)); }
}

/* pages with a fixed save bar: the AI button sits above the bar */
html.bty-ios:not(.bty-has-tabbar) .ai-chat-fab { bottom: 96px; }
html.bty-ios:not(.bty-has-tabbar) .ai-chat-win { bottom: 164px; }

/* ── phones ───────────────────────────────────────────────────────── */
@media (max-width: 767.98px) {
    /* 16px = no zoom when a field is tapped */
    html.bty-ios input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    html.bty-ios select,
    html.bty-ios textarea { font-size: 16px !important; }

    /* bottom bars clear the home indicator, and the page clears the bars */
    html.bty-ios .sh-actions,
    html.bty-ios .wiz-actions,
    html.bty-ios .salon-actions,
    html.bty-ios .sbk-sticky-bar { padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); }
    html.bty-ios .sh-wrap,
    html.bty-ios .ss-wrap,
    html.bty-ios .wiz-wrap { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
    html.bty-ios .sbk-wrap { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }

    /* public page: the AI button sits above the sticky bar, not on «Continue» */
    html.bty-ios .ai-fab { bottom: calc(84px + env(safe-area-inset-bottom)); right: 14px; }
    html.bty-ios .ai-panel { bottom: calc(150px + env(safe-area-inset-bottom)); right: 10px; left: 10px; width: auto; }

    /* dashboard: two KPI tiles a row */
    html.bty-ios .vd-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; }
    html.bty-ios .vd-cols { grid-template-columns: minmax(0, 1fr) !important; }

    /* working hours: one card per stylist instead of an 880px table */
    html.bty-ios .sh-card { overflow: visible; background: transparent; box-shadow: none; padding: 0; }
    html.bty-ios .sh-grid { min-width: 0 !important; width: 100%; border: 0; }
    html.bty-ios .sh-grid thead { display: none; }
    html.bty-ios .sh-grid,
    html.bty-ios .sh-grid tbody,
    html.bty-ios .sh-grid tr,
    html.bty-ios .sh-grid td { display: block; }
    html.bty-ios .sh-grid tr {
        background: var(--ios-card);
        border-radius: 16px;
        margin: 0 0 12px;
        padding: 6px 14px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
    }
    html.bty-ios .sh-grid td { border: 0; padding: 8px 0; }
    html.bty-ios .sh-grid td + td { border-top: 1px solid var(--ios-sep); }
    html.bty-ios .sh-grid td.stylist { padding: 10px 0; }
    html.bty-ios .sh-grid .sh-day-cell[data-label] {
        display: grid;
        grid-template-columns: 52px minmax(0, 1fr) auto;
        align-items: center;
        gap: 10px;
    }
    html.bty-ios .sh-grid .sh-day-cell[data-label]::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--ios-ink);
    }
    html.bty-ios .sh-day-cell .times { display: flex; gap: 6px; min-width: 0; }
    html.bty-ios .sh-day-cell .times input { min-width: 0; flex: 1 1 0; padding: 6px 8px; border-radius: 10px; background: var(--ios-fill); border: 0; }
    html.bty-ios .sh-day-cell .off-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--ios-sub); }

    /* pages with their own save bar: the AI button and «report issue»
       sit above it, not on its buttons */
    html.bty-ios:not(.bty-has-tabbar) .ai-chat-fab { bottom: calc(215px + env(safe-area-inset-bottom)); right: 14px; }
    html.bty-ios:not(.bty-has-tabbar) .ai-chat-win { bottom: calc(280px + env(safe-area-inset-bottom)); }
    html.bty-ios .lb-report-issue-pill { bottom: calc(215px + env(safe-area-inset-bottom)); }
    html.bty-ios.bty-has-tabbar .lb-report-issue-pill { bottom: calc(var(--ios-tab-h) + 14px + env(safe-area-inset-bottom)); }

    /* room for the tab bar */
    html.bty-ios.bty-has-tabbar .admin-main { padding-bottom: calc(var(--ios-tab-h) + 16px + env(safe-area-inset-bottom)); }
    html.bty-ios.bty-has-tabbar .ai-chat-fab { bottom: calc(var(--ios-tab-h) + 14px + env(safe-area-inset-bottom)); right: 14px; }
    html.bty-ios.bty-has-tabbar .ai-chat-win { bottom: calc(var(--ios-tab-h) + 80px + env(safe-area-inset-bottom)); }
}

/* the smallest phones: the «Off» switch without its word, so the two
   time fields keep room */
@media (max-width: 359.98px) {
    html.bty-ios .sh-grid .sh-day-cell[data-label] { grid-template-columns: 40px minmax(0, 1fr) auto; gap: 8px; }
    html.bty-ios .sh-day-cell .off-toggle { font-size: 0; gap: 0; }
    html.bty-ios .sh-day-cell .times input { padding: 6px 4px; }
}

/* ── phone tab bar (dashboard, calendar, services, staff, clients) ─ */
.bty-tabbar { display: none; }
@media (max-width: 767.98px) {
    html.bty-ios .bty-tabbar {
        display: grid;
        grid-template-columns: repeat(5, minmax(0, 1fr));
        position: fixed; left: 0; right: 0; bottom: 0;
        z-index: 1030;
        height: calc(var(--ios-tab-h) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: rgba(249, 249, 249, .94);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        backdrop-filter: saturate(180%) blur(20px);
        border-top: .5px solid rgba(0, 0, 0, .18);
        font-family: var(--ios-font);
    }
    html.bty-ios .bty-tabbar a,
    html.bty-ios .bty-tabbar button {
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 2px;
        min-width: 0;
        border: 0; background: transparent;
        color: #999;
        font-size: 10px; font-weight: 500; letter-spacing: .01em;
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
    }
    html.bty-ios .bty-tabbar i { font-size: 1.35rem; line-height: 1; }
    html.bty-ios .bty-tabbar span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    html.bty-ios .bty-tabbar .on { color: var(--salon-accent, #0a84ff); }
    html.admin-nav-hidden.bty-ios .bty-tabbar { display: grid; }
    body:has(#adminOffcanvas.show) .bty-tabbar { display: none !important; }
}
@media print { .bty-tabbar { display: none !important; } }
