/* Statistics dashboard */

/* metric toggle (Alumnos / Importe) */
.stats-toggle {
  display: inline-flex;
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
}

.stats-toggle-btn {
  border: none;
  background-color: white;
  color: #555;
  font-size: 12px;
  font-family: inherit;
  padding: 6px 14px;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}

.stats-toggle-btn:focus { outline: none; }

/* vertical divider between toggle buttons (border on every button but the last) */
.stats-toggle-btn:not(:last-child) {
  border-right: 1px solid #cfcfcf;
}

.stats-toggle-btn.active {
  background-color: var(--color1);
  color: white;
}

/* dashboard shell: fills the viewport below the sticky header.
   the topbar stays fixed; only .stats-charts scrolls. */
.stats-dashboard {
  display: flex;
  flex-direction: column;
  /* header is ~61px (logo 49 + padding); leave room for it */
  height: calc(100vh - 61px);
  overflow: hidden;
}

/* fixed top bar: title + shared filters */
.stats-topbar {
  flex-shrink: 0;
  background-color: white;
  padding: 12px 32px 14px;
  border-bottom: 1px solid #e8e8e8;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  z-index: 3;
}

/* filters row */
.stats-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 18px 24px;
}

/* scrollable charts area */
.stats-charts {
  flex: 1;
  overflow-y: auto;
  padding: 20px 32px 28px;
  display: flex;
  flex-direction: column;
  row-gap: 20px;
}

/* top row: year (narrow) + month (wide) side by side */
.stats-charts-row {
  display: flex;
  gap: 20px;
  align-items: stretch;
}

.stats-card-year { flex: 1 1 0; }
.stats-card-month { flex: 2 1 0; }

/* chart cards */
.stats-chart-card {
  position: relative;
  background-color: white;
  border: 1px solid #e8e8e8;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  padding: 18px 20px;
}

.stats-chart-title {
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: #4a4a4a;
  margin: 0 0 4px;
}

.stats-chart-canvas {
  position: relative;
  height: 300px;
  width: 100%;
}

.stats-chart-canvas canvas {
  display: block;
}

/* month card: chart (60%) + summary table (40%) side by side */
.stats-month-body {
  display: flex;
  gap: 20px;
  align-items: stretch;
}

.stats-month-chart {
  position: relative;
  flex: 0 0 65%;
  max-width: 65%;
}

.stats-month-table-wrap {
  flex: 1 1 35%;
  display: flex;
  flex-direction: column;
  /* center the table+note group vertically */
  justify-content: center;
}

/* table + note stack naturally as a normal block, so the note sits right
   below the table (not stretched to the bottom of the wrap) */
.stats-month-table-group {
  width: 100%;
}

.stats-month-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  overflow: hidden;
  border-radius: 8px;
}

.stats-month-table th,
.stats-month-table td {
  padding: 6px 8px;
  text-align: center;
  border-bottom: 1px solid #eee;
}

/* soft light header with blue text (not a heavy dark bar), rounded top corners */
.stats-month-table th {
  background-color: var(--color3);
  color: var(--color1);
  font-weight: 600;
  font-size: 11px;
}

.stats-month-table thead th:first-child {
  border-top-left-radius: 8px;
}

.stats-month-table thead th:last-child {
  border-top-right-radius: 8px;
}

.stats-month-table tbody tr:nth-child(even) {
  background-color: #fafcfd;
}

.stats-month-td-type {
  font-weight: 600;
  color: #555;
}

.stats-month-total-row td {
  background-color: #f2f6f8;
  font-weight: 700;
  color: var(--color1);
  border-bottom: none;
}

.stats-month-note {
  margin-top: 10px;
  font-size: 11px;
  color: #999;
  font-style: italic;
}

.stats-filter-group {
  display: flex;
  flex-direction: column;
  row-gap: 8px;
}

.stats-filter-title {
  font-size: 11px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* course type checks (checkbox + colored alias, multi-select) */
.stats-type-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.stats-type-check {
  display: inline-flex;
  align-items: center;
  column-gap: 7px;
  font-size: 13px;
  cursor: pointer;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 4px 8px 4px 10px;
  background-color: #fafafa;
  transition: border-color 0.15s, background-color 0.15s;
}

.stats-type-check:hover {
  border-color: var(--color2);
}

.stats-type-check input {
  cursor: pointer;
  accent-color: var(--color1);
}

/* alias badge keeps its type background color whether checked or not */
.stats-type-alias {
  font-weight: 600;
  color: #fff;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
}

.w-year-stats { width: 150px; }

/* weekly chart (full width, taller) */
.stats-week-chart {
  position: relative;
  height: 400px;
  width: 100%;
}

.stats-week-chart canvas {
  display: block;
}

/* week detail — floating tooltip shown on column hover */
.stats-detail {
  display: none;
  position: absolute;
  z-index: 5;
  min-width: 190px;
  max-width: 260px;
  background-color: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
  padding: 10px 12px;
  pointer-events: none;
}

.stats-detail-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--color1);
  text-align: center;
  margin-bottom: 8px;
}

.stats-detail-body {
  max-height: 260px;
  overflow: auto;
}

.stats-detail-row {
  display: flex;
  align-items: center;
  column-gap: 8px;
  padding: 4px 2px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 11px;
  color: #333;
}

.stats-detail-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.stats-detail-alias {
  flex: 1;
}

.stats-detail-value {
  font-weight: 500;
  color: #4a4a4a;
  white-space: nowrap;
}

.stats-detail-total {
  border-bottom: none;
  border-top: 2px solid var(--color1);
  margin-top: 2px;
  padding-top: 6px;
}

.stats-detail-total .stats-detail-alias,
.stats-detail-total .stats-detail-value {
  color: var(--color1);
  font-weight: 700;
}
