/* ════════════════════════════════════════════════════════
   Portal Nayax — Base, primitives, components
   ════════════════════════════════════════════════════════ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

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

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { background: none; border: none; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ─────── Type primitives ─────── */
.t-display   { font-size: 56px; line-height: 1.05; font-weight: 700; letter-spacing: -0.02em; }
.t-h1        { font-size: 36px; line-height: 1.1;  font-weight: 700; letter-spacing: -0.015em; }
.t-h2        { font-size: 28px; line-height: 1.2;  font-weight: 700; letter-spacing: -0.01em; }
.t-h3        { font-size: 22px; line-height: 1.3;  font-weight: 600; letter-spacing: -0.005em; }
.t-h4        { font-size: 18px; line-height: 1.35; font-weight: 600; }
.t-body      { font-size: 14px; line-height: 1.55; font-weight: 400; }
.t-body-lg   { font-size: 16px; line-height: 1.6;  font-weight: 400; }
.t-small     { font-size: 13px; line-height: 1.5;  font-weight: 400; color: var(--text-2); }
.t-caption   { font-size: 12px; line-height: 1.45; font-weight: 500; color: var(--text-2); }
.t-overline  { font-size: 11px; line-height: 1.2;  font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-3); }
.t-mono      { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.muted { color: var(--text-2); }

/* ─────── App shell ─────── */
.app-root { min-height: 100vh; }

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.app-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.app-topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--line-1);
  padding: 0 var(--space-7);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  position: sticky; top: 0; z-index: 30;
}

.app-content {
  flex: 1;
  padding: var(--space-7) var(--space-7) var(--space-9);
  min-width: 0;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-7);
}
.page-header h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.015em; }
.page-header .sub { color: var(--text-2); margin-top: 4px; font-size: 14px; }

/* ─────── Sidebar ─────── */
.sidebar {
  background: var(--bg-inverse);
  color: var(--text-on-inverse);
  display: flex;
  flex-direction: column;
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 20px 22px 18px;
  border-bottom: 1px solid var(--line-on-inverse);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-brand .mark {
  width: 28px; height: 28px;
  background: var(--accent); border-radius: 7px;
  display: grid; place-items: center; flex-shrink: 0;
  font-weight: 800; font-size: 13px; color: var(--neutral-15);
}
.sidebar-brand .word { font-weight: 800; font-size: 15px; letter-spacing: 0.18em; }
.sidebar-brand .sub  { font-size: 10px; color: var(--text-on-inverse-2); letter-spacing: 0.15em; text-transform: uppercase; margin-top: 1px; }

.sidebar-account {
  padding: 16px 22px;
  border-bottom: 1px solid var(--line-on-inverse);
}
.sidebar-account .label { font-size: 10px; color: var(--text-on-inverse-2); letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 4px; }
.sidebar-account .name  { font-size: 14px; font-weight: 600; color: var(--text-on-inverse); }
.sidebar-account .code {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 8px;
  background: rgba(255,205,0,0.10);
  border: 1px solid rgba(255,205,0,0.22);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 11px; font-weight: 600;
  padding: 3px 8px; border-radius: var(--radius-xs);
  letter-spacing: 0.06em;
}

.sidebar-nav { flex: 1; padding: 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-section-label {
  padding: 14px 10px 6px;
  font-size: 10px; color: rgba(242,239,234,0.4);
  letter-spacing: 0.12em; text-transform: uppercase; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px;
  font-size: 13.5px; font-weight: 500;
  color: rgba(242,239,234,0.6);
  border-radius: var(--radius-sm);
  cursor: pointer; transition: background .12s, color .12s;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text-on-inverse); }
.nav-item.active {
  background: rgba(255,205,0,0.10);
  color: var(--accent);
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item .count {
  margin-left: auto;
  font-size: 11px;
  background: rgba(255,255,255,0.08);
  padding: 1px 7px; border-radius: 10px;
  font-weight: 600;
  color: var(--text-on-inverse-2);
}
.nav-item.active .count { background: var(--accent); color: var(--neutral-15); }

.sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid var(--line-on-inverse);
  display: flex; flex-direction: column; gap: 8px;
}
.sidebar-cart-card {
  background: rgba(255,205,0,0.07);
  border: 1px solid rgba(255,205,0,0.22);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.sidebar-cart-card .row1 { display: flex; align-items: center; justify-content: space-between; }
.sidebar-cart-card .lbl { font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-on-inverse-2); }
.sidebar-cart-card .badge { font-size: 10px; font-weight: 700; background: var(--accent); color: var(--neutral-15); padding: 2px 7px; border-radius: 10px; }
.sidebar-cart-card .total { font-size: 17px; font-weight: 700; color: var(--text-on-inverse); margin-top: 2px; }
.sidebar-cart-card .sub  { font-size: 11px; color: var(--text-on-inverse-2); margin: 2px 0 10px; }
.sidebar-cart-monthly {
  font-size: 11px;
  color: var(--accent);
  margin-top: 2px;
  font-weight: 600;
}
.sidebar-cart-thumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  padding: 8px 10px;
  background: rgba(0,0,0,0.20);
  border-radius: var(--radius-sm);
}
.sidebar-cart-thumb {
  width: 26px; height: 26px;
  border-radius: 5px;
  overflow: hidden;
  border: 1.5px solid var(--bg-inverse);
  margin-left: -6px;
  flex-shrink: 0;
}
.sidebar-cart-thumb:first-child { margin-left: 0; }
.sidebar-cart-thumb-more {
  width: 26px; height: 26px;
  border-radius: 5px;
  background: rgba(255,255,255,0.10);
  color: var(--accent);
  display: grid; place-items: center;
  font-size: 10px; font-weight: 700;
  margin-left: -6px;
  border: 1.5px solid var(--bg-inverse);
}
.sidebar-cart-thumb-label {
  display: flex; flex-direction: column;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-on-inverse);
  line-height: 1.25;
  min-width: 0;
  flex: 1;
  margin-left: 4px;
}
.sidebar-cart-thumb-label span {
  font-size: 9px;
  font-weight: 500;
  color: var(--text-on-inverse-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 1px;
}
.sidebar-cart-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 10.5px;
  color: var(--text-on-inverse-2);
  margin-bottom: 10px;
  font-weight: 500;
}
.sidebar-cart-status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--spring);
  box-shadow: 0 0 0 3px rgba(37,239,137,0.18);
  flex-shrink: 0;
}
.sidebar-cart-card .cta  {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: var(--accent); color: var(--neutral-15);
  border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 700;
  cursor: pointer;
}
.sidebar-cart-cta {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 4px 4px 4px 14px;
  background: var(--accent);
  color: var(--dark);
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background .15s, transform .12s;
  box-shadow: 0 4px 14px rgba(255,205,0,0.22);
  position: relative;
  overflow: hidden;
}
.sidebar-cart-cta:hover {
  background: var(--accent-strong);
}
.sidebar-cart-cta:active {
  transform: translateY(1px);
}
.sidebar-cart-cta-arrow {
  width: 28px; height: 28px;
  border-radius: 6px;
  background: var(--dark);
  color: var(--accent);
  display: grid; place-items: center;
  transition: transform .2s cubic-bezier(.4,0,.2,1);
}
.sidebar-cart-cta:hover .sidebar-cart-cta-arrow {
  transform: translateX(3px);
}

