/* ============================================================================
   EVALIA — Components
   Botones, inputs, chips, badges, alerts, modal, toast, segmented, tabla.
   ============================================================================ */

/* ---------- BUTTONS ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: 8px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-bright);
  color: var(--on-surface);
  font-weight: 600;
  font-size: var(--fs-13);
  line-height: 1.3;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast),
              transform var(--t-fast), box-shadow var(--t-fast);
  box-shadow: var(--sh-xs);
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-bright);
  box-shadow: var(--sh-sm);
}
.btn:active {
  box-shadow: inset 0 1px 2px rgb(0 0 0 / .08);
}
.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.btn .ico { width: 16px; height: 16px; }

.btn.sm  { padding: 6px 12px; font-size: 12.5px; gap: 6px; }
.btn.sm .ico { width: 14px; height: 14px; }

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 1px 2px rgb(7 22 47 / .12), 0 1px 0 rgb(255 255 255 / .15) inset;
}
.btn.primary:hover {
  background: var(--primary-alt);
  border-color: var(--primary-alt);
  box-shadow: 0 2px 6px rgb(7 22 47 / .18), 0 1px 0 rgb(255 255 255 / .15) inset;
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--on-surface-muted);
}
.btn.ghost:hover {
  background: var(--surface-dim);
  color: var(--on-surface);
  border-color: transparent;
  box-shadow: none;
}

.btn.danger {
  color: var(--danger);
  border-color: var(--danger-soft);
  background: var(--surface-bright);
}
.btn.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.row-actions {
  display: inline-flex;
  gap: var(--s-2);
  align-items: center;
}

/* ---------- ICON BUTTON ---------- */
.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--on-surface-muted);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--surface-dim); color: var(--on-surface); border-color: var(--line); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger-soft); }

/* ---------- INPUTS ---------- */
.fld {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.fld.full { grid-column: 1 / -1; }
.fld label {
  font-size: 12px;
  font-weight: 600;
  color: var(--on-surface);
  letter-spacing: 0;
  text-transform: none;
}
.fld input,
.fld select,
.fld textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--surface-bright);
  color: var(--on-surface);
  font-size: var(--fs-14);
  line-height: 1.4;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.fld input::placeholder,
.fld textarea::placeholder {
  color: var(--on-surface-faint);
}
.fld input:hover:not(:focus),
.fld select:hover:not(:focus),
.fld textarea:hover:not(:focus) {
  border-color: var(--line-strong);
}
.fld input:focus,
.fld select:focus,
.fld textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--sh-focus);
}
.fld textarea { resize: vertical; min-height: 80px; line-height: 1.55; }
.fld select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%234A5A75' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: var(--fs-13);
  color: var(--on-surface);
}
.check-row input { width: 16px; height: 16px; accent-color: var(--primary); }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5);
}
@media (max-width: 620px) {
  .form-grid { grid-template-columns: 1fr; }
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-4);
}

/* ---------- SEGMENTED ---------- */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface-dim);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  flex-shrink: 0;
}
.seg-btn {
  padding: 6px 13px;
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--on-surface-muted);
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
  white-space: nowrap;
}
.seg-btn:hover:not(.on) {
  background: rgb(255 255 255 / .5);
  color: var(--on-surface);
}
.seg-btn.on {
  background: var(--surface-bright);
  color: var(--on-surface);
  box-shadow: 0 1px 2px rgb(7 22 47 / .08);
}
.seg-btn.si.on    { color: var(--success); }
.seg-btn.no.on    { color: var(--danger); }
.seg-btn.nose.on  { color: var(--info); }
.seg-btn.na.on    { color: var(--on-surface-muted); }
.seg.status .seg-btn.cumple.on    { color: var(--success); }
.seg.status .seg-btn.parcial.on   { color: var(--warn); }
.seg.status .seg-btn.no.on        { color: var(--danger); }
.seg.status .seg-btn.na.on        { color: var(--on-surface-muted); }
.seg.status .seg-btn.pendiente.on { color: var(--info); }

/* ---------- CHIPS (azul claro pill) ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 13px;
  border-radius: var(--r-pill);
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid transparent;
  font-size: var(--fs-13);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  white-space: nowrap;
}
.chip:hover { background: #CFE5FF; }
.chip.on {
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}
.chip.on .chip-dot { box-shadow: 0 0 0 2px rgb(255 255 255 / .25); }
.chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.chip-dot.r-prohibido { background: var(--danger); }
.chip-dot.r-alto      { background: var(--warn); }
.chip-dot.r-limitado  { background: var(--primary); }
.chip-dot.r-minimo    { background: var(--success); }
.chip-dot.r-fuera     { background: var(--on-surface-faint); }
.chip-dot.r-purple    { background: var(--purple); }

/* ---------- ESTADOS / RIESGOS como TEXTO COLOREADO (no badges) ---------- */
.tx-completado { color: var(--success); font-weight: 600; }
.tx-revision   { color: var(--warn); font-weight: 600; }
.tx-brechas    { color: var(--purple); font-weight: 600; }
.tx-prohibido  { color: var(--danger); font-weight: 600; }
.tx-provisional{ color: var(--info); font-weight: 600; }

