@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Core Palette - Deep Tech */
  --bg-primary: #FFFFFF;
  --bg-secondary: #F8F9FA;
  --bg-tertiary: #F1F3F5;
  --text-primary: #111827;
  --text-secondary: #4B5563;
  --text-tertiary: #9CA3AF;
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.15);
  
  /* Brand Colors */
  --blue: #1A73E8;
  --blue-dark: #1557B0;
  --blue-light: #E8F0FE;
  --blue-text: #174EA6;
  
  --purple: #7C4DFF;
  --purple-dark: #651FFF;
  --purple-light: #F3E5F5;
  
  --orange: #F97316;
  --orange-dark: #EA580C;
  /* Transitions & Shadows */
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  /* Status Colors */
  --green: #10b981;
  --red: #ef4444;
  --yellow: #f59e0b;
  --purple: #8b5cf6;
  --orange: #f97316;
  
  --green-light: rgba(16, 185, 129, 0.1);
  --red-light: rgba(239, 68, 68, 0.1);
  --yellow-light: rgba(245, 158, 11, 0.1);
  --blue-light: rgba(59, 130, 246, 0.1);
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  
  /* Glassmorphism Tokens */
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-blur: 12px;
}

.dark {
  --bg-primary: #0B0E14;
  --bg-secondary: #141820;
  --bg-tertiary: #1C212C;
  --text-primary: #F9FAFB;
  --text-secondary: #D1D5DB;
  --text-tertiary: #9CA3AF;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  
  --glass-bg: rgba(20, 24, 32, 0.7);
  --glass-border: rgba(255, 255, 255, 0.05);
  
  --blue-light: rgba(26, 115, 232, 0.1);
  --blue-text: #8AB4F8;
}

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  transition: background var(--transition), color var(--transition);
  font-size: 14px;
  line-height: 1.6;
}

h1, h2, h3, h4, h5, h6, .font-outfit {
  font-family: 'Outfit', sans-serif;
}

h1 { font-size: 26px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 20px; font-weight: 600; margin: 0; }
h3 { font-size: 18px; font-weight: 600; margin: 0; }

/* LAYOUT UTILITIES */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
}

/* HEADER */
/* HEADER - CLAUDE STYLE */
.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--bg-primary);
  position: sticky;
  top: 0;
  z-index: 900;
  border-bottom: none;
  min-height: 80px;
  height: auto;
  transition: all var(--transition);
}

.top-header::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 24px;
  background: linear-gradient(to bottom, var(--bg-primary), transparent);
  pointer-events: none;
}

.header-left {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
}

.header-titles {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#view-title {
  font-family: 'Outfit', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
  letter-spacing: -0.02em;
}

.view-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
  font-weight: 400;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 4px; /* Align with title baseline */
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: var(--blue);
  font-size: 16px;
}

/* SIDEBAR */
.sidebar {
  width: 240px;
  background-color: var(--bg-primary);
  border-right: 0.5px solid var(--border);
  padding: 0; /* Changed to 0 to control padding via internal containers */
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  overflow-y: auto;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none;  /* IE/Edge */
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), background var(--transition);
  display: flex;
  flex-direction: column;
  z-index: 1000;
}

.sidebar::-webkit-scrollbar {
  display: none; /* Chrome/Safari */
}

.sidebar.collapsed {
  width: 68px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 12px 16px;
  min-height: 100px;
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  z-index: 11;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 1;
}

.logo-container #logo-img {
  height: 80px; /* Adjusted to balance with horizontal layout */
  width: auto;
  max-width: 140px;
  object-fit: contain;
  transition: transform 0.3s, opacity 0.3s;
}

.sidebar.collapsed #logo-img {
  opacity: 0;
  transform: translateX(-40px);
}

.sidebar-toggle {
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s;
  background: transparent;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar.collapsed .sidebar-toggle {
  margin: 0 auto;
}

.sidebar-toggle:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  padding: 0 8px 12px; /* Added internal padding for nav items */
}

