/* ========================================
   Admin Analytics Dashboard Styles
   Premium analytics page with vibrant design
   ======================================== */

/* Header Refresh Button */
.header-refresh {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: hsl(var(--secondary));
  border: 1px solid hsl(var(--border));
  border-radius: 0.5rem;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: all 0.2s ease;
}

.header-btn:hover {
  color: hsl(var(--foreground));
  background: hsl(var(--foreground) / 0.08);
  border-color: hsl(var(--foreground) / 0.2);
}

.header-btn.refreshing svg {
  animation: spin 1s linear infinite;
}

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

.last-updated {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

/* Access Denied State */
.access-denied-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  padding: 2rem;
}

.access-denied-icon {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: hsl(0 84% 60% / 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: hsl(0 84% 60%);
  margin-bottom: 1.5rem;
}

.access-denied-state h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: hsl(var(--foreground));
}

.access-denied-state p {
  color: hsl(var(--muted-foreground));
  margin-bottom: 1.5rem;
  max-width: 400px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: hsl(var(--foreground));
  color: hsl(var(--background));
  padding: 0.75rem 1.5rem;
  border-radius: 0.625rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 20px -4px hsl(var(--foreground) / 0.3);
}

/* Analytics Sections */
.analytics-section {
  margin-bottom: 2rem;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.section-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.section-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  background: hsl(142 76% 36% / 0.12);
  color: hsl(142 76% 36%);
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.section-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: hsl(142 76% 36%);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Overview Grid */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

@media (max-width: 1400px) {
  .overview-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .overview-grid {
    grid-template-columns: 1fr;
  }
}

/* Metric Cards */
.metric-card {
  position: relative;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  padding: 1.25rem;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.metric-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px -15px hsl(0 0% 0% / 0.15);
  border-color: hsl(var(--foreground) / 0.15);
}

.metric-card-glow {
  position: absolute;
  top: -50%;
  right: -30%;
  width: 100%;
  height: 200%;
  pointer-events: none;
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.metric-card:hover .metric-card-glow {
  opacity: 0.8;
}

/* Card Color Variants */
.metric-card-users .metric-card-glow {
  background: radial-gradient(circle, hsl(220 90% 56% / 0.15) 0%, transparent 60%);
}
.metric-card-users .metric-icon {
  background: hsl(220 90% 56% / 0.12);
  color: hsl(220 90% 56%);
}

.metric-card-revenue .metric-card-glow {
  background: radial-gradient(circle, hsl(142 76% 36% / 0.15) 0%, transparent 60%);
}
.metric-card-revenue .metric-icon {
  background: hsl(142 76% 36% / 0.12);
  color: hsl(142 76% 36%);
}

.metric-card-generations .metric-card-glow {
  background: radial-gradient(circle, hsl(280 70% 50% / 0.15) 0%, transparent 60%);
}
.metric-card-generations .metric-icon {
  background: hsl(280 70% 50% / 0.12);
  color: hsl(280 70% 50%);
}

.metric-card-api .metric-card-glow {
  background: radial-gradient(circle, hsl(35 90% 55% / 0.15) 0%, transparent 60%);
}
.metric-card-api .metric-icon {
  background: hsl(35 90% 55% / 0.12);
  color: hsl(35 90% 55%);
}

.metric-card-dau .metric-card-glow {
  background: radial-gradient(circle, hsl(180 70% 45% / 0.15) 0%, transparent 60%);
}
.metric-card-dau .metric-icon {
  background: hsl(180 70% 45% / 0.12);
  color: hsl(180 70% 45%);
}

/* API Metrics Grid */
.api-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  padding: 0.75rem 0;
}

.api-metric {
  text-align: center;
}

.api-metric-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: hsl(var(--foreground));
  margin-bottom: 0.25rem;
}

.api-metric-label {
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
}

.metric-content {
  margin-bottom: 1rem;
}

.metric-value {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: hsl(var(--foreground));
  line-height: 1.2;
  margin-bottom: 0.25rem;
}

.metric-value .skeleton-value {
  display: inline-block;
  width: 80px;
  height: 2rem;
  background: hsl(var(--secondary));
  border-radius: 0.5rem;
  position: relative;
  overflow: hidden;
}

.metric-value .skeleton-value::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, hsl(var(--foreground) / 0.08), transparent);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.metric-label {
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  font-weight: 500;
}

.metric-breakdown {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  padding-top: 1rem;
  border-top: 1px solid hsl(var(--border));
}

.breakdown-item {
  text-align: center;
}

.breakdown-value {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.breakdown-label {
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  padding: 1.25rem;
  transition: all 0.3s ease;
}

.chart-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -10px hsl(0 0% 0% / 0.1);
}

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

.chart-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.chart-legend {
  display: flex;
  gap: 1rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-dau .legend-dot {
  background: hsl(220 90% 56%);
}

.legend-signups .legend-dot {
  background: hsl(142 76% 36%);
}

.chart-value-display {
  font-size: 1.25rem;
  font-weight: 700;
  color: hsl(142 76% 36%);
}

.chart-container {
  height: 220px;
  position: relative;
}

.chart-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: hsl(var(--card));
}

.chart-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid hsl(var(--border));
  border-top-color: hsl(var(--foreground));
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Simple Chart Bars (No external library) */
.chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  height: 100%;
  gap: 4px;
  padding-bottom: 24px;
}

.chart-bar-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.chart-bar-group {
  flex: 1;
  display: flex;
  gap: 2px;
  align-items: flex-end;
  width: 100%;
  justify-content: center;
}

