/* ============================================================
   BASE.CSS — Design System (Dark Premium Theme)
   ─────────────────────────────────────────────
   🎨 ALIGNED with Foodly Design System
      Deep Navy + Vivid Cyan · Material Icons · Inter Font
   ============================================================ */

/* ── CSS Custom Properties ── */
:root {
  /* ─── Brand Colors (Foodly identical) ─── */
  --brand-primary: #06f9f9;
  --brand-secondary: #0d9488;
  --brand-primary-dark: #05d6d6;
  --text-on-brand: #0f2323;

  /* ─── Brand Opacity Variants (via RGB) ─── */
  --brand-rgb: 6, 249, 249;
  --brand-sec-rgb: 13, 148, 136;
  --brand-glow: rgba(var(--brand-rgb), 0.25);
  --brand-tint-03: rgba(var(--brand-rgb), 0.03);
  --brand-tint-04: rgba(var(--brand-rgb), 0.04);
  --brand-tint-05: rgba(var(--brand-rgb), 0.05);
  --brand-tint-06: rgba(var(--brand-rgb), 0.06);
  --brand-tint-08: rgba(var(--brand-rgb), 0.08);
  --brand-tint-10: rgba(var(--brand-rgb), 0.10);
  --brand-tint-12: rgba(var(--brand-rgb), 0.12);
  --brand-tint-15: rgba(var(--brand-rgb), 0.15);
  --brand-tint-20: rgba(var(--brand-rgb), 0.20);
  --brand-tint-25: rgba(var(--brand-rgb), 0.25);
  --brand-tint-30: rgba(var(--brand-rgb), 0.30);

  /* ─── Surfaces — Deep Navy ─── */
  --bg-body: #020617;
  --bg-body-gradient: #0f172a;
  --bg-sidebar: rgba(15, 23, 42, 0.6);
  --bg-card: rgba(255, 255, 255, 0.03);
  --bg-card-hover: rgba(255, 255, 255, 0.05);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --bg-input: rgba(255, 255, 255, 0.05);
  --bg-toolbar: rgba(15, 23, 42, 0.3);
  --bg-surface: rgba(255, 255, 255, 0.05);

  /* ─── Borders ─── */
  --border-subtle: rgba(255, 255, 255, 0.1);
  --border-glow: rgba(var(--brand-rgb), 0.3);

  /* ─── Text ─── */
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --text-tertiary: #94a3b8;

  /* ─── Semantic States ─── */
  --success: #22c55e;
  --success-light: #4ade80;
  --success-dark: #16a34a;
  --warning: #fbbf24;
  --warning-dark: #f59e0b;
  --danger: #f43f5e;
  --danger-dark: #e11d48;
  --info: #3b82f6;
  --info-dark: #2563eb;
  --purple: #8b5cf6;
  --teal: #10b981;

  /* ─── State Tint Backgrounds ─── */
  --bg-success-tint: rgba(34, 197, 94, 0.1);
  --bg-success-tint-hover: rgba(34, 197, 94, 0.2);
  --bg-warning-tint: rgba(251, 191, 36, 0.1);
  --bg-warning-tint-hover: rgba(251, 191, 36, 0.2);
  --bg-danger-tint: rgba(244, 63, 94, 0.1);
  --bg-danger-tint-hover: rgba(244, 63, 94, 0.2);
  --bg-info-tint: rgba(59, 130, 246, 0.1);
  --bg-info-tint-hover: rgba(59, 130, 246, 0.2);
  --bg-purple-tint: rgba(139, 92, 246, 0.1);

  /* ─── Sensor Colors (IoT specific) ─── */
  --color-temp: #FF6B35;
  --color-ph: var(--brand-primary);
  --color-tds: #FBBF24;
  --color-co2: #38BDF8;
  --color-humidity: #A78BFA;
  --color-ambient: #FB7185;

  /* ─── Neutral Scale (Slate) ─── */
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* ─── Spacing / Radius ─── */
  --sidebar-width: 215px;
  --toolbar-height: 56px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* ─── Shadows ─── */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.37);
  --shadow-glow: 0 0 20px rgba(var(--brand-rgb), 0.2);
  --shadow-glow-lg: 0 0 30px rgba(var(--brand-rgb), 0.3);

  /* ─── Transitions ─── */
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

  /* ─── Font ─── */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

