﻿/* =====================================================
   CropPulse – Main CSS Design System
   Modern dark-first agriculture intelligence platform
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* ── CSS Variables ──────────────────────────────────── */
:root {
  /* Brand Colors */
  --primary:        #16a34a;
  --primary-dark:   #15803d;
  --primary-light:  #22c55e;
  --primary-glow:   rgba(22, 163, 74, 0.25);

  --secondary:      #2563eb;
  --secondary-dark: #1d4ed8;
  --secondary-light:#3b82f6;

  --accent:         #f59e0b;
  --accent-dark:    #d97706;
  --danger:         #dc2626;
  --danger-light:   #ef4444;
  --warning:        #f97316;
  --success:        #10b981;
  --info:           #06b6d4;

  /* Dark Theme (default) */
  --bg-base:        #0a0f1a;
  --bg-surface:     #0f1724;
  --bg-card:        #141e2e;
  --bg-card-hover:  #1a2640;
  --bg-input:       #1a2234;
  --bg-overlay:     rgba(10, 15, 26, 0.85);

  --text-primary:   #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;
  --text-inverse:   #0a0f1a;

  --border:         rgba(255, 255, 255, 0.08);
  --border-hover:   rgba(22, 163, 74, 0.4);
  --border-active:  var(--primary);

  /* Gradients */
  --grad-primary:   linear-gradient(135deg, #15803d 0%, #2563eb 100%);
  --grad-hero:      linear-gradient(135deg, #0a0f1a 0%, #0f2418 50%, #0a0f1a 100%);
  --grad-card:      linear-gradient(145deg, rgba(20,30,46,0.9), rgba(15,23,36,0.95));
  --grad-green:     linear-gradient(135deg, #16a34a, #22c55e);
  --grad-blue:      linear-gradient(135deg, #1d4ed8, #3b82f6);
  --grad-amber:     linear-gradient(135deg, #d97706, #f59e0b);
  --grad-danger:    linear-gradient(135deg, #b91c1c, #dc2626);

  /* Shadows */
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.3);
  --shadow-md:      0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg:      0 8px 40px rgba(0,0,0,0.5);
  --shadow-green:   0 0 30px rgba(22,163,74,0.2);
  --shadow-glow:    0 0 60px rgba(22,163,74,0.15);

  /* Typography */
  --font-base:      'Inter', system-ui, sans-serif;
  --font-display:   'Space Grotesk', system-ui, sans-serif;

  /* Spacing */
  --radius-sm:      8px;
  --radius-md:      12px;
  --radius-lg:      16px;
  --radius-xl:      24px;
  --radius-full:    9999px;

  /* Transitions */
  --trans-fast:     0.15s ease;
  --trans-base:     0.25s ease;
  --trans-slow:     0.4s ease;

  /* Navbar height */
  --navbar-h:       70px;
}

/* Light theme overrides applied via class */
body.light-mode {
  --bg-base:        #f8fafc;
  --bg-surface:     #ffffff;
  --bg-card:        #ffffff;
  --bg-card-hover:  #f1f5f9;
  --bg-input:       #f8fafc;
  --bg-overlay:     rgba(248, 250, 252, 0.92);
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --border:         rgba(0,0,0,0.1);
  --shadow-sm:      0 2px 8px rgba(0,0,0,0.08);
  --shadow-md:      0 4px 20px rgba(0,0,0,0.12);
  --shadow-lg:      0 8px 40px rgba(0,0,0,0.16);
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  font-family: var(--font-base);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--trans-slow), color var(--trans-slow);
  overflow-x: hidden;
}

/* ── Typography ─────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.5rem); }
h3 { font-size: clamp(1.25rem, 2vw, 1.75rem); }

a { color: var(--primary-light); text-decoration: none; transition: color var(--trans-fast); }
a:hover { color: var(--primary); }

p { color: var(--text-secondary); line-height: 1.7; }

/* ── Navbar ─────────────────────────────────────────── */
.ag-navbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  height: var(--navbar-h);
  background: rgba(10, 15, 26, 0.95);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 1.5rem;
  transition: background var(--trans-slow);
}
.light-mode .ag-navbar { background: rgba(255,255,255,0.95); }

.ag-navbar .brand {
  font-family: var(--font-display);
  font-size: 1.4rem; font-weight: 700;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.ag-navbar .nav-link {
  color: var(--text-secondary) !important;
  font-weight: 500; font-size: 0.9rem;
  transition: color var(--trans-fast);
  position: relative; padding: 0.5rem 0.75rem;
}
.ag-navbar .nav-link:hover,
.ag-navbar .nav-link.active { color: var(--primary-light) !important; }
.ag-navbar .nav-link.active::after {
  content: '';
  position: absolute; bottom: -2px; left: 0.75rem; right: 0.75rem;
  height: 2px; background: var(--primary);
  border-radius: var(--radius-full);
}

.ag-navbar .nav-icon-btn {
  width: 38px; height: 38px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--trans-fast);
  color: var(--text-secondary);
  position: relative;
}
.ag-navbar .nav-icon-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  color: var(--primary-light);
}

.badge-notif {
  position: absolute; top: -4px; right: -4px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--danger); color: #fff;
  font-size: 0.65rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

/* ── Page Wrapper ───────────────────────────────────── */
.ag-page {
  min-height: 100vh;
  padding-top: var(--navbar-h);
}

.ag-container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* ── Cards ──────────────────────────────────────────── */
.ag-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  transition: all var(--trans-base);
  position: relative;
  overflow: hidden;
}
.ag-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.ag-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--grad-primary);
  opacity: 0;
  transition: opacity var(--trans-base);
}
.ag-card:hover::before { opacity: 1; }

