/* CSS Theme: Amber Grain - Premium Barley Analytics Dashboard */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
  /* Design Tokens - Premium Light Theme with Dark Navy Sidebar */
  --bg-app: #f8fafc; /* Light Slate background */
  --bg-sidebar: #0f172a; /* Slate 900 - Dark Navy Sidebar */
  --bg-sidebar-hover: #1e293b;
  --bg-sidebar-active: #16a34a; /* Emerald green background for active nav */
  --bg-card: #ffffff; /* White cards */
  --bg-card-hover: #f8fafc;
  --bg-input: #ffffff; /* White inputs */
  
  --text-main: #0f172a; /* Slate 900 main text */
  --text-muted: #64748b; /* Slate 500 */
  --text-dimmed: #94a3b8; /* Slate 400 */
  
  --primary-gold: #3b82f6; /* Blue */
  --primary-gold-rgb: 59, 130, 246;
  --secondary-emerald: #16a34a; /* Emerald Green */
  --secondary-emerald-rgb: 22, 163, 74;
  
  /* Status Colors */
  --color-green: #16a34a;
  --color-yellow: #eab308;
  --color-orange: #3b82f6;
  --color-red: #ef4444;
  
  --border-light: #e2e8f0; /* Light Slate borders */
  --border-accent: rgba(22, 163, 74, 0.2);
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  
  --font-family: 'Outfit', sans-serif;
  --transition-speed: 0.25s;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--primary-gold) var(--bg-sidebar);
}

/* Custom Scrollbar Styles */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-card);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary-gold);
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
}

/* APP LAYOUT */
#app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* SIDEBAR NAVIGATION */
#sidebar {
  width: 280px;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 100;
}

.brand-section {
  padding: 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  font-size: 24px;
  color: var(--secondary-emerald);
}

.brand-name {
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.5px;
  color: #ffffff;
}

.nav-links {
  list-style: none;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  flex-grow: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
  border: 1px solid transparent;
}

.nav-item:hover {
  background-color: var(--bg-sidebar-hover);
  color: #ffffff;
}

.nav-item.active {
  background-color: var(--bg-sidebar-active);
  color: #ffffff;
  font-weight: 600;
}

.nav-item i {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border-light);
  font-size: 12px;
  color: var(--text-dimmed);
  text-align: center;
}

/* MAIN CONTENT */
#main-viewport {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* TOP HEADER & GLOBAL FILTER */
#top-header {
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-light);
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 90;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
}

.last-update {
  font-size: 12px;
  color: var(--text-dimmed);
}

/* Filter Panel Container */
.filter-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  padding: 4px 0;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: #f8fafc;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 6px 12px;
}

.filter-group label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.filter-select {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  outline: none;
  cursor: pointer;
  padding-right: 4px;
}

.filter-select option {
  background-color: var(--bg-input);
  color: var(--text-main);
}

.clear-btn {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 500;
  transition: all var(--transition-speed);
}

.clear-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border-color: var(--primary-gold);
}

/* CONTENT CONTAINER */
.content-body {
  padding: 24px;
  overflow-y: auto;
  flex-grow: 1;
  background-color: var(--bg-app);
}

.tab-pane {
  display: none;
  animation: fadeIn 0.3s ease-in-out;
}

.tab-pane.active {
  display: block;
}

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

/* KPI CARD STYLING */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: all var(--transition-speed) ease;
  box-shadow: var(--shadow-sm);
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-accent);
  background-color: var(--bg-card-hover);
  box-shadow: var(--shadow-md);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 8px;
}

.kpi-title {
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-icon {
  color: var(--primary-gold);
  font-size: 16px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.kpi-sub-row {
  display: flex;
  justify-content: space-between;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 11px;
}

.kpi-sub-item {
  display: flex;
  flex-direction: column;
}

.kpi-sub-label {
  color: var(--text-dimmed);
}

.kpi-sub-value {
  color: var(--text-main);
  font-weight: 600;
}

/* Decorative progress light indicator in card */
.kpi-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
}

.kpi-indicator.green { background-color: var(--color-green); }
.kpi-indicator.yellow { background-color: var(--color-yellow); }
.kpi-indicator.orange { background-color: var(--color-orange); }
.kpi-indicator.red { background-color: var(--color-red); }

/* GRID STRUCTURES */
.dashboard-grid-2x1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.dashboard-grid-1x1 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.dashboard-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

/* SECTION CARD TEMPLATE */
.section-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.section-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.section-card-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-card-title i {
  color: var(--primary-gold);
}

/* INTERACTIVE MAP CONTAINER */
#map-container {
  height: 500px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
  overflow: hidden;
  background-color: var(--bg-input);
  position: relative;
}

