/* =========================================================
   SimFarm 2026 - Modern Smart Agriculture UI Theme
   Mobile-First, Responsive for iOS, Android & Modern Web
   ========================================================= */

:root {
  --bg-dark: #090d16;
  --bg-surface: rgba(15, 23, 42, 0.88);
  --bg-sheet: rgba(15, 23, 42, 0.96);
  --bg-card: rgba(30, 41, 59, 0.75);
  --bg-card-hover: rgba(51, 65, 85, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.09);
  --border-active: rgba(16, 185, 129, 0.5);

  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-cyan: #06b6d4;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-blue: #3b82f6;

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-dark);
  font-family: var(--font-family);
  font-size: 13px;
  color: var(--text-primary);
  touch-action: manipulation;
}

/* =========================================================
   TOP GLASS HUD / STATUS BAR
   ========================================================= */

#top-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: calc(52px + var(--safe-top));
  padding-top: var(--safe-top);
  padding-left: 10px;
  padding-right: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, rgba(9, 13, 22, 0.95) 0%, rgba(9, 13, 22, 0.7) 70%, transparent 100%);
  z-index: 50;
  pointer-events: none;
}

.hud-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
}

.hud-btn {
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 9999px;
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 15px;
  transition: all 0.15s ease;
}

.hud-btn:active {
  transform: scale(0.94);
  background: var(--accent-emerald);
  color: #000;
}

.hud-cash {
  color: var(--accent-emerald);
  font-weight: 700;
}

.hud-eco {
  color: var(--accent-cyan);
  font-weight: 600;
  font-size: 11px;
}

/* Speed Controls Pill */
.speed-pill {
  margin-left: auto;
  padding: 3px 6px;
  gap: 2px;
}

.speed-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 7px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.speed-btn:active {
  transform: scale(0.92);
}

.speed-btn.active {
  background: var(--accent-emerald);
  color: #000000;
}

/* =========================================================
   FLOATING TOAST NOTIFICATION BANNER
   ========================================================= */

.toast-banner {
  position: absolute;
  top: calc(56px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-15px);
  max-width: 90%;
  background: rgba(15, 23, 42, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-active);
  border-radius: 9999px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* =========================================================
   MAIN VIEWPORT (CANVAS)
   ========================================================= */

#viewport-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 10;
}

#farmCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* Floating GPS Radar / Minimap Widget */
.radar-widget {
  position: absolute;
  top: calc(58px + var(--safe-top));
  right: 12px;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  z-index: 40;
  transition: all 0.25s ease;
}

.radar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
}

.radar-mini-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  padding: 2px 4px;
}

#minimapCanvas {
  display: block;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  width: 130px;
  height: 130px;
  cursor: crosshair;
}

.radar-modes {
  display: flex;
  gap: 3px;
  margin-top: 6px;
}

.view-mode-btn {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 9px;
  font-weight: 600;
  padding: 3px 2px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.view-mode-btn.selected {
  background: var(--accent-emerald);
  color: #000;
  border-color: var(--accent-emerald);
}

.radar-widget.collapsed .radar-body {
  display: none;
}

/* Floating Actions: Pan/Select & Zoom */
#floating-actions {
  position: absolute;
  right: 12px;
  bottom: calc(76px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-end;
  z-index: 40;
}

.floating-pill-btn {
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 8px 14px;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  transition: all 0.15s ease;
}

.floating-pill-btn.active {
  background: var(--accent-cyan);
  color: #000;
  border-color: var(--accent-cyan);
}

.floating-pill-btn:active {
  transform: scale(0.94);
}

.zoom-pill-group {
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.zoom-btn {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: bold;
  width: 40px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.zoom-btn:first-child {
  border-bottom: 1px solid var(--border-subtle);
}

.zoom-btn:active {
  background: rgba(255, 255, 255, 0.15);
}

/* =========================================================
   BOTTOM NAVIGATION DOCK (Thumb Reachable)
   ========================================================= */

#bottom-dock {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(62px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding-left: 8px;
  padding-right: 8px;
  z-index: 50;
}

.dock-tab {
  flex: 1;
  max-width: 78px;
  height: 50px;
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 12px;
  transition: all 0.15s ease;
}

.dock-icon {
  font-size: 20px;
  transition: transform 0.15s ease;
}

.dock-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.dock-tab:active {
  transform: scale(0.92);
}

.dock-tab.active {
  color: var(--accent-emerald);
}

.dock-tab.active .dock-icon {
  transform: scale(1.15);
}

/* =========================================================
   MODERN BOTTOM SHEETS (SLIDE-UP MODALS)
   ========================================================= */

.sheet-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.sheet-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 85vh;
  background: var(--bg-sheet);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--border-subtle);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 36px rgba(0, 0, 0, 0.65);
  z-index: 110;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
  padding-bottom: var(--safe-bottom);
}

.bottom-sheet.open {
  transform: translateY(0);
  visibility: visible;
  pointer-events: auto;
}