.ag-card-glass {
  background: rgba(20,30,46,0.6);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.light-mode .ag-card-glass { background: rgba(255,255,255,0.7); }

/* ── Stat Cards ─────────────────────────────────────── */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex; align-items: flex-start; gap: 1rem;
  transition: all var(--trans-base);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-green); }

.stat-icon {
  width: 52px; height: 52px; border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-icon.green  { background: rgba(22,163,74,0.15); color: var(--primary-light); }
.stat-icon.blue   { background: rgba(37,99,235,0.15); color: var(--secondary-light); }
.stat-icon.amber  { background: rgba(245,158,11,0.15); color: var(--accent); }
.stat-icon.red    { background: rgba(220,38,38,0.15); color: var(--danger-light); }
.stat-icon.cyan   { background: rgba(6,182,212,0.15); color: var(--info); }

.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-value { font-family: var(--font-display); font-size: 2rem; font-weight: 700; color: var(--text-primary); line-height: 1; margin-top: 0.25rem; }
.stat-change { font-size: 0.78rem; margin-top: 0.25rem; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger-light); }

/* ── Buttons ────────────────────────────────────────── */
.btn-ag-primary {
  background: var(--grad-green);
  color: #fff; border: none;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600; font-size: 0.9rem;
  cursor: pointer; transition: all var(--trans-fast);
  display: inline-flex; align-items: center; gap: 0.5rem;
  box-shadow: 0 4px 15px rgba(22,163,74,0.3);
}
.btn-ag-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(22,163,74,0.45);
  filter: brightness(1.1);
}
.btn-ag-primary:active { transform: translateY(0); }

.btn-ag-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600; font-size: 0.9rem;
  cursor: pointer; transition: all var(--trans-fast);
  display: inline-flex; align-items: center; gap: 0.5rem;
}
.btn-ag-secondary:hover {
  border-color: var(--primary);
  color: var(--primary-light);
  background: var(--primary-glow);
}

.btn-ag-danger {
  background: var(--grad-danger);
  color: #fff; border: none;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-md);
  font-weight: 600; cursor: pointer;
  transition: all var(--trans-fast);
  box-shadow: 0 4px 15px rgba(220,38,38,0.3);
}

.btn-ag-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--trans-fast);
  color: var(--text-muted);
}
.btn-ag-icon:hover {
  background: var(--primary-glow);
  border-color: var(--primary);
  color: var(--primary-light);
}

