/* ============================================================
   Crew Dashboard — mobile-first PWA for farm crew
   Color-coded task cards, one-tap actions
   ============================================================ */

:root {
  --c-plant:   #2d8a5e;
  --c-water:    #2e6fa8;
  --c-harvest:  #c8933f;
  --c-urgent:   #c83a3a;
  --c-done:     #4a4a4a;
  --c-flag:     #c83a3a;
  --gold:       #c8933f;
  --gold-light: #e8b96a;
  --dark:       #0e1a0f;
  --dark-2:     #162016;
  --dark-3:     #1e2e1c;
  --cream:      #f5f0e8;
  --muted:      #8a9e89;
  --border:     rgba(200,147,63,0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--dark);
  color: var(--cream);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

h1, h2, h3 { font-family: 'Playfair Display', serif; font-weight: 600; }

/* ---- Mobile shell ---- */
.crew-shell {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Top bar */
.crew-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--dark-2);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.crew-brand {
  font-family: 'Playfair Display', serif;
  font-size: 1rem;
  color: var(--gold);
  font-weight: 600;
}
.crew-date {
  font-size: 0.82rem;
  color: var(--muted);
}
.crew-topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--dark-3);
  border: 1px solid var(--border);
  color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}
.icon-btn:active { transform: scale(0.95); }
.icon-btn:hover { border-color: var(--gold); color: var(--gold); }
.icon-btn.notif-badge::after {
  content: '';
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--c-urgent);
  border-radius: 50%;
}

/* Pull to refresh indicator */
.refresh-indicator {
  text-align: center;
  padding: 10px;
  font-size: 0.8rem;
  color: var(--gold);
  display: none;
}
.refresh-indicator.active { display: block; }

/* ---- Task list ---- */
.crew-content { flex: 1; padding: 16px; padding-bottom: 100px; }

.section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 10px;
  padding-left: 4px;
}

/* Task cards */
.task-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--dark-3);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  margin-bottom: 10px;
  transition: all 0.2s;
}
.task-card:active { transform: scale(0.99); }

/* Color coding by task type */
.task-card[data-type="seed"]    { border-left: 4px solid var(--c-plant); }
.task-card[data-type="water"]    { border-left: 4px solid var(--c-water); }
.task-card[data-type="harvest"]  { border-left: 4px solid var(--c-harvest); }
.task-card[data-type="check"],
.task-card[data-type="nurture"] { border-left: 4px solid var(--c-plant); }
.task-card[data-type="clean"],
.task-card[data-type="rotate"]   { border-left: 4px solid var(--muted); }
.task-card[data-type="mist"]     { border-left: 4px solid var(--c-water); }

/* Priority */
.task-card[data-priority="urgent"] { border-color: rgba(200,58,58,0.4); background: rgba(200,58,58,0.06); }
.task-card[data-priority="high"]   { border-color: rgba(200,147,63,0.3); }

.task-card.completed { opacity: 0.5; border-left-color: var(--c-done); }