.sheet-handle {
  width: 38px;
  height: 4px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 9999px;
  margin: 10px auto 4px auto;
  flex-shrink: 0;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px 12px 18px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sheet-title-group h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.sheet-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.sheet-close-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 13px;
  width: 30px;
  height: 30px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.sheet-close-btn:active {
  background: var(--accent-rose);
  color: #fff;
  transform: scale(0.92);
}

.sheet-content {
  padding: 14px 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

/* Tool Action Grid in Field Sheet */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 10px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-card-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.tool-card-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
}

.tool-card-desc {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 2px;
}

.tool-card:active {
  transform: scale(0.94);
}

.tool-card.active {
  background: var(--accent-emerald-glow);
  border-color: var(--accent-emerald);
  box-shadow: 0 0 12px var(--accent-emerald-glow);
}

.tool-card.active .tool-card-name {
  color: var(--accent-emerald);
}

/* Sub-Selectors for Crops & Sprays */
.subselector-box {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 12px;
  margin-top: 10px;
}

.subselector-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.crop-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.crop-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s ease;
}

.crop-pill span {
  font-size: 10px;
  color: var(--accent-amber);
}

.crop-pill:active {
  transform: scale(0.95);
}

.crop-pill.selected {
  background: var(--accent-emerald);
  color: #000;
  border-color: var(--accent-emerald);
}

.crop-pill.selected span {
  color: #000;
  font-weight: 700;
}

.spray-btn-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.spray-pill {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
}

.spray-pill:active {
  transform: scale(0.98);
}

.spray-pill.selected {
  background: var(--accent-cyan);
  color: #000;
  border-color: var(--accent-cyan);
}

/* =========================================================
   FIELD INSPECTOR CARDS & METRIC BARS
   ========================================================= */

.inspector-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 10px;
}

.metric-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.metric-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.3s ease;
}

.crop-status-card {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15) 0%, rgba(6, 182, 212, 0.1) 100%);
  border: 1px solid var(--accent-emerald);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.crop-status-icon {
  font-size: 32px;
}

.crop-status-info h4 {
  font-size: 15px;
  color: var(--text-primary);
}

.crop-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 9999px;
  margin-top: 3px;
}

.crop-badge.ripe {
  background: var(--accent-amber);
  color: #000;
  animation: pulse-badge 1.5s infinite;
}

.crop-badge.growing {
  background: var(--accent-emerald);
  color: #000;
}

.crop-badge.dead {
  background: var(--accent-rose);
  color: #fff;
}

@keyframes pulse-badge {
  0% { transform: scale(1); }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.quick-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.quick-action-btn {
  flex: 1;
  background: var(--accent-emerald);
  color: #000;
  font-size: 12px;
  font-weight: 700;
  padding: 10px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.quick-action-btn:active {
  transform: scale(0.96);
}

.quick-action-btn.secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}

/* =========================================================
   CARDS & TABLES FOR MARKET, FLEET, LIVESTOCK, ETC.
   ========================================================= */

.fleet-card, .livestock-card, .infra-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-lead {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-lead-icon {
  font-size: 26px;
}

.card-lead-text h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-lead-text p {
  font-size: 11px;
  color: var(--text-secondary);
}

.card-action-btn {
  background: var(--accent-emerald);
  color: #000;
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.card-action-btn:active {
  transform: scale(0.95);
}

/* Market Realtime Table */
.modern-table {
  width: 100%;
  border-collapse: collapse;
}

.modern-table th {
  font-size: 10px;
  color: var(--text-muted);
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.modern-table td {
  padding: 8px;
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.market-price-up {
  color: var(--accent-emerald);
  font-weight: 700;
}

.market-price-down {
  color: var(--accent-rose);
  font-weight: 700;
}

/* =========================================================
   MODERN SIDE DRAWER
   ========================================================= */

.side-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 290px;
  max-width: 85vw;
  height: 100%;
  background: var(--bg-sheet);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border-right: 1px solid var(--border-subtle);
  z-index: 120;
  transform: translateX(-100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.28s;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.side-drawer.open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.drawer-header {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  font-size: 24px;
}

.drawer-brand h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-emerald);
}

.brand-sub {
  font-size: 10px;
  color: var(--text-secondary);
}

.drawer-content {
  padding: 14px;
  overflow-y: auto;
  flex: 1;
}

.drawer-group-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin: 12px 0 6px 4px;
}

.drawer-action-btn {
  width: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  margin-bottom: 6px;
  transition: all 0.15s ease;
}

.drawer-action-btn:active {
  background: var(--accent-emerald);
  color: #000;
}

.text-warning {
  color: #f87171 !important;
}

/* =========================================================
   DESKTOP / TABLET RESPONSIVE REFINEMENTS (> 768px)
   ========================================================= */

@media (min-width: 769px) {
  .bottom-sheet {
    max-width: 580px;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border-radius: 24px 24px 0 0;
  }

  .bottom-sheet.open {
    transform: translateX(-50%) translateY(0);
  }

  #bottom-dock {
    max-width: 480px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 20px 20px 0 0;
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
  }
}
