/*
 * Gráficos — linguagem visual do Egghead anterior.
 * Mantém a estrutura e os dados da migração, mas recupera a paleta pastel,
 * grades discretas, curvas suaves e barras sem o contorno neo-brutalista.
 */

:root {
  --legacy-chart-accent: #746fb6;
  --legacy-chart-accent-dark: #565192;
  --legacy-chart-accent-soft: #eceaff;
  --legacy-chart-success: #2f7d72;
  --legacy-chart-success-soft: #e8f8f4;
  --legacy-chart-info: #58799a;
  --legacy-chart-info-soft: #edf5ff;
  --legacy-chart-danger: #a25467;
  --legacy-chart-danger-soft: #fde9ed;
  --legacy-chart-warn: #c8a968;
  --legacy-chart-grid: #d9e3e7;
  --legacy-chart-grid-soft: #e8eef2;
  --legacy-chart-muted: #758093;
  --legacy-chart-surface: #fffefd;
  --legacy-chart-radius: 12px;
}

/* Elementos compartilhados */
.chart-labels,
.graphx-x-labels,
.graphx-y-labels,
.graphx-mini-chart > div,
.admx-chart-days {
  color: var(--legacy-chart-muted) !important;
  font-size: 10px !important;
  font-weight: 650 !important;
}

.chart-legend {
  gap: 16px;
}

.chart-legend span {
  color: var(--legacy-chart-muted);
  font-size: 11px;
  font-weight: 700;
}

.chart-legend i,
.chart-legend i.yellow {
  width: 11px;
  height: 11px;
  border: 0;
  border-radius: 4px;
  background: var(--legacy-chart-accent);
}

.chart-legend i.yellow {
  background: var(--legacy-chart-info);
}

/* Desempenho — colunas de volume e curva de acerto */
.performance-combo-chart {
  min-height: 300px;
  padding: 18px 4px 28px;
}

.performance-combo-chart::before {
  inset: 18px 4px 40px;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 58px,
    var(--legacy-chart-grid-soft) 58px 59px
  );
}

.performance-bars {
  inset: 18px 22px 40px;
  gap: 14px;
}

.performance-bars span {
  width: clamp(12px, 4vw, 27px);
  border: 0;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, #9fc7df, var(--legacy-chart-info));
  box-shadow: 0 5px 12px rgba(88, 121, 154, .18);
  opacity: .88;
}

.performance-combo-chart .trend {
  fill: none;
  stroke: var(--legacy-chart-accent) !important;
  stroke-width: 4 !important;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 4px rgba(116, 111, 182, .18));
}

.performance-trend-points circle {
  fill: var(--legacy-chart-surface);
  stroke: var(--legacy-chart-accent);
  stroke-width: 3;
  vector-effect: non-scaling-stroke;
}

.performance-goal-track,
.performance-ranking i,
.hit-error-days i,
.error-causes i,
.xray-incidence-list i,
.xray-detail-table i {
  overflow: hidden;
  border: 0 !important;
  border-radius: 999px !important;
  background: var(--legacy-chart-grid-soft) !important;
  box-shadow: inset 0 0 0 1px rgba(88, 121, 154, .08);
}

.performance-goal-track {
  height: 12px;
}

.performance-goal-track i {
  border: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--legacy-chart-accent), #9f9ad7);
}

.performance-ranking i b,
.hit-error-days i b,
.xray-incidence-list i b,
.xray-detail-table i b {
  border: 0 !important;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--legacy-chart-accent), #9f9ad7) !important;
}

.hit-error-total {
  overflow: hidden;
  border: 0 !important;
  border-radius: var(--legacy-chart-radius) !important;
  box-shadow: inset 0 0 0 1px var(--legacy-chart-grid);
}

.hit-error-total .hit-segment {
  background: var(--legacy-chart-success-soft) !important;
  color: var(--legacy-chart-success) !important;
}

.hit-error-total .error-segment {
  background: var(--legacy-chart-danger-soft) !important;
  color: var(--legacy-chart-danger) !important;
}

/* Histórico de erros */
.error-causes {
  gap: 16px;
}

.error-causes > div {
  gap: 7px;
  color: var(--legacy-chart-muted);
  font-size: 11px;
}

.error-causes i {
  height: 9px;
}

