/* ============================================
   粮仓管理系统 - Cyberpunk Industrial UI
   ============================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700;800;900&family=Rajdhani:wght@300;400;500;600;700&family=Inter:wght@300;400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* CSS Variables - Dark Theme (Default) */
:root {
  /* Colors */
  --primary: #00D4FF;
  --primary-rgb: 0, 212, 255;
  --secondary: #7B2FFF;
  --secondary-rgb: 123, 47, 255;
  --accent: #00FF88;
  --accent-rgb: 0, 255, 136;
  --warning: #FFB800;
  --warning-rgb: 255, 184, 0;
  --danger: #FF4757;
  --danger-rgb: 255, 71, 87;
  --success: #00FF88;
  
  --bg-primary: #0A0E17;
  --bg-secondary: #141B2D;
  --bg-tertiary: #1E2738;
  --bg-card: rgba(20, 27, 45, 0.8);
  
  --text-primary: #FFFFFF;
  --text-secondary: #8892A0;
  --text-muted: #5A6270;
  
  --border-color: rgba(0, 212, 255, 0.2);
  --border-hover: rgba(0, 212, 255, 0.5);
  
  /* Gradients */
  --gradient-primary: linear-gradient(135deg, var(--primary), var(--secondary));
  --gradient-accent: linear-gradient(135deg, var(--accent), #00B865);
  --gradient-danger: linear-gradient(135deg, var(--danger), #FF6B7A);
  
  /* 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-glow: 0 0 20px rgba(0, 212, 255, 0.3);
  --shadow-glow-strong: 0 0 40px rgba(0, 212, 255, 0.5);
  
  /* Typography */
  --font-display: 'Orbitron', 'Rajdhani', sans-serif;
  --font-heading: 'Rajdhani', 'Inter', sans-serif;
  --font-body: 'Inter', 'Noto Sans SC', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  
  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 300ms ease;
  --transition-slow: 500ms ease;
  --transition-theme: 400ms ease;
  
  /* Z-index */
  --z-dropdown: 100;
  --z-modal: 200;
  --z-tooltip: 300;
  --z-toast: 400;
}

/* Light Theme */
[data-theme="light"] {
  --primary: #0066FF;
  --primary-rgb: 0, 102, 255;
  --secondary: #6B4EFF;
  --secondary-rgb: 107, 78, 255;
  --accent: #00B85C;
  --accent-rgb: 0, 184, 92;
  --warning: #E69500;
  --warning-rgb: 230, 149, 0;
  --danger: #E63946;
  --danger-rgb: 230, 57, 70;
  
  --bg-primary: #F5F7FA;
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #EEF1F6;
  --bg-card: rgba(255, 255, 255, 0.9);
  
  --text-primary: #1A1F36;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  
  --border-color: rgba(0, 102, 255, 0.15);
  --border-hover: rgba(0, 102, 255, 0.3);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.12);
  --shadow-glow: 0 0 20px rgba(0, 102, 255, 0.15);
  --shadow-glow-strong: 0 0 40px rgba(0, 102, 255, 0.25);
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition-theme), color var(--transition-theme);
}

/* Grid Background */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    linear-gradient(rgba(var(--primary-rgb), 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--primary-rgb), 0.03) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
  z-index: -1;
}

[data-theme="light"] body::before {
  background-image: 
    linear-gradient(rgba(var(--primary-rgb), 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(var(--primary-rgb), 0.02) 1px, transparent 1px);
}

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

h1 { font-size: 2.5rem; font-family: var(--font-display); }
h2 { font-size: 2rem; font-family: var(--font-display); }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

.text-gradient {
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-mono {
  font-family: var(--font-mono);
}

.text-primary { color: var(--primary); }
.text-secondary { color: var(--secondary); }
.text-accent { color: var(--accent); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }

/* ============================================
   Layout
   ============================================ */
.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.gap-xl { gap: var(--space-xl); }

.grid { display: grid; }

/* ============================================
   Navbar
   ============================================ */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
  transition: all var(--transition-base);
}

.navbar.scrolled {
  box-shadow: var(--shadow-md);
}

.navbar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  padding: 0 var(--space-lg);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.navbar-logo {
  width: 40px;
  height: 40px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.navbar-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
}

[data-theme="light"] .navbar-title {
  color: var(--primary);
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
}

.nav-link {
  position: relative;
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  padding: var(--space-sm) 0;
  transition: color var(--transition-fast);
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--gradient-primary);
  transition: width var(--transition-base);
}

