/* Enhanced Insights Lab CSS */

/* Insights Lab Header */
.insights-lab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding: 2rem;
  background: linear-gradient(135deg, #1e40af 0%, #3730a3 50%, #581c87 100%);
  border-radius: 16px;
  color: white;
  position: relative;
  overflow: hidden;
}

.insights-lab-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: 
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,0.05) 0%, transparent 50%);
  pointer-events: none;
}

.lab-overview {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: relative;
  z-index: 1;
}

.lab-icon {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  backdrop-filter: blur(10px);
}

.lab-content h2 {
  margin: 0 0 0.5rem 0;
  font-size: 1.75rem;
  font-weight: 700;
}

.lab-content p {
  margin: 0;
  opacity: 0.9;
  font-size: 1rem;
}

.lab-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

.time-selector .uba-select {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  backdrop-filter: blur(10px);
}

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

/* Section Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #e2e8f0;
}

.section-header h3 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-header p {
  margin: 0.25rem 0 0 0;
  color: #64748b;
  font-size: 0.95rem;
}

.refresh-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
  font-weight: 500;
}

.refresh-btn:hover {
  background: #f1f5f9;
  border-color: #3b82f6;
}

.refresh-icon {
  animation: spin 2s linear infinite;
}

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

/* KPI Analysis Section */
.kpi-analysis-section {
  margin-bottom: 3rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.kpi-card {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.revenue-kpi::before {
  background: linear-gradient(90deg, #10b981, #059669);
}

.client-kpi::before {
  background: linear-gradient(90deg, #3b82f6, #1d4ed8);
}

.project-kpi::before {
  background: linear-gradient(90deg, #f59e0b, #d97706);
}

.productivity-kpi::before {
  background: linear-gradient(90deg, #ef4444, #dc2626);
}

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

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: white;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
}

.revenue-kpi .kpi-icon {
  background: linear-gradient(135deg, #10b981, #059669);
}

.project-kpi .kpi-icon {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.productivity-kpi .kpi-icon {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.kpi-info {
  flex: 1;
}

.kpi-info h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
}

.kpi-value {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.kpi-value span:first-child {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1e293b;
}

.kpi-change {
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 12px;
}

.kpi-change.positive {
  background: #dcfce7;
  color: #166534;
}

.kpi-change.negative {
  background: #fef2f2;
  color: #dc2626;
}

.kpi-trend {
  width: 60px;
  height: 30px;
}

.kpi-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e2e8f0;
}

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

.metric-label {
  display: block;
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 0.25rem;
  font-weight: 500;
}

.metric-value {
  display: block;
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
}

/* Charts Section */
.charts-section {
  margin-bottom: 3rem;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 2rem;
}

.chart-container {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
}

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

.chart-header h4 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
}

.chart-controls {
  display: flex;
  gap: 0.5rem;
  background: #f8fafc;
  padding: 0.25rem;
  border-radius: 8px;
}

.chart-btn {
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  color: #64748b;
}

.chart-btn:hover {
  color: #3b82f6;
}

.chart-btn.active {
  background: white;
  color: #3b82f6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chart-wrapper {
  position: relative;
  height: 300px;
  margin-bottom: 1rem;
}

.chart-insights {
  padding: 1rem;
  background: #f8fafc;
  border-radius: 8px;
  border-left: 4px solid #3b82f6;
}

.insight-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.insight-item:last-child {
  margin-bottom: 0;
}

.insight-icon {
  font-size: 1.25rem;
  margin-top: 0.125rem;
}

.insight-content {
  flex: 1;
}

.insight-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0 0 0.25rem 0;
}

.insight-description {
  font-size: 0.875rem;
  color: #64748b;
  margin: 0;
  line-height: 1.5;
}

/* Insights Categories Section */
.insights-categories-section {
  margin-bottom: 3rem;
}

.insights-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.insight-tab {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  background: white;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  position: relative;
}

.insight-tab:hover {
  border-color: #3b82f6;
  background: #f8fafc;
}

.insight-tab.active {
  border-color: #3b82f6;
  background: #dbeafe;
}

.tab-icon {
  font-size: 1.25rem;
}

.tab-label {
  font-weight: 600;
  color: #1e293b;
  font-size: 0.875rem;
}

.insight-count {
  background: #3b82f6;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.125rem 0.5rem;
  border-radius: 12px;
  min-width: 20px;
  text-align: center;
}

.insights-content {
  position: relative;
  min-height: 400px;
}

.insight-category {
  display: none;
}

.insight-category.active {
  display: block;
}

.insights-list {
  display: grid;
  gap: 1rem;
}

.insight-card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
}

.insight-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  border-color: #3b82f6;
}

.insight-card-header {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.insight-priority {
  padding: 0.25rem 0.75rem;
  border-radius: 16px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.insight-priority.high {
  background: #fef2f2;
  color: #dc2626;
}

.insight-priority.medium {
  background: #fef3c7;
  color: #d97706;
}

.insight-priority.low {
  background: #f0fdf4;
  color: #059669;
}

.insight-card-content h5 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
}

.insight-card-content p {
  margin: 0 0 1rem 0;
  color: #64748b;
  line-height: 1.6;
}

.insight-metrics {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.insight-metric {
  background: #f8fafc;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  text-align: center;
}

.insight-metric-value {
  display: block;
  font-size: 1.125rem;
  font-weight: 700;
  color: #1e293b;
}

.insight-metric-label {
  display: block;
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.125rem;
}

.insight-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.insight-action {
  padding: 0.5rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.insight-action:hover {
  border-color: #3b82f6;
  color: #3b82f6;
}

.insight-action.primary {
  background: #3b82f6;
  color: white;
  border-color: #3b82f6;
}

.insight-action.primary:hover {
  background: #1d4ed8;
}

/* Weekly Reports Section */
.weekly-reports-section {
  margin-bottom: 3rem;
}

.reports-config {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
}

.report-schedule,
.report-history {
  background: white;
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  border: 1px solid #e2e8f0;
}

.report-schedule h4,
.report-history h4 {
  margin: 0 0 1.5rem 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: #1e293b;
}

.schedule-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #374151;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 20px;
  height: 20px;
  border: 2px solid #d1d5db;
  border-radius: 4px;
  position: relative;
  transition: all 0.2s ease;
}

.checkbox-label input:checked + .checkmark {
  background: #3b82f6;
  border-color: #3b82f6;
}

.checkbox-label input:checked + .checkmark::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
}

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

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.history-date {
  font-size: 0.875rem;
  color: #64748b;
}

.history-status {
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.history-status.sent {
  background: #dcfce7;
  color: #166534;
}

.history-status.failed {
  background: #fef2f2;
  color: #dc2626;
}

/* Modals */
.insights-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.insights-modal.active {
  display: flex;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 16px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  z-index: 1001;
}

.report-preview-content {
  width: 800px;
}

.export-options-content {
  width: 600px;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  color: #1e293b;
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #64748b;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: #e2e8f0;
  color: #374151;
}

.modal-body {
  padding: 2rem;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1.5rem;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

/* Export Format Selector */
.export-format-selector h4 {
  margin: 0 0 1rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #1e293b;
}

.format-options {
  display: grid;
  gap: 1rem;
}

.format-option {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.format-option:hover {
  border-color: #3b82f6;
  background: #f8fafc;
}

.format-option input[type="radio"] {
  display: none;
}

.format-option input:checked + .format-icon + .format-label + .format-desc {
  border-color: #3b82f6;
  background: #dbeafe;
}

.format-option:has(input:checked) {
  border-color: #3b82f6;
  background: #dbeafe;
}

.format-icon {
  font-size: 2rem;
  flex-shrink: 0;
}

.format-label {
  font-weight: 600;
  color: #1e293b;
  margin-bottom: 0.25rem;
}

.format-desc {
  font-size: 0.875rem;
  color: #64748b;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .reports-config {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .insights-lab-header {
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
  }
  
  .lab-overview {
    flex-direction: column;
    text-align: center;
  }
  
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  
  .charts-grid {
    grid-template-columns: 1fr;
  }
  
  .insights-tabs {
    flex-wrap: wrap;
  }
  
  .modal-content {
    margin: 1rem;
    max-width: calc(100vw - 2rem);
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .kpi-card,
  .chart-container,
  .report-schedule,
  .report-history,
  .insight-card,
  .modal-content {
    background: #1e293b;
    border-color: #334155;
  }
  
  .kpi-info h4,
  .chart-header h4,
  .insight-card-content h5,
  .modal-header h2 {
    color: #f1f5f9;
  }
  
  .kpi-value span:first-child,
  .metric-value,
  .insight-metric-value {
    color: #f1f5f9;
  }
  
  .metric-label,
  .insight-description,
  .insight-metric-label {
    color: #94a3b8;
  }
  
  .insight-metric {
    background: #334155;
  }
  
  .section-header h3 {
    color: #f1f5f9;
  }
  
  .section-header p {
    color: #94a3b8;
  }
}

/* Animation utilities */
.fade-in {
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.slide-in {
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s infinite;
  border-radius: 4px;
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Chart tooltip styling */
.chart-tooltip {
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Success indicators */
.success-indicator {
  color: #10b981;
  font-weight: 600;
}

.warning-indicator {
  color: #f59e0b;
  font-weight: 600;
}

.danger-indicator {
  color: #ef4444;
  font-weight: 600;
}

/* Pulse animation for real-time data */
.pulse {
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}