/* ============================================================
   AcuPet · shell
   Header, footer y componentes compartidos por TODAS las páginas.
   Objetivo: que index.php, admin/users.php, account/password.php,
   auth/login.php, legal/cookies.html y messages.php dejen de tener
   cada una su propio <style> con su propio header.
   ============================================================ */

/* ---------- Header ---------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--s5);
  height: var(--header-h);
  padding: 0 var(--s5);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
  text-decoration: none;
  color: inherit;
  flex: none;
}
.brand img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}
.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}
.brand__text strong {
  font-size: var(--fs-lg);
  letter-spacing: -0.01em;
}
.brand__text em {
  font-style: normal;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}

.app-nav {
  display: flex;
  gap: var(--s1);
  margin-right: auto;
}
.app-nav a {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 var(--s3);
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  transition: background-color .15s, color .15s;
}
.app-nav a:hover { background: var(--surface-2); color: var(--ink); }
.app-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.app-user {
  display: flex;
  align-items: center;
  gap: var(--s3);
  flex: none;
}
.app-user__name {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
}
.app-user__link {
  color: var(--ink-2);
  text-decoration: none;
  padding: var(--s1) var(--s2);
  border-radius: var(--radius-sm);
}
.app-user__link:hover { color: var(--ink); background: var(--surface-2); }
.app-user__link--out { color: var(--muted); }

/* ---------- Main ---------- */

.app-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s5);
  min-width: 0;
}

/* Sin margen alrededor: lo usa la consola de mensajes, que gana leyendo a
   ancho completo. */
.app-main--flush {
  padding: 0;
  max-width: none;
}

/* ---------- Encabezado de página ---------- */

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
  flex-wrap: wrap;
}
.page-head h1 {
  font-size: var(--fs-2xl);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-wrap: balance;
}
.page-head__meta {
  margin-top: var(--s1);
  font-size: var(--fs-sm);
  color: var(--muted);
}
.page-head__actions { display: flex; gap: var(--s2); }

/* ---------- Footer ----------
   El degradado del logo como hairline: es el único adorno de la
   página, y sirve para separar el chrome del contenido. */

.app-footer {
  flex: none;
  background: var(--dark);
  border-top: 2px solid transparent;
  border-image: var(--brand-grad) 1;
  color: var(--dark-ink);
}
.app-footer__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s5);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s5);
  flex-wrap: wrap;
}
.app-footer__legal {
  font-size: var(--fs-sm);
  color: #7fa3ac;
}
.app-footer__ver {
  margin-left: var(--s2);
  padding: 2px var(--s2);
  border: 1px solid #244a54;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}
.app-footer__nav {
  display: flex;
  gap: var(--s6);
  flex-wrap: wrap;
}
.app-footer__nav a {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #e6f2f4;
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px solid transparent;
  transition: border-color .15s, color .15s;
}
.app-footer__nav a:hover {
  color: #fff;
  border-bottom-color: var(--brand-cyan);
}
.app-footer__note {
  font-weight: 400;
  font-size: var(--fs-xs);
  color: #7fa3ac;
}

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  height: 34px;
  padding: 0 var(--s4);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, color .15s;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-deep); }

.btn--ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--ink-2);
}
.btn--ghost:hover { border-color: var(--accent-line); color: var(--accent-deep); }

.btn--quiet {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-2);
}
.btn--quiet:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- Campos ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s1);
  min-width: 0;
}
.field > span {
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}
.field--inline {
  flex-direction: row;
  align-items: center;
  gap: var(--s2);
}
.field--inline > span { text-transform: none; letter-spacing: 0; font-size: var(--fs-md); color: var(--ink-2); }
.field--narrow { max-width: 120px; }

.field input,
.field select {
  height: 34px;
  padding: 0 var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: var(--ink);
  min-width: 0;
}
.field input:hover,
.field select:hover { border-color: var(--accent-line); }

/* ---------- Ver contraseña ----------
   El <span> lo inserta password-toggle.js alrededor de cada
   <input type="password">. Es display:flex para que, dentro de un .field
   (columna) o de un .inline-form (fila), ocupe lo mismo que ocupaba el
   input suelto y no descuadre la rejilla. */

