/* Modern Analytics Dashboard Styles */

body.auth-guard {
  opacity: 0;
  pointer-events: none;
}

.dashboard-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
}

.dashboard-header nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1400px;
  margin: 0 auto;
}

.dashboard-header .nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.btn-logout {
  background: rgba(255, 59, 48, 0.1);
  color: #ff3b30;
  border: 1px solid rgba(255, 59, 48, 0.3);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-logout:hover {
  background: rgba(255, 59, 48, 0.2);
  transform: translateY(-1px);
}

.analytics-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  padding-top: 2rem;
}

/* Dashboard Header Section */
.dashboard-header-section {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.dashboard-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 0 0.5rem 0;
  background: linear-gradient(135deg, var(--orange), var(--purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.dashboard-subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
}

.btn-icon {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.75rem;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  width: 44px;
  height: 44px;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--orange);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(255, 122, 24, 0.2);
}

.btn-icon.btn-danger {
  color: #ff3b30;
  border-color: rgba(255, 59, 48, 0.3);
}

.btn-icon.btn-danger:hover {
  background: rgba(255, 59, 48, 0.1);
  border-color: #ff3b30;
}

/* Loading & Empty States */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  gap: 1rem;
}

.spinner-large {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-color);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg {
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.5rem;
  margin: 0.5rem 0;
  color: var(--text-primary);
}

.empty-state p {
  margin: 0;
  font-size: 1rem;
}

/* Statistics Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--orange), var(--purple));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
  border-color: var(--orange);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card-primary::before {
  background: var(--orange);
  opacity: 1;
}

.stat-card-success::before {
  background: #34c759;
  opacity: 1;
}

.stat-card-info::before {
  background: #007aff;
  opacity: 1;
}

.stat-card-warning::before {
  background: #ff9500;
  opacity: 1;
}

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

.stat-icon-wrapper {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(255, 122, 24, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--orange);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1;
}

.stat-change {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Charts Section */
.charts-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 2rem;
  margin-bottom: 2.5rem;
}

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

.chart-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  border-color: var(--orange);
}

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

.chart-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.chart-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

/* Tables Section */
.tables-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.table-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  transition: all 0.3s ease;
}

.table-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  border-color: var(--orange);
}

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

.table-header h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.table-count {
  font-size: 0.875rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

.table-container {
  overflow-x: auto;
}

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

thead {
  border-bottom: 1px solid var(--border-color);
}

th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.2s ease;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

tbody tr:last-child {
  border-bottom: none;
}

td {
  padding: 1rem;
  font-size: 0.9rem;
  color: var(--text-primary);
}

td code {
  background: rgba(255, 122, 24, 0.1);
  color: var(--orange);
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.85rem;
  font-family: 'Inter', monospace;
}

.badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.table-empty {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
}

.table-empty td {
  padding: 2rem;
}

/* Progress Bar */
.progress-bar {
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 999px;
  height: 24px;
  overflow: hidden;
}

.progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--orange), var(--purple));
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-primary);
  z-index: 1;
}

/* Responsive */
@media (max-width: 768px) {
  .analytics-container {
    padding: 1rem;
  }

  .dashboard-header-section {
    flex-direction: column;
  }

  .dashboard-title {
    font-size: 2rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .charts-section {
    grid-template-columns: 1fr;
  }

  .tables-section {
    grid-template-columns: 1fr;
  }

  .chart-container {
    height: 250px;
  }
}

/* Light theme adjustments */
[data-theme="light"] .stat-card,
[data-theme="light"] .chart-card,
[data-theme="light"] .table-card {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .stat-card:hover,
[data-theme="light"] .chart-card:hover,
[data-theme="light"] .table-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .progress-bar {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] td code {
  background: rgba(255, 122, 24, 0.15);
}


/* Device & Location Lists */
.device-list,
.location-list {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-height: 200px;
}

.device-stat,
.location-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--bg-secondary);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  transition: all 0.3s ease;
}

.device-stat:hover,
.location-item:hover {
  border-color: var(--orange);
  transform: translateX(4px);
}

.device-name,
.country {
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.device-count,
.visits {
  color: var(--orange);
  font-weight: 600;
  font-size: 1.1rem;
}

/* Chart Controls */
.chart-controls {
  display: flex;
  gap: 0.5rem;
}

.chart-btn {
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  font-weight: 500;
}

.chart-btn:hover {
  background: var(--bg-primary);
  border-color: var(--orange);
}

.chart-btn.active {
  background: linear-gradient(120deg, var(--orange), var(--purple));
  border-color: transparent;
  color: var(--white);
}

.stat-card-accent {
  background: linear-gradient(135deg, rgba(127, 29, 255, 0.1), rgba(255, 122, 24, 0.1));
  border-color: var(--purple);
}

.loading-spinner {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.95rem;
}

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