/* ============================================================
   Anchor Point Crew - Staff PWA stylesheet
   Phone-first, big tap targets, high contrast.
   Reuses brand palette but renders as a tool, not a brochure.
   ============================================================ */

:root {
  --navy: #1B2D5C;
  --navy-soft: #2a3d70;
  --navy-deep: #131f42;
  --cream: #FBF7EC;
  --cream-card: #ffffff;
  --brass: #B08B4F;
  --brass-soft: #c9a674;
  --ink: #1a1a1a;
  --ink-soft: #4a4a4a;
  --muted: #7a7a7a;
  --rule: #e3ddc9;
  --rule-strong: #cabfa3;
  --good: #2d8a4b;
  --warn: #c47b2a;
  --bad: #b04a3a;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;

  --radius: 12px;
  --radius-sm: 8px;
  --tap-min: 48px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  background: var(--cream);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.5;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: 76px;  /* room for bottom nav */
}

a {
  color: var(--brass);
  text-decoration: none;
}
a:hover, a:active { color: var(--navy); }

img { max-width: 100%; height: auto; display: block; }

/* ----- Top bar ----- */
.topbar {
  background: var(--navy);
  color: var(--cream);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.topbar .brand {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.topbar .brand .sub {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--brass-soft);
}
.topbar .user-info {
  font-size: 0.85rem;
  color: var(--cream);
  opacity: 0.85;
}

/* ----- Main content ----- */
main.staff-main {
  flex: 1;
  padding: 1rem 1rem 1.5rem;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}

@media (min-width: 720px) {
  main.staff-main {
    padding: 1.5rem 2rem;
  }
}

/* ----- Headings ----- */
.staff-h1 {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 500;
  margin: 0 0 0.25rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.staff-h2 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  margin: 1.75rem 0 0.75rem;
  color: var(--ink);
}
.staff-sub {
  font-size: 0.9rem;
  color: var(--muted);
  margin: 0 0 1.25rem;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 0.5rem;
}
.eyebrow::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--brass);
}

/* ----- Cards ----- */
.card {
  background: var(--cream-card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.85rem;
}

.card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: transform 0.1s ease;
}
.card-link:active {
  transform: scale(0.99);
  background: var(--cream);
}

/* ----- Job card on Today / Jobs list ----- */
.job-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem 1rem;
  align-items: start;
}
.job-card .time {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 500;
  color: var(--navy);
  line-height: 1.1;
}
.job-card .customer {
  font-weight: 600;
  color: var(--ink);
  margin-top: 0.2rem;
}
.job-card .address {
  font-size: 0.875rem;
  color: var(--ink-soft);
  margin-top: 0.1rem;
}
.job-card .meta {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.35rem;
}
.job-card .badge-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}

/* ----- Status badges ----- */
.badge {
  display: inline-block;
  padding: 0.22rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  line-height: 1.2;
  white-space: nowrap;
}
.badge-scheduled { background: #e0eaf8; color: var(--navy); }
.badge-in_progress { background: var(--brass); color: white; }
.badge-pending_review { background: #fff0c4; color: #6d5414; }
.badge-approved { background: #d5ead7; color: var(--good); }
.badge-rework_requested { background: #fadcd0; color: var(--bad); }
.badge-canceled { background: #ececec; color: #5a5a5a; }
.badge-invoiced { background: #ddd0f0; color: #4a2a82; }
.badge-paid { background: #c9e5d0; color: var(--good); }

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--tap-min);
  padding: 0.85rem 1.3rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}
.btn-primary {
  background: var(--navy);
  color: var(--cream);
  border-color: var(--navy);
}
.btn-primary:hover, .btn-primary:active {
  background: var(--navy-deep);
}
.btn-brass {
  background: var(--brass);
  color: white;
  border-color: var(--brass);
}
.btn-brass:hover, .btn-brass:active { background: #97743b; }
.btn-secondary {
  background: transparent;
  color: var(--navy);
  border-color: var(--navy);
}
.btn-secondary:hover { background: var(--cream-card); }
.btn-danger {
  background: var(--bad);
  color: white;
  border-color: var(--bad);
}
.btn-block { width: 100%; }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-lg {
  font-size: 1.1rem;
  min-height: 56px;
  padding: 1rem 1.5rem;
}

/* ----- Forms ----- */
.staff-input,
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"],
input[type="date"], input[type="time"], textarea, select {
  width: 100%;
  min-height: var(--tap-min);
  padding: 0.75rem 0.95rem;
  font-family: inherit;
  font-size: 1rem;
  background: white;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
.staff-input:focus,
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(176, 139, 79, 0.18);
}

.field-group { margin-bottom: 1.25rem; }
.field-group label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.5rem;
  color: var(--ink);
}
.field-error {
  color: var(--bad);
  font-size: 0.85rem;
  margin-top: 0.4rem;
}
.field-help {
  color: var(--muted);
  font-size: 0.825rem;
  margin-top: 0.35rem;
}

/* ----- Login ----- */
.login-screen {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--navy);
  color: var(--cream);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2rem 1.5rem;
}
.login-card {
  background: white;
  color: var(--ink);
  padding: 2rem 1.5rem;
  border-radius: var(--radius);
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}
.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-logo img {
  width: 64px;
  height: 64px;
  margin: 0 auto 0.75rem;
}
.login-logo .name {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: white;
}
.login-logo .sub {
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--brass-soft);
}

/* ----- Bottom nav ----- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--rule);
  display: flex;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 10px 4px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  min-height: 64px;
}
.bottom-nav a.active {
  color: var(--navy);
}
.bottom-nav a .icon {
  font-size: 1.4rem;
  line-height: 1;
}
.bottom-nav a.active .icon {
  filter: none;
}

/* ----- Photos ----- */
.photos-section {
  margin-bottom: 1.5rem;
  padding: 0.85rem 0.9rem 0.9rem;
  border-radius: var(--radius-sm);
  border-left: 4px solid var(--rule-strong);
  background: rgba(255, 255, 255, 0.5);
}
.photos-section.batch-before {
  border-left-color: var(--brass);
  background: #fbf3e3;
}
.photos-section.batch-after {
  border-left-color: var(--good, #2d6a4f);
  background: #e9f3ec;
}
.photos-section.batch-issue {
  border-left-color: var(--warn, #c9881f);
  background: #fdf4e0;
}
.photos-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.6rem;
}
.photos-header h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--navy);
}
.photos-header .batch-count {
  color: var(--muted);
  font-size: 0.825rem;
  font-weight: 500;
}
.photos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 0.5rem;
}
.photo-tile {
  background: var(--cream-card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}
.photo-tile img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}
.photo-tile .caption {
  padding: 0.4rem 0.55rem;
  font-size: 0.78rem;
  color: var(--ink-soft);
  border-top: 1px solid var(--rule);
}
.photo-tile .tile-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  font-size: 14px;
  line-height: 22px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0;
}
.photo-tile:hover .tile-remove,
.photo-tile:focus-within .tile-remove {
  opacity: 1;
}

