/* FWS Field — mobile-first worker app styles */

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --line: #e2e8f0;
  --brand: #0f172a;
  --brand-ink: #38bdf8;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

#app { min-height: 100vh; display: flex; flex-direction: column; }

/* --- Top bar -------------------------------------------------------------- */

.topbar {
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand { font-weight: 700; letter-spacing: 0.02em; }
.brand span { color: var(--brand-ink); }

.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }

/* --- Layout --------------------------------------------------------------- */

main { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 0 12px 32px; }

.view[hidden], .pane[hidden] { display: none !important; }

/* --- Login ----------------------------------------------------------------- */

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px 20px;
  margin-top: 48px;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.login-card h1 { margin: 0 0 4px; font-size: 1.4rem; }
.login-card p.muted { margin-top: 0; }

form label { display: block; margin: 14px 0 4px; font-size: 0.9rem; color: var(--ink-soft); }

input, textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--ink);
}

textarea { min-height: 120px; resize: vertical; }

input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* --- Buttons ---------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px; /* comfortable touch target */
}

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:disabled { background: #94a3b8; cursor: not-allowed; }
.btn-secondary { background: #e2e8f0; color: var(--ink); }
.btn-danger { background: #fee2e2; color: var(--bad); }
.btn-ghost { background: transparent; color: inherit; border-color: transparent; }
.btn-ghost:hover { background: rgba(148, 163, 184, 0.18); }
.btn-sm { padding: 6px 10px; min-height: 36px; font-size: 0.9rem; }
.btn-block { width: 100%; margin-top: 18px; }

/* --- Tabs ------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: 8px;
  margin: 12px 0;
  position: sticky;
  top: 56px;
  background: var(--bg);
  padding: 8px 0;
  z-index: 5;
}

.tab {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}

.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* --- Calendar ---------------------------------------------------------------- */

.cal-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; }

.cal-title { font-weight: 700; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}

.cal-dow {
  text-align: center;
  font-size: 0.72rem;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 4px 0;
}

.cal-cell {
  position: relative;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
}

.cal-cell:disabled { background: transparent; border-color: transparent; cursor: default; color: var(--ink-soft); }

.cal-cell .dots { position: absolute; bottom: 4px; left: 0; right: 0; display: flex; justify-content: center; gap: 3px; }

.cal-cell .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

.cal-cell.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }

.cal-cell.today { font-weight: 700; }

.cal-day { font-weight: 700; margin: 12px 0 8px; }

/* --- Appointment cards ------------------------------------------------------- */

.appt-list { display: flex; flex-direction: column; gap: 10px; }

.appt-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font: inherit;
}

.appt-card:active { background: #f8fafc; }

.appt-card .row1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }

.appt-card .client { font-weight: 700; }

.appt-card .time { color: var(--ink-soft); font-size: 0.9rem; white-space: nowrap; }

.appt-card .addr { color: var(--ink-soft); font-size: 0.9rem; margin-top: 2px; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--ink-soft);
}

.badge.accepted { background: #dcfce7; color: var(--ok); border-color: #bbf7d0; }
.badge.declined { background: #fee2e2; color: var(--bad); border-color: #fecaca; }
.badge.in-progress { background: #dbeafe; color: var(--accent); border-color: #bfdbfe; }
.badge.completed { background: #e2e8f0; color: var(--ink-soft); }
.badge.crew { background: #fef3c7; color: var(--warn); border-color: #fde68a; }

/* --- Detail panel -------------------------------------------------------------- */

.detail-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin: 10px 0; }

.detail-section h3 { margin: 0 0 8px; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }

.detail-title { margin: 8px 0 2px; font-size: 1.25rem; }

.detail-sub { color: var(--ink-soft); margin: 0 0 4px; }

.task-list { list-style: none; margin: 0; padding: 0; }

.task-list li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; gap: 8px; align-items: flex-start; }

.task-list li:last-child { border-bottom: none; }

.note-pets { color: var(--warn); font-weight: 600; }

.note-alarm { font-family: ui-monospace, monospace; font-weight: 700; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

.actions .btn { flex: 1 1 auto; }

.report-item { border-top: 1px solid var(--line); padding: 8px 0; }

.report-item:first-child { border-top: none; }

.report-meta { font-size: 0.78rem; color: var(--ink-soft); }

/* --- Misc ------------------------------------------------------------------------ */

.muted { color: var(--ink-soft); }
.small { font-size: 0.82rem; }
.error { color: var(--bad); font-weight: 600; }

.embed-notice {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 0.85rem;
}

/* FR-8: the app must stay operable inside a frame smaller than a browser
   window. The login card and the main panes already flex; these media queries
   tighten the fixed paddings and the calendar's aspect-ratio cells so a
   ~360px-wide, ~480px-tall frame renders without horizontal scroll. */
@media (max-width: 480px) {
  .login-card { margin-top: 16px; padding: 18px 14px; }
  .login-card h1 { font-size: 1.2rem; }
  main { padding: 0 8px 16px; }
  .cal-cell { font-size: 0.78rem; }
  .appt-card { padding: 10px 12px; }
  .appt-card .time { font-size: 0.82rem; }
  .detail-title { font-size: 1.1rem; }
  .actions .btn { min-height: 40px; }
}

@media (max-height: 560px) {
  .login-card { margin-top: 12px; }
  .cal-cell { aspect-ratio: auto; height: 34px; }
  .cal-day { margin: 8px 0 6px; }
}
.empty { text-align: center; color: var(--ink-soft); padding: 32px 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  z-index: 50;
  max-width: 90vw;
}

.toast.error { background: var(--bad); }

code { background: #e2e8f0; padding: 1px 5px; border-radius: 4px; }