/* 
  EduFlow SaaS Educational ERP - Reports & Analytics Module Stylesheet
  -------------------------------------------------------------------
*/

/* Import app and design system styles */
@import url("app.css");

/* --- Main workspace grid --- */
.reports-workspace-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  width: 100%;
}

.reports-screen-element {
  display: none;
  width: 100%;
  animation: fadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.reports-screen-element.active {
  display: block;
}

/* --- Executive Dashboard KPI Cards --- */
.reports-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.reports-kpi-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  position: relative;
}

.reports-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}

.reports-kpi-card .trend-pill {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.reports-kpi-card .trend-up {
  background-color: var(--color-success-bg);
  color: var(--color-success);
}

.reports-kpi-card .trend-down {
  background-color: var(--color-danger-bg);
  color: var(--color-danger);
}

/* --- Executive Insights Panel --- */
.insight-card {
  background-color: var(--color-surface-hover);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-xs) var(--radius-md) var(--radius-md) var(--radius-xs);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

/* --- SVG Chart Layouts --- */
.reports-chart-box {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.reports-chart-wrapper {
  position: relative;
  width: 100%;
  height: 220px;
  margin-top: var(--space-4);
}

/* Bar Chart Grid styling */
.chart-bar-group {
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  height: 100%;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--color-border);
}

.chart-bar-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 30px;
}

.chart-bar-fill {
  width: 100%;
  background-color: var(--color-primary);
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
  transition: height 0.5s ease-out;
  position: relative;
}

.chart-bar-fill:hover {
  background-color: var(--color-primary-hover);
}

.chart-bar-label {
  font-size: 0.6875rem;
  color: var(--color-text-secondary);
  margin-top: 6px;
  white-space: nowrap;
}

.chart-bar-value {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

/* --- Circular Progress / Dials (Health score) --- */
.health-score-dial-wrapper {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto;
}

.health-score-dial-svg {
  transform: rotate(-90deg);
}

.health-score-dial-track {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 12;
}

.health-score-dial-fill {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 12;
  stroke-dasharray: 440;
  stroke-dashoffset: 440;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s ease-out;
}

.health-score-dial-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.health-score-num {
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-text-primary);
  line-height: 1;
}

.health-score-lbl {
  font-size: 0.6875rem;
  color: var(--color-text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 4px;
}

/* --- Attendance Heat Map --- */
.attendance-heatmap-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  max-width: 100%;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.heatmap-cell:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.heatmap-cell.level-high { background-color: rgba(16, 185, 129, 0.25); color: #065F46; }
.heatmap-cell.level-medium { background-color: rgba(245, 158, 11, 0.25); color: #92400E; }
.heatmap-cell.level-low { background-color: rgba(239, 68, 68, 0.25); color: #991B1B; }
.heatmap-cell.level-zero { background-color: var(--color-surface-hover); color: var(--color-text-tertiary); }

/* --- Full Analytics Calendar Grid --- */
.analytics-calendar-wrapper {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.analytics-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.analytics-calendar-cell {
  min-height: 80px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
  background-color: var(--color-surface);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.analytics-calendar-cell:hover {
  background-color: var(--color-surface-hover);
}

.analytics-calendar-cell.muted {
  opacity: 0.3;
}

.calendar-cell-date {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-secondary);
}

.calendar-cell-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 4px;
}

.calendar-event-tag {
  font-size: 0.625rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 2px;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-academic { background-color: var(--color-primary); }
.event-exam { background-color: var(--color-warning); }
.event-finance { background-color: var(--color-danger); }
.event-holiday { background-color: var(--color-success); }
.event-meeting { background-color: var(--color-info); }

/* --- Custom Report Builder --- */
.builder-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-6);
}

.builder-sidebar {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-5);
}

/* --- Export Document Preview --- */
.export-preview-box {
  background-color: #FFFFFF;
  color: #1E2030;
  border: 1px solid # CED2E6;
  border-radius: var(--radius-sm);
  padding: var(--space-8);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.75rem;
  white-space: pre-wrap;
  max-height: 350px;
  overflow-y: auto;
  box-shadow: var(--shadow-inner);
}

/* --- CSS Media Print Rules --- */
@media print {
  body * {
    visibility: hidden;
  }
  .printable-document-area, .printable-document-area * {
    visibility: visible;
  }
  .printable-document-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    box-shadow: none;
    border: none;
    padding: 0;
    margin: 0;
  }
  .layout-portal-header, .erp-sidebar, .erp-header, .layout-portal-controls, .btn, .builder-sidebar {
    display: none !important;
  }
}

/* --- Dark Theme overrides --- */
[data-theme="dark"] .export-preview-box {
  background-color: #140E2E;
  color: #F0EDF9;
  border-color: #251D4B;
}

[data-theme="dark"] .heatmap-cell.level-high { background-color: rgba(16, 185, 129, 0.4); color: #A7F3D0; }
[data-theme="dark"] .heatmap-cell.level-medium { background-color: rgba(245, 158, 11, 0.4); color: #FDE68A; }
[data-theme="dark"] .heatmap-cell.level-low { background-color: rgba(239, 68, 68, 0.4); color: #FCA5A5; }
[data-theme="dark"] .heatmap-cell.level-zero { background-color: #1A123D; color: var(--color-text-secondary); }
