/* ==============================================================================
   AGRI-TRACE COLD CHAIN - DESIGN SYSTEM
   Style: Organic Biophilic & Modern Supply Chain
   Standard: UI/UX Pro Max
   Typography: Plus Jakarta Sans
   ============================================================================== */

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

:root {
  /* Color Palette - Organic Biophilic */
  --color-primary: #15803d;
  --color-primary-hover: #166534;
  --color-primary-active: #14532d;
  --color-primary-light: #dcfce7;
  --color-primary-surface: #f0fdf4;
  
  --color-secondary: #22c55e;
  --color-accent: #a16207;
  --color-accent-light: #fef3c7;
  
  --color-bg: #f8faf9;
  --color-surface: #ffffff;
  --color-surface-hover: #fcfdfc;
  
  --color-text-main: #0f172a;
  --color-text-muted: #64748b;
  --color-text-light: #94a3b8;
  
  --color-border: #e2e8f0;
  --color-border-green: #bbf7d0;
  --color-border-focus: #15803d;
  
  /* Status Semantics */
  --color-success: #16a34a;
  --color-success-bg: #dcfce7;
  --color-success-border: #86efac;
  
  --color-warning: #d97706;
  --color-warning-bg: #fef3c7;
  --color-warning-border: #fde68a;
  
  --color-danger: #dc2626;
  --color-danger-bg: #fee2e2;
  --color-danger-border: #fca5a5;

  --color-info: #0284c7;
  --color-info-bg: #e0f2fe;
  --color-info-border: #bae6fd;
  
  /* Spacing & Radii */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  /* Natural Depth Shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.08), 0 1px 2px -1px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 4px 20px -2px rgba(22, 101, 52, 0.06), 0 2px 6px -1px rgba(0, 0, 0, 0.03);
  --shadow-hover: 0 12px 28px -4px rgba(22, 101, 52, 0.12), 0 4px 10px -2px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
  
  /* Transitions */
  --transition-fast: all 0.15s cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--color-text-main);
  background-color: var(--color-bg);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button, input, select, textarea {
  font: inherit;
}

/* Accessible focus ring */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ==============================================================================
   Shared Navigation Bar (App Header)
   ============================================================================== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border-green);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  transition: var(--transition-fast);
}

.brand-link:hover {
  opacity: 0.9;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(21, 128, 61, 0.25);
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-primary-active);
  line-height: 1.2;
}

.brand-tag {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Navigation Tabs */
.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--color-bg);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-muted);
  transition: var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
}

.nav-item svg {
  transition: var(--transition-fast);
}

.nav-item:hover {
  color: var(--color-primary);
  background: rgba(255, 255, 255, 0.8);
}

.nav-item.active {
  color: var(--color-primary-active);
  background: var(--color-surface);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

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

/* User Controls Section */
.user-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 6px;
  background: var(--color-primary-surface);
  border: 1px solid var(--color-border-green);
  border-radius: var(--radius-full);
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}

.user-meta {
  display: flex;
  flex-direction: column;
}

.user-email {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-main);
  line-height: 1.2;
}

.user-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.badge-org {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-primary-active);
  background: rgba(21, 128, 61, 0.1);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
}

.badge-role {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-accent);
  background: var(--color-accent-light);
  padding: 1px 6px;
  border-radius: var(--radius-xs);
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.btn-logout:hover {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border-color: var(--color-danger-border);
}

/* ==============================================================================
   Page Containers & Common Components
   ============================================================================== */
.main-wrapper {
  max-width: 1200px;
  margin: 32px auto;
  padding: 0 24px 64px 24px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.page-title-group h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--color-text-main);
  margin-bottom: 4px;
}

.page-subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
}

/* Metric / Stat Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition-fast);
}

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

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

.stat-icon.green {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.stat-icon.amber {
  background: var(--color-warning-bg);
  color: var(--color-warning);
}

.stat-icon.blue {
  background: var(--color-info-bg);
  color: var(--color-info);
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--color-text-main);
  line-height: 1.1;
}

.stat-label {
  font-size: 13px;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-top: 2px;
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
  color: white;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(21, 128, 61, 0.25);
  transition: var(--transition-fast);
  min-height: 44px;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(21, 128, 61, 0.35);
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-main);
  font-size: 14px;
  font-weight: 600;
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: var(--transition-fast);
  min-height: 44px;
}

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

/* Status Badges */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-pill.success {
  background: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
}

.status-pill.success .status-dot {
  background: var(--color-success);
  box-shadow: 0 0 0 2px rgba(22, 163, 74, 0.2);
}

.status-pill.warning {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning-border);
}

.status-pill.warning .status-dot {
  background: var(--color-warning);
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.2);
}

.status-pill.danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger-border);
}

.status-pill.danger .status-dot {
  background: var(--color-danger);
}

/* Alerts */
.alert-box {
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: slideDown 0.2s ease-out;
}

.alert-success {
  background: var(--color-success-bg);
  border: 1px solid var(--color-success-border);
  color: #14532d;
}

.alert-error {
  background: var(--color-danger-bg);
  border: 1px solid var(--color-danger-border);
  color: #7f1d1d;
}

.alert-info {
  background: var(--color-info-bg);
  border: 1px solid var(--color-info-border);
  color: #0c4a6e;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Responsive adjustments */
@media (max-width: 820px) {
  .header-container {
    height: auto;
    padding: 14px 20px;
    flex-wrap: wrap;
  }
  
  .nav-links {
    order: 3;
    width: 100%;
    justify-content: center;
    margin-top: 4px;
  }
  
  .user-email {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