.error-causes b {
  border: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--legacy-chart-danger), #cf8295);
}

/* Raio X — distribuição e incidência */
.xray-donut {
  border: 0 !important;
  background: conic-gradient(
    var(--legacy-chart-accent) 0 24%,
    var(--legacy-chart-success) 24% 45%,
    var(--legacy-chart-info) 45% 63%,
    var(--legacy-chart-danger) 63% 79%,
    var(--legacy-chart-grid) 79% 100%
  );
  box-shadow: 0 12px 28px rgba(87, 103, 136, .14);
}

.xray-donut::after {
  border: 0 !important;
  background: var(--legacy-chart-surface) !important;
  box-shadow: inset 0 0 0 1px var(--legacy-chart-grid-soft);
}

.xray-legend i {
  border: 0 !important;
  border-radius: 4px !important;
}

.xray-legend .tone-1 { background: var(--legacy-chart-accent) !important; }
.xray-legend .tone-2 { background: var(--legacy-chart-success) !important; }
.xray-legend .tone-3 { background: var(--legacy-chart-info) !important; }
.xray-legend .tone-4 { background: var(--legacy-chart-danger) !important; }
.xray-legend .tone-5 { background: var(--legacy-chart-warn) !important; }

.xray-incidence-list i,
.xray-detail-table i {
  height: 8px !important;
}

/* Hub Gráficos — mesma curva lavanda usada no design anterior */
.graphx-chart-shell {
  border-right-color: var(--legacy-chart-grid-soft);
  background: linear-gradient(180deg, rgba(248, 251, 255, .7), rgba(255, 254, 253, 0));
}

.graphx-grid-lines line,
.graphx-mini-chart .graphx-grid-lines line {
  stroke: var(--legacy-chart-grid) !important;
  stroke-dasharray: 4 7 !important;
  stroke-width: 1 !important;
}

.graphx-area-fill {
  fill: rgba(116, 111, 182, .13) !important;
}

.graphx-main-line,
.graphx-mini-chart svg > path {
  fill: none;
  stroke: var(--legacy-chart-accent) !important;
  stroke-width: 4 !important;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 4px rgba(116, 111, 182, .16));
}

.graphx-points circle,
.graphx-mini-chart svg > g:last-child circle {
  fill: var(--legacy-chart-surface) !important;
  stroke: var(--legacy-chart-accent) !important;
  stroke-width: 3 !important;
}

.graphx-mini-chart {
  background: linear-gradient(180deg, rgba(236, 234, 255, .36), transparent 72%);
}

.graphx-mini-value {
  color: var(--legacy-chart-accent-dark);
}

.graphx-subject-index,
.graphx-subject-index.neutral,
.graphx-subject-index.light,
.graphx-subject-index.dark {
  border: 0;
  border-radius: 10px;
  background: var(--legacy-chart-accent-soft);
  box-shadow: none;
  color: var(--legacy-chart-accent-dark);
}

.graphx-record-list > div.is-current {
  border-color: transparent;
  border-radius: var(--legacy-chart-radius);
  background: var(--legacy-chart-accent-soft);
  box-shadow: none;
}

.graphx-record-list > div > span {
  border: 0;
  border-radius: 8px;
  background: #f2f8f6;
  color: var(--legacy-chart-muted);
}

/* Cronograma — carga semanal */
.crx-load-bars > div > i {
  border: 0 !important;
  border-radius: 8px 8px 3px 3px !important;
  background: var(--legacy-chart-grid-soft) !important;
}

