/* =========================================================
   GLOBAL TUTORS PREP DOCENTE
   HISTORIAL Y PROGRESO GENERAL V3.1
   Módulo independiente: no altera Pantallas 7, 8 ni 9.
   ========================================================= */

#pantalla-historial.gt-history-screen {
  --gh-navy: #08265e;
  --gh-navy-deep: #061b46;
  --gh-blue: #155eef;
  --gh-teal: #0f9f8f;
  --gh-green: #069b61;
  --gh-red: #e12d39;
  --gh-orange: #e67e00;
  --gh-purple: #7c3aed;
  --gh-slate-50: #f8fafc;
  --gh-slate-100: #f1f5f9;
  --gh-slate-200: #e2e8f0;
  --gh-slate-300: #cbd5e1;
  --gh-slate-500: #64748b;
  --gh-slate-700: #334155;
  --gh-shadow: 0 18px 44px rgba(15, 23, 42, 0.08);
  width: 100%;
  max-width: 1500px !important;
  padding: 0 !important;
  overflow: visible;
  background: transparent !important;
  box-shadow: none !important;
}

#pantalla-historial.gt-history-screen::before {
  display: none !important;
}

.gt-history-screen,
.gt-history-screen * {
  box-sizing: border-box;
}

.gt-history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 30px;
  color: #fff;
  background: linear-gradient(135deg, var(--gh-navy-deep), var(--gh-navy));
  border-radius: 22px 22px 0 0;
}

.gt-history-header h2 {
  margin: 8px 0 5px !important;
  color: #fff !important;
  font-size: clamp(25px, 2.4vw, 38px) !important;
  line-height: 1.08;
}

.gt-history-header p {
  margin: 0;
  color: #dbeafe;
  font-size: 14px;
}

