/* Liquid Glass — complementary layer on top of theme.css (does not replace the dark ERP base).
   Inspired by Apple Liquid Glass (iOS 26 / macOS Tahoe): frost, rim sheen, soft refraction. */

:root {
  --lg-tint: rgba(255, 255, 255, 0.06);
  --lg-tint-strong: rgba(255, 255, 255, 0.10);
  --lg-rim: rgba(255, 255, 255, 0.22);
  --lg-rim-soft: rgba(255, 255, 255, 0.10);
  --lg-blur: 18px;
  --lg-sat: 160%;
  --lg-radius: 16px;
  --lg-radius-sm: 12px;
  --lg-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --lg-inset:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    inset 0 -1px 0 rgba(255, 255, 255, 0.06),
    inset 1px 0 0 rgba(255, 255, 255, 0.08),
    inset -1px 0 0 rgba(255, 255, 255, 0.08);
}

/* Ambient field so glass has something to refract */
body.app-body {
  /* Stronger ambient so frost/blur actually reads (blue only — no purple wash) */
  background:
    radial-gradient(1000px 520px at 6% -12%, rgba(80, 170, 255, 0.34), transparent 58%),
    radial-gradient(820px 460px at 96% 4%, rgba(30, 136, 255, 0.18), transparent 52%),
    radial-gradient(900px 560px at 50% 118%, rgba(40, 150, 255, 0.14), transparent 48%),
    var(--bg);
  background-attachment: fixed;
}

/* Shared glass material */
.lg-surface,
.app-header,
.panel,
.stat-card,
.product-hits,
.login-glass {
  background: linear-gradient(
      165deg,
      rgba(255, 255, 255, 0.10) 0%,
      rgba(255, 255, 255, 0.03) 42%,
      rgba(18, 25, 34, 0.55) 100%
    ),
    var(--lg-tint);
  backdrop-filter: blur(var(--lg-blur)) saturate(var(--lg-sat)) brightness(1.05);
  -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(var(--lg-sat)) brightness(1.05);
  border: 1px solid var(--lg-rim-soft);
  box-shadow: var(--lg-shadow), var(--lg-inset);
}

@supports (backdrop-filter: url(#lg-refract)) {
  .app-header,
  .panel,
  .stat-card,
  .product-hits,
  .login-glass {
    backdrop-filter: blur(12px) saturate(var(--lg-sat)) brightness(1.06) url(#lg-refract);
    -webkit-backdrop-filter: blur(12px) saturate(var(--lg-sat)) brightness(1.06) url(#lg-refract);
  }
}

/* Specular sheen (static highlight — no motion spam) */
.app-header::before,
.panel::before,
.stat-card::before,
.login-glass::before {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    125deg,
    rgba(255, 255, 255, 0.18) 0%,
    rgba(255, 255, 255, 0.04) 28%,
    transparent 52%
  );
  opacity: 0.55;
  mix-blend-mode: soft-light;
}

.panel,
.stat-card,
.login-glass {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.app-header {
  position: sticky;
  isolation: isolate;
}

.app-header {
  top: 0.65rem;
  margin: 0.65rem clamp(0.75rem, 2vw, 1.25rem) 0;
  padding: 0.85rem 1.15rem;
  border-radius: 999px;
  border-bottom: none;
  z-index: 40;
  max-width: calc(1400px + 2.5rem);
  margin-left: auto;
  margin-right: auto;
  width: calc(100% - 1.5rem);
  background: linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.14),
      rgba(15, 21, 32, 0.42)
    ),
    rgba(15, 21, 32, 0.32);
  /* allow nav chips; sheen still clipped via ::before radius */
  overflow: visible;
}

.app-header .nav a {
  border-radius: 999px;
  transition: background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.app-header .nav a:hover {
  background: rgba(255, 255, 255, 0.10);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.panel {
  border-radius: var(--lg-radius);
  background: linear-gradient(
      160deg,
      rgba(255, 255, 255, 0.09),
      rgba(18, 25, 34, 0.62)
    ),
    rgba(18, 25, 34, 0.42);
}

/* Login card geometry lives in login.css (centered stage). Keep glass material only. */
.login-glass {
  border-radius: calc(var(--lg-radius) + 6px);
}

.stat-card {
  border-radius: var(--lg-radius-sm);
  background: linear-gradient(
      150deg,
      rgba(255, 255, 255, 0.10),
      rgba(18, 25, 34, 0.5)
    ),
    rgba(18, 25, 34, 0.35);
}

.nested-panel {
  background: linear-gradient(
      165deg,
      rgba(255, 255, 255, 0.06),
      rgba(15, 21, 32, 0.72)
    ),
    rgba(15, 21, 32, 0.55) !important;
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid var(--lg-rim-soft);
  border-radius: var(--lg-radius-sm);
  box-shadow: var(--lg-inset);
}

/* Controls: glass chips, not solid slabs */
.btn-tenant,
.btn:not(.primary):not(.danger):not(.danger-lite) {
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  border-color: var(--lg-rim-soft);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
  border-radius: 999px;
}

.btn-tenant.active {
  background: rgba(30, 136, 255, 0.22);
  border-color: rgba(120, 190, 255, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 0 0 1px rgba(30, 136, 255, 0.15);
}

.btn.primary,
.btn-primary {
  border-radius: 999px;
  box-shadow:
    0 8px 24px rgba(30, 136, 255, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.form-stack input,
.form-stack select,
.form-stack textarea,
.lines-edit input,
.lines-edit select,
.add-line input,
.add-line select,
.product-picker input {
  background: rgba(10, 14, 20, 0.55) !important;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-color: var(--lg-rim-soft) !important;
  border-radius: 10px !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.product-hits {
  border-radius: var(--lg-radius-sm);
  background: rgba(18, 25, 34, 0.72) !important;
}

/* Dense tables stay readable — only light glass wash on header cells */
.data-table thead th {
  background: rgba(255, 255, 255, 0.03);
}

.kind-chapter td {
  background: rgba(30, 136, 255, 0.10) !important;
}

.app-main {
  padding-top: 1.1rem;
}

.app-footer {
  opacity: 0.85;
}

/* Accessibility: system wants less transparency */
@media (prefers-reduced-transparency: reduce) {
  .app-header,
  .panel,
  .stat-card,
  .product-hits,
  .login-glass,
  .nested-panel {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--bg-elev);
    box-shadow: none;
  }

  .app-header::before,
  .panel::before,
  .stat-card::before,
  .login-glass::before {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-header,
  .panel,
  .stat-card,
  .btn,
  .btn-tenant {
    transition: none;
  }
}
