/**
 * FundRaise Pro - Enhanced Reports Styles
 * Add this to your styles.css or include as separate file
 */

/* ============================================================================
   REPORT FILTERS ENHANCED
   ============================================================================ */

.report-filters-enhanced {
  background: var(--bg-secondary, #f8fafc);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--border-color, #e2e8f0);
}

.report-filters-enhanced .form-group {
  margin-bottom: 0;
}

.report-filters-enhanced label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary, #64748b);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Multi-select container for campaigns */
.multi-select-container {
  background: white;
  padding: 0.5rem;
  border-radius: 8px;
  border: 1px solid var(--border-color, #e2e8f0);
  max-height: 150px;
  overflow-y: auto;
}

.multi-select-container label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
  font-weight: 400;
}

.multi-select-container label:hover {
  background: var(--bg-secondary, #f1f5f9);
}

.multi-select-container input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary, #6366f1);
  cursor: pointer;
}

/* Toggle switch styles */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary, #64748b);
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  width: 40px;
  height: 22px;
  background: var(--border-color, #cbd5e1);
  border-radius: 22px;
  position: relative;
  transition: all 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: white;
  border-radius: 50%;
  transition: transform 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--primary, #6366f1);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* ============================================================================
   CHART CONTAINER
   ============================================================================ */

#reportChartContainer {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid var(--border-color, #e2e8f0);
}

#reportChartContainer canvas {
  max-height: 350px;
}

/* Chart title styling */
#reportChartContainer .chart-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
  margin-bottom: 1rem;
  text-align: center;
}

/* ============================================================================
   ENHANCED SUMMARY CARDS
   ============================================================================ */

.report-summary-enhanced {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.report-stat-card {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid var(--border-color, #e2e8f0);
  transition: transform 0.2s, box-shadow 0.2s;
}

.report-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.report-stat-card .stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

.report-stat-card .stat-icon.primary { background: rgba(99, 102, 241, 0.12); }
.report-stat-card .stat-icon.success { background: rgba(34, 197, 94, 0.12); }
.report-stat-card .stat-icon.warning { background: rgba(245, 158, 11, 0.12); }
.report-stat-card .stat-icon.danger { background: rgba(239, 68, 68, 0.12); }

.report-stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary, #1e293b);
  line-height: 1.2;
}

.report-stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  margin-top: 0.25rem;
}

.report-stat-card .stat-change {
  font-size: 0.75rem;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.report-stat-card .stat-change.positive { color: #22c55e; }
.report-stat-card .stat-change.negative { color: #ef4444; }

/* ============================================================================
   REPORT TABLE ENHANCEMENTS
   ============================================================================ */

#reportTable {
  font-size: 0.875rem;
}

#reportTable th {
  background: linear-gradient(to bottom, #f8fafc, #f1f5f9);
  font-weight: 600;
  color: var(--text-secondary, #475569);
  padding: 0.75rem 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
}

#reportTable td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light, #f1f5f9);
  vertical-align: middle;
}

#reportTable tbody tr {
  transition: background 0.15s;
}

#reportTable tbody tr:hover {
  background: var(--bg-secondary, #f8fafc);
}

/* Clickable rows for drill-down */
#reportTable tbody tr.clickable {
  cursor: pointer;
}

#reportTable tbody tr.clickable:hover {
  background: rgba(99, 102, 241, 0.05);
}

/* Status badges in tables */
.report-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.report-status-badge.excellent {
  background: rgba(34, 197, 94, 0.12);
  color: #16a34a;
}

.report-status-badge.good {
  background: rgba(74, 222, 128, 0.15);
  color: #22c55e;
}

.report-status-badge.fair {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
}

.report-status-badge.at-risk {
  background: rgba(249, 115, 22, 0.12);
  color: #ea580c;
}

.report-status-badge.critical {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
}

