/* ==========================================================================
   Use On Style — Design System
   Preto/Branco premium, minimalista, inspirado em Shopify Admin / Linear
   ========================================================================== */

:root {
  --ink: #0B0B0C;
  --ink-soft: #1A1A1C;
  --paper: #FFFFFF;
  --canvas: #FAFAF9;
  --line: #E8E7E4;
  --line-soft: #F1F0EE;
  --muted: #8A8985;
  --muted-2: #57564F;
  --success: #16A34A;
  --success-soft: #ECFDF3;
  --danger: #DC2626;
  --danger-soft: #FEF2F2;
  --info: #2563EB;
  --info-soft: #EFF4FF;
  --warn: #D97706;
  --warn-soft: #FFF7ED;
  --gold: #A88A4A;
  --shadow-sm: 0 1px 2px rgba(11,11,12,0.04);
  --shadow-md: 0 4px 16px rgba(11,11,12,0.06), 0 1px 2px rgba(11,11,12,0.04);
  --shadow-lg: 0 12px 40px rgba(11,11,12,0.10), 0 2px 8px rgba(11,11,12,0.04);
  --shadow-xl: 0 24px 64px rgba(11,11,12,0.16);
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--canvas);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
}

.font-display {
  font-family: 'Fraunces', Georgia, serif;
  font-optical-sizing: auto;
}