.nav-item {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 16px;
  text-decoration: none;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  width: 100%;
}

.nav-item i, .nav-item svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.sidebar.collapsed .nav-item i, .sidebar.collapsed .nav-item svg {
  color: var(--text-primary);
}

.nav-item span {
  transition: opacity 0.2s, visibility 0.2s;
}

.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-label {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

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

.nav-item.active {
  background-color: var(--blue-light);
  color: var(--blue);
  font-weight: 600;
}

.nav-item.active i, .nav-item.active svg {
  color: var(--blue);
}

.nav-label {
  font-size: 11px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 12px 2px;
  margin-top: 10px;
}

/* MAIN CONTENT */
.main-wrapper {
  margin-left: 240px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding-top: 0; /* Header padding handles this now */
}

.sidebar.collapsed ~ .main-wrapper {
  margin-left: 68px;
}

.main-content {
  flex: 1;
  padding: 40px 40px 40px;
  overflow-y: auto;
}

/* CARDS */
.card {
  background-color: var(--bg-primary);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: none;
  transition: border-color var(--transition), background var(--transition);
}

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

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  text-decoration: none;
  font-family: 'Outfit', sans-serif;
  letter-spacing: 0.01em;
}

.btn-primary {
  background-color: var(--blue);
  color: #FFFFFF;
  box-shadow: 0 4px 12px rgba(26, 115, 232, 0.25);
}

.btn-primary:hover {
  background-color: var(--blue-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(26, 115, 232, 0.35);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

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

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

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

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
}

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

/* INPUTS & FORMS */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input, select, textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  height: 44px;
  padding: 10px 16px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  width: 100%;
  transition: all 0.2s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px var(--blue-light);
}

/* AUTH COMPONENTS (Glassmorphism) */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
}

.auth-overlay.active, .auth-overlay.open {
  display: flex;
}

.auth-box, .tracking-box {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 24px;
  width: 95vw;
  max-width: 450px;
  max-height: 90vh;
  box-shadow: var(--shadow-lg);
  position: relative;
  display: flex;
  flex-direction: column;
  overflow-y: auto; /* Single scroll for the whole box */
  scrollbar-width: thin;
}

.auth-box {
  padding: 0;
}

.tracking-box {
  padding: 0; /* Remove 40px to allow header to be sticky to the top */
  max-width: 600px;
}

.auth-header, .tracking-header {
  position: sticky;
  top: 0;
  background: var(--bg-primary);
  padding: 32px;
  z-index: 10;
  border-bottom: 1px solid var(--border);
}

.auth-body, .tracking-content {
  padding: 32px;
  flex: 1 1 auto;
}

.glass-auth {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
}

.auth-header {
  text-align: center;
  margin-bottom: 30px;
}

.auth-header h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.auth-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

.glass-input-group {
  position: relative;
  margin-bottom: 16px;
}

.glass-input-group i {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  width: 18px;
}

.glass-input-group input {
  padding-left: 48px;
  border-radius: 14px;
  background: var(--bg-secondary);
  border-color: transparent;
}

.glass-input-group input:focus {
  background: var(--bg-primary);
  border-color: var(--blue);
}

/* TOGGLE SWITCH */
.theme-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: background var(--transition), color var(--transition);
}

.theme-toggle:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

/* OVERLAYS & MODALS */
.overlay, .auth-overlay, .modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  z-index: 10000;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.overlay.active, .auth-overlay.open, .modal-overlay.active {
  display: flex;
}

/* Fix for z-index issues and dropdowns in modals */
.modal-overlay {
  z-index: 10000;
}

.dropdown-menu {
  z-index: 10100 !important;
}

.select-dropdown {
  z-index: 10100 !important;
}

/* METRICS GRID */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.metric-card {
  background-color: var(--bg-primary);
  border: 0.5px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.metric-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.metric-value {
  font-size: 24px;
  font-weight: 500;
  color: var(--text-primary);
}
