/* Zafra: estilos de la interfaz (Paso 8a.2). Propios, sin recursos externos (DECISIONES P8.2).
   De móvil a escritorio; solo tema claro en la Fase 1 (P8.9); colores como variables para el tema del
   cliente (Paso 9) y un tema oscuro futuro. Contrastes sobre blanco: tinta 18,3:1; azul 13,2:1; gris 7,6:1; error 8,2:1. */

:root {
  --azul: #1b2a6b;          /* marca: menú lateral, enlaces y foco en el contenido */
  --tinta: #0c1230;         /* texto */
  --gris: #4b5563;          /* texto secundario */
  --borde: #c9ced6;         /* separadores (decorativos) */
  --fondo: #ffffff;
  --fondo-suave: #f4f5f8;
  --blanco: #ffffff;
  --acento: #d9890b;        /* solo como acento (IV2): sobre el azul (4,74:1) y como fondo con texto tinta */
  --texto-sobre-acento: #0c1230;
  --error: #9b1c1c;
  --cabecera-alto: 3.5rem;  /* 56 px */
  --menu-ancho: 16.5rem;    /* 264 px */
  --radio: 0.375rem;
  --fuente: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fuente-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--fuente);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--tinta);
  background: var(--fondo);
}

h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 1rem; }
h2 { font-size: 1.25rem; margin: 1.5rem 0 0.75rem; }
p { margin: 0 0 1rem; }
code { font-family: var(--fuente-mono); font-size: 0.95em; }

a { color: var(--azul); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }

/* Foco siempre visible y no solo por color: contorno grueso. */
:focus-visible { outline: 3px solid var(--azul); outline-offset: 2px; }
main:focus { outline: none; }

/* Enlace para saltar al contenido: primer elemento enfocable, visible al recibir el foco. */
.saltar {
  position: absolute;
  left: 0.5rem;
  top: -10rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--blanco);
  color: var(--azul);
  border: 2px solid var(--azul);
  border-radius: var(--radio);
}
.saltar:focus { top: 0.5rem; }

.icono { width: 1.25rem; height: 1.25rem; flex: none; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }

/* Cabecera */
.cabecera {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--cabecera-alto);
  padding: 0.25rem 1rem;
  background: var(--fondo);
  border-bottom: 1px solid var(--borde);
}
/* Una sola línea: la cabecera mide siempre 56 px y el panel del menú empieza justo debajo (8a.2). */
.marca-cliente { margin: 0; font-weight: 600; flex: 1; min-width: 0; display: flex; align-items: center;
  gap: 0.625rem; }
.marca-nombre { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Logo de la empresa (Cotizaciones C18): cabe en los 56 px de la cabecera, sin deformarse. */
.marca-logo { flex: none; height: 2.5rem; width: auto; max-width: 9rem; object-fit: contain; }
.persona { display: flex; align-items: center; gap: 0.75rem; }
.persona form { margin: 0; }
.persona-correo { color: var(--gris); font-size: 0.875rem; white-space: nowrap; }

/* Botones: objetivos táctiles de 44 px como mínimo. */
.boton, .boton-menu, button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  min-width: 2.75rem;
  padding: 0.5rem 1rem;
  font: inherit;
  font-weight: 600;
  border-radius: var(--radio);
  cursor: pointer;
}
button[type="submit"] {
  background: var(--acento);
  color: var(--texto-sobre-acento);
  border: 2px solid var(--tinta);
}
.boton-secundario, .boton-menu {
  background: var(--fondo);
  color: var(--azul);
  border: 2px solid var(--azul);
}
.boton-secundario { padding: 0.5rem 0.75rem; }

/* Formularios */
form p, form > div { margin: 0 0 1rem; }
label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], select, textarea {
  display: block;
  width: 100%;
  max-width: 28rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  font: inherit;
  color: var(--tinta);
  background: var(--fondo);
  border: 1px solid var(--gris);
  border-radius: var(--radio);
}
.errorlist { margin: 0 0 0.5rem; padding: 0; list-style: none; color: var(--error); font-weight: 600; }
.helptext { display: block; color: var(--gris); font-size: 0.875rem; margin-top: 0.25rem; }
.helptext ul { margin: 0.25rem 0 0; padding-left: 1.25rem; }

