/* ============================================================
   AgriSync - Professional Agriculture Management Platform
   Main Stylesheet v1.0
   ============================================================ */

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

:root {
  --primary:       #1a6b3c;
  --primary-light: #2d9a58;
  --primary-dark:  #124d2c;
  --primary-pale:  #e8f5ee;
  --accent:        #f59e0b;
  --accent-light:  #fef3c7;
  --danger:        #dc2626;
  --danger-light:  #fee2e2;
  --info:          #0ea5e9;
  --info-light:    #e0f2fe;
  --warning:       #d97706;
  --warning-light: #fffbeb;
  --success:       #16a34a;
  --success-light: #dcfce7;
  --purple:        #7c3aed;
  --purple-light:  #ede9fe;

  --bg:            #f0f4f1;
  --surface:       #ffffff;
  --surface-2:     #f8faf9;
  --border:        #d1ddd5;
  --border-light:  #e8f0ea;

  --text:          #1a2e1f;
  --text-2:        #4a6352;
  --text-3:        #7a9985;
  --text-inv:      #ffffff;

  --sidebar-w:     260px;
  --sidebar-bg:    #0f3d22;
  --sidebar-text:  #a8d5b5;
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-active:#1a6b3c;

  --topbar-h:      64px;
  --radius:        10px;
  --radius-lg:     16px;
  --shadow:        0 1px 3px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-md:     0 4px 12px rgba(0,0,0,0.12);
  --transition:    0.2s ease;

  --font:          'Outfit', sans-serif;
  --mono:          'DM Mono', monospace;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
input, select, textarea, button { font-family: var(--font); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 200;
  transition: transform var(--transition);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.brand-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}
.brand-name  { display: block; font-size: 18px; font-weight: 700; color: #fff; line-height: 1; }
.brand-sub   { display: block; font-size: 10px; color: var(--sidebar-text); margin-top: 2px; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: rgba(255,255,255,0.04);
  margin: 12px 12px 0;
  border-radius: var(--radius);
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--primary-light);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  flex-shrink: 0;
}
.user-name  { display: block; font-size: 13px; font-weight: 600; color: #fff; line-height: 1.2; }
.user-role  { display: block; font-size: 10px; margin-top: 3px; padding: 1px 6px; border-radius: 4px; font-weight: 500; }

.badge-role-admin       { background: #dc2626; color: #fff; }
.badge-role-manager     { background: #7c3aed; color: #fff; }
.badge-role-accountant  { background: #0ea5e9; color: #fff; }
.badge-role-field_officer { background: #f59e0b; color: #fff; }
.badge-role-member      { background: #16a34a; color: #fff; }

.sidebar-nav { flex: 1; padding: 16px 0 8px; }
.nav-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(168,213,181,0.45);
  padding: 14px 20px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--sidebar-text);
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  border-left: 3px solid transparent;
}
.nav-item i { width: 18px; text-align: center; font-size: 14px; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active {
  background: rgba(26,107,60,0.4);
  color: #fff;
  border-left-color: var(--primary-light);
}

.sidebar-footer {
  padding: 8px 0 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.logout-btn { color: #f87171 !important; }
.logout-btn:hover { background: rgba(220,38,38,0.15) !important; }

/* ============================================================
   MAIN WRAPPER
   ============================================================ */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.sidebar-toggle {
  width: 36px; height: 36px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: var(--text-2);
  transition: background var(--transition);
}
.sidebar-toggle:hover { background: var(--primary-pale); color: var(--primary); }
.page-title { font-size: 16px; font-weight: 600; color: var(--text); }

.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-time { font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.user-menu { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.user-avatar-sm {
  width: 30px; height: 30px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}

/* ============================================================
   CONTENT AREA
   ============================================================ */
.content-area { padding: 24px; flex: 1; }

/* ============================================================
   CARDS & STAT CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  overflow: hidden;
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 600; color: var(--text); }
.card-body { padding: 22px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.green   { background: var(--primary-pale); color: var(--primary); }
.stat-icon.amber   { background: var(--accent-light); color: var(--accent); }
.stat-icon.blue    { background: var(--info-light);   color: var(--info); }
.stat-icon.red     { background: var(--danger-light); color: var(--danger); }
.stat-icon.purple  { background: var(--purple-light); color: var(--purple); }
.stat-icon.success { background: var(--success-light); color: var(--success); }
.stat-label { font-size: 12px; color: var(--text-3); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-sub   { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ============================================================
   CHARTS GRID
   ============================================================ */
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.chart-wrap { position: relative; padding: 20px; }
.chart-title { font-size: 14px; font-weight: 600; margin-bottom: 16px; color: var(--text); }

/* ============================================================
   DATA TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  background: var(--surface-2);
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--primary-pale); }
.table-action { display: flex; gap: 6px; }

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success  { background: var(--success-light); color: var(--success); }
.badge-danger   { background: var(--danger-light);  color: var(--danger); }
.badge-warning  { background: var(--warning-light); color: var(--warning); }
.badge-info     { background: var(--info-light);    color: var(--info); }
.badge-purple   { background: var(--purple-light);  color: var(--purple); }
.badge-grey     { background: #f1f5f2; color: var(--text-2); }
.badge-primary  { background: var(--primary-pale);  color: var(--primary); }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
}
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-warning  { background: var(--accent); color: #fff; }
.btn-info     { background: var(--info); color: #fff; }
.btn-outline  { background: transparent; border: 1.5px solid var(--border); color: var(--text-2); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: 8px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 18px; }
.form-grid-3 { grid-template-columns: repeat(3,1fr); }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1/-1; }
label { font-size: 12px; font-weight: 600; color: var(--text-2); }
input[type=text], input[type=email], input[type=number], input[type=date],
input[type=password], input[type=tel], select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--text);
  background: var(--surface);
  transition: border-color var(--transition);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,107,60,0.1);
}
textarea { resize: vertical; min-height: 80px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-3); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-success { background: var(--success-light); color: var(--success); border-left: 4px solid var(--success); }
.alert-danger  { background: var(--danger-light);  color: var(--danger);  border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: var(--warning); border-left: 4px solid var(--warning); }
.alert-info    { background: var(--info-light);    color: var(--info);    border-left: 4px solid var(--info); }

/* ============================================================
   UTILITY
   ============================================================ */
.flex         { display: flex; }
.flex-center  { display: flex; align-items: center; justify-content: center; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.gap-4        { gap: 16px; }
.mb-4         { margin-bottom: 16px; }
.mb-5         { margin-bottom: 20px; }
.mb-6         { margin-bottom: 24px; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.text-green   { color: var(--primary); }
.text-red     { color: var(--danger); }
.text-muted   { color: var(--text-3); }
.text-sm      { font-size: 12px; }
.mono         { font-family: var(--mono); }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.page-header h2 { font-size: 20px; font-weight: 700; }
.page-header p  { font-size: 13px; color: var(--text-3); }

.search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.search-input {
  position: relative;
  flex: 1;
}
.search-input i {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  font-size: 13px;
}
.search-input input { padding-left: 36px !important; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f3d22 0%, #1a6b3c 50%, #2d9a58 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: #fff;
  border-radius: 20px;
  padding: 44px 48px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo .logo-icon {
  width: 64px; height: 64px;
  background: var(--primary);
  border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #fff;
  margin: 0 auto 12px;
}
.login-logo h1 { font-size: 24px; font-weight: 800; color: var(--primary-dark); }
.login-logo p  { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.login-card .form-group { margin-bottom: 16px; }
.login-btn {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 8px;
  transition: background var(--transition);
}
.login-btn:hover { background: var(--primary-dark); }
.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-3);
}

/* ============================================================
   PROGRESS BARS
   ============================================================ */
.progress { height: 6px; background: var(--border); border-radius: 10px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 10px; }
.progress-bar.amber  { background: var(--accent); }
.progress-bar.red    { background: var(--danger); }
.progress-bar.blue   { background: var(--info); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-3);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-2); margin-bottom: 8px; }
.empty-state p  { font-size: 13px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2,1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .content-area { padding: 16px; }
  .login-card { padding: 32px 24px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* Sidebar collapsed */
.sidebar-collapsed .sidebar { width: 64px; }
.sidebar-collapsed .sidebar .brand-text,
.sidebar-collapsed .sidebar .nav-item span,
.sidebar-collapsed .sidebar .nav-section-label,
.sidebar-collapsed .sidebar .sidebar-user .user-info { display: none; }
.sidebar-collapsed .sidebar .nav-item { justify-content: center; padding: 12px; }
.sidebar-collapsed .sidebar .nav-item i { width: auto; }
.sidebar-collapsed .sidebar .sidebar-brand { justify-content: center; padding: 22px 12px; }
.sidebar-collapsed .sidebar .sidebar-user { justify-content: center; padding: 12px; }
.sidebar-collapsed .main-wrapper { margin-left: 64px; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
