/* Club Anastasia — hoja de estilo única (ADR-006).
   Cambiar la identidad visual = editar las variables de :root.

   Paleta y tipografía de marca tomadas del sitio institucional
   (anastasia_web): negro/rojo/blanco, "Anton" para títulos + ".marca",
   "Inter" para el resto. Adaptado, no calcado: el cuerpo de la app son
   tablas y formularios densos de uso frecuente, así que el fondo/texto
   de trabajo se mantiene claro (u oscuro con prefers-color-scheme) para
   legibilidad — el negro de marca se reserva para la barra superior,
   que es un elemento de identidad, no de lectura densa. */

:root {
  --negro: #111111;
  --negro-suave: #1c1c1c;
  --rojo: #d81f26;
  --blanco: #f5f5f5;
  --gris-marca: #9a9a9a;

  --fondo: #f5f5f5;
  --superficie: #ffffff;
  --texto: #171717;
  --texto-tenue: #6b6b6b;
  --borde: #e6e6e6;
  --borde-fuerte: #d4d4d4;
  --acento: var(--rojo);
  --acento-suave: #fbe9ea;
  --acento-texto: #ffffff;
  /* Color de enlaces de texto: separado de --acento porque en modo oscuro
     el rojo de marca no llega a 4.5:1 sobre --fondo (falla WCAG AA para
     texto), así que ahí usa una variante más clara solo para texto. Los
     botones (fondo rojo + texto blanco) sí cumplen con --acento tal cual. */
  --enlace: var(--rojo);
  --ok-fondo: #edf8f0;
  --ok-borde: #57b877;
  --error-fondo: #fdecec;
  --error-borde: #e05656;
  --radio: 10px;
  --sombra: 0 1px 2px rgba(20, 20, 30, 0.04), 0 1px 3px rgba(20, 20, 30, 0.06);
  --ancho: 62rem;

  --fuente-cuerpo:
    "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --fuente-marca: "Anton", "Inter", sans-serif;

  /* La barra superior es negra siempre, en modo claro y oscuro: es marca,
     no contenido de lectura. */
  --topbar-fondo: var(--negro);
  --topbar-texto: var(--blanco);
  --topbar-tenue: var(--gris-marca);
  --topbar-borde: var(--rojo);
}

@media (prefers-color-scheme: dark) {
  :root {
    --fondo: var(--negro);
    --superficie: var(--negro-suave);
    --texto: var(--blanco);
    --texto-tenue: var(--gris-marca);
    --borde: #2a2a2a;
    --borde-fuerte: #3a3a3a;
    --acento: var(--rojo);
    --acento-suave: #2a1414;
    --acento-texto: #ffffff;
    --enlace: #ff6b6b;
    --ok-fondo: #14261a;
    --ok-borde: #3f8f5b;
    --error-fondo: #2a1616;
    --error-borde: #b84a4a;
    --sombra: 0 1px 2px rgba(0, 0, 0, 0.3), 0 1px 3px rgba(0, 0, 0, 0.4);

    --topbar-fondo: var(--negro-suave);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font-family: var(--fuente-cuerpo);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--enlace);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* --- Barra superior ---
   Siempre negra (--topbar-*), en modo claro y oscuro: es el elemento de
   identidad de marca, el resto de la app prioriza legibilidad. */

.barra {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1.5rem;
  background: color-mix(in srgb, var(--topbar-fondo) 92%, transparent);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 3px solid var(--topbar-borde);
}

.barra a {
  color: var(--topbar-texto);
}

.barra a:hover {
  color: var(--topbar-borde);
  text-decoration: none;
}

.barra .marca {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--fuente-marca);
  font-size: 1.05rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--topbar-texto);
}

.barra .marca .logo {
  display: block;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.barra .marca .marca-texto {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.barra .marca .marca-subtitulo {
  font-family: var(--fuente-cuerpo);
  font-size: 0.65rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--topbar-tenue);
}

.barra .sesion {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--topbar-tenue);
  min-width: 0;
}

.barra .sesion span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Contenedor --- */

main {
  max-width: var(--ancho);
  margin: 2rem auto;
  padding: 0 1.5rem;
}

main > .volver,
main > p:first-child {
  margin-top: 0;
}

.volver {
  font-size: 0.875rem;
  color: var(--texto-tenue);
}

