/*
 * Fontech Base: tokens, shell y componentes compartidos por Service, Hotel y Files.
 * Mantén este archivo idéntico en las tres apps. Cada app solo redefine su acento en
 * `:root` (--accent, --accent-hover, --accent-soft, --accent-ink) en su propia hoja.
 * Los tokens van en :where(:root) (especificidad cero) para que el acento de cada app
 * gane sin importar el orden en que el bundler junte las hojas.
 * Las fuentes (Inter y Manrope) las carga cada app.
 */
:where(:root) {
  color-scheme: light;

  /* Tipografía */
  --font-heading: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, sans-serif;

  /* Superficies y texto */
  --bg: #f6f7f9;
  --bg-nav: #fbfbfc;
  --surface: #fff;
  --surface-muted: #f2f4f7;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --ink: #141a1f;
  --muted: #5b6470;
  --subtle: #8a93a0;

  /* Estados */
  --success: #1f7a4d;
  --success-soft: #e6f4ec;
  --warning: #8a5a0b;
  --warning-soft: #ffeedd;
  --danger: #b42318;
  --danger-soft: #ffedea;
  --info: #2f5bd3;
  --info-soft: #eef2ff;

  /* Acento por defecto (Service); cada app lo redefine en :root */
  --accent: #0f766e;
  --accent-hover: #0b5f58;
  --accent-soft: #e3f3ef;
  --accent-ink: #0b4f49;
  --on-accent: #fff;

  /* Forma */
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-empty: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  /* Elevación */
  --shadow-card: 0 1px 2px rgb(20 26 31 / 5%);
  --shadow-pop: 0 8px 24px rgb(20 26 31 / 10%);
  --scrim: rgb(20 26 31 / 40%);

  /* Estructura */
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --content-max: 100rem;
  --control-height: 40px;
  --control-height-sm: 32px;
  --bottom-bar: calc(4.25rem + env(safe-area-inset-bottom));

  /* Movimiento */
  --ease-state: 120ms ease-out;
}

/* ---------- Shell: sidebar + barra superior + página ---------- */
.fx-shell {
  display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100svh; background: var(--bg); color: var(--ink); font-family: var(--font-body);
}
.fx-sidebar {
  display: flex; flex-direction: column; gap: 1.25rem; position: sticky; top: 0;
  height: 100svh; padding: 1rem .75rem; overflow-y: auto;
  background: var(--bg-nav); border-right: 1px solid var(--line); color: var(--ink);
}
.fx-brand {
  display: inline-flex; align-items: center; gap: .75rem; width: fit-content; margin: .25rem .5rem;
  color: var(--ink); font: 700 1.125rem/1.2 var(--font-heading); letter-spacing: -.01em; text-decoration: none;
}
.fx-brand small { display: block; margin-top: .1rem; color: var(--muted); font: 500 .75rem/1.3 var(--font-body); letter-spacing: 0; }
.fx-brand-mark {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px;
  border-radius: var(--radius-md); background: var(--accent); color: var(--on-accent); font: 800 1.1rem/1 var(--font-heading);
}
.fx-nav { display: grid; gap: .25rem; }
.fx-nav :is(a, button) {
  display: flex; align-items: center; gap: .75rem; width: 100%; min-height: 44px; padding: .5rem .75rem;
  border: 0; border-radius: var(--radius-md); background: transparent; color: var(--ink);
  font: 500 .9375rem/1.3 var(--font-body); text-align: left; text-decoration: none; cursor: pointer;
  transition: background-color var(--ease-state), color var(--ease-state); -webkit-tap-highlight-color: transparent;
}
.fx-nav :is(a, button) svg { flex: none; width: 20px; height: 20px; }
@media (hover: hover) { .fx-nav :is(a, button):not([aria-current]):hover { background: var(--surface-muted); } }
.fx-nav :is(a, button)[aria-current] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.fx-nav :is(a, button):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fx-nav-icon { display: grid; place-items: center; flex: none; }
.fx-sidebar-footer { display: grid; gap: .65rem; margin-top: auto; }
.fx-account {
  display: flex; align-items: center; gap: .5rem; min-width: 0; padding: .5rem .65rem;
  border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface);
  color: var(--ink); font-size: .875rem; font-weight: 600; overflow-wrap: anywhere;
}
.fx-account svg { flex: none; width: 20px; height: 20px; color: var(--accent); }
.fx-account select { flex: 1; min-width: 0; min-height: 0; padding: .2rem; border: 0; background: transparent; color: inherit; font: inherit; }
.fx-account small { display: block; color: var(--muted); font-weight: 500; }
.fx-logout { display: grid; justify-items: start; gap: .5rem; font-size: .875rem; color: var(--muted); overflow-wrap: anywhere; }
.fx-session-trigger { display: none; }
.fx-session-dialog {
  width: min(23rem, calc(100% - 2rem)); padding: 1.5rem; border: 1px solid var(--line);
  border-radius: var(--radius-lg); color: var(--ink); background: var(--surface); box-shadow: var(--shadow-pop);
}
.fx-session-dialog::backdrop { background: var(--scrim); }
.fx-session-dialog > div { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.fx-session-dialog > :not(:first-child) { margin-top: 1rem; }
.fx-workspace { min-width: 0; display: flex; flex-direction: column; }
.fx-topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem;
  min-height: var(--topbar-height); padding: .5rem clamp(1rem, 2.5vw, 2rem);
  background: var(--bg-nav); border-bottom: 1px solid var(--line); color: var(--muted); font-size: .875rem;
}
.fx-breadcrumb { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.fx-breadcrumb svg { flex: none; width: 20px; height: 20px; }
.fx-breadcrumb a { color: inherit; text-underline-offset: .2em; }
.fx-breadcrumb strong { color: var(--ink); font-weight: 600; }
.fx-breadcrumb-separator { color: var(--subtle); }
.fx-topbar-actions { display: flex; align-items: center; gap: .75rem; margin-inline-start: auto; min-width: 0; }
.fx-page { width: 100%; max-width: var(--content-max); padding: clamp(1rem, 3vw, 2rem); }
.fx-page-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem 1rem; margin-bottom: 1.5rem;
}
.fx-page-header h1 {
  margin: 0; color: var(--ink); font: 700 clamp(1.625rem, 3vw, 2rem)/1.25 var(--font-heading); letter-spacing: -.02em; overflow-wrap: anywhere;
}
.fx-page-header p { margin: .25rem 0 0; color: var(--muted); font-size: .875rem; }
.fx-page-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: .5rem; }

