/*
 * Work Order — field-first phone layout for office roles (WorkOrderMobileHeader / WorkOrderMobileOverview).
 * These classes only render when the layout reports a phone viewport; desktop markup never carries them.
 * One page scroll; the global bottom nav stays the only fixed bottom bar.
 */

.wo-ops-center--mobile {
    padding-inline: 4px;
    /* Last card must clear the floating + (which already sits above the nav + safe area). */
    padding-bottom: calc(var(--fo-phone-fab, 56px) + 20px);
    overflow-x: clip;
}

/* ── Identity header ─────────────────────────────────────────── */
.wo-m-title-region {
    position: static;
}

.wo-m-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 8px 8px;
    min-width: 0;
}

.wo-m-header__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.75rem;
}

.wo-m-header__number {
    opacity: 0.7;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
}

.wo-m-header__project {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 32px;
    text-decoration: none;
}

.wo-m-header__title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.wo-m-header__customer {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.wo-m-header__address {
    display: inline-flex;
    align-items: flex-start;
    gap: 6px;
    margin: 0;
    min-height: 32px;
    padding: 4px 0;
    font-size: 0.9rem;
    color: inherit;
    text-decoration: none;
    overflow-wrap: anywhere;
}

a.wo-m-header__address span {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.wo-m-header__status,
.wo-m-header__schedule {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin: 0;
    font-size: 0.875rem;
}

.wo-m-header__crew::before {
    content: "·";
    margin-right: 6px;
    opacity: 0.6;
}

.wo-m-more {
    margin-top: 4px;
}

.wo-m-more > summary {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.wo-m-more__list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.wo-m-more__item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 6px 10px;
    border: 1px solid var(--fo-border, rgba(127, 127, 127, 0.3));
    border-radius: 10px;
    background: transparent;
    color: inherit;
    font-size: 0.85rem;
    text-decoration: none;
}

.wo-m-more__item--danger {
    color: var(--bs-danger, #dc3545);
}

/* ── Overview stack ──────────────────────────────────────────── */
.wo-m-overview {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.wo-m-card {
    padding: 12px;
    border: 1px solid var(--fo-border, rgba(127, 127, 127, 0.3));
    border-radius: 12px;
    background: var(--fo-surface, var(--fo-card, transparent));
    min-width: 0;
}

.wo-m-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.wo-m-card__title {
    margin: 0 0 6px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.75;
}

.wo-m-card__head .wo-m-card__title {
    margin-bottom: 0;
}

.wo-m-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--fo-accent, var(--bs-link-color, #3b82f6));
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
}

.wo-m-scope__text {
    margin: 0;
    font-size: 1rem;
    line-height: 1.45;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.wo-m-scope__text--clamped {
    display: -webkit-box;
    -webkit-line-clamp: 8;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.wo-m-scope__empty {
    margin: 0;
    opacity: 0.75;
}

/* Field actions: thumb-friendly 2-column grid. */
.wo-m-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.wo-m-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 8px 10px;
    border: 1px solid var(--fo-border, rgba(127, 127, 127, 0.3));
    border-radius: 12px;
    background: var(--fo-surface, var(--fo-card, transparent));
    color: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    touch-action: manipulation;
}

.wo-m-action .bi {
    font-size: 1.1rem;
}

.wo-m-action--primary,
.wo-m-action--complete {
    grid-column: 1 / -1;
    border-color: transparent;
    color: #fff;
}

.wo-m-action--primary {
    background: var(--bs-primary, #2563eb);
}

.wo-m-action--complete {
    background: var(--bs-success, #198754);
}

.wo-m-action:disabled {
    opacity: 0.6;
}

/* Solid fills keep white labels readable (opacity would wash them out to ~2.5:1). */
.wo-m-action--primary:disabled,
.wo-m-action--complete:disabled {
    opacity: 1;
    background: var(--fo-neutral-500, #64748b);
}

[data-fo-theme="light"] .wo-m-link {
    color: var(--fo-info-text, #1d4ed8);
}

[data-fo-theme="dark"] .wo-m-more__item--danger {
    color: var(--fo-danger-text, #fca5a5);
}

.wo-m-lifecycle-alt {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px 20px;
    margin-top: -4px;
}

.wo-m-facts {
    display: grid;
    gap: 6px;
    margin: 6px 0 0;
}

.wo-m-facts > div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.9rem;
}

.wo-m-facts dt {
    font-weight: 500;
    opacity: 0.7;
}

.wo-m-facts dd {
    margin: 0;
    text-align: right;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.wo-m-attention__list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 6px;
}

.wo-m-attention__btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 6px 10px;
    border: 0;
    border-left: 3px solid var(--bs-warning, #f59e0b);
    border-radius: 6px;
    background: rgba(127, 127, 127, 0.08);
    color: inherit;
    font-size: 0.9rem;
    text-align: left;
}

.wo-m-attention__item--critical .wo-m-attention__btn {
    border-left-color: var(--bs-danger, #dc3545);
}

.wo-m-attention__label {
    flex: 0 0 auto;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.8;
}

.wo-m-office {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    border: 1px dashed var(--fo-border, rgba(127, 127, 127, 0.4));
    border-radius: 10px;
    font-size: 0.85rem;
}

.wo-m-office__detail {
    display: block;
    opacity: 0.75;
}

.wo-m-jobsite {
    padding: 8px;
}

.wo-m-latest {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 4px 10px;
    font-size: 0.8rem;
    opacity: 0.85;
}

.wo-m-latest__text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.wo-m-overview .fo-wo-crew-status {
    margin-bottom: 0 !important;
}

.wo-m-action:focus-visible,
.wo-m-link:focus-visible,
.wo-m-more__item:focus-visible,
.wo-m-more > summary:focus-visible,
.wo-m-attention__btn:focus-visible,
.wo-m-header__address:focus-visible,
.wo-m-header__project:focus-visible {
    outline: 2px solid var(--fo-brand-600, #2563eb);
    outline-offset: 2px;
}

/* ── Section dropdown (native select: the OS picker handles fit + internal scroll) ── */
@media (max-width: 768px) {
    .wo-ops-center--mobile .wo-section-nav {
        padding: 4px 0 8px;
        margin-bottom: 10px;
    }

    .wo-ops-center--mobile #wo-section-select {
        width: 100%;
        max-width: 100%;
        min-height: 44px;
        font-size: 16px; /* ≥16px stops iOS zooming the page on focus */
        font-weight: 600;
    }
}

/* ---- Mobile field Work Order (MobileFieldWorkOrderView): one screen, one primary control ---- */
.fo-fwo {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 8px 4px calc(var(--fo-phone-fab, 56px) + 24px);
    min-width: 0;
    /* Same single-column screen on iPad and phone landscape: never stretch into a desktop-width layout. */
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
}

.fo-fwo__head {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fo-fwo__title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.fo-fwo__title {
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.25;
    margin: 0;
    overflow-wrap: anywhere;
}

.fo-fwo__status {
    flex: none;
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    background: #e2e8f0;
    color: #0f172a;
}

.fo-fwo__status--active { background: #dcfce7; color: #14532d; }
.fo-fwo__status--paused { background: #fef3c7; color: #78350f; }
.fo-fwo__status--done { background: #dbeafe; color: #1e3a8a; }
.fo-fwo__status--muted { background: #f1f5f9; color: #475569; }

.fo-fwo__customer {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
}

.fo-fwo__link {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 48px;
    margin: 0;
    padding: 6px 2px;
    font-size: 1rem;
    color: var(--fo-brand-600, #2563eb);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.fo-fwo__link i { font-size: 1.25rem; }

.fo-fwo__msg {
    padding: 12px 14px;
    border-radius: 12px;
    font-weight: 600;
}

.fo-fwo__msg--ok { background: #dcfce7; color: #14532d; }
.fo-fwo__msg--error { background: #fee2e2; color: #7f1d1d; }

.fo-fwo__primary {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.fo-fwo__timer {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: 0;
    font-size: 0.95rem;
    color: #475569;
}

.fo-fwo__timer strong {
    font-size: 1.35rem;
    color: #0f172a;
}

.fo-fwo__timer--mine strong {
    font-size: 1.1rem;
}

/* Driven by fieldops-circuit.js on <html>: works while the circuit is down, when Blazor cannot re-render. */
.fo-fwo__reconnect {
    display: none;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 0.95rem;
    color: #1e3a8a;
}

html[data-fo-circuit="reconnecting"] .fo-fwo__reconnect,
html[data-fo-circuit="checking"] .fo-fwo__reconnect,
html[data-fo-circuit="offline"] .fo-fwo__reconnect,
html[data-fo-circuit="reload-required"] .fo-fwo__reconnect {
    display: flex;
}

/* Greyed rather than faded: a faded blue button with white text drops below readable contrast. */
html[data-fo-circuit="reconnecting"] .fo-fwo [data-fo-mutation],
html[data-fo-circuit="checking"] .fo-fwo [data-fo-mutation],
html[data-fo-circuit="offline"] .fo-fwo [data-fo-mutation],
html[data-fo-circuit="reload-required"] .fo-fwo [data-fo-mutation] {
    filter: grayscale(1);
    cursor: not-allowed;
}

.fo-fwo__primary-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    min-height: 80px;
    padding: 12px 16px;
    border: 0;
    border-radius: 16px;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #ffffff;
    background: #2563eb;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.fo-fwo__primary-btn i { font-size: 1.7rem; }
.fo-fwo__primary-btn .spinner-border { width: 1.6rem; height: 1.6rem; }
.fo-fwo__primary-btn--finish { background: #15803d; }
.fo-fwo__primary-btn--done { background: #e2e8f0; color: #334155; }
.fo-fwo__primary-btn:disabled { opacity: 1; cursor: not-allowed; background: #64748b; color: #ffffff; }
.fo-fwo__primary-btn[aria-busy="true"]:disabled { cursor: progress; background: #1d4ed8; }
.fo-fwo__primary-btn--finish[aria-busy="true"]:disabled { background: #166534; }
.fo-fwo__primary-btn--done:disabled { background: #e2e8f0; color: #334155; }

.fo-fwo__hint {
    margin: 0;
    font-size: 0.95rem;
    color: #7c2d12;
}

.fo-fwo__pause {
    align-self: center;
    min-height: 48px;
    padding: 8px 18px;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    background: transparent;
    font-weight: 600;
    color: #334155;
}

.fo-fwo__tools {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.fo-fwo__tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 72px;
    border: 1px solid #cbd5e1;
    border-radius: 14px;
    background: #ffffff;
    font-weight: 700;
    color: #0f172a;
}

.fo-fwo__tool i { font-size: 1.5rem; }
.fo-fwo__tool--on { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25); }

.fo-fwo__panel,
.fo-fwo__scope {
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #ffffff;
}

.fo-fwo__note { font-size: 1rem; }

.fo-fwo__save {
    width: 100%;
    min-height: 52px;
    margin-top: 10px;
    border: 0;
    border-radius: 12px;
    background: #2563eb;
    color: #ffffff;
    font-weight: 700;
}

.fo-fwo__save:disabled { cursor: not-allowed; background: #64748b; }

.fo-fwo__section-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin: 0 0 6px;
}

.fo-fwo__scope-text {
    white-space: pre-line;
    font-size: 1rem;
    line-height: 1.5;
}

.fo-fwo__office-link {
    align-self: center;
    min-height: 44px;
    border: 0;
    background: transparent;
    color: #475569;
    font-weight: 600;
    text-decoration: underline;
}

[data-fo-theme="dark"] .fo-fwo__panel,
[data-fo-theme="dark"] .fo-fwo__scope,
[data-fo-theme="dark"] .fo-fwo__tool {
    background: #15233a;
    border-color: #334155;
    color: #f8fafc;
}

[data-fo-theme="dark"] .fo-fwo__timer strong { color: #f8fafc; }

/* Readable text on both themes: the shell's inherited colour is not guaranteed on this screen. */
[data-fo-theme="light"] .fo-fwo { color: var(--fo-neutral-900, #0f172a); }
[data-fo-theme="dark"] .fo-fwo { color: var(--fo-neutral-50, #f8fafc); }

/* Dark theme: the light-theme slate/navy text above sits on near-black and must flip to light tones. */
[data-fo-theme="dark"] .fo-fwo__link { color: var(--fo-brand-200, #93c5fd); }
[data-fo-theme="dark"] .fo-fwo__timer { color: var(--fo-neutral-300, #cbd5e1); }
[data-fo-theme="dark"] .fo-fwo__hint { color: var(--fo-warning-text, #fbbf24); }
[data-fo-theme="dark"] .fo-fwo__reconnect { color: var(--fo-info-text, #93c5fd); }
[data-fo-theme="dark"] .fo-fwo__section-title { color: var(--fo-neutral-300, #cbd5e1); }
[data-fo-theme="dark"] .fo-fwo__office-link { color: var(--fo-neutral-300, #cbd5e1); }
[data-fo-theme="dark"] .fo-fwo__pause {
    border-color: var(--fo-neutral-600, #475569);
    color: var(--fo-neutral-100, #f1f5f9);
}
[data-fo-theme="dark"] .fo-fwo .text-muted { color: var(--fo-neutral-300, #cbd5e1) !important; }

/* ── Neutral placeholder while the Work Order and device layout resolve (no office/field flash) ── */
.wo-view-pending {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 8px;
}

.wo-view-pending > div {
    border-radius: 12px;
    background: var(--fo-neutral-200, #e2e8f0);
    animation: wo-view-pending-pulse 1.4s ease-in-out infinite;
}

[data-fo-theme="dark"] .wo-view-pending > div { background: var(--fo-neutral-800, #1e293b); }

.wo-view-pending__title { height: 28px; width: 70%; }
.wo-view-pending__line { height: 18px; width: 45%; }
.wo-view-pending__card { height: 120px; }
.wo-view-pending__button { height: 80px; border-radius: 16px; }

@media (prefers-reduced-motion: reduce) {
    .wo-view-pending > div { animation: none; }
}

@keyframes wo-view-pending-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}