h1 {
  font-family: var(--fuente-marca);
  font-size: 1.65rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  margin: 0.25rem 0 1.25rem;
}

h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 2rem 0 0.75rem;
}

h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--texto-tenue);
  margin: 1.5rem 0 0.5rem;
}

/* --- Superficie tipo tarjeta para el contenido principal --- */

main > h1 + *,
main > table,
main > form,
main > dl,
main > ul:not(.mensajes) {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 1.25rem;
}

/* Bloque plegable (p. ej. el alta de socio, arriba de una lista larga). */
main > details {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 0.85rem 1.25rem;
  margin-bottom: 1.25rem;
}

main > details > summary {
  cursor: pointer;
  font-weight: 600;
}

main > details[open] > summary {
  margin-bottom: 0.75rem;
}

/* --- Paginación --- */

.resumen-lista {
  margin: 1.25rem 0 0;
  font-size: 0.875rem;
  color: var(--texto-tenue);
}

.paginacion {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.25rem;
  margin: 0.75rem 0;
  font-size: 0.875rem;
  color: var(--texto-tenue);
}

.paginacion-enlaces {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
}

.paginacion .deshabilitado {
  opacity: 0.45;
}

main > h2 + table,
main > h2 + form,
main > h3 + table,
main > h3 + form {
  margin-top: 0;
}

/* --- Tablas --- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.925rem;
}

thead th {
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--texto-tenue);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--borde-fuerte);
}

tbody td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--borde);
  vertical-align: top;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: var(--acento-suave);
}

/* --- Listas de navegación --- */

main > ul:not(.mensajes) {
  list-style: none;
  margin: 0;
}

main > ul:not(.mensajes) li + li {
  margin-top: 0.5rem;
}

/* --- Definiciones (ficha) --- */

dl {
  display: grid;
  grid-template-columns: minmax(9rem, max-content) 1fr;
  gap: 0.5rem 1.25rem;
  margin: 0;
}

dt {
  color: var(--texto-tenue);
  font-size: 0.9rem;
}

dd {
  margin: 0;
}

/* --- Formularios --- */

form p {
  margin: 0 0 0.9rem;
}

form p:last-of-type {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--texto-tenue);
  margin-bottom: 0.25rem;
}

input,
select,
textarea {
  width: 100%;
  font: inherit;
  color: var(--texto);
  background: var(--superficie);
  border: 1px solid var(--borde-fuerte);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--acento);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--acento) 22%, transparent);
}

textarea {
  min-height: 4.5rem;
  resize: vertical;
}

select[multiple] {
  min-height: 8rem;
}

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--acento-texto);
  background: var(--acento);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0.45rem 0.9rem;
}

button:hover {
  background: color-mix(in srgb, var(--acento) 88%, black);
}

button:active {
  transform: translateY(0.5px);
}

/* Botones dentro de celdas de tabla: compactos y secundarios */

td form {
  display: inline;
}

td button {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
  color: var(--texto);
  background: transparent;
  border-color: var(--borde-fuerte);
}

td button:hover {
  background: var(--acento-suave);
}

/* --- Mensajes --- */

.mensajes {
  list-style: none;
  margin: 0 0 1.5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mensaje {
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--borde);
  border-left-width: 3px;
  border-radius: 8px;
  background: var(--superficie);
  font-size: 0.9rem;
}

.mensaje.success {
  background: var(--ok-fondo);
  border-left-color: var(--ok-borde);
}

.mensaje.error {
  background: var(--error-fondo);
  border-left-color: var(--error-borde);
}

.mensaje.warning {
  border-left-color: var(--acento);
}

/* --- Errores de formulario de Django --- */

.errorlist {
  list-style: none;
  margin: 0 0 0.35rem;
  padding: 0;
  color: var(--error-borde);
  font-size: 0.85rem;
}

/* --- Responsive --- */