figure { margin: 0 0 1rem; }
figure svg { display: block; background: var(--blanco); padding: 0.5rem; }
figcaption { color: var(--gris); font-size: 0.875rem; }

/* Mensajes */
.mensajes { margin-bottom: 1rem; }
.mensaje { padding: 0.75rem 1rem; border-left: 4px solid var(--azul); background: var(--fondo-suave); }
.mensaje-error { border-left-color: var(--error); }

/* Contenido */
.marco { flex: 1; display: block; }
.contenido { flex: 1; padding: 1.5rem 1rem; max-width: 60rem; }
.contenido-publico { width: 100%; max-width: 32rem; margin: 0 auto; padding: 2rem 1rem; }

.pie { padding: 1rem; color: var(--gris); font-size: 0.875rem; border-top: 1px solid var(--borde); }
.pie p { margin: 0; }

/* Menú lateral. Sin JavaScript: en el flujo, completo bajo la cabecera (P8.10). */
.menu { background: var(--azul); color: var(--blanco); padding: 0.5rem 0; }
.menu-lista { list-style: none; margin: 0; padding: 0; }
.menu-enlace {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  color: var(--blanco);
  text-decoration: none;
  border-left: 4px solid transparent;
}
.menu-enlace:hover { background: rgba(255, 255, 255, 0.08); }
.menu-enlace[aria-current="page"] { border-left-color: var(--acento); font-weight: 600; }
.menu :focus-visible { outline-color: var(--acento); outline-offset: -3px; }
.menu-seccion { margin: 1rem 1rem 0.25rem; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--blanco); }
.menu-grupo { display: flex; align-items: center; gap: 0.75rem; min-height: 2.75rem; padding: 0.5rem 1rem;
  border-left: 4px solid transparent; }
.menu-sublista { list-style: none; margin: 0; padding: 0; }
.menu-enlace-hijo { padding-left: 3rem; }

/* Con JavaScript, en pantallas estrechas: panel deslizante. */
.js .app .menu {
  position: fixed;
  top: var(--cabecera-alto);
  bottom: 0;
  left: 0;
  z-index: 20;
  width: min(85vw, 20rem);
  overflow-y: auto;
  transform: translateX(-100%);
  visibility: hidden;
  /* Al cerrar, se oculta cuando termina de deslizarse; al abrir, es visible de inmediato para poder
     llevar el foco a su primer enlace (comprobado en navegador real, 8a.2). */
  transition: transform 0.2s ease, visibility 0s linear 0.2s;
}
.js.menu-abierto .app .menu { transform: none; visibility: visible; transition: transform 0.2s ease, visibility 0s; }
.velo { position: fixed; inset: var(--cabecera-alto) 0 0 0; z-index: 10; background: rgba(12, 18, 48, 0.45); }

@media (prefers-reduced-motion: reduce) {
  .js .app .menu { transition: none; }
}

/* Pantallas estrechas: el correo de la persona no cabe en la cabecera; queda para lectores de pantalla. */
@media (max-width: 39.99rem) {
  .persona-correo {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap; border: 0;
  }
  .marca-logo { height: 2rem; max-width: 5rem; }
}

/* Escritorio: columna fija; el botón y el velo sobran. */
@media (min-width: 60rem) {
  .marco { display: grid; grid-template-columns: var(--menu-ancho) minmax(0, 1fr); }
  .menu, .js .app .menu {
    position: sticky;
    top: var(--cabecera-alto);
    height: calc(100vh - var(--cabecera-alto));
    width: auto;
    transform: none;
    visibility: visible;
    overflow-y: auto;
  }
  .boton-menu, .velo { display: none !important; }
  .contenido { padding: 2rem; }
}
