/*
 * Sistema de diseño premium para ENS Checklist (Autoevaluación)
 */

:root {
  --bg: #f5f7fb;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-strong: #ffffff;
  --ink: #162033;
  --muted: #667085;
  --line: #d9e0ec;
  --brand: #2357d9;
  --brand-hover: #1e4bbd;
  --brand-2: #0e9f6e;
  --danger: #d92d20;
  --danger-hover: #b92217;
  --warn: #b7791f;
  --soft-blue: #eaf0ff;
  --soft-green: #eaf8f1;
  --soft-red: #fff0f0;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.12);
  --radius-xl: 24px;
  --radius: 16px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% -10%, rgba(35, 87, 217, 0.18), transparent 34rem),
    radial-gradient(circle at 92% 5%, rgba(14, 159, 110, 0.16), transparent 32rem),
    linear-gradient(180deg, #f8fbff, var(--bg));
  min-height: 100vh;
}

a {
  color: var(--brand);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.wrap {
  max-width: 1600px;
  margin: 0 auto;
  padding: 26px;
}

/* Hero Section */
.hero {
  padding: 16px 20px;
  border: 1px solid rgba(217, 224, 236, 0.8);
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.04);
  position: relative;
  overflow: hidden;
}

.hero::after {
  display: none;
}

.eyebrow {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: #1e429f;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

h1 {
  margin: 10px 0 6px;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.hero p {
  max-width: 880px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  z-index: 5;
  position: relative;
}

/* Botones */
button, .btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(16, 24, 40, 0.06);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button:hover, .btn:hover {
  transform: translateY(-1px);
  border-color: #9eb3da;
}

button.primary, .btn.primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
button.primary:hover, .btn.primary:hover {
  background: var(--brand-hover);
  border-color: var(--brand-hover);
}

button.success, .btn.success {
  background: var(--brand-2);
  color: #fff;
  border-color: var(--brand-2);
}

button.danger, .btn.danger {
  background: #fff;
  color: var(--danger);
  border-color: #fecdca;
}
button.danger:hover, .btn.danger:hover {
  background: var(--soft-red);
  border-color: var(--danger);
}

button.ghost {
  background: rgba(255, 255, 255, 0.58);
}

/* Layout y Sidebar */
.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.side {
  position: sticky;
  top: 14px;
  display: grid;
  gap: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid rgba(217, 224, 236, 0.9);
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.06);
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.card-pad {
  padding: 18px;
}

/* Selector de Proyectos */
.project-selector-wrapper {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: grid;
  gap: 8px;
}

.project-select-row {
  display: flex;
  gap: 8px;
}

/* KPI y Progreso */
.kpi-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
}

.kpi strong {
  display: block;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.kpi span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.progress-track {
  height: 12px;
  background: #e8edf7;
  border-radius: 999px;
  overflow: hidden;
  margin: 12px 0 6px;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
  border-radius: inherit;
  transition: width 0.35s ease;
}

.small {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* Formularios */
.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(35, 87, 217, 0.10);
}

textarea {
  resize: vertical;
  min-height: 76px;
}

/* Filtros */
.filters {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.filter-row {
  display: grid;
  grid-template-columns: 1fr auto 220px;
  gap: 10px;
  align-items: center;
}

/* Interruptor de estado (Toggle Switch) */
.toggle-group {
  display: inline-flex;
  background: #f2f5fb;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--line);
}

.toggle-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 800;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: none;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toggle-btn:hover {
  color: var(--ink);
  transform: none;
}

.toggle-btn.active {
  background: #fff;
  color: var(--brand);
  box-shadow: 0 2px 8px rgba(16, 24, 40, 0.08);
}

/* Tabs */
.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
}

.tab {
  border-radius: 999px;
  padding: 9px 12px;
  font-size: 13px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--ink);
  box-shadow: none;
}

.tab:hover {
  background: rgba(0, 0, 0, 0.04);
}

.tab.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* Títulos y Secciones */
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin: 8px 0 12px;
}

.section-title h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.section-title p {
  margin: 4px 0 0;
  color: var(--muted);
}

/* Lista de Medidas */
.measure-list {
  display: grid;
  gap: 12px;
}

.measure {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.05);
  overflow: hidden;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.measure.done {
  border-color: rgba(14, 159, 110, 0.35);
  background: linear-gradient(180deg, #ffffff, #fbfffd);
}

.measure-head {
  display: grid;
  grid-template-columns: 100px 1fr auto;
  gap: 14px;
  align-items: start;
  padding: 16px;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 900;
  color: #1e429f;
  background: var(--soft-blue);
  border-radius: 999px;
  padding: 7px 9px;
  text-align: center;
  border: 1px solid #c7d7fe;
}

.measure h3 {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  font-size: 12px;
  color: #344054;
  background: #fff;
  font-weight: 800;
}

.badge.green {
  background: var(--soft-green);
  border-color: #abefc6;
  color: #067647;
}

.badge.amber {
  background: #fffaeb;
  border-color: #fedf89;
  color: #b54708;
}

.badge.red {
  background: var(--soft-red);
  border-color: #fecdca;
  color: #b42318;
}

.measure-body {
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 14px;
  padding: 16px;
  background: rgba(248, 250, 252, 0.75);
}

.evidence {
  color: #344054;
  line-height: 1.5;
  margin: 0;
}

.obs-tools {
  display: grid;
  gap: 8px;
}

.status-select {
  min-width: 185px;
  font-weight: 900;
}

.status-select.done {
  border-color: #75e0a7;
  background: #f0fdf4;
}

.status-select.pending {
  border-color: #fecdca;
  background: #fff8f8;
}

/* Bloques de Resumen */
.group-summary {
  display: grid;
  gap: 8px;
  padding-right: 4px;
}

.group-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}