.leaflet-container {
  background: var(--bg-app) !important;
}

.map-legend {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background-color: var(--bg-sidebar);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 12px;
  z-index: 1000;
  box-shadow: var(--shadow-lg);
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.color-commercial { background-color: var(--primary-gold); }
.color-transfarm { background-color: var(--secondary-emerald); }
.color-multiplication { background-color: #3b82f6; }

/* DATA TABLES */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.data-table th {
  background-color: #0f172a;
  color: #f8fafc;
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* PROGRESS BARS */
.progress-container {
  width: 100%;
  background-color: var(--bg-input);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 6px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-gold), var(--secondary-emerald));
  border-radius: 4px;
  transition: width 0.5s ease-out;
}

/* TRAFFIC LIGHT BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge.green { background-color: rgba(16, 185, 129, 0.15); color: var(--color-green); }
.badge.green .badge-dot { background-color: var(--color-green); }

.badge.yellow { background-color: rgba(234, 179, 8, 0.15); color: var(--color-yellow); }
.badge.yellow .badge-dot { background-color: var(--color-yellow); }

.badge.orange { background-color: rgba(249, 115, 22, 0.15); color: var(--color-orange); }
.badge.orange .badge-dot { background-color: var(--color-orange); }

.badge.red { background-color: rgba(239, 68, 68, 0.15); color: var(--color-red); }
.badge.red .badge-dot { background-color: var(--color-red); }

/* SUB-KPI MATRIX (Grid display inside cards) */
.sub-kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.sub-kpi-item {
  background-color: var(--bg-input);
  padding: 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.03);
}

.sub-kpi-label {
  font-size: 11px;
  color: var(--text-dimmed);
  margin-bottom: 2px;
  display: block;
}

.sub-kpi-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

/* DUAL RATIO INDICATORS */
.ratio-comparison {
  margin-top: 12px;
}

.ratio-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.ratio-track {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background-color: var(--bg-input);
}

.ratio-bar-commercial {
  background-color: var(--primary-gold);
  height: 100%;
}

.ratio-bar-transfarm {
  background-color: var(--secondary-emerald);
  height: 100%;
}

/* SEED ORDER PROGRESS LIST */
.seed-order-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.seed-order-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: #f8fafc;
  padding: 12px;
  border-radius: 6px;
}

/* HISTORIC VISITS TIMELINE */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  padding-left: 20px;
}

.timeline::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 6px;
  bottom: 4px;
  width: 2px;
  background-color: var(--border-light);
}

.timeline-item {
  position: relative;
}

.timeline-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--primary-gold);
  border: 3px solid var(--bg-card);
}

.timeline-content {
  background-color: var(--bg-input);
  padding: 12px;
  border-radius: 6px;
  font-size: 12px;
}

.timeline-header {
  display: flex;
  justify-content: space-between;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.timeline-title {
  font-weight: 600;
  color: var(--text-main);
}

/* REGIONAL COMMENTS SECTION */
.comment-box {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.05), rgba(59, 130, 246, 0.01));
  border: 1px solid var(--border-accent);
  padding: 16px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-main);
  margin-top: 12px;
  display: flex;
  gap: 12px;
}

.comment-box i {
  color: var(--primary-gold);
  font-size: 18px;
  margin-top: 2px;
}

/* SILO GRID & PROGRESS VISUALS */
.silo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.silo-card {
  background-color: var(--bg-input);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.silo-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.silo-progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}

/* Leaflet Custom Popups Styling */
.custom-leaflet-popup .leaflet-popup-content-wrapper {
  background-color: #ffffff;
  color: #0f172a;
  border: 1px solid var(--border-light);
  font-family: var(--font-family);
  border-radius: 8px;
}

.custom-leaflet-popup .leaflet-popup-tip {
  background-color: #ffffff;
}

.popup-header {
  font-size: 14px;
  font-weight: 700;
  border-bottom: 1px solid #cbd5e1;
  padding-bottom: 6px;
  margin-bottom: 8px;
  color: var(--secondary-emerald);
}

.popup-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 4px;
}

.popup-label {
  color: var(--text-muted);
}

.popup-value {
  font-weight: 600;
}

/* RESPONSIVE MEDIA QUERIES */
@media (max-width: 1024px) {
  #app-container {
    flex-direction: column;
  }
  
  #sidebar {
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-light);
  }
  
  .nav-links {
    flex-direction: row;
    overflow-x: auto;
    padding: 10px;
  }
  
  .nav-item {
    white-space: nowrap;
  }
  
  #main-viewport {
    height: calc(100vh - 120px);
  }
  
  .dashboard-grid-2x1, .dashboard-grid-1x1 {
    grid-template-columns: 1fr;
  }
}
