/* =========================================================
   COMPONENTES
   Piezas que se repiten en toda la web. Se definen UNA vez aquí
   y se adaptan solas al fondo claro u oscuro (.theme-dark).
   ========================================================= */

/* ---------- Botones ----------
   .btn + variante: --solar (principal), --dark, --line (contorno), --danger
   Tamaño pequeño: --sm. --solar lleva además un icono circular (flecha)
   que gira e invierte de color al pasar el ratón. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
  transition:
    background .25s var(--hv),
    color .25s var(--hv),
    border-color .25s var(--hv),
    transform .2s var(--hv);
}
.btn:active {
  transform: scale(.97);
}
.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}
.btn--solar {
  background: var(--solar);
  color: var(--eclipse);
  gap: 12px;
  padding: 10px 10px 10px 24px;
}
.btn--solar::after {
  content: "";
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--eclipse) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23F6F1ED' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M9 7h8v8'/%3E%3C/svg%3E") center / 12px no-repeat;
  transition: transform .35s var(--hv), background-color .25s var(--hv);
}
.btn--sm.btn--solar {
  padding: 7px 7px 7px 16px;
}
.btn--sm.btn--solar::after {
  width: 20px;
  height: 20px;
  background-size: 9px;
}
.btn--solar:hover {
  background: var(--ink);
  color: var(--paper);
}
.btn--solar:hover::after {
  transform: rotate(-45deg);
  background-color: var(--natural);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23050706' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M9 7h8v8'/%3E%3C/svg%3E");
}
.theme-dark .btn--solar:hover {
  background: var(--natural);
  color: var(--eclipse);
}
.theme-dark .btn--solar:hover::after {
  background-color: var(--eclipse);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23F6F1ED' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M9 7h8v8'/%3E%3C/svg%3E");
}
.btn--dark {
  background: var(--ink);
  color: var(--paper);
}
.btn--dark:hover {
  background: var(--impulso);
  color: var(--puro);
}
.btn--line {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}
.btn--line:hover {
  border-color: var(--solar);
  color: var(--ink);
  background: var(--card);
}
.theme-dark .btn--line:hover {
  background: transparent;
  color: var(--solar);
}
.btn--danger {
  background: transparent;
  color: var(--impulso);
  border-color: var(--impulso);
}
.btn--danger:hover {
  background: var(--impulso);
  color: var(--puro);
}
.btn--danger-solid {
  background: var(--impulso);
  color: var(--puro);
}
.btn--danger-solid:hover {
  background: var(--ink);
  color: var(--paper);
}
.btn--sm {
  padding: 9px 14px;
  font-size: 13px;
}
.btn--full {
  width: 100%;
}
.btn-link {
  background: none;
  border: 0;
  padding: 0;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Filtros ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-size: var(--t-sm);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition:
    background .25s var(--hv),
    color .25s var(--hv);
}
.chip:hover {
  background: var(--card);
}
.chip.is-on {
  background: var(--ink);
  color: var(--paper);
}
.chip .n {
  opacity: 0.6;
}

/* Etiqueta negra, como «INCLUIDO EN LA OPCIÓN B» */
.tag {
  display: inline-block;
  padding: 5px 9px;
  background: var(--ink);
  color: var(--paper);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
}
.tag--line {
  background: transparent;
  color: var(--ink);
  border: 1px solid currentColor;
}

/* Estado de un caso o envío: «En pruebas», «Nuevo»… */
.status {
  display: inline-block;
  padding: 4px 9px;
  border: 1px dashed var(--impulso);
  color: var(--impulso);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  line-height: 1.2;
}
.theme-dark .status {
  border-color: var(--solar);
  color: var(--solar);
}
.status--publicado {
  border-style: solid;
  border-color: var(--ink-soft);
  color: var(--ink-soft);
}
.status--descartado {
  border-color: var(--line);
  color: var(--ink-soft);
  text-decoration: line-through;
}

/* Número en círculo (envíos nuevos) */
.badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--impulso);
  color: var(--puro);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}
/* Punto que late (sesión de admin activa) */
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
  animation: latido 2s ease-in-out infinite;
}
@keyframes latido {
  50% {
    opacity: 0.35;
  }
}

/* ---------- Campos de formulario ---------- */
.form {
  display: grid;
  gap: var(--s-5);
}
.f {
  display: grid;
  gap: var(--s-2);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.f-row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr));
  gap: var(--s-4);
}
.opt {
  text-transform: none;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-soft);
}
.input,
.f input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
.f select,
.f textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 0;
  font-size: var(--t-base);
  -webkit-appearance: none;
  appearance: none;
}
.f select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) 50%,
    calc(100% - 14px) 50%;
  background-size: 6px 6px;
  background-repeat: no-repeat;
  padding-right: 40px;
}
.f textarea {
  resize: vertical;
  line-height: 1.5;
}
.f textarea.code {
  font-family: var(--mono);
  font-size: 13px;
}
.input:focus,
.f input:focus,
.f select:focus,
.f textarea:focus {
  outline: 3px solid var(--solar);
  outline-offset: 0;
}

