/* Modern CSS Variables & Resets */
:root {
  --bg-primary: #0b0d17;
  --bg-secondary: #121424;
  --bg-card: rgba(22, 26, 47, 0.65);
  --bg-sidebar: #090a12;
  --border-light: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  
  /* Accent Colors */
  --accent-indigo: #6366f1;
  --accent-violet: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  
  /* Text Colors */
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  /* Font Families */
  --font-title: 'Outfit', 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;
  
  /* Shadows */
  --glow-indigo: 0 0 20px rgba(99, 102, 241, 0.25);
  --glow-emerald: 0 0 20px rgba(16, 185, 129, 0.25);
  --glow-amber: 0 0 20px rgba(245, 158, 11, 0.25);
  --glow-violet: 0 0 20px rgba(139, 92, 246, 0.25);
  --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  
  /* Transitions */
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.06) 0%, transparent 40%);
  background-attachment: fixed;
}

/* Dashboard Layout */
.dashboard-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-violet));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-title);
  font-weight: 800;
  font-size: 20px;
  color: white;
  box-shadow: var(--glow-indigo);
}

.brand-name {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #ffffff, #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: 10px;
  font-weight: 500;
  font-size: 14px;
  transition: var(--transition-smooth);
}

.nav-icon {
  width: 20px;
  height: 20px;
  transition: var(--transition-smooth);
}

.nav-item:hover, .nav-item.active {
  color: white;
  background-color: rgba(255, 255, 255, 0.03);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.02) 100%);
  border-left: 3px solid var(--accent-indigo);
}

.nav-item.active .nav-icon {
  color: var(--accent-indigo);
  filter: drop-shadow(0 0 5px rgba(99, 102, 241, 0.5));
}

.sidebar-footer {
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

.system-version {
  font-size: 12px;
  color: var(--text-dim);
}

/* Main Content Styling */
.main-content {
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 32px;
  overflow-y: auto;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}

.page-title {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 32px;
  color: white;
  letter-spacing: -0.5px;
}

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

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Environment Info Panel */
.env-info-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-light);
  padding: 10px 18px;
  border-radius: 12px;
  backdrop-filter: blur(10px);
}

.env-badge-container {
  display: flex;
  align-items: center;
}

.env-badge {
  font-family: var(--font-title);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-radius: 20px;
  display: inline-block;
  box-shadow: var(--shadow-card);
}

/* Environment-specific badge themes */
.env-badge.local {
  background-color: rgba(139, 92, 246, 0.1);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.3);
  animation: pulse-violet 2s infinite;
}

.env-badge.staging {
  background-color: rgba(245, 158, 11, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
  animation: pulse-amber 2s infinite;
}

.env-badge.production {
  background-color: rgba(16, 185, 129, 0.1);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  animation: pulse-emerald 2s infinite;
}

.deploy-timestamp-container {
  font-size: 11px;
  margin-top: 6px;
  display: flex;
  gap: 4px;
}

.deploy-label {
  color: var(--text-dim);
}

.deploy-time {
  color: var(--text-muted);
  font-weight: 500;
}

/* Refresh Button */
.btn-refresh {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--text-main);
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-refresh:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.05);
  transform: translateY(-2px);
}

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

.refresh-icon {
  width: 18px;
  height: 18px;
}

.btn-refresh.spinning .refresh-icon {
  animation: spin 0.8s linear infinite;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  transition: var(--transition-smooth);
}

.kpi-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.kpi-title {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.kpi-icon-wrapper {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon-wrapper svg {
  width: 18px;
  height: 18px;
}

.kpi-icon-wrapper.revenue {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent-indigo);
}

.kpi-icon-wrapper.aov {
  background: rgba(139, 92, 246, 0.1);
  color: var(--accent-violet);
}

.kpi-icon-wrapper.customers {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
}

.kpi-icon-wrapper.subs {
  background: rgba(244, 63, 94, 0.1);
  color: var(--accent-rose);
}

.kpi-value {
  font-family: var(--font-title);
  font-size: 28px;
  font-weight: 700;
  color: white;
  margin-top: 16px;
}

.kpi-trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  margin-top: 12px;
  font-weight: 500;
}

.kpi-trend.positive {
  color: var(--accent-emerald);
}

.kpi-trend.negative {
  color: var(--accent-rose);
}

/* Charts and Lists Layout */
.charts-section {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.glass {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
}

.chart-card {
  padding: 24px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.chart-card-title {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 18px;
  color: white;
}

.chart-controls {
  display: flex;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border-light);
}

.btn-filter {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-filter:hover {
  color: white;
}

.btn-filter.active {
  background: var(--accent-indigo);
  color: white;
  box-shadow: var(--glow-indigo);
}

.chart-body {
  position: relative;
  height: 320px;
  width: 100%;
}

/* Recent Transactions Card */
.transactions-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.transactions-header {
  margin-bottom: 20px;
}

.transactions-title {
  font-family: var(--font-title);
  font-weight: 600;
  font-size: 18px;
  color: white;
}

.transactions-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex-grow: 1;
  overflow-y: auto;
}

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 14px;
}

.transaction-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid transparent;
  transition: var(--transition-smooth);
}

.transaction-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border-light);
  transform: translateX(4px);
}

.tx-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tx-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid var(--border-light);
}

.tx-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tx-name {
  font-size: 14px;
  font-weight: 500;
  color: white;
}

.tx-time {
  font-size: 11px;
  color: var(--text-dim);
}

.tx-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.tx-amount {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 14px;
  color: white;
}

.tx-status {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.tx-status.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-emerald);
}

.tx-status.pending {
  background: rgba(245, 158, 11, 0.1);
  color: var(--accent-amber);
}

/* Footer Styling */
.footer {
  margin-top: auto;
  padding-top: 40px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: center;
  align-items: center;
}

.footer p {
  font-size: 12px;
  color: var(--text-dim);
}

/* Keyframes / Animations */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse-violet {
  0% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(139, 92, 246, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(139, 92, 246, 0);
  }
}

@keyframes pulse-amber {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

@keyframes pulse-emerald {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* Media Queries */
@media (max-width: 1024px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
  }
  
  .sidebar {
    display: none; /* Can be enhanced to a mobile drawer, kept simple for mock */
  }
  
  .charts-section {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main-content {
    padding: 20px;
  }
  
  .header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .header-right {
    width: 100%;
    justify-content: space-between;
  }
}
