:root {
  /* Core Colors - Dark Theme */
  --bg-body: #09090b;
  --bg-card: #18181b;
  --bg-card-hover: #27272a;
  --bg-input: #27272a;
  --border-color: #3f3f46;
  
  /* Brand Colors - Agri-Tech */
  --primary: #10b981; /* Emerald Green */
  --primary-hover: #059669;
  --primary-glow: rgba(16, 185, 129, 0.3);
  
  --accent-blue: #3b82f6; /* Logistics */
  --accent-gold: #f59e0b; /* Finance/Wheat */
  --accent-purple: #8b5cf6; /* Tech/SaaS */
  --accent-red: #ef4444; /* Alerts */

  /* Text Colors */
  --text-main: #fafafa;
  --text-muted: #a1a1aa;
  --text-dark: #18181b;

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Borders & Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 20px var(--primary-glow);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden; /* Prevent horizontal scroll */
  width: 100%;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }

p { font-size: 14px; color: var(--text-muted); }
small { font-size: 12px; color: var(--text-muted); }

a { text-decoration: none; color: inherit; transition: 0.2s; }
ul { list-style: none; }

/* Layout Structure */
.app-container {
  display: flex;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--bg-card);
  border-right: 1px solid var(--border-color);
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: var(--spacing-lg);
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-xl);
  color: var(--primary);
  font-size: 20px;
  font-weight: 800;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
}

.nav-item:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.1) 0%, transparent 100%);
  color: var(--primary);
  border-left: 3px solid var(--primary);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border-color);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.avatar {
  width: 40px;
  height: 40px;
  background: var(--bg-input);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: var(--spacing-xl);
  max-width: 1600px;
  margin: 0 auto;
}

/* Header */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-xl);
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 8px 16px;
  border-radius: var(--radius-full);
  width: 100%;
  max-width: 400px;
  color: var(--text-muted);
}

.search-bar input {
  background: transparent;
  border: none;
  color: var(--text-main);
  margin-left: var(--spacing-sm);
  width: 100%;
  outline: none;
}

.location-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent-blue);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Grid Layouts */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--spacing-lg);
}

.col-left {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

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

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* Stats Cards */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-lg);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  margin: var(--spacing-xs) 0;
  color: var(--text-main);
}

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

.stat-icon.green { background: rgba(16, 185, 129, 0.15); color: var(--primary); }
.stat-icon.gold { background: rgba(245, 158, 11, 0.15); color: var(--accent-gold); }
.stat-icon.blue { background: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }

/* Quick Actions / Services */
.services-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--spacing-md);
}

.service-item {
  background: var(--bg-input);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--spacing-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.service-item:hover {
  border-color: var(--primary);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
}

.service-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--bg-body);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  margin-bottom: 4px;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

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

.table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}

.table td {
  padding: var(--spacing-md) 0;
  font-size: 14px;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-color);
}

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

/* Warehouse Discovery */
.warehouse-card {
  display: flex;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-md);
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-color);
}

.warehouse-img {
  width: 80px;
  height: 80px;
  background: #3f3f46;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.warehouse-info {
  flex: 1;
}

.warehouse-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 4px;
}

.warehouse-name {
  font-weight: 600;
  font-size: 15px;
}

.warehouse-meta {
  display: flex;
  gap: var(--spacing-md);
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Badges */
.badge {
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge.success { background: rgba(16, 185, 129, 0.2); color: var(--primary); }
.badge.warning { background: rgba(245, 158, 11, 0.2); color: var(--accent-gold); }
.badge.info { background: rgba(59, 130, 246, 0.2); color: var(--accent-blue); }
.badge.purple { background: rgba(139, 92, 246, 0.2); color: var(--accent-purple); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  border-color: var(--text-muted);
  background: var(--bg-input);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* Market Ticker */
.market-ticker-item {
  display: flex;
  justify-content: space-between;
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--border-color);
}
.market-ticker-item:last-child { border: none; }
.price-up { color: var(--primary); }
.price-down { color: var(--accent-red); }

/* Utility */
.flex-between { display: flex; justify-content: space-between; width: 100%; }
.text-right { text-align: right; }
.mt-4 { margin-top: 16px; }

/* Placeholder Map */
.map-placeholder {
  width: 100%;
  height: 200px;
  background: #27272a;
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  margin-bottom: var(--spacing-md);
}
.map-dot {
  width: 12px;
  height: 12px;
  background: var(--primary);
  border-radius: 50%;
  position: absolute;
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.3);
}

/* Mobile Responsiveness */
@media (max-width: 1024px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: var(--spacing-md);
  }

  .nav-menu {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: var(--spacing-sm);
    gap: var(--spacing-sm);
    /* Hide scrollbar for cleaner look */
    -ms-overflow-style: none;  /* IE and Edge */
    scrollbar-width: none;  /* Firefox */
  }
  
  .nav-menu::-webkit-scrollbar {
    display: none;
  }

  .nav-item {
    white-space: nowrap;
    padding: 8px 12px;
    font-size: 13px;
  }

  .sidebar-footer {
    display: none; /* Hide user profile in sidebar on mobile to save space */
  }
  
  .brand {
    margin-bottom: var(--spacing-md);
  }

  .main-content {
    padding: var(--spacing-md);
  }
  
  .dashboard-grid {
    grid-template-columns: 1fr; 
  }
}

@media (max-width: 768px) {
  .top-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-lg);
  }

  .top-header > div:last-child {
    width: 100%;
    flex-direction: column;
    align-items: stretch !important; /* Override inline style */
    gap: var(--spacing-md);
  }

  .search-bar {
    width: 100%;
  }

  .location-badge {
    justify-content: center;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  /* Adjust Warehouse Cards for mobile */
  .warehouse-card {
    flex-direction: column;
  }

  .warehouse-img {
    width: 100%;
    height: 160px;
  }
  
  .warehouse-img svg {
    margin-top: 68px !important; /* Center icon vertically in taller container */
  }

  .warehouse-meta {
    flex-wrap: wrap;
  }
  
  /* Services Grid - 2 cols is fine, but maybe tighten padding */
  .services-grid {
    gap: var(--spacing-sm);
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: var(--spacing-md) var(--spacing-sm); /* Reduce side padding */
  }

  /* Header adjustments */
  .top-header {
    margin-bottom: var(--spacing-md);
  }

  .top-header > div:last-child {
    gap: 12px;
  }
  
  h1 {
    font-size: 20px;
  }
  
  .search-bar {
    max-width: 100%;
  }

  /* Compact Cards for Mobile */
  .card {
    padding: var(--spacing-md);
  }

  /* Stats adjustments */
  .stat-card {
    padding: var(--spacing-md);
    flex-direction: row;
    align-items: flex-start;
  }
  
  .stat-value {
    font-size: 24px;
  }

  /* Warehouse Card Mobile Fixes */
  .warehouse-card {
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
  }

  .warehouse-img {
    height: 140px;
  }
  
  .warehouse-img svg {
    margin-top: 58px !important;
  }

  /* Action Buttons in Cards */
  .warehouse-card .flex-between {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }
  
  .warehouse-card .btn,
  .warehouse-card .badge {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  /* Nav Menu Scroll Hints */
  .nav-menu {
    padding-bottom: 0;
    margin-bottom: var(--spacing-md);
    mask-image: linear-gradient(to right, black 90%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
  }

  /* Table Mobile Optimization */
  .table th, .table td {
    padding: 12px 8px;
    font-size: 13px;
  }
  
  /* Ensure badge text doesn't wrap awkwardly */
  .badge {
    white-space: nowrap;
  }
}
