/*
  PashuRakshak Farmer App - Modern Rural PWA Stylesheet
  Theme: Glassmorphic Emerald & Deep Carbon
  Optimized for high-contrast mobile displays in rural sunlight.
*/

@import url('https://fonts.googleapis.com/css2?family=Mukta:wght@400;500;600;700;800&family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --bg-primary: #07100D;
  --bg-surface: #0E1D18;
  --bg-card: rgba(18, 35, 29, 0.75);
  --bg-glass: rgba(22, 44, 37, 0.6);
  --border-subtle: rgba(52, 211, 153, 0.15);
  --border-glow: rgba(16, 185, 129, 0.4);

  --accent-green: #10B981;
  --accent-green-glow: rgba(16, 185, 129, 0.25);
  --accent-amber: #F59E0B;
  --accent-red: #EF4444;
  --accent-red-bg: rgba(239, 68, 68, 0.12);
  --accent-blue: #3B82F6;

  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Mukta', 'Outfit', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0;
  overflow-x: hidden;
}

/* Mobile Frame Container */
.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  background: radial-gradient(circle at top right, #112821 0%, #07100D 70%);
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
}

/* App Header */
.app-header {
  padding: 16px 20px 12px;
  background: rgba(11, 22, 18, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  font-size: 26px;
  background: linear-gradient(135deg, #10B981, #059669);
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #FFFFFF;
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--accent-green);
  font-weight: 600;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-dropdown {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: #FFFFFF;
  font-family: 'Mukta', sans-serif;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

.online-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.online-indicator.live {
  background: #10B981;
  box-shadow: 0 0 8px #10B981;
}

.online-indicator.cached {
  background: #F59E0B;
}

/* Low-Bandwidth Banner */
.low-bandwidth-banner {
  background: rgba(16, 185, 129, 0.08);
  border-bottom: 1px solid rgba(16, 185, 129, 0.15);
  padding: 6px 16px;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #6EE7B7;
}

/* App Main Content */
.main-content {
  flex: 1;
  padding: 16px;
  padding-bottom: 90px;
  overflow-y: auto;
}

/* Filter Chips */
.filter-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 12px;
  scrollbar-width: none;
}

.filter-bar::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-chip.active {
  background: var(--accent-green);
  color: #07100D;
  border-color: var(--accent-green);
  box-shadow: 0 2px 10px var(--accent-green-glow);
}

/* Cow Risk Cards */
.herd-cards-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cow-card {
  background: var(--bg-card);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: transform 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.cow-card.critical {
  border-color: rgba(239, 68, 68, 0.45);
  background: linear-gradient(180deg, rgba(239, 68, 68, 0.08) 0%, rgba(18, 35, 29, 0.85) 100%);
}

.cow-card.warning {
  border-color: rgba(245, 158, 11, 0.45);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08) 0%, rgba(18, 35, 29, 0.85) 100%);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.cow-name {
  font-size: 17px;
  font-weight: 700;
  color: #FFFFFF;
}

.cow-breed {
  font-size: 12px;
  color: var(--text-muted);
}

/* Status Badges */
.badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
  text-transform: uppercase;
}

.badge-critical {
  background: rgba(239, 68, 68, 0.2);
  color: #F87171;
  border: 1px solid rgba(239, 68, 68, 0.5);
  animation: pulseAlarm 2s infinite;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #FBBF24;
  border: 1px solid rgba(245, 158, 11, 0.5);
}

.badge-healthy {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

@keyframes pulseAlarm {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Risk Highlight Box */
.risk-highlight {
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 12px;
  border-left: 4px solid var(--accent-red);
}

.cow-card.warning .risk-highlight {
  border-left-color: var(--accent-amber);
}

.risk-prob-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.risk-pct {
  font-size: 24px;
  font-weight: 800;
  color: #EF4444;
  line-height: 1;
}

.cow-card.warning .risk-pct {
  color: #F59E0B;
}

.risk-details strong {
  font-size: 14px;
  color: #FFFFFF;
}

.lead-time {
  font-size: 12px;
  color: #CBD5E1;
}

.lead-time b {
  color: #34D399;
}

.action-summary {
  font-size: 12px;
  color: #E2E8F0;
  line-height: 1.4;
}

/* Healthy Banner */
.healthy-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(16, 185, 129, 0.08);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 12px;
  color: #A7F3D0;
}

.check-icon {
  background: #10B981;
  color: #07100D;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 12px;
}

/* Vitals Grid */
.vitals-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.vital-cell {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
}

.vital-cell.vital-alarm {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

.v-label {
  font-size: 10px;
  color: var(--text-dim);
}

.v-val {
  font-size: 13px;
  font-weight: 700;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  gap: 2px;
}

.drop-tag {
  color: #EF4444;
  font-size: 10px;
}

/* Actions Row */
.card-actions {
  display: flex;
  gap: 8px;
}

.btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-family: 'Mukta', sans-serif;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-primary {
  background: linear-gradient(135deg, #EF4444, #DC2626);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

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

.btn-secondary {
  background: var(--bg-surface);
  color: #E2E8F0;
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* Bottom Navigation Bar */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: rgba(11, 22, 18, 0.95);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-around;
  padding: 8px 12px;
  z-index: 100;
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: 'Mukta', sans-serif;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: color 0.2s;
  padding: 4px 12px;
}

.nav-tab-btn .tab-icon {
  font-size: 20px;
}

.nav-tab-btn.active {
  color: var(--accent-green);
}

/* Detail View */
.back-bar {
  margin-bottom: 14px;
}

.back-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: #CBD5E1;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
}

.detail-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
}

.metric-selector {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 12px;
}

.metric-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.metric-btn.active {
  background: rgba(16, 185, 129, 0.2);
  color: #34D399;
  border-color: var(--accent-green);
}

.chart-wrapper {
  width: 100%;
  height: 190px;
}

.vitals-svg-chart {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Vaccination Log */
.vaccine-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.vaccine-row:last-child {
  border-bottom: none;
}

.v-info strong {
  display: block;
  font-size: 13px;
  color: #FFFFFF;
}

.v-info small {
  font-size: 11px;
  color: var(--text-muted);
}

.status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 10px;
}

.pill-done {
  background: rgba(16, 185, 129, 0.15);
  color: #34D399;
}

.pill-due {
  background: rgba(245, 158, 11, 0.15);
  color: #FBBF24;
}

.pill-critical {
  background: rgba(239, 68, 68, 0.2);
  color: #F87171;
}

/* Symptom Reporter */
.symptom-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.symptom-textarea {
  width: 100%;
  min-height: 110px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: #FFFFFF;
  padding: 12px;
  font-family: 'Mukta', sans-serif;
  font-size: 15px;
  outline: none;
  resize: vertical;
}

.symptom-textarea:focus {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 2px var(--accent-green-glow);
}

.symptom-btn-row {
  display: flex;
  gap: 8px;
}

.recording-pulse {
  background: #EF4444 !important;
  color: #FFFFFF !important;
  animation: recPulse 1.2s infinite;
}

@keyframes recPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
  70% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.triage-result-box {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-top: 14px;
}

.triage-result-box h4 {
  font-size: 16px;
  color: #34D399;
  margin-bottom: 8px;
}

.triage-actions-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.triage-actions-list li {
  font-size: 13px;
  color: #E2E8F0;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  line-height: 1.4;
}

.triage-actions-list li span:first-child {
  color: #10B981;
  font-weight: 800;
}

/* WhatsApp Mock Box */
.whatsapp-mock-box {
  background: #0B141A;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wa-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 10px;
}

.wa-avatar {
  width: 38px;
  height: 38px;
  background: #00A884;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.wa-header strong {
  font-size: 14px;
  display: block;
}

.wa-header small {
  font-size: 11px;
  color: #00A884;
}

.wa-bubble {
  background: #005C4B;
  color: #E9EDEF;
  border-radius: 10px 10px 0 10px;
  padding: 12px;
  font-size: 13px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-self: flex-end;
  max-width: 95%;
}

.wa-time {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  align-self: flex-end;
}

/* ============================================================
   Farmer Live Barn CCTV Player
   ============================================================ */
.farmer-cctv-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000000;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, 0.3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

#farmerCCTVCanvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.farmer-cctv-hud {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.8);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #F8FAFC;
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

