/* ==========================================================================
   LumiStore Web Admin — legacy component classes, on the Tangram tokens

   The React shell and pages are styled by Tailwind and the shadcn/ui
   components. What is left here is the handful of class names that markup
   OUTSIDE React still wears -- the login card, core.js's modals, drawers,
   toasts, pager and first-paint skeletons -- plus a few the React pages kept
   (stacked tables, velocity bands, the Telegram preview).

   No colour is written here. Every value is a token from
   buildtools/app/src/styles/tokens/, so these follow the scheme, the theme
   and the density exactly as the React side does, and there is no separate
   dark block to keep in step: the tokens flip themselves.
   ========================================================================== */

:root {
  /* The platform's own faces: SF on a Mac, Segoe on Windows. */
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', ui-sans-serif, system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, 'Cascadia Mono', 'Segoe UI Mono', Menlo, Consolas, monospace;
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
}

html,
body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

* {
  -webkit-tap-highlight-color: transparent;
}

button:disabled,
[aria-disabled='true'] {
  cursor: not-allowed;
}

/* The page behind everything: the scheme's canvas, flat. */
.circuit-light-bg {
  background: var(--canvas);
}

.brand-logo-img {
  width: 32px !important;
  height: 32px !important;
  max-width: 32px !important;
  max-height: 32px !important;
  object-fit: contain !important;
}

.brand-logo-login {
  width: 64px !important;
  height: 64px !important;
  max-width: 64px !important;
  max-height: 64px !important;
  object-fit: contain !important;
}

/* -- tiles ----------------------------------------------------------------
   `.glass-card` is the bento tile now: surface, no border, the density's
   radius. It beats the `rounded-xl` the old templates pass alongside it
   because this sheet loads after Tailwind's. */
.glass-card {
  position: relative;
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-tile);
  box-shadow: var(--shadow-tile);
}

.glass-card-interactive {
  cursor: pointer;
  transition: transform var(--duration) var(--ease-out), background-color var(--duration) ease;
}
.glass-card-interactive:hover {
  transform: translateY(-2px);
  background: var(--surface-hover);
}
.glass-card-interactive:active {
  transform: scale(0.98);
}

/* -- skeletons ------------------------------------------------------------ */
@keyframes shimmerWave {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  display: block;
  border-radius: 0.5rem;
  background: linear-gradient(90deg, var(--surface-muted) 25%, var(--surface-hover) 50%, var(--surface-muted) 75%);
  background-size: 200% 100%;
  animation: shimmerWave 1.8s ease-in-out infinite;
}

/* -- fields and buttons: 6px corners, no pills (owner, 22 Oct 2026) --------- */
.glass-input {
  font-family: inherit;
  font-size: 0.8125rem;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-control);
  outline: none;
  transition: box-shadow var(--duration) ease, border-color var(--duration) ease;
}
textarea.glass-input {
  border-radius: var(--radius-inner);
}
.glass-input:hover {
  border-color: color-mix(in srgb, var(--ink) 40%, var(--surface));
}
.glass-input:focus {
  box-shadow: 0 0 0 2px var(--focus);
}
.glass-input::placeholder {
  color: var(--ink-muted);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--on-primary);
  background: var(--primary);
  border: 0;
  border-radius: var(--radius-control);
  cursor: pointer;
  transition: transform var(--duration) ease, opacity var(--duration) ease;
}
.btn-primary:hover {
  opacity: 0.9;
}
.btn-primary:active {
  transform: scale(0.98);
}
.btn-primary:disabled {
  opacity: 0.55;
  transform: none;
}

/* -- tables --------------------------------------------------------------- */
.glass-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.glass-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: var(--surface);
  border-bottom: 1px solid var(--surface-muted);
}
.glass-table td {
  height: var(--row-h);
  padding: 0.25rem 0.75rem;
  font-size: 12px;
  color: var(--ink);
  border-bottom: 1px solid var(--surface-muted);
}
.glass-table tbody tr:hover {
  background: var(--surface-muted);
}
.glass-table tbody tr:last-child td {
  border-bottom: 0;
}

