/* ============================================================
   FarmerConnect - Main Stylesheet
   High-contrast, large tap targets, farmer-friendly UI
   WCAG AA compliant, optimized for low-end Android
   ============================================================ */

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

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans Devanagari', 'Noto Sans', sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ---------- High Contrast Mode ---------- */
@media (prefers-contrast: high) {
  body { background: #fff !important; color: #000 !important; }
  .card { border: 2px solid #000 !important; }
}

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- Large Tap Targets (48px minimum) ---------- */
button, a, [role="button"], input, select, textarea {
  min-height: 44px;
  min-width: 44px;
}

input, select, textarea {
  font-size: 16px; /* Prevents iOS zoom */
  border-radius: 12px;
  border: 2px solid #d1d5db;
  padding: 12px 16px;
  width: 100%;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #16a34a;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

/* ---------- Cards ---------- */
.card {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border: 1px solid #e5e7eb;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.1); }
.card:active { transform: scale(0.98); }

/* ---------- Feature Cards on Home ---------- */
.feature-card {
  background: linear-gradient(135deg, #fff 0%, #f0fdf4 100%);
  border-radius: 20px;
  padding: 24px 20px;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
}

.feature-card:hover { border-color: #16a34a; transform: translateY(-2px); }
.feature-card:active { transform: scale(0.97); }

.feature-card .icon-wrap {
  width: 64px; height: 64px;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 12px;
  font-size: 28px;
}

.feature-card h3 { font-size: 1rem; font-weight: 700; color: #1a1a1a; margin-bottom: 4px; }
.feature-card p { font-size: 0.8rem; color: #6b7280; }

/* ---------- Voice Button Animations ---------- */
.voice-btn {
  position: relative;
  overflow: visible;
  cursor: pointer;
  border: 3px solid #fff;
}

.voice-btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(59, 130, 246, 0.3);
  animation: voice-ring 2s infinite;
}

@keyframes voice-ring {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

.voice-btn.listening {
  background: linear-gradient(135deg, #dc2626, #991b1b) !important;
}

.voice-btn.listening::before {
  border-color: rgba(220, 38, 38, 0.5);
  animation: voice-ring-active 0.8s infinite;
}

@keyframes voice-ring-active {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

.voice-listening-anim {
  animation: pulse-glow 1.5s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
  50% { box-shadow: 0 0 0 20px rgba(59, 130, 246, 0); }
}

/* ---------- Navigation ---------- */
.nav-btn {
  color: #9ca3af;
  min-width: 52px;
}

.nav-btn.active {
  color: #16a34a;
  background: #f0fdf4;
}

.nav-btn.active i { transform: scale(1.1); }

/* ---------- Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

.badge-green { background: #dcfce7; color: #166534; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red { background: #fecaca; color: #991b1b; }
.badge-gray { background: #f3f4f6; color: #4b5563; }

/* ---------- Rating Stars ---------- */
.stars { color: #f59e0b; letter-spacing: 1px; }

/* ---------- Worker / Equipment Card ---------- */
.listing-card {
  display: flex;
  gap: 12px;
  padding: 16px;
  align-items: flex-start;
}

.listing-card .avatar {
  width: 56px; height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f0fdf4, #dcfce7);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 24px;
}

.listing-card .info { flex: 1; min-width: 0; }
.listing-card .info h4 { font-weight: 700; font-size: 0.95rem; color: #1a1a1a; }
.listing-card .info .meta { font-size: 0.8rem; color: #6b7280; }

.listing-card .actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.listing-card .actions button, .listing-card .actions a {
  padding: 8px 16px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
}

.btn-primary { background: #16a34a; color: #fff; }
.btn-primary:hover { background: #15803d; }
.btn-secondary { background: #f3f4f6; color: #374151; }
.btn-secondary:hover { background: #e5e7eb; }
.btn-call { background: #2563eb; color: #fff; }
.btn-call:hover { background: #1d4ed8; }

/* ---------- Scheme Cards ---------- */
.scheme-card {
  border-left: 4px solid #16a34a;
  padding-left: 12px;
}

.scheme-card .scheme-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

.scheme-card .scheme-amount {
  font-size: 1.1rem;
  font-weight: 800;
  color: #16a34a;
}

/* ---------- Profile Form ---------- */
.form-field {
  margin-bottom: 16px;
}

.form-field label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 6px;
  color: #374151;
}

.form-field .required { color: #dc2626; }

.form-field .voice-hint {
  width: 36px; height: 36px;
  min-width: 36px; min-height: 36px;
  border-radius: 50%;
  background: #eff6ff;
  color: #2563eb;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  font-size: 0.75rem;
}

/* ---------- Profile Mode Toggle ---------- */
.mode-toggle {
  display: flex;
  background: #f3f4f6;
  border-radius: 14px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 20px;
}

.mode-toggle button {
  flex: 1;
  border: none;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.mode-toggle button.active {
  background: #fff;
  color: #16a34a;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ---------- Completeness Meter ---------- */
.completeness-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 100px;
  overflow: hidden;
  margin: 8px 0;
}

.completeness-bar .fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, #f59e0b, #22c55e);
  transition: width 0.5s ease;
}

/* ---------- Visibility Toggle ---------- */
.visibility-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s;
  border: 2px solid transparent;
}

.visibility-option:hover { background: #f9fafb; }
.visibility-option.selected {
  border-color: #16a34a;
  background: #f0fdf4;
}

.visibility-option input[type="radio"] { display: none; }

/* ---------- Map Container ---------- */
.map-container {
  width: 100%;
  height: 280px;
  border-radius: 16px;
  overflow: hidden;
  background: #e5e7eb;
  position: relative;
}

.map-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #6b7280;
  font-size: 0.9rem;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
}

/* ---------- Admin Dashboard ---------- */
.stat-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  color: #16a34a;
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: #6b7280;
  margin-top: 4px;
}

/* ---------- Search Bar ---------- */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-bar input {
  flex: 1;
  border-radius: 12px;
}

.search-bar button {
  width: 48px;
  border-radius: 12px;
  background: #16a34a;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Skeleton Loading ---------- */
.skeleton {
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text { height: 16px; margin-bottom: 8px; }
.skeleton-title { height: 24px; width: 60%; margin-bottom: 12px; }
.skeleton-card { height: 120px; margin-bottom: 12px; }

/* ---------- Toast Notifications ---------- */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1f2937;
  color: #fff;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 0.9rem;
  z-index: 100;
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}

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

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #9ca3af;
}

.empty-state i { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }
.empty-state h3 { font-size: 1.1rem; color: #6b7280; margin-bottom: 4px; }
.empty-state p { font-size: 0.85rem; }

/* ---------- Scroll behavior for bottom nav ---------- */
main { padding-bottom: 100px !important; }

/* ---------- Print styles (for judges) ---------- */
@media print {
  nav, .voice-btn, #voice-fab, #install-prompt, #offline-banner, #demo-indicator, #conn-sim { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
