/*
 * Suitiee as an app on a phone: the install banner (resources/views/pwa/body.blade.php)
 * and the phone-width fixes to the panels found by the 360/390/768 sweep. Loaded on every
 * panel page after Filament's and the panel theme's styles. Bump App\Support\Pwa\Pwa::VERSION
 * on every change.
 *
 * Fixes only, within the current look: nothing here changes a colour, a font or a
 * layout at desktop widths.
 */

/* ---------- the install / alerts banner ---------- */

.sx-pwa-banner {
    position: fixed;
    z-index: 45;
    inset-inline: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    margin-inline: auto;
    max-width: 28rem;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 14px 12px;
    background: #FFFFFF;
    color: #1C1917;
    border: 1px solid #E7E5E4;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(28, 25, 23, .12);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .2s ease, transform .2s ease;
}
.sx-pwa-banner.is-open { opacity: 1; transform: none; }
.sx-pwa-banner[hidden] { display: none; }
.sx-pwa-banner-icon { flex: none; width: 44px; height: 44px; border-radius: 10px; }
.sx-pwa-banner-text { flex: 1; min-width: 0; }
.sx-pwa-banner-title { margin: 0 0 2px; font-weight: 600; font-size: 15px; line-height: 1.35; }
.sx-pwa-banner-body { margin: 0; font-size: 14px; line-height: 1.45; color: #57534E; }
.sx-pwa-share { display: inline-block; width: 18px; height: 18px; vertical-align: -3px; color: #0A84FF; }
.sx-pwa-banner-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.sx-pwa-btn {
    min-height: 44px;
    padding: 0 16px;
    border-radius: 6px;
    border: 1px solid #D6D3D1;
    background: #FFFFFF;
    color: #1C1917;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.sx-pwa-btn-primary { background: #C2703D; border-color: #C2703D; color: #FFFFFF; }
.sx-pwa-btn:disabled { opacity: .6; }
.dark .sx-pwa-banner { background: #1C1917; color: #F5F5F4; border-color: #44403C; }
.dark .sx-pwa-banner-body { color: #A8A29E; }
.dark .sx-pwa-btn { background: transparent; color: #F5F5F4; border-color: #57534E; }
.dark .sx-pwa-btn-primary { background: #C2703D; border-color: #C2703D; color: #FFFFFF; }
@media (prefers-reduced-motion: reduce) { .sx-pwa-banner { transition: none; } }

/* ---------- the push section of Settings › Notifications ---------- */

.sx-push-note { margin: 0 0 12px; font-size: 14px; line-height: 1.5; color: var(--tv-ink-2, #57534E); }
.sx-push-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.sx-push-switch { display: flex; align-items: flex-start; gap: 12px; margin: 0 0 16px; padding: 0 0 16px; border-bottom: 1px solid var(--tv-line, #E7E5E4); cursor: pointer; }
.sx-push-switch input { width: 20px; height: 20px; margin-top: 2px; flex: none; accent-color: var(--tv-accent, #B05F33); }
.sx-push-switch-label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.sx-push-switch .sx-push-note { margin: 0; }
.sx-push-list-heading { margin: 20px 0 8px; font-size: 14px; font-weight: 600; }
.sx-push-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--tv-line, #E7E5E4); }
.sx-push-item {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 0; border-bottom: 1px solid var(--tv-line, #E7E5E4);
}
.sx-push-item-text { display: flex; flex-direction: column; min-width: 0; }
.sx-push-item-name { font-size: 14px; font-weight: 600; }
.sx-push-item-meta { font-size: 13px; color: var(--tv-ink-3, #78716C); }
.sx-push-this {
    margin-inline-start: 6px; padding: 1px 6px; border-radius: 4px; font-size: 12px; font-weight: 600;
    background: var(--tv-accent-wash, #FBF1EA); color: var(--tv-accent, #A85A2C);
}

/* ---------- phone-width fixes (the 360 / 390 / 768 sweep) ---------- */

/*
 * Touch screens only (`pointer: coarse`): a mouse user at any width sees no change.
 *
 * 1. iOS Safari zooms the page into any field whose text is under 16px and leaves it
 *    zoomed. Filament's fields are 14px (and the panel theme's bare inputs 0.875rem), so
 *    every tap into a form on an iPhone zoomed. 16px on touch screens, for every field.
 *    !important because the panel theme's own rule for bare inputs is a long :not() chain
 *    and Filament's sizes live in utility classes; this one property is the whole fix.
 */
@media (pointer: coarse) {
    .fi-body input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='file']):not([type='color']),
    .fi-body select,
    .fi-body textarea,
    .fi-body .fi-select-input-btn,
    .fi-body .fi-input {
        font-size: 16px !important;
    }
}

/*
 * 2. Tap targets of at least 44 x 44 px (Apple's and WCAG 2.5.5's size) for the controls a
 *    host uses with a thumb on every screen. The icons keep their size; only the box
 *    around them grows.
 */
@media (pointer: coarse) {
    /* Top bar: menu, bell, language, account. */
    .fi-body .fi-topbar .fi-icon-btn,
    .fi-body .fi-topbar .fi-user-menu-trigger,
    .fi-body .fi-topbar summary.sui-lang {
        min-width: 44px;
        min-height: 44px;
    }
    .fi-body .fi-topbar .fi-user-menu-trigger { justify-content: center; }

    /* Row actions, table toolbar buttons (filters, columns), a field's own buttons
       (show password, clear), a dialog's close button, pagination. */
    .fi-body .fi-ta .fi-icon-btn,
    .fi-body .fi-ta .fi-ac-icon-btn-action,
    .fi-body .fi-input-wrp .fi-icon-btn,
    .fi-body .fi-modal-close-btn,
    .fi-body .fi-pagination-item-btn {
        min-width: 44px;
        min-height: 44px;
    }

    /* Tabs (Arriving / Departing / ..., a cluster's sub-navigation) and the inbox filters. */
    .fi-body .fi-tabs-item,
    .fi-body .tv-inbox__filter {
        min-height: 44px;
    }

    /* Calendar steppers (rates grid, all-units timeline, provider calendar) and the
       dashboard's follow-up and step buttons. The components' own styles set smaller
       minimums inline (`.cx-tl .cx-btn`), hence the longer selectors. */
    .fi-body .fi-main .cx-btn,
    .fi-body .tv-cal-step__btn,
    .fi-body .tv-sb-ghost,
    .fi-body .tv-sb-step {
        min-height: 44px;
        min-width: 44px;
    }

    .fi-body .fi-select-input-value-remove-btn { padding: 12px; margin: -12px; }

    /* The help card's close and Skip, on the panels and on the cleaner's app (/w). */
    .driver-popover-close-btn,
    .tv-tour__link {
        min-width: 44px;
        min-height: 44px;
    }
}

/*
 * 3. A long form's Save bar, which Filament pins to the bottom of a phone screen
 *    (`.fi-sticky .fi-ac`, fixed at bottom 0 below 640px), keeps its 1rem and adds the
 *    home indicator's inset. env() is 0 unless a page opts into the full screen, so this
 *    is a guard for the installed app rather than a change anybody sees today.
 */
@media (max-width: 639px) {
    .fi-sticky .fi-ac {
        padding-bottom: calc(var(--spacing, 0.25rem) * 4 + env(safe-area-inset-bottom, 0px));
    }
}

/* The cleaner's day card (resources/views/cleaner/today.blade.php): one big button. */
.sx-push-card[hidden], .sx-push-card [hidden] { display: none !important; }
.sx-push-card { text-align: center; }
.sx-push-card .sx-push-card-title { margin: .25rem 0 .75rem; font-size: 1.2rem; font-weight: 800; }
.sx-push-card .sx-push-card-note { margin: .75rem 0 0; color: var(--muted, #6B5645); font-size: 1rem; }
.sx-push-card .sx-push-card-links { display: flex; justify-content: center; gap: 1rem; margin-top: .75rem; }
.sx-push-card .sx-push-card-links button { background: none; border: 0; color: var(--muted, #6B5645); text-decoration: underline; font: inherit; font-size: 1rem; min-height: 44px; padding: 0 .5rem; }