.nav-link:hover,
.nav-link.active {
  color: var(--primary);
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

/* Theme Toggle */
.theme-toggle {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-base);
  color: var(--text-secondary);
}

.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform var(--transition-base);
}

.theme-toggle:hover svg {
  transform: rotate(180deg);
}

.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: block; }

[data-theme="light"] .theme-toggle .sun { display: block; }
[data-theme="light"] .theme-toggle .moon { display: none; }

/* User Avatar */
.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all var(--transition-fast);
}

.user-avatar:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
  padding-top: 64px;
  min-height: 100vh;
}

/* Page Header */
.page-header {
  padding: var(--space-xl) 0;
  text-align: center;
}

.page-title {
  font-family: var(--font-display);
  font-size: 2rem;
  letter-spacing: 3px;
  margin-bottom: var(--space-sm);
}

.page-subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
}

/* ============================================
   Cards
   ============================================ */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-base);
}

.card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-glow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border-color);
}

.card-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.card-title svg {
  color: var(--primary);
}

/* Stat Cards */
.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-base);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--gradient-primary);
}

.stat-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-glow);
}

.stat-card.accent::before {
  background: var(--gradient-accent);
}

.stat-card.danger::before {
  background: var(--gradient-danger);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-md);
}

.stat-icon svg {
  width: 24px;
  height: 24px;
}

.stat-icon.primary {
  background: rgba(var(--primary-rgb), 0.15);
  color: var(--primary);
}

.stat-icon.accent {
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent);
}

.stat-icon.warning {
  background: rgba(var(--warning-rgb), 0.15);
  color: var(--warning);
}

.stat-icon.danger {
  background: rgba(var(--danger-rgb), 0.15);
  color: var(--danger);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  margin-bottom: var(--space-xs);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.stat-trend {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  margin-top: var(--space-sm);
  font-size: 0.75rem;
}

.stat-trend.up {
  color: var(--accent);
}

.stat-trend.down {
  color: var(--danger);
}

/* ============================================
   Dashboard Layout
   ============================================ */
.dashboard {
  display: grid;
  grid-template-columns: 280px 1fr 300px;
  gap: var(--space-lg);
  padding: var(--space-lg);
  min-height: calc(100vh - 64px);
}

.dashboard-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.dashboard-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.dashboard-right {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* Stats Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}

/* Map Container */
.map-container {
  flex: 1;
  min-height: 500px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  position: relative;
}

.map-header {
  position: absolute;
  top: var(--space-md);
  left: var(--space-md);
  right: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1000;
}

.map-select {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-sm) var(--space-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  cursor: pointer;
  min-width: 160px;
}

.map-select:focus {
  outline: none;
  border-color: var(--primary);
}

#map {
  width: 100%;
  height: 100%;
  min-height: 500px;
}

/* Leaflet Custom Styles */
.leaflet-container {
  background: var(--bg-secondary);
  font-family: var(--font-body);
}

.leaflet-popup-content-wrapper {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
  margin: var(--space-md);
  color: var(--text-primary);
}

.leaflet-popup-tip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}

/* Custom Marker */
.granary-marker {
  background: var(--gradient-primary);
  border: 2px solid #fff;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-glow);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.granary-marker:hover {
  transform: scale(1.2);
  box-shadow: var(--shadow-glow-strong);
}

.granary-marker.warning {
  background: var(--gradient-danger);
}

.granary-marker svg {
  width: 18px;
  height: 18px;
  color: #fff;
}

/* Pulse Animation */
@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.5);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 0;
  }
}

.marker-pulse {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--primary);
  animation: pulse 2s ease-out infinite;
}

.granary-marker.warning .marker-pulse {
  background: var(--danger);
}

/* ============================================
   Data List
   ============================================ */
.data-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 400px;
  overflow-y: auto;
}

.data-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--primary);
  transition: all var(--transition-fast);
}

.data-item:hover {
  background: rgba(var(--primary-rgb), 0.1);
  transform: translateX(4px);
}

.data-item.warning {
  border-left-color: var(--danger);
}

.data-item.warning:hover {
  background: rgba(var(--danger-rgb), 0.1);
}

.data-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.data-name {
  font-weight: 500;
  font-size: 0.875rem;
}