/* ── Form Inputs ────────────────────────────────────── */
.ag-form-group {
  margin-bottom: 1.25rem;
}
.ag-label {
  display: block;
  font-size: 0.85rem; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.ag-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: 0.9rem;
  transition: all var(--trans-fast);
  outline: none;
}
.ag-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-card);
}
.ag-input::placeholder { color: var(--text-muted); }
.ag-select { appearance: none; cursor: pointer; }

.input-wrapper {
  position: relative;
}
.input-wrapper .input-icon {
  position: absolute; left: 0.9rem; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 1rem; pointer-events: none;
}
.input-wrapper .ag-input { padding-left: 2.75rem; }

/* ── Severity Badges ────────────────────────────────── */
.badge-severity {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem; font-weight: 600;
  text-transform: capitalize;
}
.badge-severity.healthy  { background: rgba(16,185,129,0.15); color: #10b981; border: 1px solid rgba(16,185,129,0.3); }
.badge-severity.mild     { background: rgba(245,158,11,0.15); color: #f59e0b; border: 1px solid rgba(245,158,11,0.3); }
.badge-severity.moderate { background: rgba(249,115,22,0.15); color: #f97316; border: 1px solid rgba(249,115,22,0.3); }
.badge-severity.severe   { background: rgba(220,38,38,0.15);  color: #ef4444; border: 1px solid rgba(220,38,38,0.3); }

/* ── Tables ─────────────────────────────────────────── */
.ag-table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.ag-table {
  width: 100%; border-collapse: collapse;
}
.ag-table thead th {
  background: var(--bg-surface);
  padding: 0.9rem 1.25rem;
  text-align: left;
  font-size: 0.78rem; font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
.ag-table tbody td {
  padding: 0.9rem 1.25rem;
  font-size: 0.88rem; color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  transition: background var(--trans-fast);
}
.ag-table tbody tr:last-child td { border-bottom: none; }
.ag-table tbody tr:hover td { background: var(--bg-card-hover); }

/* ── Progress Bars ──────────────────────────────────── */
.ag-progress {
  height: 8px; border-radius: var(--radius-full);
  background: var(--bg-input); overflow: hidden;
}
.ag-progress-bar {
  height: 100%; border-radius: var(--radius-full);
  transition: width 1s ease;
}
.ag-progress-bar.green  { background: var(--grad-green); }
.ag-progress-bar.blue   { background: var(--grad-blue); }
.ag-progress-bar.amber  { background: var(--grad-amber); }
.ag-progress-bar.danger { background: var(--grad-danger); }

/* ── Toast Notifications ────────────────────────────── */
.ag-toast-container {
  position: fixed; top: calc(var(--navbar-h) + 1rem); right: 1rem;
  z-index: 9999; display: flex; flex-direction: column; gap: 0.5rem;
  max-width: 360px; width: 100%;
}
.ag-toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex; align-items: flex-start; gap: 0.75rem;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease forwards;
}
.ag-toast.success { border-left: 4px solid var(--success); }
.ag-toast.error   { border-left: 4px solid var(--danger); }
.ag-toast.warning { border-left: 4px solid var(--accent); }
.ag-toast.info    { border-left: 4px solid var(--info); }

.ag-toast .toast-icon { font-size: 1.2rem; flex-shrink: 0; margin-top: 0.1rem; }
.ag-toast .toast-title { font-weight: 600; font-size: 0.9rem; color: var(--text-primary); }
.ag-toast .toast-msg   { font-size: 0.82rem; color: var(--text-secondary); margin-top: 0.15rem; }
.ag-toast .toast-close {
  margin-left: auto; cursor: pointer; color: var(--text-muted);
  flex-shrink: 0; font-size: 1rem; transition: color var(--trans-fast);
}
.ag-toast .toast-close:hover { color: var(--text-primary); }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes slideOutRight {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(110%); opacity: 0; }
}

/* ── Loading Skeletons ──────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ── Upload Drop Zone ───────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--trans-base);
  background: var(--bg-card);
  position: relative;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-glow);
  box-shadow: var(--shadow-green);
}
.upload-zone .upload-icon {
  font-size: 3rem; color: var(--text-muted);
  transition: all var(--trans-base);
}
.upload-zone:hover .upload-icon { color: var(--primary-light); transform: scale(1.1); }
.upload-zone input[type="file"] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer;
}

/* ── Confidence Meter ───────────────────────────────── */
.confidence-ring {
  position: relative; display: inline-flex;
  align-items: center; justify-content: center;
}
.confidence-ring svg { transform: rotate(-90deg); }
.confidence-ring .cr-value {
  position: absolute;
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.4rem; color: var(--text-primary);
}
.confidence-ring .cr-label {
  position: absolute; top: calc(50% + 1.2rem);
  font-size: 0.7rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.05em;
}

/* ── Sidebar (admin/dashboard) ──────────────────────── */
.ag-sidebar {
  width: 260px; min-height: calc(100vh - var(--navbar-h));
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  position: fixed; top: var(--navbar-h); left: 0;
  overflow-y: auto; padding: 1.5rem 1rem;
  z-index: 100;
  transition: transform var(--trans-base);
}
.ag-sidebar .sidebar-section-label {
  font-size: 0.7rem; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.08em; padding: 0.5rem 0.75rem;
  margin-top: 1rem;
}
.ag-sidebar .sidebar-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500; font-size: 0.88rem;
  cursor: pointer; transition: all var(--trans-fast);
  text-decoration: none;
}
.ag-sidebar .sidebar-link:hover {
  background: var(--bg-card);
  color: var(--primary-light);
}
.ag-sidebar .sidebar-link.active {
  background: var(--primary-glow);
  color: var(--primary-light);
  font-weight: 600;
}
.ag-sidebar .sidebar-link .link-icon { font-size: 1.1rem; flex-shrink: 0; }
.ag-sidebar .sidebar-link .link-badge {
  margin-left: auto; background: var(--danger);
  color: #fff; border-radius: var(--radius-full);
  padding: 0.1rem 0.5rem; font-size: 0.7rem; font-weight: 700;
}

.ag-content-area { margin-left: 260px; padding: 2rem 1.5rem; }

/* ── Pagination ─────────────────────────────────────── */
.ag-pagination {
  display: flex; align-items: center; gap: 0.4rem;
  justify-content: center; margin-top: 1.5rem;
}
.ag-page-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--trans-fast); font-size: 0.88rem;
}
.ag-page-btn:hover  { border-color: var(--primary); color: var(--primary-light); }
.ag-page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Section Headers ────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.section-title {
  font-family: var(--font-display);
  font-size: 1.3rem; font-weight: 700;
  color: var(--text-primary);
}
.section-subtitle { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.2rem; }