.tx-rk-prohibido { color: var(--danger); font-weight: 600; }
.tx-rk-alto      { color: var(--warn); font-weight: 600; }
.tx-rk-limitado  { color: var(--success); font-weight: 600; }
.tx-rk-minimo    { color: var(--success); font-weight: 600; }
.tx-rk-fuera     { color: var(--on-surface-muted); font-weight: 500; }

/* ---------- BADGES (GPAI / RGPD …) ---------- */
.badge-row { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-4) 0 0; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  border: 1px solid var(--line);
  background: var(--surface-bright);
  color: var(--on-surface-muted);
}
.badge.b-gpai { background: var(--on-surface); color: #fff; border-color: var(--on-surface); }
.badge.b-rgpd { background: var(--info-soft); color: var(--info); border-color: var(--info-soft); }
.badge.b-exc  { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-soft); }

/* ---------- NOTE / ALERT ---------- */
.note {
  background: var(--surface-bright);
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  padding: 14px 18px;
  border-radius: 0 var(--r) var(--r) 0;
  font-size: var(--fs-13);
  color: var(--on-surface);
  margin: var(--s-4) 0;
  line-height: 1.6;
}
.note.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.note.bad  { border-left-color: var(--danger); background: var(--danger-soft); }
.note.idk  { border-left-color: var(--info); background: var(--info-soft); }

.alert {
  display: block;
  border-radius: var(--r);
  border: 1px solid;
  padding: 14px 18px;
  margin: 0 0 var(--s-5);
  font-size: var(--fs-13);
}
.alert .alert-title { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: var(--fs-14); }
.alert .alert-title .ico { width: 16px; height: 16px; }
.alert ul { margin: 0; padding-left: 20px; }
.alert.danger { background: var(--danger-soft); border-color: rgb(122 27 38 / .25); color: var(--danger); }
.alert.warn   { background: var(--warn-soft); border-color: rgb(185 133 32 / .25); color: var(--warn); }

/* ---------- MODAL ---------- */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgb(7 22 47 / .40);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-5);
}
.modal {
  background: var(--surface-bright);
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  max-width: 600px;
  width: 100%;
  max-height: 86vh;
  overflow: auto;
  box-shadow: var(--sh-xl);
}
.modal .m-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: var(--fs-15);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal .m-body { padding: 18px 22px; }
.modal .m-body p { font-size: var(--fs-14); }
.modal .m-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: var(--s-2);
  background: var(--surface-dim);
}
.modal .m-x {
  background: transparent;
  border: 0;
  color: var(--on-surface-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--r-sm);
}
.modal .m-x:hover { background: var(--surface-dim); color: var(--on-surface); }
.modal .m-x svg { width: 18px; height: 18px; }

.modal-stack { display: flex; flex-direction: column; gap: var(--s-2); }
.modal-stack .btn { justify-content: flex-start; padding: 10px 14px; }

.cmp-out { margin-top: var(--s-4); }
.cmp-summary { font-size: var(--fs-13); margin-bottom: var(--s-3); }

/* ---------- IMPORT MODAL ---------- */
.import-lead {
  font-size: var(--fs-14);
  color: var(--on-surface);
  line-height: 1.6;
  margin: 0 0 var(--s-3);
}
.import-list {
  margin: 0 0 var(--s-4);
  padding-left: 22px;
  font-size: 12.5px;
  color: var(--on-surface-muted);
  line-height: 1.6;
}
.import-list li { margin: 4px 0; }
.import-list code {
  font-family: var(--font-mono);
  font-size: .92em;
  background: var(--surface-dim);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--on-surface);
}
.import-pick {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3);
  background: var(--surface-dim);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  flex-wrap: wrap;
}
.import-pick input[type="file"] {
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  z-index: -1;
}
.import-pick .import-chosen {
  font-size: 12.5px;
  color: var(--on-surface-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.import-pick .import-chosen strong { color: var(--on-surface); font-weight: 600; }
.import-pick .import-chosen .import-err { color: var(--danger); }

/* ---------- TOAST ---------- */
.toast {
  position: fixed;
  bottom: var(--s-6);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--on-surface);
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--r);
  font-size: var(--fs-13);
  font-weight: 600;
  z-index: 300;
  box-shadow: var(--sh-xl);
  opacity: 0;
  transition: opacity var(--t-base), transform var(--t-base);
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ---------- DATA TABLE (genérica) ---------- */
.data-card {
  background: var(--surface-bright);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--sh-xs);
}
.data-tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-14);
  color: var(--on-surface);
}
.data-tbl th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--on-surface-muted);
  padding: 12px 18px;
  background: var(--surface-dim);
  border-bottom: 1px solid var(--line);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.data-tbl td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.data-tbl tbody tr {
  transition: background var(--t-fast);
  cursor: pointer;
}
.data-tbl tbody tr:hover td { background: var(--surface-dim); }
.data-tbl tbody tr:last-child td { border-bottom: 0; }

.compare-tbl td { font-family: var(--font-mono); font-size: 12px; }
.compare-tbl .diff { background: var(--warn-soft); }