.data-location {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.data-values {
  display: flex;
  gap: var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

.data-temp {
  color: var(--warning);
}

.data-humidity {
  color: var(--primary);
}

/* ============================================
   Tables
   ============================================ */
.table-container {
  overflow-x: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.data-table tbody tr {
  transition: all var(--transition-fast);
}

.data-table tbody tr:hover {
  background: rgba(var(--primary-rgb), 0.05);
}

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

/* Status Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-success {
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent);
}

.badge-warning {
  background: rgba(var(--warning-rgb), 0.15);
  color: var(--warning);
}

.badge-danger {
  background: rgba(var(--danger-rgb), 0.15);
  color: var(--danger);
}

.badge-muted {
  background: rgba(139, 149, 165, 0.2);
  color: #8b95a5;
}

[data-theme='light'] .badge-muted {
  background: rgba(107, 114, 128, 0.12);
  color: #6b7280;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--gradient-primary);
  color: #fff;
  border-color: transparent;
}

.btn-primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: var(--gradient-danger);
  color: #fff;
}

.btn-danger:hover {
  box-shadow: 0 0 20px rgba(var(--danger-rgb), 0.4);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: var(--space-xs);
}

.btn-ghost:hover {
  color: var(--primary);
  background: rgba(var(--primary-rgb), 0.1);
}

.btn-sm {
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
}

.btn-lg {
  padding: var(--space-md) var(--space-lg);
  font-size: 1rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Button Group */
.btn-group {
  display: flex;
  gap: var(--space-sm);
}

/* ============================================
   Forms
   ============================================ */
.form-group {
  margin-bottom: var(--space-md);
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  transition: all var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.15);
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
}

/* Input with icon */
.input-icon {
  position: relative;
}

.input-icon .form-input {
  padding-left: 40px;
}

.input-icon svg {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

/* ============================================
   Modal & Drawer
   ============================================ */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow: hidden;
  transform: translateY(20px);
  transition: transform var(--transition-base);
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

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

.modal-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--danger);
}

.modal-body {
  padding: var(--space-lg);
  overflow-y: auto;
  max-height: calc(90vh - 140px);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-lg);
  border-top: 1px solid var(--border-color);
}

/* Drawer */
.drawer-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: var(--z-modal);
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.drawer-overlay.active {
  opacity: 1;
  visibility: visible;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  max-width: 100%;
  height: 100%;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  transform: translateX(100%);
  transition: transform var(--transition-base);
  display: flex;
  flex-direction: column;
  z-index: calc(var(--z-modal) + 1);
}

.drawer-overlay.active .drawer {
  transform: translateX(0);
}

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

.drawer-body {
  flex: 1;
  padding: var(--space-lg);
  overflow-y: auto;
}

.drawer-footer {
  padding: var(--space-lg);
  border-top: 1px solid var(--border-color);
}

/* ============================================
   Granary Detail Card
   ============================================ */
.granary-detail {
  min-width: 280px;
}

.granary-detail-header {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.granary-detail-icon {
  width: 48px;
  height: 48px;
  background: var(--gradient-primary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.granary-detail-icon svg {
  width: 24px;
  height: 24px;
  color: #fff;
}

.granary-detail-name {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
}

.granary-detail-location {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.granary-detail-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.detail-stat {
  background: var(--bg-tertiary);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  text-align: center;
}

.detail-stat-value {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 600;
}

.detail-stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

/* ============================================
   Mobile Styles
   ============================================ */
.mobile-container {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg-primary);
  position: relative;
}

.mobile-header {
  position: sticky;
  top: 0;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  padding: var(--space-md) var(--space-lg);
  z-index: 100;
}

.mobile-header-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  text-align: center;
}

.mobile-search {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  padding: var(--space-sm) var(--space-md);
  margin-top: var(--space-md);
}

.mobile-search svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.mobile-search input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.mobile-search input::placeholder {
  color: var(--text-muted);
}

.mobile-search input:focus {
  outline: none;
}

.mobile-content {
  padding: var(--space-lg);
  padding-bottom: 80px;
}

.mobile-tabs {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: var(--radius-lg);
  padding: var(--space-xs);
  margin-bottom: var(--space-lg);
}

.mobile-tab {
  flex: 1;
  padding: var(--space-sm) var(--space-md);
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
}

.mobile-tab svg {
  width: 18px;
  height: 18px;
}

.mobile-tab.active {
  background: var(--gradient-primary);
  color: #fff;
}

/* Mobile Granary Card */
.mobile-granary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  transition: all var(--transition-fast);
}

.mobile-granary-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-glow);
}