html,
body {
  min-height: 100%;
  font-family: var(--font-family);
  font-size: 14px;
  background-color: var(--bg-body);
  background-image:
    radial-gradient(at 0% 0%, rgba(6, 249, 249, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(79, 70, 229, 0.1) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(6, 249, 249, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

::selection {
  background: rgba(6, 249, 249, 0.3);
  color: #fff;
}

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

.text-mono {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.text-sm {
  font-size: 13px;
}

.text-xs {
  font-size: 11px;
}

.text-lg {
  font-size: 16px;
}

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

.text-secondary {
  color: var(--text-secondary);
}

.text-brand {
  color: var(--brand-primary);
}

/* ── Links ── */
a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--brand-primary-dark);
}

/* ── Buttons (Foodly style) ── */
.btn-neon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  background: var(--brand-primary);
  color: var(--text-on-brand);
  font-weight: 700;
  font-size: 13px;
  border-radius: var(--radius-xl);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: -0.01em;
}

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

.btn-neon:active {
  transform: translateY(0) scale(0.97);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--slate-400);
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  transform: translateY(-1px);
}

/* Backward compat (old btn class) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 22px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--slate-400);
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font-family);
}

.btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--brand-primary);
  color: var(--text-on-brand);
  font-weight: 700;
  border: none;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: var(--shadow-glow);
  color: var(--text-on-brand);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 11px;
  border-radius: var(--radius-md);
}

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-success {
  background: var(--bg-success-tint);
  color: var(--success);
}

.badge-warning {
  background: var(--bg-warning-tint);
  color: var(--warning);
}

.badge-danger {
  background: var(--bg-danger-tint);
  color: var(--danger);
}

.badge-info {
  background: var(--bg-info-tint);
  color: var(--info);
}

.badge-accent {
  background: var(--brand-tint-10);
  color: var(--brand-primary);
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.badge-dot.pulse {
  animation: pulse 2s ease-in-out infinite;
}

/* ── Form Elements (Foodly glass) ── */
input,
select {
  font-family: var(--font-family);
  font-size: 13px;
  padding: 10px 16px;
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 1px var(--brand-primary);
  background: rgba(255, 255, 255, 0.1);
}

input::placeholder {
  color: var(--slate-500);
}

select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color-scheme: dark;
}

select option {
  background: #0f172a;
  color: var(--text-primary);
}

/* Inputs/selects inside forms go full width */
.chart-card input,
.chart-card select,
.compare-slot select {
  width: 100%;
}

/* Toolbar selects stay compact */
.table-toolbar-right select {
  min-width: 120px;
  width: auto;
  padding: 8px 32px 8px 12px;
  min-height: 36px;
  border-radius: var(--radius-md);
}

button {
  outline: none !important;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

/* ── Scrollbar — hidden but scrollable ── */
html::-webkit-scrollbar,
body::-webkit-scrollbar {
  display: none;
}

html,
body {
  scrollbar-width: none;
}

/* ── Utilities ── */
.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

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

.gap-xs {
  gap: 4px;
}

.gap-sm {
  gap: 8px;
}

.gap-md {
  gap: 16px;
}

.gap-lg {
  gap: 24px;
}

.gap-xl {
  gap: 32px;
}

.w-full {
  width: 100%;
}

.hidden {
  display: none !important;
}

/* ── Animations ── */
@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.5;
    transform: scale(0.95);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.96);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

.animate-fade-in {
  animation: fadeIn 0.35s ease-out;
}

/* Staggered card entry (premium effect) */
.metrics-grid>.metric-card:nth-child(1) {
  animation: fadeIn 0.35s ease-out 0.05s both;
}

.metrics-grid>.metric-card:nth-child(2) {
  animation: fadeIn 0.35s ease-out 0.10s both;
}

.metrics-grid>.metric-card:nth-child(3) {
  animation: fadeIn 0.35s ease-out 0.15s both;
}

.metrics-grid>.metric-card:nth-child(4) {
  animation: fadeIn 0.35s ease-out 0.20s both;
}

.metrics-grid>.metric-card:nth-child(5) {
  animation: fadeIn 0.35s ease-out 0.25s both;
}