/* -- status pills --------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.125rem 0.625rem;
  border-radius: var(--radius-control);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}
.badge-success {
  background: var(--tile-good);
  color: var(--tile-ink);
}
.badge-warning {
  background: var(--tile-hero);
  color: var(--tile-ink);
}

/* -- modals, drawers, toasts (core.js) ------------------------------------ */
.glass-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  overflow-y: auto;
  background: var(--scrim);
  animation: fadeIn 0.12s ease-out;
}
.glass-modal {
  width: 100%;
  max-height: calc(100vh - 2.5rem);
  display: flex;
  flex-direction: column;
  margin: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--ink);
  background: var(--surface);
  border-radius: var(--radius-tile);
  box-shadow: var(--shadow-pop);
  animation: modalScaleUp 0.18s var(--ease-spring);
}
.glass-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  justify-content: flex-end;
  background: var(--scrim);
  animation: fadeIn 0.12s ease-out;
}
.glass-drawer {
  width: 100%;
  max-width: 580px;
  height: 100%;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  animation: drawerSlideIn 0.2s var(--ease-spring);
}
.glass-toast {
  position: relative;
  overflow: hidden;
  pointer-events: auto;
  border-radius: var(--radius-tile) !important;
  border: 0 !important;
  box-shadow: var(--shadow-pop);
  animation: toastSlideIn 0.2s var(--ease-spring);
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalScaleUp {
  from { opacity: 0; transform: scale(0.97) translateY(6px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes drawerSlideIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(16px) scale(0.97); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

.command-kbd {
  flex-shrink: 0;
  white-space: nowrap;
  padding: 0.15rem 0.45rem;
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.2;
  color: var(--ink-muted);
  background: var(--surface);
  border-radius: var(--radius-control);
}

/* -- vanilla lucide icons (core.js) --------------------------------------- */
.lucide-icon {
  display: inline-block;
  vertical-align: middle;
  stroke-width: 2.1;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.85); }
}
.telemetry-pulse {
  animation: pulseDot 2s infinite;
}

.view-enter {
  animation: viewFade 0.12s ease-out;
}
@keyframes viewFade {
  from { opacity: 0.85; }
  to { opacity: 1; }
}
@keyframes view-enter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}
#view-content > * {
  animation: view-enter 0.2s var(--ease-spring) both;
}

.permission-hidden {
  display: none !important;
}

/* IDs and codes read as chips in both themes. */
code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 0.08em 0.4em;
  border-radius: var(--radius-control);
  color: var(--ink);
  background: var(--surface-muted);
  white-space: nowrap;
}

/* -- pager (core.js) ------------------------------------------------------ */
.pager {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 4px 0;
}
.pager-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--ink-muted);
}
.pager-size {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
}
.pager-select {
  padding: 3px 1.6rem 3px 10px !important;
  font-size: 11px !important;
}
.pager-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pager-btn,
.pager-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 28px;
  border: 0;
  border-radius: var(--radius-control);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-muted);
  cursor: pointer;
}
.pager-btn {
  padding: 0 10px;
}
.pager-num {
  min-width: 28px;
  padding: 0 8px;
  font-family: var(--font-mono);
  background: transparent;
}
.pager-btn:hover:not(:disabled),
.pager-num:hover {
  background: var(--surface-hover);
}
.pager-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.pager-num-active,
.pager-num-active:hover {
  color: var(--on-primary);
  background: var(--primary);
}

