/* ============================================================
   resistencias.css — UI/UX profesional para calculadora de resistencias
   ============================================================ */

.logo-res {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.45);
}

.card-sub {
  margin: -8px 0 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

/* ---------- Selector 4/5 bandas ---------- */
.card-cabecera {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.selector-bandas {
  display: flex;
  gap: 6px;
  background: var(--sutil);
  padding: 4px;
  border-radius: 10px;
}

.chip-bandas {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 7px;
  transition: all 0.15s;
}

.chip-bandas:hover { color: var(--texto); }
.chip-bandas.activo {
  background: var(--card);
  color: var(--primario);
  box-shadow: var(--sombra);
}

/* ---------- Info de bandas ---------- */
.bandas-info {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.info-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--sutil);
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
}

.info-pill:hover {
  background: var(--borde);
  color: var(--texto);
}

.info-pill.activa {
  background: var(--primario);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.35);
}

/* ---------- Resistor interactivo ---------- */
.resistor-area {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px 0;
}

.resistor-cuerpo {
  position: relative;
  width: 240px;
  height: 68px;
  border-radius: 34px;
  background: linear-gradient(180deg, #f8d7a8 0%, #e8b878 50%, #d4a060 100%);
  box-shadow:
    inset 0 2px 5px rgba(255, 255, 255, 0.4),
    inset 0 -3px 8px rgba(0, 0, 0, 0.18),
    0 8px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

body[data-tema="oscuro"] .resistor-cuerpo {
  background: linear-gradient(180deg, #fde68a 0%, #d4a060 50%, #b08040 100%);
}

.resistor-banda {
  width: 18px;
  height: 52px;
  border-radius: 4px;
  border: 1px solid transparent;
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.25),
    0 1px 3px rgba(0,0,0,0.25);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  outline: none;
}

.resistor-banda:hover {
  transform: scale(1.08);
  box-shadow:
    inset 0 1px 2px rgba(255,255,255,0.25),
    0 3px 8px rgba(0,0,0,0.3);
}

.resistor-banda.activa {
  box-shadow:
    0 0 0 3px var(--primario),
    inset 0 1px 2px rgba(255,255,255,0.25),
    0 3px 8px rgba(0,0,0,0.3);
  transform: scale(1.08);
}

.resistor-banda:focus-visible {
  box-shadow: 0 0 0 3px var(--primario), inset 0 1px 2px rgba(255,255,255,0.25);
}

.resistor-terminal {
  position: absolute;
  top: 50%;
  width: 100px;
  height: 4px;
  background: linear-gradient(180deg, #d1d5db 0%, #6b7280 100%);
  transform: translateY(-50%);
  z-index: -1;
  border-radius: 999px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.resistor-terminal-izq { left: -82px; }
.resistor-terminal-der { right: -82px; }

/* ---------- Resultado ---------- */
.valor-principal {
  text-align: center;
  font-family: var(--mono);
  font-size: 42px;
  font-weight: 700;
  color: var(--texto);
  margin-top: 4px;
}

.valor-rango {
  text-align: center;
  font-size: 14px;
  color: var(--muted);
  margin-top: 10px;
  line-height: 1.5;
}

.valor-rango strong {
  color: var(--primario);
}

.valor-rango .delta {
  color: var(--muted);
  font-size: 12.5px;
}

.formula-box {
  margin-top: 22px;
  padding: 12px 16px;
  background: var(--sutil);
  border: 1px dashed var(--borde);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 13.5px;
  text-align: center;
  color: var(--muted);
}

/* ---------- Selector de colores ---------- */
.picker-card {
  min-height: 320px;
}

.picker-ayuda {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 40px 12px;
  background: var(--sutil);
  border-radius: 10px;
  border: 1px dashed var(--borde);
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.color-swatch {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--borde);
  border-radius: 10px;
  background: var(--card);
  cursor: pointer;
  transition: all 0.12s;
  text-align: left;
}

.color-swatch:hover {
  border-color: var(--primario);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
}

.color-swatch.activa {
  border-color: var(--primario);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.swatch-color {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex: none;
  box-shadow: inset 0 1px 2px rgba(255,255,255,0.3), 0 1px 2px rgba(0,0,0,0.15);
}

.swatch-text {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--texto);
}

/* ---------- Tabla de guardados ---------- */
.card-guardados {
  display: flex;
  flex-direction: column;
}

.acciones-tabla,
.acciones-json {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.acciones-tabla { margin-bottom: 14px; }
.acciones-json { margin-top: 14px; }

.acciones-tabla button,
.acciones-json button {
  flex: 1;
  min-width: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.acciones-tabla button svg,
.acciones-json button svg { width: 14px; height: 14px; }

.btn-primario {
  background: var(--primario);
  color: #ffffff;
}
.btn-primario:hover { background: var(--primario-hover); }

.btn-secundario {
  background: var(--sutil);
  color: var(--texto);
  border: 1px solid var(--borde) !important;
}
.btn-secundario:hover { background: var(--borde); }

.tabla-guardados-wrap {
  flex: 1;
  min-height: 120px;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--borde);
  border-radius: 10px;
  background: var(--card);
}

.tabla-vacia {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
}

.tabla-guardados {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.tabla-guardados thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.tabla-guardados th {
  background: var(--sutil);
  color: var(--muted);
  font-weight: 600;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid var(--borde);
}

.tabla-guardados td {
  padding: 8px;
  border-bottom: 1px solid var(--borde);
  color: var(--texto);
  vertical-align: middle;
}

.tabla-guardados tbody tr {
  cursor: pointer;
  transition: background 0.12s;
}

.tabla-guardados tbody tr:hover {
  background: var(--sutil);
}

.tabla-guardados tbody tr.activa {
  background: rgba(59, 130, 246, 0.08);
}

.col-check {
  width: 28px;
  text-align: center;
}

.row-check {
  cursor: pointer;
  width: 16px;
  height: 16px;
  accent-color: var(--primario);
}

.mini-bandas {
  display: flex;
  gap: 3px;
}

.mini-banda {
  width: 8px;
  height: 22px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.1);
}

.col-valor {
  font-family: var(--mono);
  font-weight: 600;
  white-space: nowrap;
}

.col-tol {
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- Conexiones ---------- */
.conexiones {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--borde);
  opacity: 0.55;
  transition: opacity 0.2s;
}

.conexiones.activa {
  opacity: 1;
}

.conexiones-titulo {
  margin: 0 0 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--texto);
}

.contador-seleccion {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.acciones-conexion {
  display: flex;
  gap: 8px;
}

.btn-conexion {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 10px;
  border: none;
  border-radius: 8px;
  background: var(--primario);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-conexion:hover:not(:disabled) {
  background: var(--primario-hover);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(59, 130, 246, 0.3);
}

.btn-conexion:disabled {
  background: var(--sutil);
  color: var(--muted);
  border: 1px solid var(--borde);
  cursor: not-allowed;
  opacity: 0.7;
}

.btn-conexion svg { width: 14px; height: 14px; }

/* ---------- Modal de conexión ---------- */
.modal-overlay.modal-conexion {
  z-index: 110;
}

.modal-grande {
  width: 820px;
  max-width: 96vw;
}

.canvas-conexion-wrap {
  display: flex;
  justify-content: center;
  background: var(--sutil);
  border-radius: 12px;
  padding: 16px;
  overflow-x: auto;
}

#canvasConexion {
  display: block;
  max-width: 100%;
  border-radius: 8px;
  background: var(--card);
}

.resultado-conexion {
  margin-top: 18px;
  text-align: center;
  font-size: 16px;
  color: var(--texto);
}

.resultado-conexion strong {
  color: var(--primario);
  font-family: var(--mono);
  font-size: 18px;
}

.resultado-conexion .rango {
  color: var(--muted);
  font-size: 13px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--borde);
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--texto);
}

.modal-cerrar {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  transition: all 0.15s;
}

.modal-cerrar:hover {
  background: var(--sutil);
  color: var(--texto);
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--borde);
}

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .contenido {
    grid-template-columns: 1fr;
  }
  .tabla-guardados-wrap {
    max-height: 260px;
  }
}

@media (max-width: 420px) {
  .resistor-cuerpo {
    width: 190px;
    height: 56px;
    border-radius: 28px;
    gap: 8px;
  }
  .resistor-banda {
    width: 14px;
    height: 42px;
  }
  .resistor-terminal {
    width: 55px;
  }
  .resistor-terminal-izq { left: -45px; }
  .resistor-terminal-der { right: -45px; }
  .valor-principal { font-size: 32px; }
  .card-cabecera { flex-direction: column; align-items: flex-start; }
  .color-grid { grid-template-columns: 1fr; }
}
