/* ==========================================================================
   MagecQR — Component layer (UX Rebuild Max Pass)
   Aditivo sobre app.css. Reutiliza las variables de :root de app.css.
   Prefijo c-* para componentes reutilizables del frontend interno.
   No cambia comportamiento; solo presentación. No afecta a la carta pública.
   ========================================================================== */

/* ---- Shell ------------------------------------------------------------- */
.c-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---- Topbar (sistema: bar, rol, caja, hardware, usuario) --------------- */
.c-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 10px 14px;
  background: var(--surface, #fff);
  border: 1px solid var(--line, #dfe6df);
  border-radius: 14px;
  box-shadow: var(--shadow-small, 0 10px 28px rgba(10, 55, 45, 0.08));
}
.c-topbar__item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--ink-soft, #29433b);
}
.c-topbar__item strong { color: var(--ink, #10241f); }
.c-topbar__spacer { margin-left: auto; }

/* ---- Primary navigation (unified) -------------------------------------- */
.c-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 22px;
}
.c-nav__group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.c-nav__group-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted, #687b75);
  margin-right: 4px;
}
.c-nav__link {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 10px;
  color: var(--ink-soft, #29433b);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
}
.c-nav__link:hover { background: var(--green-soft, #e7f2ec); color: var(--green-dark, #064c3d); }
.c-nav__link.is-active,
.c-nav__link[aria-current="page"] {
  background: var(--green, #0d765d);
  color: #fff;
}

/* ---- Contextual sub-nav (TPV subsections only) ------------------------- */
.c-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px;
  background: var(--surface-muted, #f0f3ed);
  border-radius: 12px;
}
.c-subnav__link {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 9px;
  color: var(--ink-soft, #29433b);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
}
.c-subnav__link:hover { background: #fff; }
.c-subnav__link.is-active,
.c-subnav__link[aria-current="page"] { background: var(--green, #0d765d); color: #fff; }

/* ---- Mobile nav toggle ------------------------------------------------- */
.c-mobile-nav__toggle {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line, #dfe6df);
  border-radius: 10px;
  background: var(--surface, #fff);
  color: var(--ink, #10241f);
  font-weight: 700;
  cursor: pointer;
}

/* ---- Page header ------------------------------------------------------- */
.c-page-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 6px;
}
.c-page-header__title { margin: 0; font-size: 1.4rem; color: var(--ink, #10241f); }
.c-page-header__subtitle { margin: 2px 0 0; color: var(--muted, #687b75); font-size: 0.92rem; }

/* ---- Card -------------------------------------------------------------- */
.c-card {
  background: var(--surface, #fff);
  border: 1px solid var(--line, #dfe6df);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow-small, 0 10px 28px rgba(10, 55, 45, 0.08));
}
.c-card__title { margin: 0 0 10px; font-size: 1rem; color: var(--ink, #10241f); }

/* ---- Stat -------------------------------------------------------------- */
.c-stat { display: flex; flex-direction: column; gap: 2px; }
.c-stat__label { font-size: 0.78rem; color: var(--muted, #687b75); }
.c-stat__value { font-size: 1.3rem; font-weight: 700; color: var(--ink, #10241f); }

/* ---- Button ------------------------------------------------------------ */
.c-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--green, #0d765d);
  color: #fff;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
}
.c-button:hover { background: var(--green-dark, #064c3d); }
.c-button--secondary {
  background: var(--surface, #fff);
  color: var(--ink, #10241f);
  border-color: var(--line, #dfe6df);
}
.c-button--danger { background: var(--danger, #b84646); }
.c-button--danger:hover { filter: brightness(0.92); }
.c-button[disabled], .c-button:disabled {
  background: #94a3b8;
  cursor: not-allowed;
  opacity: 0.8;
}

/* ---- Badge ------------------------------------------------------------- */
.c-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
  background: var(--surface-muted, #f0f3ed);
  color: var(--ink-soft, #29433b);
}
.c-badge--ok { background: var(--green-soft, #e7f2ec); color: var(--green-dark, #064c3d); }
.c-badge--warn { background: var(--warning-soft, #fff8df); color: var(--warning, #9b7016); }
.c-badge--danger { background: var(--danger-soft, #fff0ee); color: var(--danger, #b84646); }

/* ---- Alert ------------------------------------------------------------- */
.c-alert {
  border: 1px solid var(--line, #dfe6df);
  border-left-width: 4px;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--surface, #fff);
}
.c-alert--warn { border-left-color: var(--warning, #9b7016); background: var(--warning-soft, #fff8df); }
.c-alert--danger { border-left-color: var(--danger, #b84646); background: var(--danger-soft, #fff0ee); }
.c-alert--ok { border-left-color: var(--green, #0d765d); background: var(--green-soft, #e7f2ec); }

/* ---- Table ------------------------------------------------------------- */
.c-table { width: 100%; border-collapse: collapse; }
.c-table th, .c-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line, #dfe6df);
  font-size: 0.9rem;
}
.c-table th { color: var(--muted, #687b75); font-weight: 700; }

/* ---- Tabs -------------------------------------------------------------- */
.c-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line, #dfe6df); }
.c-tabs__tab {
  padding: 8px 14px;
  border: none;
  background: none;
  color: var(--ink-soft, #29433b);
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.c-tabs__tab.is-active { border-bottom-color: var(--green, #0d765d); color: var(--green-dark, #064c3d); }

/* ---- Action bar -------------------------------------------------------- */
.c-action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}

/* ---- Danger zone ------------------------------------------------------- */
.c-danger-zone {
  border: 1px solid var(--danger, #b84646);
  border-radius: 14px;
  padding: 16px;
  background: var(--danger-soft, #fff0ee);
}
.c-danger-zone__title {
  margin: 0 0 6px;
  color: var(--danger, #b84646);
  font-size: 1rem;
}

/* ---- Empty state ------------------------------------------------------- */
.c-empty-state {
  text-align: center;
  padding: 22px;
  color: var(--muted, #687b75);
  border: 1px dashed var(--line, #dfe6df);
  border-radius: 12px;
}

/* ---- Form row ---------------------------------------------------------- */
.c-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.c-form-row label { font-size: 0.82rem; color: var(--ink-soft, #29433b); font-weight: 600; }
.c-form-row input, .c-form-row select, .c-form-row textarea {
  padding: 8px 10px;
  border: 1px solid var(--line, #dfe6df);
  border-radius: 8px;
  font: inherit;
}

/* ---- Money value ------------------------------------------------------- */
.c-money-value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--ink, #10241f);
}
.c-money-value--negative { color: var(--danger, #b84646); }

/* ---- Header layout (base.html) ----------------------------------------- */
.header-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 18px;
  flex: 1;
  justify-content: flex-end;
}
.header-system {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}
.header-logout { margin: 0; }

/* ---- Responsive -------------------------------------------------------- */
@media (max-width: 760px) {
  .c-mobile-nav__toggle { display: inline-flex; }
  .header-nav { width: 100%; justify-content: flex-start; }
  .c-nav {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  .c-nav.is-open { display: flex; }
  .c-nav__group { width: 100%; }
  .c-nav__link { width: 100%; }
  .c-page-header { flex-direction: column; align-items: stretch; }
  .c-action-bar { justify-content: stretch; }
  .c-action-bar .c-button { flex: 1; }
}

/* ---- Connectivity status banner ---------------------------------------- */
.connectivity-banner {
  padding: 0.4rem 1rem;
  text-align: center;
  font-size: 0.82rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  color: #475569;
}

/* All state spans hidden by default — JS adds a state class to root */
.connectivity-banner [data-connectivity-checking],
.connectivity-banner [data-connectivity-online],
.connectivity-banner [data-connectivity-offline],
.connectivity-banner [data-connectivity-unstable] {
  display: none;
}

/* Show only the active state span */
.connectivity-banner.connectivity-checking  [data-connectivity-checking],
.connectivity-banner.connectivity-online    [data-connectivity-online],
.connectivity-banner.connectivity-offline   [data-connectivity-offline],
.connectivity-banner.connectivity-unstable  [data-connectivity-unstable] {
  display: inline;
}

/* State-specific colours */
.connectivity-banner.connectivity-online   { background: #f0fdf4; border-bottom-color: #bbf7d0; color: #166534; }
.connectivity-banner.connectivity-offline  { background: #fef2f2; border-bottom-color: #fecaca; color: #991b1b; }
.connectivity-banner.connectivity-unstable { background: #fffbeb; border-bottom-color: #fde68a; color: #92400e; }

/* Sub-note line (always visible within the banner) */
.connectivity-note {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.78rem;
}
: 0.15rem;
  font-size: 0.78rem;
}
