/* Analytics Dashboard CSS - Comprehensive data visualization styles */

.analytics-dashboard-container {
  background: #ffffff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Header */
.analytics-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
  flex-wrap: wrap;
  gap: 1rem;
}

/* Tabs */
.analytics-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.tab-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: #5d5fef;
  background: #f5f3ff;
}

.tab-btn.active {
  background: #5d5fef;
  color: white;
  border-color: #5d5fef;
}

/* Period Selector */
.period-selector {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.period-label {
  font-size: 0.875rem;
  color: #6b7280;
  font-weight: 500;
}

.period-select {
  padding: 0.5rem 2rem 0.5rem 1rem;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #1f2937;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  background-size: 1.25rem;
}

.period-select:hover {
  border-color: #5d5fef;
}

.period-select:focus {
  outline: none;
  border-color: #5d5fef;
  box-shadow: 0 0 0 3px rgba(93, 95, 239, 0.1);
}

/* Content */
.analytics-content {
  padding: 1.5rem;
  min-height: 400px;
}

/* Summary Grid */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: #f9fafb;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  transition: all 0.3s ease;
}

.summary-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.summary-icon {
  font-size: 2.5rem;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 12px;
  flex-shrink: 0;
}

.summary-info {
  flex: 1;
}

.summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1f2937;
  line-height: 1;
}

.summary-label {
  font-size: 0.875rem;
  color: #6b7280;
  margin-top: 0.25rem;
}

.summary-trend {
  font-size: 0.875rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.summary-trend.positive {
  color: #10b981;
}

.summary-trend.negative {
  color: #ef4444;
}

/* Charts Grid */
.charts-grid {
  display: grid;
  gap: 1.5rem;
}

.overview-charts {
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
}

.progress-charts,
.volume-charts,
.intensity-charts {
  grid-template-columns: 1fr;
}

@media (min-width: 1024px) {
  .progress-charts,
  .volume-charts,
  .intensity-charts {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Chart Container */
.chart-container {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2937;
  margin: 0;
}

.chart-export-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #e5e7eb;
  background: white;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #6b7280;
  transition: all 0.2s ease;
}

.chart-export-btn:hover {
  border-color: #5d5fef;
  color: #5d5fef;
  background: #f5f3ff;
}

.chart-canvas-wrapper {
  padding: 1.5rem;
  position: relative;
  height: 300px;
}

/* Loading State */
.analytics-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  font-size: 1rem;
  color: #6b7280;
}

.analytics-loading::before {
  content: '';
  width: 40px;
  height: 40px;
  border: 3px solid #e5e7eb;
  border-top-color: #5d5fef;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 1rem;
}

/* Error State */
.analytics-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  text-align: center;
  color: #ef4444;
}

.analytics-error i {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.8;
}

.analytics-error p {
  font-size: 1rem;
  color: #6b7280;
}

/* Mobile Responsive */
@media (max-width: 767px) {
  .analytics-header {
    padding: 1rem;
  }
  
  .analytics-tabs {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .tab-btn {
    white-space: nowrap;
  }
  
  .period-selector {
    width: 100%;
    justify-content: flex-end;
  }
  
  .analytics-content {
    padding: 1rem;
  }
  
  .summary-grid {
    grid-template-columns: 1fr;
  }
  
  .charts-grid {
    gap: 1rem;
  }
  
  .overview-charts {
    grid-template-columns: 1fr;
  }
  
  .chart-canvas-wrapper {
    padding: 1rem;
    height: 250px;
  }
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
  .analytics-dashboard-container {
    background: #1f2937;
  }
  
  .analytics-header {
    background: #111827;
    border-bottom-color: #374151;
  }
  
  .tab-btn {
    color: #9ca3af;
  }
  
  .tab-btn:hover {
    color: #5d5fef;
    background: rgba(93, 95, 239, 0.1);
  }
  
  .period-label {
    color: #9ca3af;
  }
  
  .period-select {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }
  
  .period-select:hover {
    border-color: #5d5fef;
  }
  
  .analytics-content {
    background: #1f2937;
  }
  
  .summary-card {
    background: #111827;
    border-color: #374151;
  }
  
  .summary-icon {
    background: #1f2937;
  }
  
  .summary-value {
    color: #f9fafb;
  }
  
  .summary-label {
    color: #9ca3af;
  }
  
  .chart-container {
    background: #111827;
    border-color: #374151;
  }
  
  .chart-header {
    background: #1f2937;
    border-bottom-color: #374151;
  }
  
  .chart-title {
    color: #f9fafb;
  }
  
  .chart-export-btn {
    background: #374151;
    border-color: #4b5563;
    color: #9ca3af;
  }
  
  .chart-export-btn:hover {
    background: rgba(93, 95, 239, 0.1);
    border-color: #5d5fef;
    color: #5d5fef;
  }
  
  .chart-canvas-wrapper {
    background: #111827;
  }
}

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

/* Light Mode Text Visibility Fixes for Analytics Dashboard */
body:not([data-theme="dark"]) .analytics-header {
  background: #f9fafb !important;
  border-bottom-color: #e5e7eb !important;
}

body:not([data-theme="dark"]) .tab-btn {
  color: #6b7280 !important;
}

body:not([data-theme="dark"]) .tab-btn:hover {
  color: #5d5fef !important;
  background: #f5f3ff !important;
}

body:not([data-theme="dark"]) .tab-btn.active {
  background: #5d5fef !important;
  color: white !important;
}

body:not([data-theme="dark"]) .period-label {
  color: #6b7280 !important;
}

body:not([data-theme="dark"]) .period-select {
  color: #1f2937 !important;
  background: #ffffff !important;
  border-color: #e5e7eb !important;
}

body:not([data-theme="dark"]) .summary-card {
  background: #f9fafb !important;
  border-color: #e5e7eb !important;
}

body:not([data-theme="dark"]) .summary-value {
  color: #1f2937 !important;
}

body:not([data-theme="dark"]) .summary-label {
  color: #6b7280 !important;
}

body:not([data-theme="dark"]) .chart-container {
  background: white !important;
  border-color: #e5e7eb !important;
}

body:not([data-theme="dark"]) .chart-title {
  color: #1f2937 !important;
}

body:not([data-theme="dark"]) .chart-subtitle {
  color: #6b7280 !important;
}

body:not([data-theme="dark"]) .metric-value {
  color: #1f2937 !important;
}

body:not([data-theme="dark"]) .metric-label {
  color: #6b7280 !important;
}

body:not([data-theme="dark"]) .activity-label {
  color: #4b5563 !important;
}

body:not([data-theme="dark"]) .muscle-group-label,
body:not([data-theme="dark"]) .distribution-label {
  color: #4b5563 !important;
}

/* Fix "Today's Activity" text */
body:not([data-theme="dark"]) .todays-activity-title,
body:not([data-theme="dark"]) .activity-analytics-title {
  color: #1f2937 !important;
}

/* Ensure chart containers have proper backgrounds */
body:not([data-theme="dark"]) .analytics-content {
  background: transparent !important;
}

body:not([data-theme="dark"]) .analytics-dashboard-container {
  background: #ffffff !important;
}

/* Fix any distribution text */
body:not([data-theme="dark"]) .distribution-text,
body:not([data-theme="dark"]) .muscle-distribution-text {
  color: #4b5563 !important;
}