.user-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .15s;
}
.user-pill:hover { background: rgba(255,255,255,0.04); }
.user-pill .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-weight: 700; color: var(--neutral-15); font-size: 12px; }
.user-pill .name { font-size: 13px; color: var(--text-on-inverse); font-weight: 500; }
.user-pill .role { font-size: 10px; color: var(--text-on-inverse-2); letter-spacing: 0.1em; text-transform: uppercase; }

/* ─────── Buttons ─────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-lg { height: 48px; padding: 0 22px; font-size: 14px; border-radius: var(--radius-md); }

.btn-primary { background: var(--accent); color: var(--accent-on); }
.btn-primary:hover { background: var(--accent-strong); }

.btn-dark { background: var(--neutral-15); color: var(--neutral-90); }
.btn-dark:hover { background: var(--neutral-20); }

.btn-secondary { background: var(--bg-surface); color: var(--text-1); border-color: var(--line-2); }
.btn-secondary:hover { border-color: var(--neutral-30); background: var(--neutral-80); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--neutral-80); color: var(--text-1); }

.btn-link { background: transparent; color: var(--text-1); height: auto; padding: 0; }
.btn-link:hover { color: var(--text-link); }

.btn-danger { background: var(--red-soft); color: var(--red-30); }
.btn-danger:hover { background: #FBDDE1; }

.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ─────── Inputs ─────── */
.input, .select, .textarea {
  width: 100%;
  height: 40px;
  background: var(--bg-surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 14px;
  color: var(--text-1);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { padding: 10px 12px; height: auto; min-height: 80px; resize: vertical; line-height: 1.5; }
.input::placeholder, .textarea::placeholder { color: var(--neutral-60); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--neutral-15);
  box-shadow: var(--shadow-focus);
}
.input-group {
  display: flex; align-items: center; gap: 0;
  background: var(--bg-surface);
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 40px;
  transition: border-color .15s, box-shadow .15s;
}
.input-group:focus-within {
  border-color: var(--neutral-15);
  box-shadow: var(--shadow-focus);
}
.input-group svg { color: var(--text-3); flex-shrink: 0; }
.input-group input {
  flex: 1; border: none; outline: none; background: transparent;
  padding: 0 10px;
  font-size: 14px;
}

.field-label {
  display: block;
  font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-2);
  margin-bottom: 6px;
}

