/* ===== Blue2Scale — Main Stylesheet ===== */

/* ===== CSS VARIABLES ===== */
:root {
  --background: 220 20% 97%;
  --foreground: 222 47% 11%;
  --card: 0 0% 100%;
  --card-foreground: 222 47% 11%;
  --popover: 0 0% 100%;
  --popover-foreground: 222 47% 11%;
  --primary: 210 100% 50%;
  --primary-foreground: 0 0% 100%;
  --secondary: 220 14% 96%;
  --secondary-foreground: 222 47% 11%;
  --muted: 220 14% 96%;
  --muted-foreground: 220 9% 46%;
  --accent: 220 14% 96%;
  --accent-foreground: 222 47% 11%;
  --destructive: 0 84% 60%;
  --destructive-foreground: 0 0% 100%;
  --border: 220 13% 91%;
  --input: 220 13% 91%;
  --ring: 210 100% 50%;
  --radius: 0.5rem;
  --health-good: 160 84% 39%;
  --health-moderate: 38 92% 50%;
  --health-concern: 0 84% 60%;

  /* Sidebar */
  --sidebar-bg: 220 20% 97%;
  --sidebar-fg: 220 9% 46%;
  --sidebar-title: 222 47% 11%;
  --sidebar-muted: 220 9% 65%;
  --sidebar-border: 220 13% 91%;
  --sidebar-hover-bg: 220 14% 93%;
  --sidebar-hover-fg: 222 47% 11%;

  /* Gradient presets */
  --grad-blue: linear-gradient(135deg, #3b82f6, #1d4ed8);
  --grad-teal: linear-gradient(135deg, #14b8a6, #0d9488);
  --grad-green: linear-gradient(135deg, #22c55e, #16a34a);
  --grad-amber: linear-gradient(135deg, #f59e0b, #d97706);
  --grad-red: linear-gradient(135deg, #ef4444, #dc2626);
  --grad-purple: linear-gradient(135deg, #8b5cf6, #7c3aed);
  --grad-pink: linear-gradient(135deg, #ec4899, #db2777);
  --grad-cyan: linear-gradient(135deg, #06b6d4, #0891b2);
}

.dark {
  --background: 222 47% 6%;
  --foreground: 210 40% 92%;
  --card: 222 40% 10%;
  --card-foreground: 210 40% 92%;
  --popover: 222 40% 10%;
  --popover-foreground: 210 40% 92%;
  --primary: 213 94% 58%;
  --primary-foreground: 0 0% 100%;
  --secondary: 217 33% 15%;
  --secondary-foreground: 210 40% 92%;
  --muted: 217 33% 13%;
  --muted-foreground: 215 20% 55%;
  --accent: 217 33% 15%;
  --accent-foreground: 210 40% 92%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 100%;
  --border: 217 33% 17%;
  --input: 217 33% 17%;
  --ring: 213 94% 58%;
  --health-good: 160 84% 44%;
  --health-moderate: 38 92% 55%;
  --health-concern: 0 72% 55%;

  --sidebar-bg: 222 47% 7%;
  --sidebar-fg: 215 20% 70%;
  --sidebar-title: 210 40% 92%;
  --sidebar-muted: 215 20% 35%;
  --sidebar-border: 215 20% 13%;
  --sidebar-hover-bg: 217 33% 13%;
  --sidebar-hover-fg: 210 40% 92%;

  --grad-blue: linear-gradient(135deg, #2563eb, #1e40af);
  --grad-teal: linear-gradient(135deg, #0d9488, #0f766e);
  --grad-green: linear-gradient(135deg, #16a34a, #15803d);
  --grad-amber: linear-gradient(135deg, #d97706, #b45309);
  --grad-red: linear-gradient(135deg, #dc2626, #b91c1c);
  --grad-purple: linear-gradient(135deg, #7c3aed, #6d28d9);
  --grad-pink: linear-gradient(135deg, #db2777, #be185d);
  --grad-cyan: linear-gradient(135deg, #0891b2, #0e7490);
}

/* ===== BASE ===== */
*, *::before, *::after {
  border-color: hsl(var(--border));
  box-sizing: border-box;
}
body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-feature-settings: "rlig" 1, "calt" 1;
  margin: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== GRADIENT STAT CARDS ===== */
.stat-card {
  border-radius: 0.5rem;
  padding: 1.25rem;
  color: white;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}
.stat-card-blue { background: var(--grad-blue); }
.stat-card-teal { background: var(--grad-teal); }
.stat-card-green { background: var(--grad-green); }
.stat-card-amber { background: var(--grad-amber); }
.stat-card-red { background: var(--grad-red); }
.stat-card-purple { background: var(--grad-purple); }
.stat-card-pink { background: var(--grad-pink); }
.stat-card-cyan { background: var(--grad-cyan); }
.stat-card .stat-card-bg-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.15;
}

/* ===== CARD ENHANCEMENTS ===== */
.card-shadow {
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.card-shadow:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
}
.dark .card-shadow {
  box-shadow: 0 1px 3px rgba(0,0,0,0.2), 0 1px 2px rgba(0,0,0,0.15);
}
.dark .card-shadow:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.3), 0 2px 4px rgba(0,0,0,0.2);
}

/* Card accent borders */
.card-accent-blue { border-top: 3px solid #3b82f6; }
.card-accent-teal { border-top: 3px solid #14b8a6; }
.card-accent-green { border-top: 3px solid #22c55e; }
.card-accent-amber { border-top: 3px solid #f59e0b; }
.card-accent-red { border-top: 3px solid #ef4444; }
.card-accent-purple { border-top: 3px solid #8b5cf6; }
.card-accent-pink { border-top: 3px solid #ec4899; }
.card-accent-cyan { border-top: 3px solid #06b6d4; }

/* ===== TOPBAR ===== */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  height: 3.5rem;
  align-items: center;
  gap: 1rem;
  padding: 0 1rem;
  background: hsl(var(--card));
  border-bottom: 1px solid hsl(var(--border));
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
@media (min-width: 1024px) {
  .admin-topbar { padding: 0 1.5rem; }
}
.dark .admin-topbar {
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* ===== METRIC CARD ===== */
.metric-card {
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  padding: 0.875rem;
  transition: all 0.2s;
}
.metric-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  border-color: hsl(var(--primary) / 0.3);
}
.dark .metric-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* ===== SIDEBAR ===== */
.app-sidebar {
  background: hsl(var(--sidebar-bg));
  color: hsl(var(--sidebar-fg));
  border-right: 1px solid hsl(var(--sidebar-border));
}
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  border-radius: 0.375rem;
  margin: 0 0.5rem 0.125rem;
  transition: all 0.15s;
  text-decoration: none;
  color: hsl(var(--sidebar-fg));
}
.sidebar-nav-item:hover {
  background: hsl(var(--sidebar-hover-bg));
  color: hsl(var(--sidebar-hover-fg));
}
.sidebar-nav-item.active {
  background: hsl(var(--primary));
  color: white;
  box-shadow: 0 4px 6px -1px hsl(var(--primary) / 0.3);
}
.sidebar-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.5rem 1rem;
  margin-top: 0.75rem;
  color: hsl(var(--sidebar-muted));
}

/* ===== MOBILE TABS ===== */
.mobile-tabs {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  border-top: 1px solid hsl(var(--border));
  background: hsl(var(--card) / 0.95);
  backdrop-filter: blur(12px);
  box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}
@media (min-width: 640px) {
  .mobile-tabs { display: none; }
}
.mobile-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.625rem 0;
  font-size: 10px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s;
  color: hsl(var(--muted-foreground));
}
.mobile-tab.active {
  color: #3b82f6;
}
.mobile-tab i { font-size: 20px; }

/* ===== BREADCRUMB ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
}
.breadcrumb a {
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  transition: color 0.15s;
}
.breadcrumb a:hover { color: hsl(var(--primary)); }
.breadcrumb .separator { color: hsl(var(--muted-foreground) / 0.5); }
.breadcrumb .current { color: hsl(var(--foreground)); font-weight: 500; }

/* ===== TABLE ===== */
.admin-table { width: 100%; font-size: 0.875rem; }
.admin-table thead { background: hsl(var(--muted)); }
.admin-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(var(--muted-foreground));
}
.admin-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid hsl(var(--border));
}
.admin-table tbody tr { transition: background 0.15s; }
.admin-table tbody tr:hover { background: hsl(var(--muted) / 0.5); }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  line-height: 1.5;
}
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-primary {
  background: linear-gradient(to right, #3b82f6, #1d4ed8);
  color: white;
  border: 0;
  box-shadow: 0 1px 3px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover {
  background: linear-gradient(to right, #2563eb, #1e40af);
}
.btn-outline {
  background: transparent;
  border: 1px solid hsl(var(--border));
  color: hsl(var(--foreground));
}
.btn-outline:hover {
  background: hsl(var(--accent));
}
.btn-destructive {
  background: hsl(var(--destructive));
  color: white;
  border: 0;
}
.btn-destructive:hover { opacity: 0.9; }
.btn-ghost {
  background: transparent;
  border: 0;
  color: hsl(var(--foreground));
}
.btn-ghost:hover { background: hsl(var(--accent)); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-lg { padding: 0.625rem 1.5rem; font-size: 1rem; }

/* ===== FORM INPUTS ===== */
.form-input, .form-select {
  width: 100%;
  border-radius: 0.375rem;
  border: 1px solid hsl(var(--input));
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus, .form-select:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 2px hsl(var(--ring) / 0.2);
}

/* ===== CARD COMPONENT ===== */
.card {
  border-radius: 0.5rem;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
}
.card-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1.25rem 1.5rem 0;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}
.card-content {
  padding: 1rem 1.5rem 1.5rem;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toast-in 0.3s ease;
  color: hsl(var(--foreground));
}
.toast-success { border-left: 3px solid #22c55e; }
.toast-error { border-left: 3px solid #ef4444; }
.toast-info { border-left: 3px solid #3b82f6; }

/* ===== ANIMATIONS ===== */
@keyframes fade-in-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.3); opacity: 0; }
  100% { transform: scale(1); opacity: 0.3; }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes checkmark-circle {
  0% { transform: scale(0); opacity: 0; }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes checkmark-check {
  0% { stroke-dashoffset: 50; }
  100% { stroke-dashoffset: 0; }
}
@keyframes measuring-dots {
  0%, 20% { opacity: 0; }
  50% { opacity: 1; }
  80%, 100% { opacity: 0; }
}

.animate-fade-in { animation: fade-in 0.5s ease both; }
.animate-fade-in-up { animation: fade-in-up 0.4s ease both; }
.animate-pulse-ring { animation: pulse-ring 3s ease-in-out infinite; }
.animate-spin { animation: spin 1s linear infinite; }
.animate-checkmark-circle { animation: checkmark-circle 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
.animate-checkmark-check { stroke-dasharray: 50; stroke-dashoffset: 50; animation: checkmark-check 0.4s ease-out 0.3s forwards; }

.stagger-children > * { opacity: 0; animation: fade-in-up 0.4s ease-out forwards; }
.stagger-children > *:nth-child(1) { animation-delay: 0ms; }
.stagger-children > *:nth-child(2) { animation-delay: 50ms; }
.stagger-children > *:nth-child(3) { animation-delay: 100ms; }
.stagger-children > *:nth-child(4) { animation-delay: 150ms; }
.stagger-children > *:nth-child(5) { animation-delay: 200ms; }
.stagger-children > *:nth-child(6) { animation-delay: 250ms; }
.stagger-children > *:nth-child(7) { animation-delay: 300ms; }
.stagger-children > *:nth-child(8) { animation-delay: 350ms; }

.measuring-dots span:nth-child(1) { animation: measuring-dots 1.4s infinite 0s; }
.measuring-dots span:nth-child(2) { animation: measuring-dots 1.4s infinite 0.2s; }
.measuring-dots span:nth-child(3) { animation: measuring-dots 1.4s infinite 0.4s; }

/* Main page transition */
main { animation: fade-in-up 0.25s ease-out; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: hsl(var(--muted-foreground) / 0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: hsl(var(--muted-foreground) / 0.35); }

/* ===== PROGRESS BAR ===== */
.progress-bar { height: 0.5rem; border-radius: 9999px; overflow: hidden; background: hsl(var(--muted)); }
.progress-bar-fill { height: 100%; border-radius: 9999px; transition: width 0.7s ease-out; }

/* ===== SKELETON ===== */
.skeleton-shimmer {
  background: linear-gradient(90deg, hsl(var(--muted)) 25%, hsl(var(--muted-foreground) / 0.08) 50%, hsl(var(--muted)) 75%);
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}

/* ===== BADGE ===== */
.badge-gradient {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 600;
  color: white;
}

/* ===== MOBILE SIDEBAR OVERLAY ===== */
.mobile-sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0,0,0,0.5);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.mobile-sidebar-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.mobile-sidebar-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 280px;
  z-index: 51;
  background: hsl(var(--sidebar-bg));
  border-right: 1px solid hsl(var(--sidebar-border));
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}
.mobile-sidebar-panel.open {
  transform: translateX(0);
}

/* ===== CHART CARDS ===== */
.chart-card-animate {
  opacity: 0;
  transform: translateY(16px);
  animation: chartCardIn 0.5s ease-out forwards;
}
@keyframes chartCardIn {
  to { opacity: 1; transform: translateY(0); }
}
.chart-range-btn {
  padding: 2px 8px;
  font-size: 10px;
  font-weight: 600;
  border-radius: 6px;
  color: hsl(var(--muted-foreground));
  transition: all 0.15s;
  line-height: 1.6;
}
.chart-range-btn:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--accent));
}
.chart-range-btn-active {
  background: hsl(var(--primary));
  color: white;
}
.chart-range-btn-active:hover {
  background: hsl(var(--primary));
  color: white;
}

/* ===== UTILITY ===== */
.text-balance { text-wrap: balance; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
