﻿/* FieldOps mobile app shell â€” phone-first tokens and chrome (â‰¤768px).
   Desktop layouts are unchanged; rules are scoped to .mobile-mode / media query. */

:root {
  /* Defaults; phones override further via mobile-density.css + .mobile-mode */
  --fo-m-page-pad: 16px;
  --fo-m-card-gap: 12px;
  --fo-m-section-gap: 20px;
  --fo-m-radius: 14px;
  --fo-m-radius-sm: 10px;
  --fo-m-shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
  --fo-m-tap: 40px;
  --fo-m-btn-h: 40px;
  --fo-m-input-h: 40px;
  --fo-m-nav-h: 56px;
  --fo-m-fab-size: 48px;
  --fo-m-body: 13px;
  --fo-m-title: 1.1rem;
  --fo-m-safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 768px) {
  .fieldops-shell.mobile-mode .main-content,
  .fieldops-shell .main-content {
    padding-bottom: calc(var(--fo-m-nav-h) + var(--fo-m-safe-bottom) + 12px) !important;
    overflow-x: hidden;
  }

  .fo-m-page,
  .fo-m-entity-card,
  .fo-m-card,
  .fo-m-wo-header,
  .fo-m-section__body {
    overflow-x: hidden;
    max-width: 100%;
  }

  .fo-m-entity-card__title,
  .fo-m-entity-card__meta,
  .fo-m-wo-header .fo-m-entity-card__title {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .fo-m-review-only {
    margin: 0;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--fo-surface-muted, rgba(148, 163, 184, 0.08));
    color: #475569;
    font-size: 0.85rem;
    font-weight: 600;
  }

  /* When completion stepper is open, hide bottom nav to avoid duplicate chrome */
  body:has(.fo-m-stepper) .fo-m-bottom-nav {
    visibility: hidden;
    pointer-events: none;
  }

  /* â”€â”€ Bottom nav â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  .fo-m-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: end;
    gap: 0;
    min-height: calc(var(--fo-m-nav-h) + var(--fo-m-safe-bottom));
    padding: 4px 2px calc(4px + var(--fo-m-safe-bottom));
    background: var(--fo-surface-primary, var(--fo-card));
    border-top: 1px solid var(--fo-border-subtle, var(--fo-border));
    box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
  }

  .fo-m-bottom-nav--dense {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .fo-m-bottom-nav__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--fo-m-tap);
    min-width: 0;
    padding: 4px 2px;
    border: 0;
    background: transparent;
    color: #64748b !important;
    text-decoration: none;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.15;
    -webkit-tap-highlight-color: transparent;
  }

  .fo-m-bottom-nav__item i {
    font-size: 1.35rem;
    line-height: 1;
  }

  .fo-m-bottom-nav__item--active {
    color: var(--bs-primary, #0d6efd);
  }

  .fo-m-bottom-nav__item--active i {
    transform: translateY(-1px);
  }

  .fo-m-bottom-nav__fab-wrap {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin-top: -18px;
  }

  .fo-m-bottom-nav__fab {
    width: var(--fo-m-fab-size);
    height: var(--fo-m-fab-size);
    border-radius: 50%;
    border: 3px solid var(--fo-surface-primary, var(--fo-card));
    background: var(--fo-btn-primary-bg, var(--bs-primary, #0d6efd));
    color: var(--fo-btn-primary-text, #fff);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 16px rgba(13, 110, 253, 0.35);
    font-size: 1.6rem;
    line-height: 1;
    padding: 0;
  }

  .fo-m-bottom-nav__fab:focus-visible {
    outline: 3px solid rgba(13, 110, 253, 0.45);
    outline-offset: 2px;
  }

  /* Hide legacy workspace tab bar when new shell nav is present */
  .fieldops-shell.mobile-mode .mobile-nav-bar:not(.fo-m-bottom-nav) {
    display: none !important;
  }

  /* â”€â”€ Quick action sheet â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  .fo-m-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
    background: rgba(15, 23, 42, 0.45);
  }

  .fo-m-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1051;
    max-height: min(70dvh, 560px);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--fo-surface-primary, var(--fo-card));
    border-radius: 18px 18px 0 0;
    padding: 12px 16px calc(20px + var(--fo-m-safe-bottom));
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
    box-shadow: 0 -8px 32px rgba(15, 23, 42, 0.18);
  }

  .fo-m-sheet--scrollable {
    max-height: min(85dvh, 640px);
  }

  .fo-m-install {
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    padding-top: 12px;
  }

  .fo-m-install__ios {
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--fo-surface-muted, rgba(148, 163, 184, 0.08));
    color: #334155;
    font-size: 0.9rem;
  }

  /* Standalone / installed shell tweaks */
  html.fo-app-standalone .fo-m-bottom-nav {
    padding-bottom: calc(4px + env(safe-area-inset-bottom, 0px));
  }

  .fo-m-sheet__handle {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: #cbd5e1;
    margin: 4px auto 14px;
  }

  .fo-m-sheet__title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--fo-text-primary);
  }

  .fo-m-sheet__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .fo-m-sheet__action {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-height: 72px;
    padding: 14px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: var(--fo-m-radius-sm);
    background: var(--fo-surface-secondary, var(--fo-bg-alt)) !important;
    color: var(--fo-text-primary) !important;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.92rem;
  }

  .fo-m-sheet__title {
    color: var(--fo-text-primary) !important;
  }

  .fo-m-sheet__action i {
    font-size: 1.35rem;
    color: var(--bs-primary, #0d6efd);
  }

  /* â”€â”€ Shared mobile UI primitives â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  .fo-m-page {
    padding: var(--fo-m-page-pad);
    display: flex;
    flex-direction: column;
    gap: var(--fo-m-section-gap);
  }

  .fo-m-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
  }

  .fo-m-page-header h1 {
    font-size: var(--fo-m-title);
    font-weight: 800;
    margin: 0;
    color: var(--fo-text-primary);
    line-height: 1.25;
  }

  .fo-m-page-header__sub {
    margin: 4px 0 0;
    color: #64748b;
    font-size: 0.9rem;
  }

  /* Counter app.css forcing section backgrounds transparent â€” use FieldOps surfaces */
  .fo-m-card,
  .fo-m-entity-card,
  .fo-m-section,
  .fo-m-sheet,
  .fo-m-stepper,
  .fo-m-bottom-nav,
  section.fo-m-card,
  section.fo-m-section {
    background: var(--fo-surface-primary, var(--fo-card)) !important;
    background-color: var(--fo-surface-primary, var(--fo-card)) !important;
    color: var(--fo-text-primary) !important;
  }

  .fo-m-card {
    border: 1px solid var(--fo-border-subtle, var(--fo-border));
    border-radius: var(--fo-m-radius);
    box-shadow: var(--fo-m-shadow);
    padding: 14px 16px;
  }

  .fo-m-page-header h1,
  .fo-m-entity-card__title,
  .fo-m-wo-header .fo-m-entity-card__title {
    color: var(--fo-text-primary) !important;
  }

  .fo-m-page-header__sub,
  .fo-m-entity-card__meta,
  .fo-m-card__title {
    color: var(--fo-text-secondary) !important;
  }

  .fo-m-chip {
    background: var(--fo-surface-muted, rgba(148, 163, 184, 0.08)) !important;
    color: var(--fo-text-secondary) !important;
  }

  .fo-m-chip--active {
    background: var(--fo-btn-primary-bg, var(--bs-primary, #0d6efd)) !important;
    color: var(--fo-btn-primary-text, #fff) !important;
  }

  .fo-m-btn--primary {
    background: var(--fo-btn-primary-bg, var(--bs-primary, #0d6efd)) !important;
    color: var(--fo-btn-primary-text, #fff) !important;
  }

  .fo-m-btn--ghost {
    background: var(--fo-surface-muted, rgba(148, 163, 184, 0.08)) !important;
    color: var(--fo-text-primary) !important;
  }

  .fo-m-action-tile {
    background: var(--fo-surface-primary, var(--fo-card)) !important;
    color: var(--fo-text-primary) !important;
  }

  .fo-m-money-tile {
    background: var(--fo-surface-secondary, var(--fo-bg-alt)) !important;
  }

  .fo-m-money-tile__label {
    color: var(--fo-text-secondary) !important;
  }

  .fo-m-money-tile__value {
    color: var(--fo-text-primary) !important;
  }

  .fo-m-status {
    background: var(--fo-surface-muted, rgba(148, 163, 184, 0.12)) !important;
    color: var(--fo-text-secondary) !important;
  }

  .fo-m-stepper {
    background: var(--fo-surface-secondary, var(--fo-bg-alt)) !important;
  }

  .fo-m-stepper__header,
  .fo-m-stepper__footer {
    background: var(--fo-surface-primary, var(--fo-card)) !important;
  }

  .fo-m-stepper__titles h2 {
    color: var(--fo-text-primary) !important;
  }

  .fo-m-bottom-nav {
    background: var(--fo-surface-primary, var(--fo-card)) !important;
    color: var(--fo-text-secondary) !important;
  }

  .fo-m-bottom-nav__item {
    color: #64748b !important;
  }

  .fo-m-bottom-nav__item--active {
    color: var(--bs-primary, #0d6efd) !important;
  }

  .fo-m-section > summary {
    color: var(--fo-text-primary) !important;
  }

  .fo-m-card__title {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
    margin: 0 0 10px;
  }

  .fo-m-summary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .fo-m-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--fo-surface-muted, rgba(148, 163, 184, 0.08));
    color: #334155;
    font-size: 0.85rem;
    font-weight: 600;
  }

  .fo-m-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: var(--fo-m-btn-h);
    padding: 0 16px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    text-decoration: none;
    border: 0;
  }

  .fo-m-btn--primary {
    background: var(--bs-primary, #0d6efd);
    color: #fff;
  }

  .fo-m-btn--block {
    width: 100%;
  }

  .fo-m-btn--ghost {
    background: var(--fo-surface-muted, rgba(148, 163, 184, 0.08));
    color: var(--fo-text-primary);
  }

  .fo-m-action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .fo-m-action-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    min-height: 88px;
    padding: 14px;
    border-radius: var(--fo-m-radius-sm);
    background: var(--fo-surface-primary, var(--fo-card));
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: var(--fo-m-shadow);
    color: var(--fo-text-primary);
    text-decoration: none;
    font-weight: 700;
  }

  .fo-m-action-tile i {
    font-size: 1.4rem;
    color: var(--bs-primary, #0d6efd);
  }

  .fo-m-attention-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .fo-m-attention-list a,
  .fo-m-attention-list li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: var(--fo-m-tap);
    padding: 10px 12px;
    border-radius: 12px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
  }

  .fo-m-money-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .fo-m-money-tile {
    padding: 12px;
    border-radius: 12px;
    background: var(--fo-surface-secondary, var(--fo-bg-alt));
  }

  .fo-m-money-tile__label {
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 600;
    margin-bottom: 4px;
  }

  .fo-m-money-tile__value {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--fo-text-primary);
  }

  .fo-m-entity-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    border-radius: var(--fo-m-radius);
    background: var(--fo-surface-primary, var(--fo-card));
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: var(--fo-m-shadow);
    text-decoration: none;
    color: inherit;
  }

  .fo-m-entity-card__title {
    font-weight: 750;
    font-size: 1.02rem;
    color: var(--fo-text-primary);
  }

  .fo-m-entity-card__meta {
    color: #64748b;
    font-size: 0.9rem;
  }

  .fo-m-status {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    min-height: 28px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 700;
    background: var(--fo-surface-muted, rgba(148, 163, 184, 0.12));
    color: #334155;
  }

  .fo-m-empty {
    text-align: center;
    padding: 28px 16px;
    color: #64748b;
  }

  /* â”€â”€ Work-order field view â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  .fo-m-wo-primary-actions {
    grid-template-columns: 1fr 1fr;
  }

  .fo-m-section {
    background: var(--fo-surface-primary, var(--fo-card));
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: var(--fo-m-radius);
    box-shadow: var(--fo-m-shadow);
    overflow: hidden;
  }

  .fo-m-section > summary {
    list-style: none;
    cursor: pointer;
    min-height: var(--fo-m-tap);
    display: flex;
    align-items: center;
    padding: 12px 16px;
    font-weight: 700;
    color: var(--fo-text-primary);
  }

  .fo-m-section > summary::-webkit-details-marker {
    display: none;
  }

  .fo-m-section > summary::after {
    content: "";
    margin-left: auto;
    width: 0.5rem;
    height: 0.5rem;
    border-right: 2px solid #64748b;
    border-bottom: 2px solid #64748b;
    transform: rotate(45deg);
  }

  .fo-m-section[open] > summary::after {
    transform: rotate(-135deg);
  }

  .fo-m-section__body {
    padding: 0 16px 16px;
  }

  /* â”€â”€ Completion stepper â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  .fo-m-stepper-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1080;
    background: rgba(15, 23, 42, 0.5);
  }

  .fo-m-stepper {
    position: fixed;
    inset: 0;
    z-index: 1081;
    display: flex;
    flex-direction: column;
    background: var(--fo-surface-secondary, var(--fo-bg-alt));
    height: 100dvh;
    max-height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .fo-m-stepper__header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    background: var(--fo-surface-primary, var(--fo-card));
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  }

  .fo-m-stepper__icon-btn {
    min-width: var(--fo-m-tap);
    min-height: var(--fo-m-tap);
    padding: 0;
  }

  .fo-m-stepper__titles h2 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--fo-text-primary);
  }

  .fo-m-stepper__step-label {
    margin: 2px 0 0;
    color: #64748b;
    font-size: 0.85rem;
  }

  .fo-m-stepper__progress {
    height: 4px;
    background: var(--fo-surface-muted, rgba(148, 163, 184, 0.12));
  }

  .fo-m-stepper__progress-bar {
    height: 100%;
    background: var(--bs-primary, #0d6efd);
    transition: width 0.2s ease;
  }

  .fo-m-stepper__body {
    flex: 1;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }

  .fo-m-stepper__footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--fo-surface-primary, var(--fo-card));
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    position: sticky;
    bottom: 0;
    z-index: 2;
    flex-shrink: 0;
  }

  .fo-m-labor-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .fo-m-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: var(--fo-m-tap);
    font-weight: 600;
  }

  .fo-m-input {
    min-height: var(--fo-m-input-h);
    font-size: 1rem;
  }

  textarea.fo-m-input {
    min-height: 120px;
  }

  .fo-m-review-list li {
    padding: 8px 0;
    border-bottom: 1px solid #e2e8f0;
  }

  /* â”€â”€ Agenda schedule â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */
  .fo-m-agenda-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }

  .fo-m-agenda-date {
    flex: 1 1 140px;
    min-height: var(--fo-m-input-h);
  }

  .fo-m-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .fo-m-chip--active {
    background: var(--bs-primary, #0d6efd);
    color: #fff;
  }

  button.fo-m-chip {
    border: 0;
    min-height: var(--fo-m-tap);
    padding: 0 14px;
  }

  .fo-m-agenda-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .fo-m-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
  }

  .fo-m-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  /* Photo capture affordances */
  .fo-m-photo-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
  }

  .fo-m-photo-actions .fo-m-btn {
    font-size: 0.95rem;
  }
}

/* Hide new shell on desktop */
@media (min-width: 769px) {
  .fo-m-bottom-nav,
  .fo-m-sheet-backdrop,
  .fo-m-sheet,
  .fo-m-home,
  .mobile-fab,
  .fo-m-page-fab {
    display: none !important;
  }
}