.group-meter {
  grid-column: 1 / -1;
  height: 6px;
  background: #e8edf7;
  border-radius: 999px;
  overflow: hidden;
}

.group-meter span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--brand-2);
  transition: width 0.3s ease;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.info-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.info-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.info-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.na-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 14px;
}

.na-table th, .na-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.na-table th {
  background: #f2f5fb;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #475467;
}

.hidden {
  display: none !important;
}

/* Toast */
.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #101828;
  color: #fff;
  font-weight: 800;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.footer {
  margin: 20px 0 0;
  padding: 18px;
  color: var(--muted);
  line-height: 1.55;
}

.footer strong {
  color: var(--ink);
}

/* Modal Simple para Login y Nuevo Proyecto */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(16, 24, 40, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  max-width: 440px;
  width: 90%;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.modal-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

/* Estilo Login Card (cuando ACCESS_PASSWORD está activo) */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 10% -10%, rgba(35, 87, 217, 0.12), transparent 34rem),
    linear-gradient(180deg, #f8fbff, var(--bg));
}

.login-card {
  max-width: 400px;
  width: 100%;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-card h2 {
  margin: 0 0 8px 0;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.login-card p {
  color: var(--muted);
  margin-top: 0;
  margin-bottom: 24px;
  font-size: 14px;
}

/* Media Queries */
@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .side {
    position: static;
  }
  .filter-row {
    grid-template-columns: 1fr;
  }
  .measure-head {
    grid-template-columns: 1fr;
  }
  .measure-body {
    grid-template-columns: 1fr;
  }
  .info-grid {
    grid-template-columns: 1fr;
  }
}

/* Ocultar reporte de impresión en pantalla */
#printReport {
  display: none;
}

@media print {
  /* Ocultar la aplicación web interactiva completa */
  .wrap, #toast, .modal-overlay, #newProjectModal {
    display: none !important;
  }
  
  /* Mostrar el informe estructurado */
  #printReport {
    display: block !important;
    font-family: Arial, Helvetica, sans-serif;
    color: #111;
    line-height: 1.5;
    background: #fff;
    padding: 0;
  }
  
  .print-header {
    border-bottom: 3px solid #2357d9;
    padding-bottom: 12px;
    margin-bottom: 24px;
  }
  
  .print-badge {
    display: inline-block;
    padding: 4px 8px;
    background: #eaf0ff;
    color: #1e429f;
    font-size: 11px;
    font-weight: 800;
    border-radius: 4px;
    text-transform: uppercase;
    margin-bottom: 8px;
  }
  
  .print-header h1 {
    margin: 4px 0;
    font-size: 26px;
    letter-spacing: -0.02em;
    color: #162033;
  }
  
  .print-header h3 {
    margin: 4px 0;
    font-size: 16px;
    color: #475467;
  }
  
  .print-section {
    margin-bottom: 35px;
  }
  
  .print-section-title {
    font-size: 18px;
    border-bottom: 2px solid #d9e0ec;
    padding-bottom: 6px;
    margin-bottom: 16px;
    color: #2357d9;
    font-weight: 800;
  }
  
  .print-kpi-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
  }
  
  .print-kpi {
    border: 1px solid #d9e0ec;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    background: #fcfdfe;
  }
  
  .print-kpi strong {
    display: block;
    font-size: 24px;
    color: #162033;
  }
  
  .print-kpi span {
    font-size: 12px;
    color: #667085;
    font-weight: bold;
  }
  
  .print-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
  }
  
  .print-table th, .print-table td {
    border-bottom: 1px solid #e2e8f0;
    padding: 8px 10px;
    text-align: left;
    font-size: 13px;
  }
  
  .print-table th {
    background: #f8fafc;
    color: #475467;
    font-weight: 700;
  }
  
  .print-measure-item {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 14px;
    page-break-inside: avoid;
    background: #fff;
  }
  
  .print-measure-header {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
    margin-bottom: 8px;
  }
  
  .print-measure-code {
    font-family: monospace;
    font-weight: bold;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    color: #1e429f;
  }
  
  .print-measure-title {
    font-weight: bold;
    font-size: 14px;
    flex: 1;
    color: #111;
  }
  
  .print-measure-status {
    font-size: 11px;
    font-weight: 800;
    padding: 3px 8px;
    border-radius: 999px;
  }
  
  .print-measure-status.status-done {
    background: #eaf8f1;
    color: #067647;
    border: 1px solid #abefc6;
  }
  
  .print-measure-status.status-pending {
    background: #fff0f0;
    color: #b42318;
    border: 1px solid #fecdca;
  }
  
  .print-measure-body {
    font-size: 12.5px;
    color: #333;
  }
  
  .print-measure-body p {
    margin: 6px 0;
  }
  
  .print-docs-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }
  
  .print-doc-item {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    page-break-inside: avoid;
    background: #fff;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
  }
  
  .print-footer {
    margin-top: 40px;
    border-top: 1px solid #d9e0ec;
    padding-top: 12px;
    font-size: 11px;
    color: #667085;
    text-align: center;
    page-break-inside: avoid;
  }
}