.mobile-granary-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.mobile-granary-info h4 {
  font-family: var(--font-heading);
  font-size: 1rem;
  margin-bottom: var(--space-xs);
}

.mobile-granary-info p {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.mobile-granary-status {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 500;
}

.mobile-granary-stats {
  display: flex;
  gap: var(--space-lg);
}

.mobile-granary-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.mobile-granary-stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.mobile-granary-stat-value {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 600;
}

.mobile-granary-stat-value.temp {
  color: var(--warning);
}

.mobile-granary-stat-value.humidity {
  color: var(--primary);
}

/* Mobile Bottom Nav */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  padding: var(--space-sm) var(--space-lg);
  padding-bottom: calc(var(--space-sm) + env(safe-area-inset-bottom, 0));
  z-index: 100;
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.7rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.mobile-nav-item svg {
  width: 24px;
  height: 24px;
}

.mobile-nav-item.active {
  color: var(--primary);
}

.mobile-nav-item.active svg {
  filter: drop-shadow(0 0 8px rgba(var(--primary-rgb), 0.5));
}

/* ============================================
   Profile Page
   ============================================ */
.profile-header {
  text-align: center;
  padding: var(--space-xl) 0;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-md);
  font-size: 2.5rem;
  font-weight: 600;
  color: #fff;
  box-shadow: var(--shadow-glow);
}

.profile-name {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  margin-bottom: var(--space-xs);
}

.profile-role {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

.profile-menu {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.profile-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  text-decoration: none;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.profile-menu-item:last-child {
  border-bottom: none;
}

.profile-menu-item:hover {
  background: rgba(var(--primary-rgb), 0.05);
}

.profile-menu-item svg {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
}

.profile-menu-item span {
  flex: 1;
}

.profile-menu-item .arrow {
  color: var(--text-muted);
}

.profile-menu-item.danger {
  color: var(--danger);
}

.profile-menu-item.danger svg {
  color: var(--danger);
}

/* ============================================
   Map Picker
   ============================================ */
.map-picker {
  height: 300px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.map-picker-controls {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.coords-display {
  display: flex;
  gap: var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: var(--space-sm);
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.animate-fade-in-up {
  animation: fadeInUp 0.5s ease forwards;
}

.animate-fade-in {
  animation: fadeIn 0.3s ease forwards;
}

.animate-slide-in {
  animation: slideIn 0.4s ease forwards;
}

/* Stagger animation delays */
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
.stagger-5 { animation-delay: 0.5s; }

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 1200px) {
  .dashboard {
    grid-template-columns: 1fr;
  }
  
  .dashboard-sidebar,
  .dashboard-right {
    display: none;
  }
}

@media (max-width: 768px) {
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .page-title {
    font-size: 1.5rem;
  }
  
  .navbar-nav {
    display: none;
  }
  
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
  position: fixed;
  top: 80px;
  right: var(--space-lg);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 280px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
}

.toast.success {
  border-left: 3px solid var(--accent);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.warning {
  border-left: 3px solid var(--warning);
}

.toast-icon {
  width: 20px;
  height: 20px;
}

.toast.success .toast-icon { color: var(--accent); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }

/* ============================================
   Empty State
   ============================================ */
.empty-state {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--text-secondary);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: var(--space-md);
  opacity: 0.5;
}

.empty-state h3 {
  margin-bottom: var(--space-sm);
  color: var(--text-primary);
}

/* ============================================
   Loading Skeleton
   ============================================ */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 25%,
    var(--bg-secondary) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   Page Layouts
   ============================================ */
.page-layout {
  padding: var(--space-lg);
}

.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
  gap: var(--space-md);
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* Search Input */
.search-input {
  position: relative;
}

.search-input svg {
  position: absolute;
  left: var(--space-md);
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.search-input input {
  padding-left: 40px;
  width: 250px;
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden { display: none !important; }
.visible { display: block !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-center { text-align: center; }
.text-right { text-align: right; }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.w-full { width: 100%; }

/* Leaflet overrides for dark theme */
[data-theme="dark"] .leaflet-control-zoom a {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--border-color);
}

[data-theme="dark"] .leaflet-control-zoom a:hover {
  background: var(--bg-tertiary);
  color: var(--primary);
}

[data-theme="dark"] .leaflet-control-attribution {
  background: rgba(10, 14, 23, 0.8);
  color: var(--text-muted);
}
