/* ==========================================================================
   Che Firmas — muro de firmas digital
   Tokens propios (namespaced), alineados al sistema de diseño de
   Che Habana Café (ver CLAUDE.md) para no depender del theme.
   ========================================================================== */

.che-firmas, .che-firmas-modal {
  --cf-rojo: #E23D2E;
  --cf-fondo: #0d0b0a;
  --cf-fondo-2: #fee9d4;
  --cf-texto: #f7f2ec;
  --cf-texto-2: #a89d92;
  --cf-texto-3: #8a8077;
  --cf-borde: rgba(255, 255, 255, 0.09);
  --cf-borde-rojo: rgba(226, 61, 46, 0.5);
  --cf-radio: 2px;
  --che-firmas-textura: none;

  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}
.che-firmas *, .che-firmas *::before, .che-firmas *::after,
.che-firmas-modal *, .che-firmas-modal *::before, .che-firmas-modal *::after {
  box-sizing: border-box;
}

/* ---- Botones (coherentes con Botón/Sólido-Contorno del sistema) ---- */
.che-firmas-boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-radius: var(--cf-radio);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.che-firmas-boton-solido { background: var(--cf-rojo); color: var(--cf-texto); }
.che-firmas-boton-solido:hover,
.che-firmas-boton-solido:focus { background: #c72f22; color: var(--cf-texto); }
.che-firmas-boton-contorno { background: transparent; color: var(--cf-texto); border-color: var(--cf-borde); }
.che-firmas-boton-contorno:hover,
.che-firmas-boton-contorno:focus {
  border-color: var(--cf-texto);
  background-color: transparent;
  color: var(--cf-texto);
}
.che-firmas-boton:focus-visible,
.che-firmas-color:focus-visible,
.che-firmas-lienzo:focus-visible,
.che-firmas-modal-cerrar:focus-visible,
.che-firmas-campo-nombre input:focus-visible {
  outline: 2px solid var(--cf-rojo);
  outline-offset: 2px;
}

/* ==========================================================================
   Cabecera del muro: contador + acciones
   ========================================================================== */
.che-firmas-cabecera {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.che-firmas-contador {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cf-texto-3);
}
.che-firmas-acciones { display: flex; gap: 12px; flex-wrap: wrap; }

/* ==========================================================================
   El muro: lienzo pannable + textura
   ========================================================================== */
.che-firmas-lienzo {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--cf-borde);
  border-radius: var(--cf-radio);
  background-color: var(--cf-fondo-2);
  background-image: var(--che-firmas-textura);
  background-size: cover;
  background-position: center;
  cursor: grab;
  scrollbar-width: thin;
  height: 60vh;
  min-height: 360px;
  max-height: 640px;
}
.che-firmas-lienzo.che-firmas-arrastrando { cursor: grabbing; scroll-behavior: auto; }
.che-firmas-pista {
  position: relative;
  height: 100%;
  min-width: 100%;
}
.che-firmas-item {
  position: absolute;
  mix-blend-mode: multiply;
  pointer-events: none;
  will-change: transform;
}
.che-firmas-item .che-firmas-svg path {
  stroke-dasharray: var(--cf-len);
  stroke-dashoffset: var(--cf-len);
  animation: che-firmas-escribir 0.5s ease forwards;
  animation-delay: var(--cf-delay, 0s);
  animation-play-state: paused;
}
.che-firmas-item.cf-visible .che-firmas-svg path {
  animation-play-state: running;
}
@keyframes che-firmas-escribir {
  to { stroke-dashoffset: 0; }
}
.che-firmas-item.che-firmas-item-mia {
  outline: 2px dashed var(--cf-rojo);
  outline-offset: 6px;
  animation: che-firmas-pulso 1.6s ease-out 2;
}
@keyframes che-firmas-pulso {
  0%, 100% { outline-color: transparent; }
  50% { outline-color: var(--cf-rojo); }
}