.tabular { font-variant-numeric: tabular-nums; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D8D7D3; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #B9B8B3; }

/* ---------- Grain texture (signature detail) ---------- */
.grain { position: relative; isolation: isolate; }
.grain::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.4'/%3E%3C/svg%3E");
  opacity: 0.05; pointer-events: none; z-index: 0; mix-blend-mode: multiply;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--ink);
  transition: width .28s cubic-bezier(.4,0,.2,1);
}
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 10px;
  color: #B9B8C1; font-size: 13.5px; font-weight: 500;
  transition: background .18s ease, color .18s ease, transform .18s ease;
  position: relative;
  white-space: nowrap;
}
.sidebar-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-link.active { background: #fff; color: #0B0B0C; }
.sidebar-link.active svg { color: #0B0B0C; }
.sidebar-link svg { flex-shrink: 0; width: 18px; height: 18px; color: #94939C; transition: color .18s; }
.sidebar-link:hover svg { color: #fff; }
.sidebar-link.active:hover svg { color: #0B0B0C; }

.sidebar.collapsed .label { display: none; }
.sidebar.collapsed { width: 76px; }
.sidebar-scrim { transition: opacity .25s ease; }

/* ---------- Cards & surfaces ---------- */
.surface {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}
.surface-hover:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: #DEDDD8; }

.kpi-card { position: relative; overflow: hidden; }
.kpi-card::after {
  content: ''; position: absolute; top: -40%; right: -20%;
  width: 140px; height: 140px; border-radius: 999px;
  background: radial-gradient(circle, rgba(11,11,12,0.035), transparent 70%);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: 600; font-size: 13.5px; border-radius: 10px;
  padding: 9px 16px; transition: all .16s ease; cursor: pointer;
  white-space: nowrap; border: 1px solid transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--ink); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: #232324; box-shadow: var(--shadow-md); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { background: var(--canvas); border-color: #D8D7D3; }
.btn-ghost { background: transparent; color: var(--muted-2); }
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #C11F1F; }
.btn-icon { padding: 8px; border-radius: 10px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Inputs ---------- */
.input {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 12px; font-size: 13.5px; background: #fff;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(11,11,12,0.06); }
.input::placeholder { color: #B4B3AE; }
label.field-label { font-size: 12px; font-weight: 600; color: var(--muted-2); margin-bottom: 6px; display: block; letter-spacing: .01em; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; letter-spacing: .02em; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; }
.badge-dot { width: 6px; height: 6px; border-radius: 999px; }
.badge-success { background: var(--success-soft); color: #0F7A38; }
.badge-success .badge-dot { background: var(--success); }
.badge-danger { background: var(--danger-soft); color: #B91C1C; }
.badge-danger .badge-dot { background: var(--danger); }
.badge-warn { background: var(--warn-soft); color: #B45309; }
.badge-warn .badge-dot { background: var(--warn); }
.badge-info { background: var(--info-soft); color: #1D4ED8; }
.badge-info .badge-dot { background: var(--info); }
.badge-neutral { background: var(--line-soft); color: var(--muted-2); }
.badge-neutral .badge-dot { background: var(--muted); }

/* ---------- Skeleton loading ---------- */
.skeleton {
  background: linear-gradient(90deg, #EFEEEB 25%, #F7F6F4 37%, #EFEEEB 63%);
  background-size: 400% 100%;
  animation: skeleton-loading 1.4s ease infinite;
  border-radius: 8px;
}
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Toasts ---------- */
#toast-root { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 300px; max-width: 380px; background: var(--ink); color: #fff;
  border-radius: 12px; padding: 13px 16px; display: flex; align-items: center; gap: 10px;
  box-shadow: var(--shadow-xl); animation: toast-in .28s cubic-bezier(.2,.9,.3,1.2);
  font-size: 13px; font-weight: 500;
}
.toast.success { background: #0F7A38; }
.toast.error { background: #B91C1C; }
.toast.hide { animation: toast-out .22s ease forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px) scale(.96); } to { opacity: 1; transform: translateX(0) scale(1); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px) scale(.96); } }

/* ---------- Modals / Drawers ---------- */
.modal-backdrop { background: rgba(11,11,12,0.5); backdrop-filter: blur(3px); animation: fade-in .2s ease; }
.modal-panel { animation: modal-in .25s cubic-bezier(.2,.9,.3,1.1); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

.drawer { animation: drawer-in .3s cubic-bezier(.2,.9,.3,1.05); }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* ---------- Glassmorphism (carrinho PDV) ---------- */
.glass {
  background: rgba(255,255,255,0.72);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.5);
}
.glass-dark {
  background: rgba(11,11,12,0.86);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.08);
}

/* ---------- Product card (PDV/Produtos) ---------- */
.product-card { cursor: pointer; transition: all .18s ease; }
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #DEDDD8; }
.product-card:active { transform: scale(.98); }
.product-card .img-wrap { overflow: hidden; }
.product-card img { transition: transform .4s ease; }
.product-card:hover img { transform: scale(1.06); }

/* ---------- Cart add animation ---------- */
@keyframes pop-add { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }
.pop-add { animation: pop-add .28s ease; }
@keyframes slide-fade-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.cart-item-enter { animation: slide-fade-in .22s ease; }
@keyframes flyToCart { 0% { transform: scale(1); opacity: 1; } 100% { transform: scale(.2) translateY(-40px); opacity: 0; } }

/* ---------- Tabs ---------- */
.tab-btn { padding: 8px 4px; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; transition: all .16s; }
.tab-btn.active { color: var(--ink); border-color: var(--ink); }
.tab-btn:hover { color: var(--ink); }

/* ---------- Tooltip ---------- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px);
  background: var(--ink); color: #fff; font-size: 11px; font-weight: 600;
  padding: 5px 9px; border-radius: 7px; white-space: nowrap;
  opacity: 0; pointer-events: none; transition: all .16s ease; z-index: 60;
}
[data-tooltip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Progress bar (estoque) ---------- */
.stock-bar { height: 5px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.stock-bar-fill { height: 100%; border-radius: 999px; transition: width .5s ease; }

/* ---------- Table ---------- */
.table-row { transition: background .14s ease; }
.table-row:hover { background: var(--canvas); }

/* ---------- Fade/scale entrance for page content ---------- */
.page-enter { animation: page-fade .32s cubic-bezier(.2,.8,.3,1); }
@keyframes page-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.stagger > * { animation: page-fade .4s cubic-bezier(.2,.8,.3,1) both; }
.stagger > *:nth-child(1) { animation-delay: .02s; }
.stagger > *:nth-child(2) { animation-delay: .06s; }
.stagger > *:nth-child(3) { animation-delay: .10s; }
.stagger > *:nth-child(4) { animation-delay: .14s; }
.stagger > *:nth-child(5) { animation-delay: .18s; }
.stagger > *:nth-child(6) { animation-delay: .22s; }
.stagger > *:nth-child(7) { animation-delay: .26s; }
.stagger > *:nth-child(8) { animation-delay: .30s; }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--line); border: none; }
.ring-focus:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.loader-dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; animation: dot-bounce 1s infinite ease-in-out; }
@keyframes dot-bounce { 0%, 80%, 100% { opacity: .25; transform: scale(.7); } 40% { opacity: 1; transform: scale(1); } }

/* ---------- Dropdown ---------- */
.dropdown-menu { animation: dropdown-in .16s cubic-bezier(.2,.9,.3,1.1); transform-origin: top right; }
@keyframes dropdown-in { from { opacity: 0; transform: scale(.95) translateY(-4px); } to { opacity: 1; transform: scale(1) translateY(0); } }

/* ---------- Calendar mini ---------- */
.cal-day { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 11.5px; border-radius: 8px; }
.cal-day.today { background: var(--ink); color: #fff; font-weight: 700; }
.cal-day.has-event::after { content: ''; }

@media (max-width: 768px) {
  .sidebar { position: fixed; z-index: 100; height: 100vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