.gt-history-kicker {
  display: inline-flex;
  padding: 6px 10px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  color: #a7f3d0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}

.gt-history-back {
  display: block;
  margin-bottom: 10px;
  padding: 0;
  color: #bfdbfe;
  background: none;
  border: 0;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.gt-history-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.gt-history-header-actions button {
  min-height: 43px;
  padding: 10px 15px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.gt-history-pdf {
  color: var(--gh-navy);
  background: #fff;
  border: 1px solid rgba(255,255,255,.7);
}

.gt-history-filter-toggle {
  display: none;
  color: #fff;
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.22);
}

.gt-history-filters {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr .85fr .85fr auto;
  gap: 12px;
  padding: 18px 22px;
  background: #fff;
  border: 1px solid var(--gh-slate-200);
  border-top: 0;
}

.gt-history-filters label {
  display: grid;
  gap: 6px;
}

.gt-history-filters label > span {
  color: var(--gh-slate-700);
  font-size: 11px;
  font-weight: 900;
}

.gt-history-filters select,
.gt-history-filters input {
  width: 100%;
  min-height: 42px;
  padding: 8px 11px;
  border: 1px solid var(--gh-slate-300);
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font-size: 13px;
}

.gt-history-clear {
  align-self: end;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid var(--gh-slate-200);
  border-radius: 10px;
  color: var(--gh-blue);
  background: var(--gh-slate-50);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

#gt-history-content {
  padding: 22px;
  background: #f6f9fd;
  border: 1px solid var(--gh-slate-200);
  border-top: 0;
  border-radius: 0 0 22px 22px;
}

.gt-history-metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.gt-history-metric {
  position: relative;
  min-height: 126px;
  padding: 18px 15px 15px 58px;
  border: 1px solid var(--gh-slate-200);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15,23,42,.04);
}

.gt-history-metric-icon {
  position: absolute;
  top: 18px;
  left: 15px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 11px;
  font-size: 20px;
  font-weight: 900;
}

.gt-history-metric small,
.gt-history-metric strong,
.gt-history-metric span {
  display: block;
}

.gt-history-metric small {
  color: var(--gh-slate-700);
  font-size: 11px;
  font-weight: 900;
}

.gt-history-metric strong {
  margin-top: 8px;
  color: var(--gh-navy);
  font-size: 29px;
  line-height: 1;
}

.gt-history-metric > div > span {
  margin-top: 8px;
  color: var(--gh-slate-500);
  font-size: 10px;
  line-height: 1.35;
}

.gt-history-metric.promedio .gt-history-metric-icon { color: var(--gh-green); background: #e6f8ef; }
.gt-history-metric.mejor .gt-history-metric-icon { color: var(--gh-blue); background: #eaf1ff; }
.gt-history-metric.intentos .gt-history-metric-icon { color: var(--gh-purple); background: #f1eafe; }
.gt-history-metric.preguntas .gt-history-metric-icon { color: var(--gh-orange); background: #fff1dc; }
.gt-history-metric.tiempo .gt-history-metric-icon { color: var(--gh-red); background: #ffebed; }

.gt-history-analysis-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(350px, .95fr);
  gap: 14px;
  margin-top: 14px;
}

.gt-history-chart-card,
.gt-history-topics,
.gt-history-records {
  border: 1px solid var(--gh-slate-200);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15,23,42,.035);
}

.gt-history-chart-card {
  padding: 18px;
}

.gt-history-chart-card > header,
.gt-history-records > header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.gt-history-chart-card h3,
.gt-history-records h3,
.gt-history-topics h3 {
  margin: 0;
  color: var(--gh-navy);
  font-size: 16px;
}

.gt-history-chart-card p,
.gt-history-records header p {
  margin: 4px 0 0;
  color: var(--gh-slate-500);
  font-size: 11px;
}

.gt-history-chart-svg {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 10px;
}

.gt-history-chart-svg .grid {
  stroke: #e2e8f0;
  stroke-width: 1;
}

.gt-history-chart-svg .result-line {
  fill: none;
  stroke: var(--gh-blue);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gt-history-chart-svg .result-point {
  fill: var(--gh-blue);
  stroke: #fff;
  stroke-width: 3;
}

.gt-history-chart-svg .axis-label,
.gt-history-chart-svg .date-label {
  fill: #64748b;
  font-size: 11px;
  font-weight: 700;
}

.gt-history-empty-chart,
.gt-history-empty {
  display: grid;
  place-items: center;
  min-height: 230px;
  padding: 28px;
  text-align: center;
  color: var(--gh-slate-500);
}

.gt-history-empty-chart > span,
.gt-history-empty > span {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 15px;
  color: var(--gh-blue);
  background: #eaf1ff;
  font-size: 25px;
}

.gt-history-empty-chart strong,
.gt-history-empty h3 {
  margin: 12px 0 4px;
  color: var(--gh-navy);
}

.gt-history-empty-chart p,
.gt-history-empty p { margin: 0; font-size: 12px; }

.gt-history-topic-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.gt-history-topics {
  padding: 17px;
}

.gt-history-topics.dominio h3 { color: #08784e; }
.gt-history-topics.reforzar h3 { color: #c41f2d; }

.gt-history-topic-row {
  margin-top: 15px;
}

.gt-history-topic-row > div:first-child {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--gh-slate-700);
  font-size: 11px;
  font-weight: 800;
}

.gt-history-topic-bar {
  height: 5px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--gh-slate-200);
}

.gt-history-topic-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.gt-history-topics.dominio .gt-history-topic-bar span { background: var(--gh-green); }
.gt-history-topics.reforzar .gt-history-topic-bar span { background: var(--gh-red); }

.gt-history-topic-empty {
  display: grid;
  min-height: 170px;
  place-items: center;
  padding: 14px;
  color: var(--gh-slate-500);
  text-align: center;
  font-size: 11px;
  line-height: 1.55;
}

.gt-history-records {
  margin-top: 14px;
  overflow: hidden;
}

.gt-history-records > header {
  padding: 17px 18px;
  border-bottom: 1px solid var(--gh-slate-200);
}

.gt-history-delete-all {
  padding: 8px 11px;
  border: 1px solid #fecaca;
  border-radius: 9px;
  color: #b91c1c;
  background: #fff5f5;
  font-size: 11px;
  font-weight: 900;
  cursor: pointer;
}

.gt-history-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.gt-history-table {
  width: 100%;
  min-width: 1040px;
  border-collapse: collapse;
  font-size: 11px;
}

.gt-history-table th,
.gt-history-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--gh-slate-200);
  color: var(--gh-slate-700);
  text-align: left;
  vertical-align: middle;
}

.gt-history-table th {
  color: var(--gh-navy);
  background: var(--gh-slate-50);
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.gt-history-table td strong,
.gt-history-table td small {
  display: block;
}

.gt-history-table td small {
  max-width: 170px;
  margin-top: 3px;
  overflow: hidden;
  color: var(--gh-slate-500);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gt-history-score {
  display: inline-flex;
  min-width: 50px;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 999px;
  font-weight: 900;
}

.gt-history-score.destacado,
.gt-history-score.bueno { color: #08784e; background: #dcfce7; }
.gt-history-score.proceso { color: #9a5700; background: #fef3c7; }
.gt-history-score.reforzar { color: #b91c1c; background: #fee2e2; }

.gt-history-row-actions {
  display: flex;
  gap: 5px;
}

.gt-history-row-actions button {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--gh-slate-200);
  border-radius: 8px;
  color: var(--gh-blue);
  background: #fff;
  cursor: pointer;
}

.gt-history-row-actions button:last-child { color: var(--gh-red); }

.gt-history-mobile-list { display: none; }

.gt-history-more {
  display: block;
  min-height: 39px;
  margin: 14px auto;
  padding: 8px 18px;
  border: 1px solid var(--gh-slate-300);
  border-radius: 10px;
  color: var(--gh-blue);
  background: #fff;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.gt-history-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1800;
  background: rgba(2, 8, 23, .56);
}

.gt-history-modal {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1810;
  width: min(520px, 100%);
  height: 100dvh;
  padding: 22px;
  overflow-y: auto;
  background: #fff;
  box-shadow: -22px 0 55px rgba(2,8,23,.22);
}

body.gt-history-modal-open { overflow: hidden; }

.gt-history-modal > header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gh-slate-200);
}

.gt-history-modal > header span {
  color: var(--gh-blue);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
}

.gt-history-modal > header h3 {
  margin: 6px 0 4px;
  color: var(--gh-navy);
  font-size: 22px;
}

.gt-history-modal > header p { margin: 0; color: var(--gh-slate-500); font-size: 12px; }

.gt-history-modal > header button {
  flex: 0 0 38px;
  height: 38px;
  border: 1px solid var(--gh-slate-200);
  border-radius: 10px;
  background: #fff;
  color: var(--gh-navy);
  font-size: 22px;
  cursor: pointer;
}

.gt-history-modal-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 18px 0;
}

.gt-history-modal-summary div {
  padding: 12px 8px;
  border-radius: 12px;
  background: var(--gh-slate-50);
  text-align: center;
}

.gt-history-modal-summary strong,
.gt-history-modal-summary span { display: block; }
.gt-history-modal-summary strong { color: var(--gh-navy); font-size: 20px; }
.gt-history-modal-summary span { margin-top: 4px; color: var(--gh-slate-500); font-size: 9px; }

.gt-history-modal-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 0 18px;
}

.gt-history-modal-meta div {
  padding: 11px;
  border: 1px solid var(--gh-slate-200);
  border-radius: 10px;
}

.gt-history-modal-meta dt { color: var(--gh-slate-500); font-size: 10px; }
.gt-history-modal-meta dd { margin: 4px 0 0; color: var(--gh-navy); font-size: 12px; font-weight: 900; }

.gt-history-modal section {
  margin-top: 18px;
  padding-top: 17px;
  border-top: 1px solid var(--gh-slate-200);
}

.gt-history-modal h4 { margin: 0 0 12px; color: var(--gh-navy); }

.gt-history-modal-topic {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gh-slate-100);
  color: var(--gh-slate-700);
  font-size: 12px;
}

.gt-history-modal ol { padding-left: 20px; }
.gt-history-modal li { margin: 10px 0; color: var(--gh-slate-700); font-size: 12px; }
.gt-history-modal li strong,
.gt-history-modal li span { display: block; }
.gt-history-modal li span { margin-top: 3px; color: var(--gh-slate-500); line-height: 1.45; }
.gt-history-legacy-note { color: var(--gh-slate-500); font-size: 12px; line-height: 1.6; }

.gt-history-modal > footer {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--gh-slate-200);
}

.gt-history-modal > footer button {
  flex: 1;
  min-height: 43px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.gt-history-modal-delete { color: #b91c1c; background: #fff5f5; border: 1px solid #fecaca; }
.gt-history-modal-close { color: #fff; background: var(--gh-navy); border: 1px solid var(--gh-navy); }

@media (max-width: 1180px) {
  .gt-history-metrics-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gt-history-analysis-grid { grid-template-columns: 1fr; }
  .gt-history-topic-columns { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 760px) {
  #pantalla-historial.gt-history-screen {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
  }

  .gt-history-header {
    padding: 18px 16px;
    border-radius: 16px 16px 0 0;
  }

  .gt-history-header h2 { font-size: 25px !important; }
  .gt-history-header p { max-width: 250px; }
  .gt-history-header-actions { align-self: flex-start; }
  .gt-history-pdf { display: none; }
  .gt-history-filter-toggle { display: inline-flex; align-items: center; gap: 6px; }

  .gt-history-filters {
    display: none;
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .gt-history-filters.abiertos { display: grid; }

  #gt-history-content { padding: 12px; border-radius: 0 0 16px 16px; }

  .gt-history-metrics-grid {
    grid-template-columns: 1fr 1fr;
    gap: 9px;
  }

  .gt-history-metric {
    min-height: 104px;
    padding: 14px 10px 12px 46px;
    border-radius: 13px;
  }

  .gt-history-metric-icon {
    top: 13px;
    left: 10px;
    width: 29px;
    height: 29px;
    font-size: 17px;
  }

  .gt-history-metric strong { font-size: 24px; }
  .gt-history-metric.tiempo { grid-column: 1 / -1; min-height: 88px; }

  .gt-history-analysis-grid { margin-top: 10px; gap: 10px; }
  .gt-history-chart-card { padding: 13px; }
  .gt-history-topic-columns { grid-template-columns: 1fr 1fr; gap: 8px; }
  .gt-history-topics { padding: 12px; }
  .gt-history-topics h3 { font-size: 12px; }
  .gt-history-topic-row { margin-top: 11px; }
  .gt-history-topic-row > div:first-child { font-size: 9px; }

  .gt-history-records { margin-top: 10px; }
  .gt-history-records > header { padding: 14px; }
  .gt-history-table-wrap { display: none; }
  .gt-history-mobile-list { display: grid; }

  .gt-history-mobile-item {
    display: grid;
    grid-template-columns: 1fr auto 14px;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 13px 14px;
    border: 0;
    border-bottom: 1px solid var(--gh-slate-200);
    color: var(--gh-slate-700);
    background: #fff;
    text-align: left;
    cursor: pointer;
  }

  .gt-history-mobile-item time,
  .gt-history-mobile-item strong,
  .gt-history-mobile-item span { display: block; }
  .gt-history-mobile-item time { color: var(--gh-slate-500); font-size: 9px; }
  .gt-history-mobile-item strong { margin-top: 3px; color: var(--gh-navy); font-size: 11px; }
  .gt-history-mobile-item > div > span { margin-top: 3px; color: var(--gh-slate-500); font-size: 9px; }
  .gt-history-mobile-item b { color: var(--gh-blue); font-size: 20px; }
  .gt-history-mobile-item .gt-history-score { font-size: 10px; }

  .gt-history-delete-all { display: none; }

  .gt-history-modal {
    top: auto;
    bottom: 0;
    width: 100%;
    height: min(88dvh, 760px);
    padding: 18px 15px;
    border-radius: 22px 22px 0 0;
  }

  .gt-history-modal-summary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 430px) {
  .gt-history-header-actions { position: absolute; right: 16px; top: 18px; }
  .gt-history-header { position: relative; padding-right: 105px; }
  .gt-history-kicker { font-size: 9px; }
  .gt-history-header h2 { font-size: 22px !important; }
  .gt-history-header p { font-size: 11px; }
  .gt-history-topic-columns { grid-template-columns: 1fr; }
}

@media print {
  body.imprimir-historial-pro {
    background: #fff !important;
  }

  body.imprimir-historial-pro .app {
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
  }

  body.imprimir-historial-pro .app > main > section,
  body.imprimir-historial-pro .footer-empresa,
  body.imprimir-historial-pro .marca-agua {
    display: none !important;
  }

  body.imprimir-historial-pro #pantalla-historial {
    display: block !important;
  }

  body.imprimir-historial-pro .gt-history-header {
    color: #0f172a !important;
    background: #fff !important;
    border: 1px solid #cbd5e1;
  }

  body.imprimir-historial-pro .gt-history-header h2,
  body.imprimir-historial-pro .gt-history-header p {
    color: #0f172a !important;
  }

  body.imprimir-historial-pro .gt-history-header-actions,
  body.imprimir-historial-pro .gt-history-back,
  body.imprimir-historial-pro .gt-history-filters,
  body.imprimir-historial-pro .gt-history-row-actions,
  body.imprimir-historial-pro .gt-history-delete-all,
  body.imprimir-historial-pro .gt-history-more,
  body.imprimir-historial-pro .gt-history-mobile-list,
  body.imprimir-historial-pro #gt-history-modal-root {
    display: none !important;
  }

  body.imprimir-historial-pro #gt-history-content {
    padding: 12px 0 !important;
    background: #fff !important;
    border: 0 !important;
  }

  body.imprimir-historial-pro .gt-history-metric,
  body.imprimir-historial-pro .gt-history-chart-card,
  body.imprimir-historial-pro .gt-history-topics,
  body.imprimir-historial-pro .gt-history-records {
    box-shadow: none !important;
    break-inside: avoid;
  }

  body.imprimir-historial-pro .gt-history-table-wrap { display: block !important; }
  body.imprimir-historial-pro .gt-history-table { min-width: 0; font-size: 8px; }
  body.imprimir-historial-pro .gt-history-table th,
  body.imprimir-historial-pro .gt-history-table td { padding: 6px; }

  @page { margin: 1cm; size: landscape; }
}


/* V3.8.0 — Historial integrado al shell global fijo. */
body.gt-global-shell-active #pantalla-historial.gt-history-screen {
  min-height: 0 !important;
  padding-bottom: 34px !important;
}

body.gt-global-shell-active #pantalla-historial .gt-history-header {
  border-radius: 0 0 18px 18px;
}