/* ─────── Cards ─────── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: var(--space-6); }
.card-pad-lg { padding: var(--space-7); }

/* ─────── Badges ─────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.02em;
}
.badge-yellow { background: var(--yellow-90); color: var(--yellow-00); border: 1px solid var(--yellow-30); }
.badge-purple { background: var(--purple-90); color: var(--purple-10); }
.badge-green  { background: var(--green-soft); color: var(--green-30); }
.badge-red    { background: var(--red-soft); color: var(--red-30); }
.badge-orange { background: var(--orange-soft); color: var(--orange-30); }
.badge-blue   { background: var(--blue-soft); color: var(--blue-30); }
.badge-neutral{ background: var(--neutral-80); color: var(--text-2); }
.badge-inverse{ background: var(--neutral-15); color: var(--accent); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

/* ─────── Tables ─────── */
.table-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.table-toolbar {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-1);
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  flex-wrap: wrap;
}
table.t {
  width: 100%; border-collapse: collapse;
}
table.t th {
  text-align: left;
  padding: 11px 18px;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-3);
  background: var(--bg-surface-2);
  border-bottom: 1px solid var(--line-1);
  white-space: nowrap;
}
table.t td {
  padding: 14px 18px;
  font-size: 13.5px;
  color: var(--text-1);
  border-bottom: 1px solid var(--line-1);
  vertical-align: middle;
}
table.t tr:last-child td { border-bottom: none; }
table.t tbody tr { transition: background .12s; }
table.t tbody tr:hover { background: var(--neutral-80); }
.cell-mono { font-family: var(--font-mono); font-size: 12.5px; color: var(--text-2); }
.t.dn-density-compact td { padding-top: 6px; padding-bottom: 6px; }

/* ─────── Misc ─────── */
.divider { height: 1px; background: var(--line-1); }
.kpi-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi {
  background: var(--bg-surface);
  border: 1px solid var(--line-1);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.kpi .label { font-size: 11px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -0.015em; margin-top: 6px; }
.kpi .delta { font-size: 12px; font-weight: 600; margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; }
.delta-up { color: var(--green-30); }
.delta-down { color: var(--red-30); }

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--text-3);
}
.empty-state .icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--neutral-80);
  display: grid; place-items: center;
  margin: 0 auto 14px;
  color: var(--text-3);
}

/* ─────── Scrollbar polish ─────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.10); border-radius: 10px; border: 2px solid var(--bg-app); }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.20); }
.sidebar ::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-color: var(--bg-inverse); }

/* ─────── Product card hover affordance ─────── */
.prod-card { transition: transform .16s var(--ease, cubic-bezier(.4,0,.2,1)), box-shadow .16s, border-color .16s; }
.prod-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-2); }
.prod-card:hover .prod-add { background: var(--accent); color: var(--dark); border-color: transparent; }

/* ─────── Animations ─────── */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-up { animation: fadeUp .25s ease both; }
.fade-in { animation: fadeIn .2s ease both; }

/* ─────── Toast (empilhável, com tipos) ─────── */
.toast-stack {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex; flex-direction: column; align-items: center;
  gap: 10px; pointer-events: none;
  width: max-content; max-width: min(92vw, 440px);
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 11px;
  background: var(--neutral-15); color: white;
  padding: 10px 10px 10px 14px; border-radius: var(--radius-md);
  font-size: 13px; font-weight: 500; line-height: 1.35;
  box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--accent);
  max-width: 100%;
  animation: toastIn .28s cubic-bezier(.2,.9,.3,1.15) both;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.toast-ico {
  flex-shrink: 0; width: 20px; height: 20px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255,255,255,.12); color: var(--accent);
}
.toast-msg { flex: 1; min-width: 0; }
.toast-x {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 6px;
  display: grid; place-items: center;
  color: rgba(255,255,255,.5); background: transparent;
  cursor: pointer; transition: background .15s, color .15s;
}
.toast-x:hover { background: rgba(255,255,255,.14); color: white; }
.toast-green  { border-left-color: var(--green-30); }
.toast-green  .toast-ico { color: var(--green-30); }
.toast-red    { border-left-color: var(--red-30); }
.toast-red    .toast-ico { color: var(--red-30); }
.toast-orange { border-left-color: var(--orange-30); }
.toast-orange .toast-ico { color: var(--orange-30); }
.toast-blue   { border-left-color: var(--blue-30); }
.toast-blue   .toast-ico { color: var(--blue-30); }

/* ─────── Modal / Drawer ─────── */
.scrim {
  position: fixed; inset: 0;
  background: rgba(14, 17, 22, 0.5);
  backdrop-filter: blur(2px);
  z-index: 100;
  animation: fadeIn .15s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(480px, 100vw);
  background: var(--bg-surface);
  z-index: 101;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: drawerIn .25s cubic-bezier(.4,0,.2,1);
}
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  max-width: 560px; width: 100%;
  margin: auto;
  max-height: calc(100vh - 48px);
  overflow: hidden auto;
  animation: fadeUp .2s ease both;
}
.modal-wrap {
  position: fixed; inset: 0;
  background: rgba(14, 17, 22, 0.5);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadeIn .15s ease;
}

/* ─────── Responsive ─────── */
@media (max-width: 980px) {
  .app-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .app-content { padding: 16px 14px 100px; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; align-items: flex-start; }
  .app-topbar { padding: 0 14px; }
  table.t th, table.t td { padding: 10px 12px; }
  .modal-wrap { padding: 0; align-items: flex-end; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; overflow-y: auto; }
  .drawer { width: 100vw; }
}
