﻿
/* ── Alpine: ocultar antes de init ── */
[x-cloak] { display: none !important; }

/* ── Garantizar que el atributo HTML hidden siempre gane sobre display en CSS ── */
/* Sin esta regla, un componente con `display: flex` puede hacer visible un         */
/* elemento que tiene el atributo [hidden], porque el UA-stylesheet tiene menos    */
/* especificidad que las hojas del usuario. Causa documentada: menú móvil topbar.  */
[hidden] { display: none !important; }

/* ── Reset ─────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  hanging-punctuation: first last;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* Numerales ópticos de Inter: tabulares, sin serifas en ceros */
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  font-optical-sizing: auto;
}

/* ── Tipografía ─────────────────────────────── */
h1 {
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: -0.025em;
  color: var(--color-text);
}

h2 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
}

h3 {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  letter-spacing: -0.015em;
}

h4 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
  letter-spacing: -0.01em;
}

p { line-height: var(--leading-relaxed); }

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--color-primary-hover); text-decoration: underline; }

small { font-size: var(--text-sm); }

caption, .caption {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

img, svg { display: block; max-width: 100%; }

ul, ol { list-style: none; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  font-feature-settings: inherit;
}

button { cursor: pointer; border: none; }

/* ── Scrollbars ─────────────────────────────── */
::-webkit-scrollbar          { width: 5px; height: 5px; }
::-webkit-scrollbar-track    { background: transparent; }
::-webkit-scrollbar-thumb    { background: var(--color-border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-subtle); }

/* ── Selección ──────────────────────────────── */
::selection {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

/* ── Focus visible ──────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ═══════════════════════════════════════════
   LAYOUT PRINCIPAL — topbar horizontal (B.5)
   body: flex-column, height 100vh
   #topbar: fijo, 60px
   .app-layout: área scrollable
   #footer: barra fija, 40px
═══════════════════════════════════════════ */
body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* El topbar se renderiza en #topbar via topbar.js */
#topbar {
  flex-shrink: 0;
  position: relative;
  z-index: var(--z-sticky);
}

/* El layout de cada página es el área scrollable */
.app-layout {
  flex: 1;
  min-height: 0;       /* crítico: evita que flex desborde */
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--color-bg);
  scroll-padding-bottom: calc(var(--space-8) + 40px);
}

.app-main {
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-8) calc(var(--space-8) + 40px);
}

/* Footer corporativo */
#footer { flex-shrink: 0; }

@media (min-width: 1600px) {
  .app-main { padding: var(--space-8) var(--space-10); }
}

@media (max-width: 1023px) {
  .app-main { padding: var(--space-5) var(--space-6); }
}

@media (max-width: 767px) {
  .app-main { padding: var(--space-4); }
}

/* ═══════════════════════════════════════════
   UTILIDADES
═══════════════════════════════════════════ */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Flex */
.flex           { display: flex; }
.flex-col       { flex-direction: column; }
.items-center   { align-items: center; }
.items-start    { align-items: flex-start; }
.justify-between{ justify-content: space-between; }
.justify-end    { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.flex-1 { flex: 1; min-width: 0; }

/* Visibilidad */
.hidden    { display: none !important; }
.invisible { visibility: hidden; }

/* Texto */
.text-muted    { color: var(--color-text-muted); }
.text-subtle   { color: var(--color-text-subtle); }
.text-primary  { color: var(--color-primary); }
.text-success  { color: var(--color-success); }
.text-danger   { color: var(--color-danger); }
.text-warning  { color: var(--color-warning); }
.text-xs       { font-size: var(--text-xs); }
.text-sm       { font-size: var(--text-sm); }
.text-base     { font-size: var(--text-base); }
.text-lg       { font-size: var(--text-lg); }
.font-medium   { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold     { font-weight: var(--weight-bold); }

/* Números tabulares para datos */
.tabular-nums  { font-variant-numeric: tabular-nums; }