/* Health score bar */
.health-score-bar {
  width: 80px;
  height: 8px;
  background: var(--border-color, #e2e8f0);
  border-radius: 4px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.5rem;
}

.health-score-bar .fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.health-score-bar .fill.excellent { background: #22c55e; }
.health-score-bar .fill.good { background: #4ade80; }
.health-score-bar .fill.fair { background: #facc15; }
.health-score-bar .fill.at-risk { background: #f97316; }
.health-score-bar .fill.critical { background: #ef4444; }

/* ============================================================================
   SAVED PRESETS DROPDOWN
   ============================================================================ */

.preset-dropdown {
  position: relative;
}

.preset-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  max-height: 250px;
  overflow-y: auto;
  display: none;
}

.preset-dropdown-menu.open {
  display: block;
}

.preset-dropdown-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 1rem;
  cursor: pointer;
  transition: background 0.15s;
}

.preset-dropdown-item:hover {
  background: var(--bg-secondary, #f8fafc);
}

.preset-dropdown-item .preset-name {
  font-weight: 500;
  color: var(--text-primary, #1e293b);
}

.preset-dropdown-item .preset-date {
  font-size: 0.75rem;
  color: var(--text-muted, #94a3b8);
}

.preset-dropdown-item .delete-preset {
  opacity: 0;
  padding: 0.25rem 0.5rem;
  color: var(--danger, #ef4444);
  cursor: pointer;
}

.preset-dropdown-item:hover .delete-preset {
  opacity: 1;
}

/* ============================================================================
   DRILL-DOWN MODAL
   ============================================================================ */

.drill-down-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}

.drill-down-overlay.open {
  opacity: 1;
  visibility: visible;
}

.drill-down-modal {
  background: white;
  border-radius: 16px;
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  overflow: hidden;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  transform: scale(0.95);
  transition: transform 0.2s;
}

.drill-down-overlay.open .drill-down-modal {
  transform: scale(1);
}

.drill-down-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drill-down-header h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary, #1e293b);
}

.drill-down-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: var(--bg-secondary, #f1f5f9);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: var(--text-muted, #64748b);
  transition: background 0.15s;
}

.drill-down-close:hover {
  background: var(--border-color, #e2e8f0);
}

.drill-down-body {
  padding: 1.5rem;
  max-height: calc(85vh - 70px);
  overflow-y: auto;
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
  /* Hide non-essential elements */
  .report-filters-enhanced,
  .toggle-switch,
  button,
  .btn,
  .page-header-actions,
  .nav-tabs,
  .sidebar,
  header {
    display: none !important;
  }
  
  /* Full width for content */
  .main-content,
  .view-content,
  #reportResults {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  
  /* Chart container for print */
  #reportChartContainer {
    break-inside: avoid;
    page-break-inside: avoid;
    margin: 20px 0;
    box-shadow: none;
    border: 1px solid #ddd;
  }
  
  /* Table styling for print */
  #reportTable {
    font-size: 10pt;
  }
  
  #reportTable th {
    background: #f1f5f9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  
  #reportTable tbody tr:nth-child(even) {
    background: #f8fafc !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  
  /* Summary cards for print */
  .stats-grid,
  .report-summary-enhanced {
    display: flex !important;
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .stat-card,
  .report-stat-card {
    break-inside: avoid;
    page-break-inside: avoid;
    border: 1px solid #ddd !important;
    box-shadow: none !important;
  }
  
  /* Page breaks */
  .card {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  
  /* Report title */
  #reportTitle {
    font-size: 18pt;
    margin-bottom: 15px;
  }
}

/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

@media (max-width: 768px) {
  .report-filters-enhanced {
    padding: 0.75rem;
  }
  
  .report-filters-enhanced > div {
    min-width: 100% !important;
  }
  
  #reportChartContainer {
    padding: 1rem;
  }
  
  #reportChartContainer canvas {
    max-height: 250px;
  }
  
  .multi-select-container {
    max-height: 120px;
  }
  
  .report-summary-enhanced {
    grid-template-columns: repeat(2, 1fr);
  }
  
  #reportTable {
    font-size: 0.8rem;
  }
  
  #reportTable th,
  #reportTable td {
    padding: 0.5rem;
  }
}

@media (max-width: 480px) {
  .report-summary-enhanced {
    grid-template-columns: 1fr;
  }
  
  .report-stat-card .stat-value {
    font-size: 1.25rem;
  }
}

/* ============================================================================
   CHART ANIMATION
   ============================================================================ */

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

#reportChartContainer {
  animation: chartFadeIn 0.4s ease-out;
}

/* ============================================================================
   EXPORT BUTTON ENHANCEMENT
   ============================================================================ */

.export-btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.export-btn-group .btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.export-btn-group .btn .icon {
  font-size: 1rem;
}

/* Include chart checkbox styling */
.include-chart-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary, #64748b);
  margin-left: 0.5rem;
  padding-left: 0.5rem;
  border-left: 1px solid var(--border-color, #e2e8f0);
}