.crx-load-bars b {
  border: 0 !important;
  border-radius: inherit;
  background: linear-gradient(180deg, #b9c7ff, var(--legacy-chart-accent)) !important;
}

.crx-load-bars .is-today b {
  background: linear-gradient(180deg, #9bdccf, var(--legacy-chart-success)) !important;
}

/* Administração — atividade da plataforma */
.admx-chart-area {
  border-color: var(--legacy-chart-grid) !important;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0 43px,
    var(--legacy-chart-grid-soft) 43px 44px
  );
}

.admx-chart-area > i {
  width: 13px;
}

.admx-chart-area > i b,
.admin-bars div {
  border: 0 !important;
  border-radius: 7px 7px 2px 2px;
  background: linear-gradient(180deg, #d8d4f6, var(--legacy-chart-accent)) !important;
  box-shadow: 0 4px 10px rgba(116, 111, 182, .14);
}

.admx-chart-area > i em {
  width: 8px;
  height: 8px;
  border: 2px solid var(--legacy-chart-accent) !important;
  background: var(--legacy-chart-surface) !important;
}

.admx-chart-area > i.today b,
.admin-bars div.current {
  background: linear-gradient(180deg, #9bdccf, var(--legacy-chart-success)) !important;
}

.admx-chart-area polyline {
  stroke: var(--legacy-chart-accent) !important;
  stroke-width: 3 !important;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(116, 111, 182, .16));
}

.admx-chart-area polyline.secondary {
  stroke: var(--legacy-chart-success) !important;
  stroke-dasharray: 5 6;
  stroke-width: 2 !important;
}

.admx-activity footer span > i {
  border: 0 !important;
  border-radius: 4px !important;
  background: var(--legacy-chart-success) !important;
}

.admx-activity footer span > i.active {
  background: var(--legacy-chart-accent) !important;
}

.admin-bars {
  border-bottom-color: var(--legacy-chart-grid) !important;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 52px,
    var(--legacy-chart-grid-soft) 52px 53px
  );
}

@media (max-width: 760px) {
  .performance-bars {
    gap: 7px;
  }

  .performance-bars span {
    width: 14px;
  }

  .graphx-chart-shell {
    background: transparent;
  }

  .chart-labels,
  .graphx-x-labels,
  .admx-chart-days {
    font-size: 8px !important;
  }
}

/* Estados operacionais compartilhados. */
.stability-message {
  position: fixed;
  z-index: 9999;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  border: 1px solid #d9e3e7;
  border-radius: 12px;
  padding: 12px 15px;
  background: #fffefd;
  color: #20222f;
  box-shadow: 0 12px 32px rgba(87, 103, 136, .18);
  font-size: 12px;
  font-weight: 750;
}

.stability-message.is-warning { border-color: #c8a968; background: #fff9e8; }
.stability-message.is-error { border-color: #a25467; background: #fde9ed; }

html:not(.is-admin-user) [data-screen="admin"] { display: none !important; }

/* Comunidade das questões */
.bank-community {
  margin-top: 20px;
  border: 1px solid var(--legacy-chart-grid);
  border-radius: 14px;
  background: #fffefd;
}

.bank-community-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--legacy-chart-grid-soft);
  padding: 8px;
}

.bank-community-tabs button {
  border: 0;
  border-radius: 9px;
  padding: 9px 12px;
  background: transparent;
  color: var(--legacy-chart-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 800;
}

.bank-community-tabs button.is-active {
  background: var(--legacy-chart-accent-soft);
  color: var(--legacy-chart-accent-dark);
}

.bank-community-tabs .bank-question-report-trigger { margin-left: auto; color: var(--legacy-chart-muted); font-size: 9px; text-decoration: underline; text-underline-offset: 3px; }
.bank-question-report-form { display: grid; grid-template-columns: minmax(180px, .7fr) minmax(260px, 1.3fr); gap: 12px; padding: 16px; border-bottom: 1px solid var(--legacy-chart-grid-soft); background: var(--legacy-chart-accent-soft); }
.bank-question-report-form[hidden] { display: none; }
.bank-question-report-form label { display: grid; gap: 6px; color: var(--legacy-chart-muted); font-size: 9px; font-weight: 800; }
.bank-question-report-form :is(select, textarea) { width: 100%; border: 1px solid var(--legacy-chart-grid-soft); border-radius: 7px; background: #fff; color: #20222f; font: inherit; padding: 9px; }
.bank-question-report-form footer { display: flex; grid-column: 1 / -1; align-items: center; justify-content: flex-end; gap: 12px; }
.bank-question-report-form footer p { margin-right: auto; color: #237544; font-size: 9px; }
.bank-question-report-form.is-success { background: #e8f7ed; }
.bank-uem-sum { display: grid; grid-column: 1 / -1; gap: 14px; padding: 16px; border: 1px solid var(--legacy-chart-grid-soft); border-radius: 10px; background: #fffdf7; }
.bank-uem-sum > div { display: grid; gap: 3px; }
.bank-uem-sum > div span { color: var(--legacy-chart-muted); font-size: 10px; }
.bank-uem-sum ol { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.bank-uem-sum li { display: grid; grid-template-columns: 36px minmax(0, 1fr); align-items: start; gap: 10px; padding: 10px; border: 1px solid var(--legacy-chart-grid-soft); border-radius: 7px; background: #fff; }
.bank-uem-sum li b { display: grid; min-height: 30px; place-items: center; border-radius: 6px; background: var(--legacy-chart-accent-soft); color: var(--legacy-chart-accent-dark); }
.bank-uem-sum li span { width: auto !important; height: auto !important; display: block !important; border: 0 !important; background: transparent !important; font-weight: 600 !important; line-height: 1.45; }
.bank-uem-sum label { display: grid; max-width: 170px; gap: 6px; color: var(--legacy-chart-muted); font-size: 9px; font-weight: 800; }
.bank-uem-sum input { width: 100%; min-height: 44px; border: 2px solid var(--legacy-chart-accent-dark); border-radius: 8px; background: #fff; color: #20222f; font: 900 18px/1 monospace; padding: 0 12px; text-align: center; }

.bank-community-panel { padding: 16px; }
.bank-community-panel[hidden] { display: none; }
.bank-community-panel form label { display: grid; gap: 7px; }
.bank-community-panel form textarea { width: 100%; resize: vertical; }
.bank-community-panel form footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
.bank-community-panel form footer > span { color: var(--legacy-chart-muted); font-size: 10px; }
.bank-community-comment-list { display: grid; gap: 10px; margin-top: 16px; }
.bank-community-comment { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 10px; border-top: 1px solid var(--legacy-chart-grid-soft); padding-top: 12px; }
.bank-community-comment > span { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: var(--legacy-chart-accent-soft); color: var(--legacy-chart-accent-dark); font-weight: 900; }
.bank-community-comment header { display: flex; justify-content: space-between; gap: 10px; }
.bank-community-comment time { color: var(--legacy-chart-muted); font-size: 9px; }
.bank-community-comment p { margin: 5px 0 0; white-space: pre-wrap; }
.bank-community-comment footer { display: flex; gap: 10px; margin-top: 7px; }
.bank-community-comment footer button { border: 0; background: transparent; color: var(--legacy-chart-muted); cursor: pointer; font: inherit; font-size: 9px; font-weight: 800; padding: 2px 0; }
.bank-community-comment footer button:hover { color: var(--legacy-chart-accent-dark); }
.bank-community-comment footer button.is-danger:hover { color: #a24657; }
@media (max-width: 680px) {
  .bank-community-tabs { flex-wrap: wrap; }
  .bank-community-tabs .bank-question-report-trigger { width: 100%; margin-left: 0; text-align: left; }
  .bank-question-report-form { grid-template-columns: 1fr; }
  .bank-question-report-form footer { grid-column: auto; align-items: stretch; flex-direction: column; }
}
.bank-community-distribution > header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.bank-community-distribution > header div { display: grid; }
.bank-community-distribution > header span { color: var(--legacy-chart-muted); font-size: 10px; }
.bank-community-distribution > div { display: grid; gap: 11px; }
.bank-community-distribution > div > div { display: grid; grid-template-columns: 80px minmax(0, 1fr) 72px; align-items: center; gap: 9px; }
.bank-community-distribution > div > div > span { display: flex; align-items: center; gap: 6px; color: var(--legacy-chart-muted); font-size: 9px; }
.bank-community-distribution > div > div > span b { display: grid; width: 25px; height: 25px; place-items: center; border-radius: 7px; background: var(--legacy-chart-grid-soft); color: #20222f; }
.bank-community-distribution > div > div > i { height: 9px; overflow: hidden; border-radius: 999px; background: var(--legacy-chart-grid-soft); }
.bank-community-distribution > div > div > i b { display: block; height: 100%; border-radius: inherit; background: var(--legacy-chart-accent); }
.bank-community-distribution > div > div.is-user-choice > i b { background: var(--legacy-chart-success); }
.bank-community-distribution > div > div > strong { text-align: right; }
.bank-community-distribution > div > div small { color: var(--legacy-chart-muted); }