@media (max-width: 40rem) {
  .barra {
    padding: 0.5rem 1rem;
    gap: 0.5rem;
  }

  .barra .marca {
    font-size: 0.9rem;
    gap: 0.45rem;
  }

  .barra .marca .logo {
    width: 26px;
    height: 26px;
  }

  .barra .marca .marca-subtitulo {
    display: none;
  }

  .barra .sesion {
    max-width: 40%;
  }

  /* Objetivos táctiles más grandes: en un celular no hay hover, el toque
     tiene que caer sobre un área cómoda (guía usual: ~44px). */
  button,
  input,
  select,
  textarea {
    min-height: 2.75rem;
  }

  td button {
    min-height: 2.25rem;
  }

  main {
    padding: 0 1rem;
    margin: 1.25rem auto;
  }

  dl {
    grid-template-columns: 1fr;
    gap: 0.15rem;
  }

  dt {
    margin-top: 0.5rem;
  }

  table {
    display: block;
    overflow-x: auto;
  }

  /* Portal del socio: la mayoría de los ~500 socios va a entrar desde el
     celular (H26/H27) — las tablas de estado de cuenta pasan de filas
     anchas con scroll horizontal a "tarjetas" apiladas, una fila por
     tarjeta, con el encabezado de columna como etiqueta (`data-label` en
     cada <td>, ver estado_de_cuenta.html). Solo en `main.portal`: el panel
     administrativo (uso ocasional desde el celular) conserva el scroll
     horizontal simple. */
  main.portal table {
    display: block;
    overflow-x: visible;
  }

  main.portal table thead {
    display: none;
  }

  main.portal table tbody {
    display: block;
  }

  main.portal table tr {
    display: block;
    margin-bottom: 0.75rem;
    border: 1px solid var(--borde);
    border-radius: var(--radio);
    padding: 0.75rem;
  }

  main.portal table tr:last-child {
    margin-bottom: 0;
  }

  main.portal table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    padding: 0.35rem 0;
    border-bottom: none;
    text-align: right;
  }

  main.portal table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--texto-tenue);
    text-align: left;
  }
}

/* --- Portal: pantallas de acceso (H38) ---
   Celular primero (RNF-11): una columna angosta, botones a todo el ancho y el
   código en dígitos grandes, que se lee y se tipea sin zoom. */

main.portal .acceso {
  max-width: 24rem;
  margin: 0 auto;
}

main.portal .acceso form p {
  margin: 0 0 1rem;
}

main.portal .acceso button,
main.portal .acceso .boton-secundario {
  width: 100%;
  min-height: 2.75rem;
}

main.portal .acceso .boton-secundario {
  color: var(--texto);
  background: transparent;
  border-color: var(--borde-fuerte);
}

main.portal .acceso input[inputmode="numeric"] {
  font-size: 1.75rem;
  letter-spacing: 0.5em;
  text-align: center;
}

main.portal .acceso .ayuda {
  color: var(--texto-tenue);
  font-size: 0.9rem;
}

main.portal .cuentas {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* --- Portal: mis recibos y detalle (H39/H40) ---
   Tarjetas en vez de tablas: se leen de arriba abajo con una mano, el importe
   grande y un solo botón por recibo (RNF-11). */

main.portal a.boton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
  color: var(--acento-texto);
  background: var(--acento);
}

main.portal a.boton.secundario {
  color: var(--texto);
  background: transparent;
  border: 1px solid var(--borde-fuerte);
}

main.portal .total-pendiente {
  font-size: 1.1rem;
}

main.portal .recibos,
main.portal .lineas {
  list-style: none;
  padding: 0;
  margin: 0 0 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

main.portal .recibo {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.75rem;
  align-items: center;
  padding: 0.85rem 1rem;
  border: 1px solid var(--borde);
  border-radius: 10px;
  background: var(--superficie);
}

main.portal .recibo-fecha {
  font-weight: 600;
}

main.portal .recibo-importe {
  font-size: 1.25rem;
  font-weight: 700;
  text-align: right;
}

main.portal .recibo-estado {
  color: var(--texto-tenue);
  font-size: 0.9rem;
}

main.portal .recibo.pendiente .recibo-estado,
main.portal p.recibo-estado.pendiente {
  color: var(--acento);
  font-weight: 600;
}

main.portal .recibo a.boton {
  grid-column: 1 / -1;
}

main.portal .lineas li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--borde);
}

main.portal .lineas small {
  display: block;
  color: var(--texto-tenue);
}

main.portal .lineas .total {
  font-size: 1.15rem;
  font-weight: 700;
  border-bottom: none;
}

main.portal .accion-principal button {
  width: 100%;
  min-height: 3rem;
  font-size: 1.1rem;
}

main.portal .ayuda {
  color: var(--texto-tenue);
  font-size: 0.9rem;
}

main.portal .paginacion {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