/* Task icon */
.task-icon-wrap {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.task-card[data-type="seed"]   .task-icon-wrap { background: rgba(45,138,94,0.3); }
.task-card[data-type="water"]  .task-icon-wrap { background: rgba(46,111,168,0.3); }
.task-card[data-type="harvest"].task-icon-wrap { background: rgba(200,147,63,0.3); }
.task-card[data-type="check"]  .task-icon-wrap,
.task-card[data-type="nurture"].task-icon-wrap { background: rgba(45,138,94,0.2); }
.task-card[data-type="clean"]  .task-icon-wrap { background: rgba(138,158,137,0.2); }
.task-card[data-type="mist"]   .task-icon-wrap { background: rgba(46,111,168,0.2); }
.task-card.completed .task-icon-wrap { background: rgba(74,74,74,0.3); }

/* Task info */
.task-info { flex: 1; min-width: 0; }
.task-desc {
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 4px;
}
.task-card.completed .task-desc { text-decoration: line-through; color: var(--muted); }
.task-meta {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.zone-badge {
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(200,147,63,0.2);
  color: var(--gold-light);
  font-weight: 600;
}

/* Priority badge */
.priority-badge {
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.priority-badge.urgent  { background: rgba(200,58,58,0.35); color: #f08080; }
.priority-badge.high    { background: rgba(200,147,63,0.3); color: var(--gold-light); }
.priority-badge.normal  { background: rgba(138,158,137,0.15); color: var(--muted); }
.priority-badge.low     { opacity: 0.6; }

/* Camera button on card */
.task-camera-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: rgba(200,147,63,0.15);
  border: 1px solid rgba(200,147,63,0.3);
  color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: all 0.2s;
}
.task-camera-btn:hover { background: rgba(200,147,63,0.25); }

/* ---- Bottom action bar ---- */
.crew-action-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--dark-2);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  z-index: 20;
}

.action-btn {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.action-btn:active { transform: scale(0.97); }

.btn-done-main {
  background: var(--c-plant);
  color: var(--cream);
}
.btn-done-main:hover { background: #35a06f; }
.btn-flag-main {
  background: var(--dark-3);
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-flag-main:hover { border-color: var(--c-urgent); color: #f08080; }

/* ---- Empty state ---- */
.crew-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--muted);
}
.crew-empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: 0.5; }
.crew-empty h3 { font-size: 1.1rem; color: var(--cream); margin-bottom: 8px; }
.crew-empty p { font-size: 0.88rem; }

/* ---- Flag modal ---- */
.flag-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 30;
  align-items: flex-end;
  justify-content: center;
}
.flag-modal.open { display: flex; }
.flag-modal-inner {
  background: var(--dark-2);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 24px;
  width: 100%;
  max-height: 85dvh;
  overflow-y: auto;
}
.flag-modal h3 {
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 18px;
  text-align: center;
}
.flag-category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.flag-cat-btn {
  padding: 14px 10px;
  border-radius: 10px;
  background: var(--dark-3);
  border: 1.5px solid var(--border);
  color: var(--cream);
  font-size: 0.85rem;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  text-align: center;
  transition: all 0.2s;
}
.flag-cat-btn:hover, .flag-cat-btn.selected {
  border-color: var(--gold);
  background: rgba(200,147,63,0.1);
  color: var(--gold-light);
}
.flag-desc-input {
  width: 100%;
  padding: 12px 14px;
  background: var(--dark-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--cream);
  font-size: 0.9rem;
  font-family: 'DM Sans', sans-serif;
  margin-bottom: 14px;
  resize: vertical;
  min-height: 80px;
}
.flag-desc-input:focus { outline: none; border-color: var(--gold); }
.flag-modal-actions { display: flex; gap: 10px; }
.flag-submit {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  background: var(--c-urgent);
  color: var(--cream);
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}
.flag-cancel {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  background: var(--dark-3);
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: 0.9rem;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}

/* ---- Camera sheet ---- */
.camera-sheet {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  z-index: 30;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.camera-sheet.open { display: flex; }
.camera-preview {
  width: 100%;
  max-width: 480px;
  background: var(--dark-3);
  border-radius: 12px;
  overflow: hidden;
  margin: 16px;
}
.camera-preview img {
  width: 100%;
  display: block;
}
.check-type-label {
  color: var(--gold);
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.camera-actions { display: flex; gap: 12px; padding: 16px; }
.cam-btn {
  flex: 1;
  padding: 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
}
.cam-submit { background: var(--gold); color: var(--dark); }
.cam-cancel { background: var(--dark-3); color: var(--muted); border: 1px solid var(--border); }

/* ---- Bootstrap form (first login) ---- */
.bootstrap-screen {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 24px;
  justify-content: center;
}
.bootstrap-card {
  background: var(--dark-3);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px 24px;
}
.bootstrap-logo {
  text-align: center;
  margin-bottom: 24px;
}
.bootstrap-logo .brand {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: var(--gold);
}
.bootstrap-logo .sub { font-size: 0.8rem; color: var(--muted); margin-top: 4px; }
.form-field { margin-bottom: 16px; }
.form-label { font-size: 0.75rem; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.06em; display: block; }
.form-input, .form-select {
  width: 100%;
  padding: 12px 14px;
  background: var(--dark-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--cream);
  font-size: 0.95rem;
  font-family: 'DM Sans', sans-serif;
}
.form-input:focus, .form-select:focus { outline: none; border-color: var(--gold); }
.form-select { appearance: none; }
.bootstrap-submit {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--gold), #9a6e2e);
  color: var(--dark);
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  margin-top: 8px;
}
.bootstrap-submit:hover { background: linear-gradient(135deg, var(--gold-light), var(--gold)); }

/* ---- Notifications panel ---- */
.notif-panel {
  display: none;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 300px;
  max-width: 85vw;
  background: var(--dark-2);
  border-left: 1px solid var(--border);
  z-index: 25;
  flex-direction: column;
  overflow: hidden;
}
.notif-panel.open { display: flex; }
.notif-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.notif-header h3 { font-size: 1rem; color: var(--gold); }
.notif-close {
  background: none; border: none; color: var(--muted); font-size: 1.2rem; cursor: pointer;
}
.notif-list { flex: 1; overflow-y: auto; padding: 12px 16px; }
.notif-item {
  padding: 12px 14px;
  background: var(--dark-3);
  border-radius: 10px;
  border-left: 3px solid var(--gold);
  margin-bottom: 8px;
}
.notif-item.urgent { border-left-color: var(--c-urgent); }
.notif-item-title { font-size: 0.88rem; font-weight: 600; margin-bottom: 4px; }
.notif-item-body { font-size: 0.78rem; color: var(--muted); }
.notif-item-time { font-size: 0.7rem; color: var(--muted); margin-top: 4px; }

/* ---- Status badge ---- */
.status-badge {
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 8px;
  font-weight: 600;
  text-transform: uppercase;
}
.status-pending    { background: rgba(200,147,63,0.25); color: var(--gold-light); }
.status-completed  { background: rgba(45,138,94,0.3); color: #6bc98a; }
.status-in_progress{ background: rgba(46,111,168,0.3); color: #7baee8; }
.status-open       { background: rgba(200,58,58,0.25); color: #f08080; }

/* ---- Responsive ---- */
@media (min-width: 768px) {
  .crew-shell { max-width: 600px; margin: 0 auto; }
  .flag-modal { align-items: center; }
  .flag-modal-inner { max-width: 480px; border-radius: 18px; }
}

/* ---- Loading spinner ---- */
.spinner {
  width: 24px; height: 24px;
  border: 2.5px solid rgba(200,147,63,0.2);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: fixed; inset: 0;
  background: rgba(14,26,15,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  flex-direction: column;
  gap: 12px;
}
.loading-overlay span { color: var(--gold); font-size: 0.9rem; }

/* ---- Staple crop badges ---- */
.staple-badge {
  display: inline-block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(46,111,168,0.35);
  color: #7fb8e0;
  margin-right: 6px;
  vertical-align: middle;
}
.staple-card { border-left-color: var(--c-water) !important; }
.meta-staple {
  font-size: 0.68rem;
  color: #7fb8e0;
  font-style: italic;
}