/* Live upload placeholder tile (shown while a photo is uploading) */
.photo-tile.uploading {
  background: var(--cream);
  position: relative;
}
.photo-tile.uploading::before {
  content: "";
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
}
.photo-tile.uploading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  border: 3px solid var(--rule-strong);
  border-top-color: var(--navy);
  border-radius: 50%;
  animation: tile-spin 0.8s linear infinite;
}
.photo-tile.uploading .progress-text {
  position: absolute;
  bottom: 6px;
  left: 6px;
  right: 6px;
  font-size: 0.72rem;
  text-align: center;
  color: var(--muted);
}
@keyframes tile-spin {
  to { transform: rotate(360deg); }
}

.photo-upload-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
  background: var(--cream-card);
  border: 2px dashed var(--rule-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--navy);
  font-weight: 600;
  text-align: center;
  padding: 0.5rem;
  transition: border-color 0.15s, background 0.15s;
}
.photo-upload-btn:hover {
  background: white;
  border-color: var(--brass);
}
.photo-upload-btn .camera-icon {
  font-size: 1.8rem;
  margin-bottom: 0.3rem;
}
.photo-upload-btn .upload-hint {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 0.25rem;
  font-weight: 400;
}
.photo-upload-btn input[type="file"] {
  display: none;
}

.batch-empty-hint {
  font-size: 0.85rem;
  color: var(--muted);
  font-style: italic;
  margin: 0.25rem 0 0.5rem;
}

/* ----- Action panel (clock in/out, mark complete) ----- */
.action-panel {
  background: var(--cream-card);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1.25rem;
}
.action-panel h3 {
  font-family: var(--font-display);
  font-size: 1.05rem;
  margin: 0 0 0.75rem;
  color: var(--ink);
}
.action-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.action-status .label { color: var(--muted); }
.action-status .value { font-weight: 600; color: var(--ink); }

.blockers {
  background: #fdeee5;
  border-left: 3px solid var(--warn);
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.85rem;
}
.blockers ul {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.875rem;
  color: var(--ink-soft);
}

/* ----- Messages (Django) ----- */
.messages {
  margin: 0 0 1rem;
  padding: 0;
  list-style: none;
}
.messages li {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  border-left: 3px solid var(--brass);
  background: var(--cream-card);
}
.messages li.error { border-left-color: var(--bad); }
.messages li.success { border-left-color: var(--good); }

/* ----- Empty states ----- */
.empty {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--muted);
}
.empty h3 {
  font-family: var(--font-display);
  color: var(--ink);
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 500;
}

/* ----- Install banner ----- */
.install-banner {
  background: var(--brass);
  color: white;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem;
  font-size: 0.875rem;
}
.install-banner button {
  background: white;
  color: var(--brass);
  border: none;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  cursor: pointer;
}
.install-banner button.dismiss {
  background: transparent;
  color: white;
  padding: 0.5rem;
}

/* ----- Detail layout ----- */
.detail-section {
  margin-bottom: 1.25rem;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--rule);
}
.detail-row:last-child { border-bottom: none; }
.detail-row .label {
  color: var(--muted);
  font-size: 0.825rem;
}
.detail-row .value {
  font-weight: 600;
  color: var(--ink);
  text-align: right;
  max-width: 60%;
}


/* ----- Geofence status indicator ----- */
.geofence-status {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.85rem;
  font-size: 0.9rem;
}
.geofence-status .geofence-icon {
  font-size: 1.15rem;
  flex-shrink: 0;
}
.geofence-status .geofence-text {
  flex: 1;
  font-weight: 500;
}
.geofence-status .geofence-distance {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1rem;
  margin-left: 0.5rem;
}

.geofence-checking {
  background: var(--cream);
  border: 1px solid var(--rule);
  color: var(--muted);
}
.geofence-inside {
  background: #d5ead7;
  color: var(--good);
  border: 1px solid #b4d6b7;
}
.geofence-outside {
  background: #fadcd0;
  color: var(--bad);
  border: 1px solid #f0bba8;
}
.geofence-warning {
  background: #fff0c4;
  color: #6d5414;
  border: 1px solid #f0d878;
}
.geofence-error {
  background: #fadcd0;
  color: var(--bad);
  border: 1px solid #f0bba8;
}