/* Opciones en píldora (temas): se marcan en negro */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pill {
  position: relative;
  cursor: pointer;
}
.pill input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}
.pill span {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  background: var(--card);
  font-size: var(--t-sm);
  font-weight: 600;
  transition:
    background 0.2s,
    color 0.2s,
    opacity 0.2s;
}
.pill input:checked + span {
  background: var(--ink);
  color: var(--paper);
}
.pill input:focus-visible + span {
  outline: 3px solid var(--solar);
  outline-offset: 2px;
}
.pill input:disabled + span {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Lista de casillas (casos relacionados) */
.checklist {
  display: grid;
  gap: 10px;
  max-height: 260px;
  overflow: auto;
  padding: var(--s-4);
  background: var(--card);
  border: 1px solid var(--line);
}
.checklist label {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 15px;
  cursor: pointer;
}
.checklist input {
  margin-top: 4px;
  flex: none;
  accent-color: var(--solar);
}

/* ---------- Avisos ---------- */
.alert {
  margin: 0;
  padding: 12px 16px;
  border-left: 4px solid var(--solar);
  background: var(--card);
  font-weight: 600;
}
.alert--error {
  border-left-color: var(--impulso);
}

/* ---------- Filas tipo presupuesto ----------
   Línea gruesa arriba, filas con título en negrita, subtítulo gris
   y dato alineado a la derecha. */
.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--line-strong);
}
.rows > li {
  border-bottom: 1px solid var(--line);
}
.row-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px var(--s-5);
  padding: var(--s-4) 0;
  text-decoration: none;
  align-items: start;
}
a.row-item:hover .row-t {
  color: var(--impulso);
}
.row-t {
  font-weight: 700;
  font-size: var(--t-md);
  line-height: 1.3;
  transition: color 0.2s;
}
.row-s {
  grid-column: 1;
  color: var(--ink-soft);
  font-size: var(--t-sm);
  line-height: 1.45;
}
.row-end {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: grid;
  gap: 6px;
  justify-items: end;
  text-align: right;
}

/* ---------- Tabla ---------- */
.tabla-wrap {
  overflow-x: auto;
}
.tabla {
  width: 100%;
  border-collapse: collapse;
  border-top: 2px solid var(--line-strong);
  font-size: 15px;
}
.tabla th,
.tabla td {
  padding: 14px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.tabla th:first-child,
.tabla td:first-child {
  padding-left: 0;
}
.tabla th:last-child,
.tabla td:last-child {
  padding-right: 0;
  text-align: right;
}
.tabla th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  color: var(--ink-soft);
}
.tabla th a {
  text-decoration: none;
}
.tabla th a:hover,
.tabla th a.is-on {
  color: var(--ink);
}
.tabla tbody tr:hover {
  background: var(--well);
}

/* ---------- Caja gris (como los totales del presupuesto) ---------- */
.well {
  background: var(--well);
  padding: var(--s-5);
}

/* ---------- Tarjeta de caso ---------- */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 300px;
  padding: 32px 28px 28px;
  background: var(--card);
  border: 1px solid var(--line);
  text-decoration: none;
  transition: border-color 0.25s;
}
.card .pin {
  position: absolute;
  top: 22px;
  right: 22px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--solar);
  transition:
    transform 0.45s var(--ease),
    filter 0.45s,
    opacity 0.45s;
}
.card:hover,
.card:focus-visible {
  border-color: var(--solar);
}
.card:hover .pin,
.card:focus-visible .pin {
  transform: scale(7);
  filter: blur(10px);
  opacity: 0.55;
}
.card .num {
  position: relative;
  font-size: 44px;
}
.card h3 {
  position: relative;
  margin: 22px 0 0;
  max-width: 18ch;
  font-size: 22px;
  line-height: 1.2;
  font-weight: 650;
}
.card .area {
  margin-top: 14px;
  color: var(--ink-soft);
}
.card .status {
  align-self: start;
  margin-top: 10px;
  position: relative;
}
.card .impact {
  position: relative;
  margin: auto 0 0;
  padding-top: 28px;
  font-size: 15px;
  color: var(--ink-soft);
}
.card .byline {
  position: relative;
  margin-top: 10px;
}
.card--s {
  min-height: 0;
  padding: 24px 24px 22px;
}
.card--s .num {
  font-size: 32px;
}
.card--s h3 {
  margin-top: 14px;
  font-size: 18px;
}

/* ---------- Ventana de confirmación ---------- */
.modal {
  width: min(480px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-top: 6px solid var(--impulso);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
.modal::backdrop {
  background: rgba(5, 7, 6, 0.55);
  backdrop-filter: blur(2px);
}
.modal-in {
  padding: var(--s-6);
  display: grid;
  gap: var(--s-4);
}
.modal h2 {
  font-size: 34px;
}
.modal p {
  margin: 0;
  color: var(--ink-soft);
}
.modal .well {
  font-weight: 700;
  color: var(--ink);
  padding: var(--s-4);
}
.modal-botones {
  display: flex;
  gap: var(--s-3);
  justify-content: flex-end;
  margin-top: var(--s-2);
  flex-wrap: wrap;
}

@media (max-width: 680px) {
  .f-row {
    grid-template-columns: 1fr;
  }
  .row-item {
    grid-template-columns: 1fr;
  }
  .row-end {
    grid-column: 1;
    grid-row: auto;
    justify-items: start;
    text-align: left;
  }
}
