/* Light Engine Global Theme */
/* Phase 4: Unified Dark Glassmorphism */

:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --border: rgba(148, 163, 184, 0.12);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  /* Accents aligned with public/styles/le-foundation.css (Tailwind-400 shades).
     Legacy --accent-yellow kept as a back-compat alias for --accent-amber. */
  --accent-blue:   #60a5fa;
  --accent-green:  #34d399;
  --accent-amber:  #fbbf24;
  --accent-yellow: var(--accent-amber);
  --accent-red:    #f87171;
  --accent-purple: #a78bfa;
  --accent-indigo: #818cf8;
  --accent-teal:   #5eead4;
  --glass-card: linear-gradient(145deg, rgba(15, 23, 42, 0.95) 0%, rgba(30, 41, 59, 0.9) 100%);
  --glass-border: 1px solid rgba(148, 163, 184, 0.12);
  --glow-indigo: 0 0 20px rgba(99, 102, 241, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
}

a {
  text-decoration: none;
  color: inherit;
}

/* Common Layout Components */

/* Page Header */
.page-header {
  background: rgba(15, 23, 42, 0.8);
  padding: 1.5rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.page-header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #f1f5f9;
  letter-spacing: -0.02em;
  margin: 0;
}

/* Nav Buttons */
.nav-btn {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  display: inline-block;
}

.nav-btn:hover {
  background: rgba(99, 102, 241, 0.22);
  border-color: rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
  color: white;
}

.nav-btn.farm-summary {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.nav-btn.farm-summary:hover {
  background: rgba(16, 185, 129, 0.22);
  color: white;
}

.nav-btn.farm-admin {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.3);
  color: #c4b5fd;
}

.nav-btn.farm-admin:hover {
  background: rgba(139, 92, 246, 0.22);
  color: white;
}

.nav-btn.inventory {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.nav-btn.inventory:hover {
  background: rgba(245, 158, 11, 0.22);
  color: white;
}

.nav-btn.nutrient {
  background: rgba(6, 182, 212, 0.12);
  border-color: rgba(6, 182, 212, 0.3);
  color: #67e8f9;
}

.nav-btn.nutrient:hover {
  background: rgba(6, 182, 212, 0.22);
  color: white;
}

/* Alerts */
.alert-badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.alert-critical {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.alert-low {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.alert-normal {
  background: rgba(16, 185, 129, 0.15);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* --- Cards & Containers --- */

.card {
  background: var(--glass-card);
  border: var(--glass-border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 24px;
}

.card h2 {
  font-size: 18px;
  margin-bottom: 16px;
  color: var(--accent-green);
  margin-top: 0;
}

/* KPI Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.kpi-card {
  background: var(--glass-card);
  border: var(--glass-border);
  border-radius: 14px;
  padding: 20px;
}

.kpi-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
  font-weight: 600;
}

.kpi-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.kpi-change {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.kpi-change.positive { color: var(--accent-green); }
.kpi-change.negative { color: var(--accent-red); }

/* Quick Actions Card */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.action-card {
  padding: 20px;
  background: var(--glass-card);
  border: var(--glass-border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: var(--text-primary);
  display: block;
}

.action-card:hover {
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-2px);
  box-shadow: var(--glow-indigo);
}

.action-icon {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--accent-indigo);
}

.action-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.action-desc {
  font-size: 12px;
  color: var(--text-secondary);
}

/* --- Usage Bars --- */

.usage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.usage-item {
  padding: 16px;
  background: var(--glass-card);
  border: var(--glass-border);
  border-radius: 12px;
}

.usage-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.usage-value {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.usage-bar {
  height: 6px;
  background: rgba(148, 163, 184, 0.12);
  border-radius: 3px;
  overflow: hidden;
}

.usage-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-green) 0%, var(--accent-indigo) 100%);
  transition: width 0.3s;
}

/* --- Global Help Feature --- */

/* Help Toggle Button */
#le-help-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--accent-indigo);
  color: white;
  border: none;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.25);
  font-size: 24px;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

#le-help-toggle:hover {
  transform: scale(1.1);
  background: #4f46e5;
}

#le-help-toggle.active {
  background: var(--accent-green);
  transform: rotate(360deg);
}

/* Help Mode Styles */
body.le-help-active [data-help] {
  cursor: help;
  position: relative;
  outline: 2px dashed rgba(99, 102, 241, 0.4);
  outline-offset: 2px;
}

body.le-help-active [data-help]:hover {
  outline: 2px solid var(--accent-indigo);
  z-index: 1000;
}

/* Help Popup */
#le-help-popup {
  position: fixed;
  display: none;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 14px;
  padding: 16px;
  width: 300px;
  color: var(--text-primary);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  z-index: 10000;
  pointer-events: none;
  animation: fadeIn 0.2s ease;
}

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

#le-help-popup h3 {
  margin: 0 0 8px 0;
  color: var(--accent-indigo);
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

#le-help-popup p {
  margin: 0 0 12px 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}

#le-help-popup .ai-insight {
  background: rgba(139, 92, 246, 0.1);
  border-left: 3px solid var(--accent-purple);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  color: #c4b5fd;
  margin-top: 8px;
}

#le-help-popup .ai-insight strong {
  color: var(--accent-purple);
  display: block;
  margin-bottom: 4px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