/* ── Responsive ─────────────────────────────────────── */
@media (max-width: 1024px) {
  .ag-sidebar { transform: translateX(-100%); }
  .ag-sidebar.open { transform: translateX(0); }
  .ag-content-area { margin-left: 0; }
}
@media (max-width: 768px) {
  :root { --navbar-h: 60px; }
  .ag-container { padding: 0 1rem; }
  .stat-value { font-size: 1.6rem; }
  .ag-card { padding: 1rem; }
  h1 { font-size: 1.8rem; }
}

/* ── Map Container ──────────────────────────────────── */
.ag-map-container {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
#ag-map { height: 500px; }

/* ── Chart Container ────────────────────────────────── */
.chart-container {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}
.chart-title {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1rem; color: var(--text-primary);
  margin-bottom: 1rem;
}

/* ── Scrollbar ──────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Utilities ──────────────────────────────────────── */
.text-gradient {
  background: var(--grad-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.text-muted    { color: var(--text-muted) !important; }
.text-success  { color: var(--success) !important; }
.text-danger   { color: var(--danger-light) !important; }
.text-warning  { color: var(--accent) !important; }
.text-info     { color: var(--info) !important; }

.glow-green { box-shadow: var(--shadow-green); }
.hidden     { display: none !important; }
.truncate   { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