@media (prefers-reduced-motion: reduce) {
  .che-firmas-item .che-firmas-svg path { animation: none; stroke-dashoffset: 0; }
  .che-firmas-item.che-firmas-item-mia { animation: none; outline-color: var(--cf-rojo); }
  .che-firmas-lienzo { scroll-behavior: auto; }
}

/* ==========================================================================
   Modal de firma
   ========================================================================== */
.che-firmas-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.che-firmas-modal[hidden] { display: none; }
.che-firmas-modal-fondo {
  position: absolute;
  inset: 0;
  background: rgba(8, 7, 6, 0.85);
  backdrop-filter: blur(4px);
}
.che-firmas-modal-caja {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 640px;
  max-height: 100%;
  overflow-y: auto;
  background: var(--cf-fondo);
  border: 1px solid var(--cf-borde);
  border-radius: var(--cf-radio);
  padding: 28px;
  color: var(--cf-texto);
}
@media (max-width: 640px) {
  .che-firmas-modal { padding: 0; }
  .che-firmas-modal-caja {
    max-width: none;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
  }
}
.che-firmas-modal-cerrar {
  position: absolute;
  top: 16px; right: 16px;
  width: 36px; height: 36px;
  border: 1px solid var(--cf-borde);
  background: transparent;
  color: var(--cf-texto);
  border-radius: var(--cf-radio);
  cursor: pointer;
}
.che-firmas-modal-cerrar:hover,
.che-firmas-modal-cerrar:focus {
  background: transparent;
  color: var(--cf-texto);
}
.che-firmas-modal-titulo {
  font-family: 'Oswald', sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 22px;
  margin: 0 0 18px;
}

.che-firmas-lienzo-firma-wrap {
  border: 1px solid var(--cf-borde);
  border-radius: var(--cf-radio);
  background: #fdfaf5;
  margin-bottom: 18px;
  touch-action: none;
}
.che-firmas-lienzo-firma {
  display: block;
  width: 100%;
  height: 220px;
  touch-action: none;
}
@media (min-width: 640px) {
  .che-firmas-modal-caja .che-firmas-lienzo-firma { height: 260px; }
}
.che-firmas-modal-caja { flex: 1; }
@media (max-width: 640px) {
  .che-firmas-lienzo-firma-wrap { flex: 1; display: flex; }
  .che-firmas-lienzo-firma { flex: 1; height: auto; min-height: 220px; }
}

.che-firmas-controles {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.che-firmas-colores { display: flex; gap: 10px; }
.che-firmas-color {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--che-firmas-color);
  border: 2px solid var(--cf-borde);
  cursor: pointer;
  padding: 0;
}
.che-firmas-color[aria-checked="true"] { border-color: var(--cf-rojo); }
.che-firmas-color:hover,
.che-firmas-color:focus { background: var(--che-firmas-color); }
.che-firmas-herramientas { display: flex; gap: 10px; }

.che-firmas-campo-nombre { display: block; margin-bottom: 14px; }
.che-firmas-campo-nombre input {
  width: 100%;
  padding: 12px 14px;
  background: var(--cf-fondo-2);
  border: 1px solid var(--cf-borde);
  border-radius: var(--cf-radio);
  color: var(--cf-texto);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
}
.che-firmas-campo-nombre input::placeholder { color: var(--cf-texto-3); }

.che-firmas-mensaje {
  min-height: 20px;
  font-size: 13px;
  color: var(--cf-texto-2);
  margin: 0 0 14px;
}
.che-firmas-mensaje.che-firmas-error { color: var(--cf-rojo); }
.che-firmas-mensaje.che-firmas-exito { color: #7fbf7f; }

.che-firmas-modal-acciones {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}
@media (max-width: 400px) {
  .che-firmas-modal-acciones { flex-direction: column-reverse; }
  .che-firmas-modal-acciones .che-firmas-boton { width: 100%; }
}

.che-firmas-visualmente-oculto {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