/* ---------- Componentes ---------- */
.fx-overline { margin: 0; color: var(--muted); font: 600 .75rem/1.35 var(--font-body); letter-spacing: .08em; text-transform: uppercase; }
.fx-card {
  min-width: 0; padding: clamp(1rem, 2vw, 1.5rem); border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-card); overflow-wrap: anywhere;
}
.fx-card h2:not(.fx-overline) { margin: 0; color: var(--ink); font: 700 1.25rem/1.4 var(--font-heading); letter-spacing: -.01em; }
.fx-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 13rem), 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.fx-metric { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-content: start; gap: .5rem; padding: 1.25rem; }
.fx-metric > .fx-overline { grid-column: 1; align-self: center; }
.fx-metric > .fx-icon { grid-column: 2; grid-row: 1; }
.fx-metric > strong {
  grid-column: 1 / -1; color: var(--ink); font: 700 2rem/1.2 var(--font-heading);
  letter-spacing: -.015em; font-variant-numeric: tabular-nums lining-nums;
}
.fx-metric > :is(p, small, progress) { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: .8125rem; }
.fx-metric > progress { width: 100%; accent-color: var(--accent); }
.fx-icon {
  display: grid; place-items: center; flex: none; width: 36px; height: 36px;
  border-radius: var(--radius-md); background: var(--accent-soft); color: var(--accent-ink);
}
.fx-icon svg { width: 20px; height: 20px; }
.fx-empty {
  display: grid; justify-items: center; gap: .75rem; padding: 2rem 1rem;
  border-radius: var(--radius-empty); background: var(--surface-muted); color: var(--muted); text-align: center;
}
.fx-empty > .fx-icon { width: 48px; height: 48px; border-radius: var(--radius-empty); }
.fx-empty strong { color: var(--ink); font-size: 1rem; font-weight: 600; }
.fx-segmented { display: flex; gap: .25rem; padding: .25rem; border-radius: var(--radius-md); background: var(--surface-muted); }
.fx-segmented button {
  min-height: var(--control-height-sm); padding: .3rem .75rem; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); font: 600 .8125rem/1.2 var(--font-body); cursor: pointer;
}
.fx-segmented button:is([aria-pressed="true"], .is-active) { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-card); }

/* ---------- Móvil: menú abajo y cuenta arriba, igual en todas las apps ---------- */
@media (max-width: 700px) {
  .fx-shell { display: flex; flex-direction: column; padding-bottom: var(--bottom-bar); }
  .fx-sidebar { display: contents; }
  .fx-sidebar > .fx-brand, .fx-logout { display: none; }
  .fx-sidebar-footer {
    order: -1; position: sticky; top: 0; z-index: 11; display: flex; align-items: center; justify-content: space-between;
    margin: 0; padding: calc(.5rem + env(safe-area-inset-top)) max(.85rem, env(safe-area-inset-right)) .5rem max(.85rem, env(safe-area-inset-left));
    background: var(--bg-nav); border-bottom: 1px solid var(--line);
  }
  .fx-account { max-width: calc(100% - 3.25rem); min-height: 2.5rem; }
  .fx-session-trigger {
    display: grid; place-items: center; flex: none; width: 2.75rem; height: 2.75rem; padding: 0;
    border: 0; border-radius: 50%; background: var(--accent); color: var(--on-accent); cursor: pointer;
  }
  .fx-session-trigger svg { width: 20px; height: 20px; }
  .fx-nav {
    position: fixed; z-index: 10; inset: auto 0 0; display: flex; overflow-x: auto; min-height: var(--bottom-bar);
    padding: .25rem env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--bg-nav); border-top: 1px solid var(--line); scrollbar-width: none;
  }
  .fx-nav :is(a, button) {
    flex: 1 0 4.25rem; flex-direction: column; justify-content: center; gap: .15rem; min-width: 0;
    padding: .25rem .05rem; font-size: .72rem; text-align: center;
  }
  .fx-nav :is(a, button) svg { width: 3rem; height: 1.8rem; padding: .3rem 0; border-radius: 2rem; }
  .fx-nav :is(a, button)[aria-current] { background: transparent; color: var(--accent-ink); }
  .fx-nav :is(a, button)[aria-current] svg { background: var(--accent-soft); }
  .fx-workspace { flex: 1; }
  .fx-topbar { position: static; flex-wrap: wrap; min-height: 2.65rem; font-size: .8125rem; }
  .fx-topbar-actions { width: 100%; margin: 0; }
  .fx-topbar-actions > * { flex: 1; width: auto; max-width: none; }
  .fx-page-header { align-items: flex-start; flex-direction: column; }
  .fx-page-actions { justify-content: flex-start; }
}