/* -- movement bands (Fast & Slow Movers) ---------------------------------- */
.band-pill {
  display: inline-block;
  padding: 0.125rem 0.625rem;
  border-radius: var(--radius-control);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.band-fast { background: var(--tile-good); color: var(--tile-ink); }
.band-steady { background: var(--primary); color: var(--on-primary); }
.band-slow { background: var(--tile-hero); color: var(--tile-ink); }
.band-dead { background: var(--tile-urgent); color: var(--on-urgent); }
.band-new { background: var(--surface-muted); color: var(--ink-muted); }

.band-figure {
  font-size: var(--kpi-size);
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.band-figure.band-fast,
.band-figure.band-steady,
.band-figure.band-slow,
.band-figure.band-dead,
.band-figure.band-new {
  background: none;
}
.band-figure.band-fast { color: var(--good-ink); }
.band-figure.band-steady { color: var(--ink); }
.band-figure.band-slow { color: var(--hero-ink); }
.band-figure.band-dead { color: var(--urgent-ink); }
.band-figure.band-new { color: var(--ink-muted); }

.band-card {
  --fg: var(--ink);
  --fg-muted: var(--ink-muted);
  text-align: left;
  border: 0;
  border-radius: var(--radius-tile);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: transform var(--duration) var(--ease-out), background-color var(--duration) ease;
}
.band-card:hover {
  transform: translateY(-2px);
}
.band-card:active {
  transform: scale(0.98);
}
.band-card:disabled {
  cursor: default;
  transform: none;
}
.band-card[aria-pressed='true'] {
  --fg: var(--on-primary);
  --fg-muted: color-mix(in srgb, var(--on-primary) 75%, transparent);
  color: var(--on-primary);
  background: var(--primary);
}
/* The band colours are for an ivory card; on the pressed (solid) one the
   figure takes the pill's own ink, or it all but vanishes in light mode. */
.band-card[aria-pressed='true'] .band-figure {
  color: var(--on-primary);
}

/* -- the Telegram preview in the product and group editors ---------------- */
.telegram-simulator {
  background: var(--surface-muted);
  border-radius: var(--radius-inner);
}
.telegram-bubble {
  color: var(--ink);
  background: var(--surface);
  border-radius: 0.85rem 0.85rem 0.85rem 0.2rem;
  box-shadow: var(--shadow-tile);
}
.telegram-btn {
  color: var(--ink);
  background: var(--surface);
  border-radius: var(--radius-control);
  cursor: default;
}

/* A <details> used as a multi-select dropdown: only its marker goes. */
.dropdown-summary {
  list-style: none;
}
.dropdown-summary::-webkit-details-marker {
  display: none;
}

/* ==========================================================================
   Responsive & interaction layer
   ========================================================================== */

/* Scrolling tables grow edge shadows only while there is more to see in that
   direction: the cover gradients travel with the content (`local`), the
   shadows stay pinned (`scroll`), so a fully scrolled edge shows nothing. */
.overflow-x-auto,
.overflow-auto {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  background:
    linear-gradient(to right, var(--surface) 30%, transparent) left center / 36px 100% no-repeat local,
    linear-gradient(to left, var(--surface) 30%, transparent) right center / 36px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, var(--line), transparent) left center / 14px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, var(--line), transparent) right center / 14px 100% no-repeat scroll;
}

@media (pointer: coarse) {
  .btn-primary,
  .pager-btn,
  .pager-num,
  .glass-input,
  .pager-select {
    min-height: 38px;
  }
  .pager {
    justify-content: center;
  }
}

.btn-primary:active,
.pager-btn:not(:disabled):active,
.pager-num:active {
  transform: translateY(1px) scale(0.994);
}

/* Stacked tables: below `md`, a table marked `stacked-table` stops being a
   table. Each row becomes a card and each cell one "label: value" line, the
   label coming from the cell's own `data-label`. */
@media (max-width: 767px) {
  .stacked-table td button:not([role='switch']),
  .stacked-table td a[role='button'] {
    min-height: 44px;
  }

  .glass-table th,
  .glass-table td,
  .overflow-auto table:not(.stacked-table) th,
  .overflow-auto table:not(.stacked-table) td {
    white-space: nowrap;
    padding-left: 0.7rem;
    padding-right: 0.7rem;
  }

  .stacked-table thead {
    display: none;
  }
  .stacked-table,
  .stacked-table tbody,
  .stacked-table tr,
  .stacked-table td {
    display: block;
    width: 100%;
  }
  .stacked-table tr {
    margin-bottom: 0.625rem;
    padding: 0.25rem 0;
    border-radius: var(--radius-inner);
    background: var(--surface-muted);
  }
  .stacked-table tr:last-child {
    margin-bottom: 0;
  }
  .stacked-table td {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    column-gap: 0.75rem;
    row-gap: 0.2rem;
    max-width: 100%;
    height: auto;
    padding: 0.4rem 0.85rem;
    border: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }
  .stacked-table td::before {
    content: attr(data-label);
    flex: 0 1 auto;
    margin-right: auto;
    min-width: 0;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-muted);
    text-align: left;
  }
  .stacked-table td > p:not(:only-child),
  .stacked-table td > div:not(:only-child) {
    flex-basis: 100%;
  }
  .stacked-table td:not([data-label])::before,
  .stacked-table td[data-label='']::before,
  .stacked-table td[colspan]::before {
    content: none;
  }
  .stacked-table td:not([data-label]),
  .stacked-table td[data-label=''] {
    justify-content: stretch;
    padding-top: 0.55rem;
    text-align: left;
  }
  .stacked-table td[colspan] {
    justify-content: center;
    text-align: center;
  }
  .stacked-table td:has(.skeleton) {
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
  }
  .stacked-table td:has(.skeleton):nth-child(n + 4) {
    display: none;
  }
  .stacked-table td.truncate,
  .stacked-table td .truncate {
    overflow: visible;
    white-space: normal;
    text-overflow: clip;
  }
}
