/* ═══════════════════════════════════════════
   Pest Hanter Dashboard v2 — Design System
   Mobile-first · Forest Green · Inter
   ═══════════════════════════════════════════ */

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Brand */
  --primary: #0D5C4D;
  --primary-light: #14876B;
  --primary-dark: #094438;
  --secondary: #1A3A4A;
  --accent: #F59E0B;
  --accent-hover: #D97706;
  
  /* Status */
  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;
  --info: #3B82F6;
  
  /* Neutrals */
  --bg: #F1F5F4;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --text: #1E293B;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  
  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  
  /* Transition */
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 100px; /* space for submit button */
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.header {
  background: linear-gradient(135deg, var(--secondary) 0%, var(--primary-dark) 50%, var(--primary) 100%);
  padding: var(--space-lg) var(--space-md);
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
}

.header-logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: white;
  object-fit: contain;
  padding: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.header-text h1 {
  color: white;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.header-text p {
  color: rgba(255,255,255,0.75);
  font-size: 0.8rem;
  font-weight: 400;
}

/* ── Main ── */
.main {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-md);
  padding-bottom: 120px;
}

/* ── Card ── */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-md);
  overflow: hidden;
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-md) 0;
}

.card-header h2 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.card-icon {
  font-size: 1.1rem;
}

.card-body {
  padding: var(--space-md);
}

/* ── Info Grid (Report Info) ── */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.info-item label {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 2px;
}

.info-value {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.info-value.mono {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.85rem;
  color: var(--primary);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  background: rgba(13, 92, 77, 0.08);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: var(--space-md);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary-light);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Form Fields ── */
.field {
  margin-bottom: var(--space-md);
}

.field:last-child {
  margin-bottom: 0;
}

.field > label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.required {
  color: var(--danger);
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--card);
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(20, 135, 107, 0.15);
}

input[type="text"]::placeholder,
input[type="email"]::placeholder,
textarea::placeholder {
  color: var(--text-light);
}

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

/* ── Select / Dropdown ── */
select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--card);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748B'%3E%3Cpath d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(20, 135, 107, 0.15);
}

.field.error select {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

/* ── Technician Manage Buttons ── */
.tech-manage {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.btn-tech-manage {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-tech-manage:hover {
  background: rgba(13, 92, 77, 0.06);
  border-color: var(--primary-light);
  color: var(--primary);
}

.btn-tech-manage.danger:hover {
  background: rgba(239, 68, 68, 0.06);
  border-color: var(--danger);
  color: var(--danger);
}

/* ── Pill Selector ── */
.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  background: var(--card);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
}

.pill:active {
  transform: scale(0.96);
}

.pill.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 2px 6px rgba(13, 92, 77, 0.25);
}

.pill .pill-delete {
  display: none;
  width: 16px;
  height: 16px;
  line-height: 14px;
  text-align: center;
  font-size: 0.7rem;
  background: rgba(255,255,255,0.3);
  border-radius: 50%;
  margin-left: 2px;
  color: inherit;
}

.pill.custom .pill-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pill.custom.selected .pill-delete {
  background: rgba(255,255,255,0.3);
}

.btn-add-item {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  margin-top: var(--space-sm);
  border: 1.5px dashed var(--primary-light);
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--primary);
  background: transparent;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-add-item:hover {
  background: rgba(13, 92, 77, 0.06);
}

/* ── Photo Controls ── */
.photo-controls {
  display: flex;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-sm);
}

.btn-photo {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-photo:hover {
  background: var(--primary-light);
}

.btn-photo:active {
  transform: scale(0.97);
}

.btn-no-evidence {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-no-evidence.active {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}

.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.photo-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  animation: fadeScale 300ms ease-out;
}

@keyframes fadeScale {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb .remove-photo {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 0.65rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.photo-count {
  display: block;
  font-size: 0.72rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* ── AI Polish Button ── */
.btn-ai-polish {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  margin-top: var(--space-sm);
  background: linear-gradient(135deg, #7C3AED, #6D28D9);
  color: white;
  border: none;
  border-radius: var(--radius-pill);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
}

.btn-ai-polish:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.btn-ai-polish:active {
  transform: scale(0.97);
}

.btn-ai-polish.loading {
  opacity: 0.7;
  pointer-events: none;
}

.btn-ai-polish.loading::after {
  content: '';
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  margin-left: 4px;
}

.ai-icon {
  font-size: 0.9rem;
}

/* ── Signature ── */
.signature-wrapper {
  position: relative;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #FAFAFA;
  touch-action: none;
}

.signature-wrapper canvas {
  display: block;
  width: 100%;
  height: 180px;
  cursor: crosshair;
}

.btn-clear-sig {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-clear-sig:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* ── Submit ── */
.submit-section {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--space-md);
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  z-index: 90;
}

.btn-submit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 4px 16px rgba(13, 92, 77, 0.35);
}

.btn-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(13, 92, 77, 0.45);
}

.btn-submit:active {
  transform: scale(0.98);
}

.btn-submit:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--space-md);
  animation: fadeIn 200ms ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: slideUp 300ms ease-out;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--space-md);
}

.modal-card .field {
  text-align: left;
}

.modal-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-md);
  font-size: 1.8rem;
  font-weight: 700;
}

.modal-icon.success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
}

.modal-report-number {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 600;
  margin: var(--space-sm) 0 var(--space-md);
}

.modal-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.btn-primary, .btn-secondary {
  flex: 1;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-light);
}

.btn-secondary {
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

/* ── Loading Overlay ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 300;
}

.loading-overlay.active {
  display: flex;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  margin-top: var(--space-md);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ── Validation errors ── */
.field.error input,
.field.error textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.field .error-msg {
  display: none;
  font-size: 0.72rem;
  color: var(--danger);
  margin-top: 4px;
  font-weight: 500;
}

.field.error .error-msg {
  display: block;
}

.pill-group.error {
  outline: 2px solid var(--danger);
  outline-offset: 4px;
  border-radius: var(--radius-sm);
}

/* ── Responsive ── */
@media (min-width: 768px) {
  .header-inner {
    flex-direction: row;
    gap: var(--space-md);
  }
  
  .header-text {
    text-align: left;
  }
  
  .main {
    padding: var(--space-lg);
  }
}

@media (min-width: 1024px) {
  .main {
    max-width: 680px;
  }
}

/* ── Toast ── */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 10px 20px;
  background: var(--text);
  color: white;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 500;
  z-index: 250;
  opacity: 0;
  transition: all 300ms ease;
  pointer-events: none;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

.toast.success {
  background: var(--success);
}
