/* ================================================================
   Analytics Page Specific Styles
   ================================================================ */

.analytics-section {
  padding: 8rem 0 4rem;
  min-height: 100vh;
}

.analytics-header {
  text-align: center;
  margin-bottom: 3rem;
}

.analytics-subtitle {
  color: var(--text-secondary);
  font-size: 1.1rem;
  margin-top: 0.5rem;
}

/* Connection Status Indicator */
.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding: 0.4rem 1rem;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.4s ease;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.4s ease;
}

.status-dot.offline {
  background: #6b7280;
}

.status-dot.connecting {
  background: #f59e0b;
  animation: pulse-dot 1.2s ease-in-out infinite;
}

.status-dot.connected {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.status-dot.error {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.analytics-card {
  padding: 1.5rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  transition: all 0.3s ease;
}

.analytics-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

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

.card-title {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
}

.card-icon svg {
  width: 20px;
  height: 20px;
  color: white;
}

.card-value {
  font-size: 2.5rem;
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 0.5rem;
}

.card-change {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.card-change.positive {
  color: #10b981;
  background: rgba(16, 185, 129, 0.1);
}

.card-change.negative {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

.card-change svg {
  width: 14px;
  height: 14px;
}

.chart-section {
  margin-top: 2rem;
}

.chart-card {
  padding: 2rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(20px);
  margin-bottom: 2rem;
}

.chart-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.chart-placeholder {
  height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.chart-placeholder svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.chart-placeholder-content {
  text-align: center;
}

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

.traffic-table th,
.traffic-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.traffic-table th {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.traffic-table td {
  color: var(--text-primary);
}

.traffic-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.page-path {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--primary);
}

.progress-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  overflow: hidden;
  min-width: 100px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  border-radius: 4px;
  transition: width 0.5s ease;
}

.analytics-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  align-items: center;
  justify-content: space-between;
}

.date-filter {
  display: flex;
  gap: 0.5rem;
}

.filter-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.filter-btn:hover,
.filter-btn.active {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--primary);
  color: var(--text-primary);
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.refresh-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.refresh-btn svg {
  width: 16px;
  height: 16px;
}

.refresh-btn.loading svg {
  animation: spin 1s linear infinite;
}

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

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

@media (max-width: 768px) {
  .two-col-grid {
    grid-template-columns: 1fr;
  }
  
  .analytics-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .date-filter {
    overflow-x: auto;
    padding-bottom: 0.5rem;
  }
}

.realtime-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.realtime-dot {
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

.no-data-message {
  text-align: center;
  padding: 3rem;
  color: var(--text-secondary);
}

.connect-analytics {
  margin-top: 1.5rem;
}

/* ================================================================
   Device Donut Chart
   ================================================================ */

.device-breakdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2.5rem;
  padding: 1rem 0;
}

.donut-chart {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.donut-hole {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: #0d1117;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.donut-total {
  font-size: 1.5rem;
  font-weight: 800;
  font-family: var(--font-heading);
  color: var(--text-primary);
  line-height: 1;
}

.donut-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

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

.legend-name {
  flex: 1;
  color: var(--text-primary);
  font-weight: 500;
}

.legend-value {
  font-weight: 600;
  font-family: var(--font-heading);
  color: var(--text-primary);
}

/* ================================================================
   Geographic Distribution List
   ================================================================ */

.geo-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.geo-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
}

.geo-rank {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.geo-info {
  flex: 1;
  min-width: 0;
}

.geo-country {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.geo-value {
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font-heading);
  color: var(--text-primary);
  flex-shrink: 0;
}

/* ================================================================
   Traffic SVG Chart
   ================================================================ */

.chart-placeholder:has(.traffic-svg) {
  border: none;
  height: auto;
  display: block;
  padding: 0;
}

.traffic-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding-top: 1rem;
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ================================================================
   Loading Pulse Animation
   ================================================================ */

@keyframes loadingPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.loading-pulse {
  animation: loadingPulse 1.2s ease-in-out infinite;
}

/* Device / Geo charts — remove dashed border when data is loaded */
.chart-placeholder:has(.device-breakdown),
.chart-placeholder:has(.geo-list) {
  border: none;
  height: auto;
  display: block;
  padding: 0;
}

/* ================================================================
   Responsive Tweaks
   ================================================================ */

@media (max-width: 768px) {
  .device-breakdown {
    flex-direction: column;
    gap: 1.5rem;
  }

  .donut-chart {
    width: 150px;
    height: 150px;
  }

  .donut-hole {
    width: 90px;
    height: 90px;
  }

  .donut-total {
    font-size: 1.2rem;
  }
}