.chart-bar {
  width: 100%;
  max-width: 8px;
  min-height: 0;
  border-radius: 4px 4px 0 0;
  transition: height 0.5s ease;
  position: relative;
}

.chart-bar-primary {
  background: linear-gradient(to top, hsl(220 90% 56% / 0.8), hsl(220 90% 56%));
}

.chart-bar-secondary {
  background: linear-gradient(to top, hsl(142 76% 36% / 0.8), hsl(142 76% 36%));
}

.chart-bar-revenue {
  background: linear-gradient(to top, hsl(142 76% 36% / 0.6), hsl(142 76% 36%));
}

.chart-date {
  font-size: 0.625rem;
  color: hsl(var(--muted-foreground));
  margin-top: 0.5rem;
  writing-mode: vertical-lr;
  transform: rotate(180deg);
}

/* Secondary Grid */
.secondary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (max-width: 1200px) {
  .secondary-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .secondary-grid {
    grid-template-columns: 1fr;
  }
}

.stats-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  padding: 1.25rem;
  transition: all 0.3s ease;
}

.stats-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -10px hsl(0 0% 0% / 0.1);
}

.stats-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.stats-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.stats-period {
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.stats-breakdown {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stats-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

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

.stats-item-label {
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.stats-item-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.stats-bar {
  height: 6px;
  background: hsl(var(--secondary));
  border-radius: 9999px;
  overflow: hidden;
}

.stats-bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.stats-bar-email { background: hsl(220 90% 56%); }
.stats-bar-google { background: hsl(35 90% 55%); }
.stats-bar-discord { background: hsl(235 86% 65%); }
.stats-bar-starter { background: hsl(200 70% 50%); }
.stats-bar-pro { background: hsl(280 70% 50%); }
.stats-bar-enterprise { background: hsl(35 90% 55%); }
.stats-bar-admin { background: hsl(0 84% 60%); }
.stats-bar-user { background: hsl(142 76% 36%); }

.stats-footer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid hsl(var(--border));
}

.stats-footer-item {
  text-align: center;
}

.stats-footer-value {
  display: block;
  font-size: 1rem;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.stats-footer-label {
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Donut Chart */
.donut-chart-container {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.donut-chart {
  position: relative;
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}

.donut-svg {
  transform: rotate(-90deg);
}

.donut-bg {
  fill: none;
  stroke: hsl(var(--secondary));
  stroke-width: 12;
}

.donut-segment {
  fill: none;
  stroke-width: 12;
  stroke-linecap: round;
  transition: stroke-dasharray 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.donut-base {
  stroke: hsl(220 90% 56%);
}

.donut-advanced {
  stroke: hsl(280 70% 50%);
}

.donut-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.donut-total {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: hsl(var(--foreground));
}

.donut-label {
  font-size: 0.6875rem;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
}

.donut-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.donut-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.donut-legend-base {
  background: hsl(220 90% 56%);
}

.donut-legend-advanced {
  background: hsl(280 70% 50%);
}

.donut-legend-label {
  flex: 1;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
}

.donut-legend-value {
  font-size: 0.875rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

/* Tables Grid */
.tables-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (max-width: 1024px) {
  .tables-grid {
    grid-template-columns: 1fr;
  }
}

.table-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 1rem;
  overflow: hidden;
  transition: all 0.3s ease;
}

.table-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px -10px hsl(0 0% 0% / 0.1);
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  border-bottom: 1px solid hsl(var(--border));
}

.table-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.table-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.625rem;
  background: hsl(var(--secondary));
  color: hsl(var(--muted-foreground));
  border-radius: 9999px;
}

.table-container {
  max-height: 320px;
  overflow-y: auto;
}

.analytics-table {
  width: 100%;
  border-collapse: collapse;
}

.analytics-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: hsl(var(--secondary) / 0.5);
  position: sticky;
  top: 0;
}

.analytics-table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: hsl(var(--foreground));
  border-bottom: 1px solid hsl(var(--border));
}

.analytics-table tr:last-child td {
  border-bottom: none;
}

.analytics-table tbody tr:hover {
  background: hsl(var(--secondary) / 0.3);
}

.table-loading-row td {
  padding: 2rem 1rem;
}

.table-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: hsl(var(--muted-foreground));
}

.table-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid hsl(var(--border));
  border-top-color: hsl(var(--foreground));
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.table-footer {
  padding: 0.75rem 1.25rem;
  font-size: 0.8125rem;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--secondary) / 0.3);
  border-top: 1px solid hsl(var(--border));
}

.table-footer span {
  font-weight: 600;
  color: hsl(var(--foreground));
}

/* Model Badge */
.model-badge {
  display: inline-flex;
  padding: 0.25rem 0.5rem;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.model-badge-base {
  background: hsl(220 90% 56% / 0.12);
  color: hsl(220 90% 56%);
}

.model-badge-advanced {
  background: hsl(280 70% 50% / 0.12);
  color: hsl(280 70% 50%);
}

/* Endpoint Path */
.endpoint-path {
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
  font-size: 0.8125rem;
  background: hsl(var(--secondary));
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
}

/* Responsive typography */
@media (max-width: 640px) {
  .metric-value {
    font-size: 1.5rem;
  }
  
  .breakdown-value {
    font-size: 0.875rem;
  }
  
  .chart-container {
    height: 180px;
  }
  
  .donut-chart-container {
    flex-direction: column;
  }
  
  .donut-chart {
    width: 100px;
    height: 100px;
  }
}