.metrics-grid>.metric-card:nth-child(6) {
  animation: fadeIn 0.35s ease-out 0.30s both;
}

/* Smooth scroll to top on navigation */
html {
  scroll-behavior: smooth;
}

/* Live pulse indicator */
@keyframes livePulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: livePulse 2s ease-in-out infinite;
  display: inline-block;
}

/* Skeleton loading */
@keyframes shimmer {
  0% {
    background-position: -400px 0;
  }

  100% {
    background-position: 400px 0;
  }
}

.skeleton {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.03) 25%, rgba(255, 255, 255, 0.08) 50%, rgba(255, 255, 255, 0.03) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-md);
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px;
  min-height: 300px;
}

.empty-state-icon {
  font-size: 56px !important;
  width: 56px !important;
  height: 56px !important;
  color: var(--text-muted) !important;
  opacity: 0.4;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
}

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

/* ── Glow Divider (Foodly) ── */
.glow-divider {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand-primary), transparent);
  opacity: 0.3;
  margin: 16px 0;
}

/* ── Nav badge (process running indicator) ── */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 700;
  padding: 0 5px;
  margin-left: auto;
  line-height: 1;
}

.nav-badge.active {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

/* ── Quick Stat Inline ── */
.stat-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.stat-inline .material-icons {
  font-size: 14px;
}

.stat-inline strong {
  color: var(--text-primary);
  font-weight: 700;
}

/* ============================================================
   LIGHT THEME
   ============================================================ */
[data-theme="light"] {
  --bg-body: #f1f5f9;
  --bg-body-gradient: #e2e8f0;
  --bg-sidebar: rgba(255, 255, 255, 0.95);
  --bg-card: rgba(0, 0, 0, 0.02);
  --bg-card-hover: rgba(0, 0, 0, 0.04);
  --bg-glass: rgba(255, 255, 255, 0.8);
  --bg-input: rgba(0, 0, 0, 0.04);
  --bg-toolbar: rgba(255, 255, 255, 0.85);
  --bg-surface: rgba(0, 0, 0, 0.03);

  --border-subtle: rgba(0, 0, 0, 0.08);
  --border-glow: rgba(var(--brand-sec-rgb), 0.3);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-tertiary: #475569;

  --brand-tint-03: rgba(var(--brand-sec-rgb), 0.04);
  --brand-tint-04: rgba(var(--brand-sec-rgb), 0.05);
  --brand-tint-06: rgba(var(--brand-sec-rgb), 0.06);
  --brand-tint-08: rgba(var(--brand-sec-rgb), 0.08);
  --brand-tint-10: rgba(var(--brand-sec-rgb), 0.10);

  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);

  --slate-900: #f8fafc;
}

[data-theme="light"] .sidebar {
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .sidebar-brand-title {
  color: #0f172a;
}

[data-theme="light"] .sidebar-brand {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .sidebar-footer {
  border-top-color: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .sidebar-device-name {
  color: #0f172a;
}

[data-theme="light"] .nav-item {
  color: #475569;
}

[data-theme="light"] .nav-item:hover {
  background: rgba(0, 0, 0, 0.04);
  color: #0f172a;
}

[data-theme="light"] .nav-item.active {
  background: rgba(var(--brand-sec-rgb), 0.08);
  color: var(--brand-secondary);
  border-right-color: var(--brand-secondary);
}

[data-theme="light"] .nav-item.active .nav-icon {
  color: var(--brand-secondary);
}

[data-theme="light"] .metric-card,
[data-theme="light"] .chart-card,
[data-theme="light"] .process-bar,
[data-theme="light"] .data-table-wrapper {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .page-header {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .data-table th {
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .data-table tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

[data-theme="light"] .data-table tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.01);
}

[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .compare-selector {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .mobile-menu-btn {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.1);
  color: #334155;
}

/* ── Theme Toggle Switch ── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.theme-toggle-track {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  position: relative;
  transition: all 0.3s ease;
}

.theme-toggle-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--brand-primary);
  position: absolute;
  top: 2px;
  left: 2px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.theme-toggle-track.active .theme-toggle-thumb {
  left: 22px;
  background: var(--brand-secondary);
}

[data-theme="light"] .theme-toggle-track {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.1);
}