.pw-reveal {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}
/* Los selectores llevan el hijo directo a propósito: admin.css se carga
   después y sus `.admin input` / `.admin button` ganarían por orden. Con dos
   clases la especificidad es mayor y no hace falta !important. */
.pw-reveal > input[type] {
  flex: 1 1 auto;
  min-width: 0;
  /* Hueco para el botón; si no, el texto pasa por debajo. */
  padding-right: 34px;
}
.pw-reveal > .pw-reveal__btn {
  position: absolute;
  right: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
}
.pw-reveal > .pw-reveal__btn:hover { background: none; color: var(--accent-deep); }
.pw-reveal > .pw-reveal__btn[aria-pressed="true"] { color: var(--accent-deep); }

/* ---------- Búsqueda ---------- */

.search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 280px;
  min-width: 200px;
}
.search__icon {
  position: absolute;
  left: var(--s3);
  width: 14px;
  height: 14px;
  color: var(--muted);
  pointer-events: none;
}
.search input {
  width: 100%;
  height: 34px;
  padding: 0 var(--s3) 0 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.search input::placeholder { color: var(--muted); }
.search input:hover { border-color: var(--accent-line); }
.search:focus-within .search__icon { color: var(--accent); }
/* Oculta la X nativa de Chrome/Safari, que se solapa con el padding */
.search input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ---------- Tarjetas ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--s5);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  min-width: 0;
}
.card--flush { padding: 0; gap: 0; }

.card__title {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.card__hint {
  margin-top: calc(var(--s3) * -1);
  color: var(--muted);
}

.card__bar {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s3) var(--s4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  border-radius: var(--radius) var(--radius) 0 0;
  flex-wrap: wrap;
}
.card__bar--foot {
  border-bottom: 0;
  border-top: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
}
.card__bar-spacer { flex: 1; }

.form-row {
  display: flex;
  align-items: flex-end;
  gap: var(--s3);
  flex-wrap: wrap;
}
.form-row .field { flex: 1 1 180px; }
.form-row .btn { flex: none; }

/* ---------- Utilidades ---------- */

.muted { color: var(--muted); }
.mono  { font-family: var(--font-mono); font-size: var(--fs-sm); }
.num   { text-align: right; font-variant-numeric: tabular-nums; }
.nil   { color: #b7ccd1; }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 1px var(--s2);
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .02em;
}
.pill--role   { background: var(--accent-soft); color: var(--accent-deep); }
.pill--w      { background: var(--accent-soft); color: var(--accent-deep); }
.pill--g      { background: #ece7f7; color: #5b46a0; }
.pill--motion { background: var(--warn-bg); color: var(--warn); }

.dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: var(--s1);
  vertical-align: 1px;
}
.dot--live { background: var(--ok); }

/* ---------- Páginas sin sesión (login) ----------
   No llevan header ni nav: todavía no hay usuario. Comparten tokens
   para que el primario sea el mismo y no el #1976D2 que traía. */

.auth-shell {
  flex: 1 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s5);
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--s6);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
}
.auth-card__brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
}
.auth-card__brand img { width: 36px; height: 36px; border-radius: var(--radius-sm); }
.auth-card h1 { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.01em; }
.auth-card .field input { height: 38px; }
.auth-card__legal {
  text-align: center;
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* ---------- Mapa a pantalla completa ----------
   map.php ocupaba toda la ventana con los enlaces flotando encima del
   mapa. Ahora comparte cabecera con el resto y el mapa ocupa lo que
   queda. */

.map-full {
  flex: 1 1 auto;
  min-height: 60vh;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

/* ---------- Mensajes de estado ---------- */

.notice {
  padding: var(--s3) var(--s4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.notice--error { background: var(--crit-bg); border-color: #f0c9c5; color: var(--crit); }
.notice--ok    { background: var(--ok-bg);   border-color: #bfe4d4; color: var(--ok); }

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .app-header {
    height: auto;
    flex-wrap: wrap;
    padding: var(--s3) var(--s4);
    gap: var(--s3);
  }
  .app-nav { order: 3; width: 100%; margin-right: 0; }
  .app-user { margin-left: auto; }
  .app-user__name { display: none; }
  .app-main { padding: var(--s4); gap: var(--s4); }
  .app-footer__inner { flex-direction: column-reverse; padding: var(--s4); }
  .app-footer__nav { gap: var(--s4); flex-direction: column; }
}
