/* ==========================================================================
   checkin.css — Worker Check-In PWA (/checkin) module.
   Built on the master.css token set (--mc-*). Touch-first: every control
   is a >=48px target, primary punch buttons are 56px+. Scoped under
   .ci-body so nothing leaks into other pages.
   Fold into master.css if/when the app stabilises (see AGENTS.md §4).
   ========================================================================== */

.ci-body {
    background: var(--mc-color-surface, #fcf8fa);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
    touch-action: manipulation;
}

/* --------------------------------------------------------------- login -- */
.ci-login {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    padding-top: max(1.25rem, env(safe-area-inset-top));
}
.ci-login__card {
    width: 100%;
    max-width: 26rem;
    padding: 2rem 1.5rem;
    text-align: center;
}
/* body.mc-app img { height:auto } in master.css outranks a lone class —
   match its specificity so the fixed logo sizes win. */
body.mc-app .ci-login__logo { height: 56px; width: auto; margin-bottom: 1rem; }
.ci-login__title { font-size: 1.5rem; font-weight: 700; margin: 0 0 .25rem; }
.ci-login__sub { color: var(--mc-color-text-muted, #45464d); margin-bottom: 1.25rem; }
.ci-login__card form { text-align: left; }
.ci-login__note {
    margin: 1.25rem 0 0;
    font-size: .85rem;
    color: var(--mc-color-text-subtle, #64666c);
}

/* -------------------------------------------------------------- header -- */
.ci-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--mc-color-white, #fff);
    border-bottom: 1px solid var(--mc-color-border, #e2e8f0);
    padding: .5rem .75rem;
    padding-top: max(.5rem, env(safe-area-inset-top));
    display: grid;
    gap: .5rem;
}
.ci-header__row { display: flex; align-items: center; gap: .5rem; }
.ci-header__row--nav { justify-content: center; }
.ci-header__brand { display: flex; align-items: center; gap: .5rem; min-width: 0; flex: 1; }
body.mc-app .ci-header__logo { height: 28px; width: auto; flex: none; }
.ci-header__company {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: .95rem;
}
.ci-header__actions { display: flex; align-items: center; gap: .35rem; }

.ci-iconbtn {
    width: 48px; height: 48px;
    border-radius: 12px;
    border: 1px solid var(--mc-color-border, #e2e8f0);
    background: var(--mc-color-white, #fff);
    color: var(--mc-color-text, #1b1b1d);
    font-size: 1.15rem;
    display: inline-flex; align-items: center; justify-content: center;
}
.ci-iconbtn:active { background: var(--mc-color-surface-low, #f6f3f5); }

.ci-net {
    display: inline-flex; align-items: center; gap: .35rem;
    font-size: .78rem; color: var(--mc-color-text-subtle, #64666c);
    padding: 0 .35rem;
}
.ci-net__dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--mc-color-success, #15803d);
}
.ci-net--offline .ci-net__dot { background: var(--mc-color-danger, #ba1a1a); }
.ci-net--queued .ci-net__dot { background: var(--mc-color-warning, #b45309); }

.ci-datebtn {
    width: 48px; height: 48px;
    border-radius: 12px;
    border: 1px solid var(--mc-color-border, #e2e8f0);
    background: var(--mc-color-white, #fff);
    font-size: 1rem;
}
.ci-datelabel {
    border: 1px solid var(--mc-color-border, #e2e8f0);
    background: var(--mc-color-white, #fff);
    border-radius: 12px;
    height: 48px;
    padding: 0 1rem;
    font-weight: 600;
    min-width: 12rem;
}
.ci-dateinput { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.ci-todaybtn { height: 48px; border-radius: 12px; }

.ci-search {
    position: relative;
    flex: 1;
}
.ci-search .fa {
    position: absolute; left: .9rem; top: 50%; transform: translateY(-50%);
    color: var(--mc-color-text-subtle, #64666c);
}
.ci-search input {
    width: 100%;
    height: 48px;
    border-radius: 12px;
    border: 1px solid var(--mc-color-border, #e2e8f0);
    padding: 0 1rem 0 2.4rem;
    font-size: 1rem;
    background: var(--mc-color-white, #fff);
}
.ci-companypicker { max-width: 46%; height: 48px; border-radius: 12px; }

/* -------------------------------------------------------------- roster -- */
.ci-main {
    padding: .75rem .75rem 7.5rem; /* room for the bottom bar */
    max-width: 56rem;
    margin: 0 auto;
}
.ci-group { margin-bottom: 1rem; }
.ci-group__head {
    position: sticky;
    top: 172px; /* below the app header */
    z-index: 30;
    background: var(--mc-color-surface, #fcf8fa);
    padding: .5rem .25rem .35rem;
    display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
}
.ci-group__title { font-weight: 700; font-size: 1rem; }
.ci-group__meta { color: var(--mc-color-text-subtle, #64666c); font-size: .82rem; }
.ci-group--off .ci-group__title { color: var(--mc-color-text-subtle, #64666c); }

.ci-offschedule-toggle {
    width: 100%;
    border: 1px dashed var(--mc-color-outline-variant, #c6c6cd);
    background: transparent;
    border-radius: 12px;
    padding: .8rem;
    color: var(--mc-color-text-muted, #45464d);
    font-size: .95rem;
    margin: .25rem 0 1rem;
}

/* worker card */
.ci-card {
    display: flex;
    align-items: center;
    gap: .75rem;
    background: var(--mc-color-white, #fff);
    border: 1px solid var(--mc-color-border, #e2e8f0);
    border-radius: 16px;
    padding: .65rem .75rem;
    margin-bottom: .55rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.ci-card__tap {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex: 1;
    min-width: 0;
    background: none; border: 0; padding: 0; text-align: left;
}
.ci-card__avatar {
    width: 56px; height: 56px;
    border-radius: 50%;
    object-fit: cover;
    flex: none;
    background: var(--mc-color-surface-low, #f6f3f5);
    border: 1px solid var(--mc-color-border, #e2e8f0);
}
.ci-card__body { min-width: 0; flex: 1; }
.ci-card__name {
    font-weight: 600;
    font-size: 1.02rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ci-card__status {
    font-size: .84rem;
    color: var(--mc-color-text-muted, #45464d);
    display: flex; align-items: center; gap: .35rem; flex-wrap: wrap;
}
.ci-card__status .fa { font-size: .8rem; }
.ci-status--in { color: var(--mc-color-success, #15803d); font-weight: 600; }
.ci-status--warn { color: var(--mc-color-warning, #b45309); font-weight: 600; }
.ci-status--done { color: var(--mc-color-info, #1d437e); font-weight: 600; }
.ci-status--locked { color: var(--mc-color-text-subtle, #64666c); font-weight: 600; }
/* Times were typed in by a site manager, not punched (manual override). */
.ci-status--manual { color: var(--mc-color-text-subtle, #64666c); font-style: italic; }

/* primary punch buttons — the money target: fat and unmissable */
.ci-card__actions { display: flex; gap: .45rem; flex: none; align-items: center; }
.ci-punch {
    min-width: 118px;
    height: 58px;
    border-radius: 14px;
    border: 0;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: .01em;
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    transition: transform .06s ease;
}
.ci-punch:active { transform: scale(.97); }
.ci-punch--in { background: var(--mc-color-success, #15803d); color: #fff; }
.ci-punch--out { background: var(--mc-color-primary, #0f172a); color: #fff; }
.ci-punch--submit { background: var(--mc-color-brand-blue, #1d437e); color: #fff; }
.ci-punch[disabled] { opacity: .55; }
.ci-minibtn {
    width: 48px; height: 58px;
    border-radius: 14px;
    border: 1px solid var(--mc-color-border, #e2e8f0);
    background: var(--mc-color-white, #fff);
    color: var(--mc-color-text-muted, #45464d);
    font-size: 1rem;
}
/* Manual override: icon + short label, so the repair path is named rather
   than hidden behind a bare glyph. The label drops on small phones (below)
   to keep the worker's name from being squeezed out. */
.ci-minibtn--wide {
    width: auto;
    min-width: 48px;
    padding: 0 .6rem;
    display: inline-flex; flex-direction: column;
    align-items: center; justify-content: center; gap: .1rem;
    line-height: 1.05;
}
.ci-minibtn__label { font-size: .68rem; font-weight: 600; letter-spacing: .01em; }

.ci-empty {
    text-align: center;
    color: var(--mc-color-text-subtle, #64666c);
    padding: 3rem 1rem;
}
.ci-empty .fa { font-size: 2rem; display: block; margin-bottom: .75rem; }

/* ------------------------------------------------------- bottom bar ---- */
.ci-bar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 45;
    display: flex; align-items: center; gap: .75rem;
    padding: .65rem .9rem;
    padding-bottom: max(.65rem, env(safe-area-inset-bottom));
    background: var(--mc-color-white, #fff);
    border-top: 1px solid var(--mc-color-border, #e2e8f0);
    box-shadow: 0 -4px 16px rgba(15, 23, 42, .08);
}
.ci-bar__text { flex: 1; font-size: .92rem; font-weight: 600; }
.ci-bar__btn { height: 52px; border-radius: 12px; font-weight: 700; }

/* ------------------------------------------------------------- sheets -- */
.ci-scrim {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 60;
}
.ci-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 61;
    background: var(--mc-color-white, #fff);
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 32px rgba(15, 23, 42, .25);
    max-height: 88dvh;
    overflow-y: auto;
    padding: .5rem 1rem 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    max-width: 40rem;
    margin: 0 auto;
}
.ci-sheet__grab {
    width: 44px; height: 5px; border-radius: 3px;
    background: var(--mc-color-outline-variant, #c6c6cd);
    margin: .4rem auto .9rem;
}
.ci-sheet__title { font-size: 1.15rem; font-weight: 700; margin-bottom: .1rem; }
.ci-sheet__sub { color: var(--mc-color-text-muted, #45464d); font-size: .9rem; margin-bottom: .9rem; }
.ci-sheet__section { margin-bottom: 1rem; }
.ci-sheet__label {
    font-size: .8rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: .04em; color: var(--mc-color-text-subtle, #64666c);
    margin-bottom: .4rem;
}
.ci-sheet__row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.ci-sheet__actions { display: grid; gap: .6rem; margin-top: 1.1rem; }
.ci-sheet__actions .btn { height: 56px; border-radius: 14px; font-weight: 700; font-size: 1.02rem; }
.ci-sheet input[type="time"] {
    height: 54px;
    border-radius: 12px;
    border: 1px solid var(--mc-color-border, #e2e8f0);
    font-size: 1.15rem;
    padding: 0 .75rem;
    flex: 1;
    min-width: 9rem;
}
.ci-timegrid { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.ci-timegrid .ci-sheet__row { flex-wrap: nowrap; }
.ci-clearbtn {
    height: 54px; width: 54px; flex: none;
    border-radius: 12px;
    border: 1px solid var(--mc-color-border, #e2e8f0);
    background: var(--mc-color-white, #fff);
    color: var(--mc-color-danger, #ba1a1a);
}
.ci-hint { font-size: .78rem; color: var(--mc-color-text-subtle, #64666c); margin-top: .25rem; }

/* chips (lunch picker, rounding picker) */
.ci-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.ci-chip {
    min-width: 64px; height: 48px;
    padding: 0 .9rem;
    border-radius: 24px;
    border: 1.5px solid var(--mc-color-border, #e2e8f0);
    background: var(--mc-color-white, #fff);
    font-weight: 600; font-size: .95rem;
    display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
}
.ci-chip--on {
    border-color: var(--mc-color-primary, #0f172a);
    background: var(--mc-color-primary, #0f172a);
    color: #fff;
}

.ci-hours-preview {
    text-align: center;
    background: var(--mc-color-surface-low, #f6f3f5);
    border-radius: 14px;
    padding: .8rem;
    margin-top: .35rem;
}
.ci-hours-preview__num { font-size: 1.9rem; font-weight: 800; line-height: 1.1; }
.ci-hours-preview__sub { font-size: .82rem; color: var(--mc-color-text-muted, #45464d); }

.ci-callout {
    border-radius: 12px;
    padding: .7rem .8rem;
    font-size: .87rem;
    margin-top: .6rem;
}
.ci-callout--warning { background: var(--mc-color-warning-bg, #fef3c7); color: var(--mc-color-warning, #b45309); }
.ci-callout--info { background: var(--mc-color-info-bg, #dae2fd); color: var(--mc-color-info, #1d437e); }
.ci-callout--danger { background: var(--mc-color-danger-bg, #ffdad6); color: var(--mc-color-danger, #ba1a1a); }

/* review list rows */
.ci-review-row {
    display: flex; align-items: center; gap: .6rem;
    padding: .6rem 0;
    border-bottom: 1px solid var(--mc-color-border, #e2e8f0);
}
.ci-review-row__body { flex: 1; min-width: 0; }
.ci-review-row__name { font-weight: 600; }
.ci-review-row__meta { font-size: .82rem; color: var(--mc-color-text-muted, #45464d); }
.ci-review-row__hours { font-weight: 700; font-size: 1.05rem; flex: none; }
.ci-review-row__check { width: 48px; height: 48px; flex: none; accent-color: var(--mc-color-primary, #0f172a); }
.ci-review-row--done { opacity: .55; }

/* settings job list */
.ci-jobrow {
    display: flex; align-items: center; gap: .6rem;
    padding: .55rem 0;
    border-bottom: 1px solid var(--mc-color-border, #e2e8f0);
}
.ci-jobrow__title { flex: 1; min-width: 0; font-size: .92rem; font-weight: 600; }
.ci-jobrow select { width: 8.5rem; height: 48px; border-radius: 10px; }

/* ------------------------------------------------- add to home screen -- */
/* Sits above both the login card and the roster header, so it is in normal
   flow rather than fixed — it must not cover the punch buttons or the
   Review & submit bar. app.js hides it entirely once installed. */
.ci-install {
    display: flex;
    align-items: center;
    gap: .7rem;
    margin: 0;
    padding: .8rem 1rem;
    padding-top: max(.8rem, env(safe-area-inset-top));
    background: var(--mc-color-secondary-container, #d0e1fb);
    color: var(--mc-color-text, #1b1b1d);
}
.ci-install__icon {
    flex: none;
    display: grid;
    place-items: center;
    width: 2.4rem;
    height: 2.4rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, .65);
    color: var(--mc-color-brand-blue, #1d437e);
    font-size: 1.3rem;
}
.ci-install__body { flex: 1; min-width: 0; }
.ci-install__title { font-size: .95rem; font-weight: 700; line-height: 1.2; }
.ci-install__sub {
    margin-top: .15rem;
    font-size: .8rem;
    line-height: 1.3;
    color: var(--mc-color-text-muted, #45464d);
}
.ci-install__btn { flex: none; min-height: 44px; white-space: nowrap; }
.ci-install__close {
    flex: none;
    width: 36px; height: 36px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--mc-color-text-muted, #45464d);
    font-size: 1rem;
}

/* iOS Add-to-Home-Screen walkthrough (inside a sheet) */
.ci-steps {
    margin: .25rem 0 .75rem;
    padding-left: 1.35rem;
    font-size: .95rem;
    line-height: 1.55;
}
.ci-steps li { margin-bottom: .4rem; }

/* Phones in portrait: give the copy the full width and drop the button to
   its own row. Anything narrower than ~30rem squeezes the title into three
   lines if the button shares the row. */
@media (max-width: 30rem) {
    .ci-install {
        flex-wrap: wrap;
        row-gap: .55rem;
    }
    /* Row 1: icon, copy, dismiss. Row 2: the button, full width.
       Source order is icon-copy-button-dismiss, so reorder the last two.
       .ci-install__body keeps its `flex: 1; min-width: 0` — a content-sized
       basis there makes the copy refuse to shrink and every child wraps. */
    .ci-install__close { order: 2; }
    .ci-install__btn { order: 3; flex: 1 0 100%; }
}

/* app.js sets .ci-has-install on <body> while the banner is showing. The
   banner is in flow above both views, so give back the space it takes:
   the login screen must not still demand a full viewport (that pushes the
   card below the fold) and the sticky header must not add the safe-area
   inset a second time. */
body.ci-has-install .ci-login {
    min-height: 0;
    align-items: flex-start;
    padding-top: 1.5rem;
}
body.ci-has-install .ci-header {
    padding-top: .5rem;
}

/* -------------------------------------------------------------- toasts -- */
.ci-toasts {
    position: fixed;
    top: max(.6rem, env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    z-index: 80;
    display: grid;
    gap: .45rem;
    width: min(94vw, 26rem);
}
.ci-toast {
    display: flex; align-items: center; gap: .6rem;
    background: var(--mc-color-primary, #0f172a);
    color: #fff;
    border-radius: 14px;
    padding: .75rem .9rem;
    font-size: .93rem;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .3);
    animation: ci-toast-in .18s ease;
}
.ci-toast--error { background: var(--mc-color-danger, #ba1a1a); }
.ci-toast--success { background: var(--mc-color-success, #15803d); }
.ci-toast__msg { flex: 1; }
.ci-toast__btn {
    border: 0; background: rgba(255, 255, 255, .18);
    color: #fff; font-weight: 700;
    border-radius: 10px; padding: .45rem .8rem;
    min-height: 44px;
}
@keyframes ci-toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: none; }
}

/* larger screens: two-column roster */
@media (min-width: 900px) {
    .ci-group__cards { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
    .ci-card { margin-bottom: 0; }
}
@media (max-width: 420px) {
    .ci-punch { min-width: 104px; }
    .ci-datelabel { min-width: 9.5rem; }
    /* Icon only — the worker's name matters more than the word "Override". */
    .ci-minibtn--wide { width: 48px; padding: 0; }
    .ci-minibtn__label { display: none; }
}
