/* ==========================================================================
   MIK design system: vanilla CSS components layered on Tailwind utilities.
   One primary hue (violet-indigo, 252), Inter font, 4px spacing scale.
   ========================================================================== */
:root {
  --p-h: 252;
  --primary: hsl(var(--p-h) 83% 58%);
  --primary-600: hsl(var(--p-h) 70% 50%);
  --primary-soft: hsl(var(--p-h) 90% 96%);
  --bg: hsl(240 20% 98%);
  --surface: #ffffff;
  --surface-2: hsl(240 20% 96%);
  --border: hsl(240 12% 90%);
  --text: hsl(240 25% 12%);
  --muted: hsl(240 8% 46%);
  --success: hsl(152 60% 40%);
  --danger: hsl(350 75% 55%);
  --warning: hsl(36 95% 50%);
  --radius: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px hsl(240 30% 20% / .06);
  --shadow: 0 4px 18px -4px hsl(240 30% 20% / .10), 0 2px 6px -2px hsl(240 30% 20% / .06);
  --shadow-lg: 0 24px 48px -12px hsl(var(--p-h) 40% 20% / .22);
  --ring: 0 0 0 4px hsl(var(--p-h) 90% 60% / .25);
  --ease: cubic-bezier(.22, 1, .36, 1);
}
.dark {
  --primary-soft: hsl(var(--p-h) 40% 18%);
  --bg: hsl(240 22% 7%);
  --surface: hsl(240 18% 11%);
  --surface-2: hsl(240 16% 15%);
  --border: hsl(240 12% 20%);
  --text: hsl(240 20% 94%);
  --muted: hsl(240 8% 64%);
  --shadow: 0 4px 24px -6px hsl(0 0% 0% / .5);
  --shadow-lg: 0 24px 48px -12px hsl(0 0% 0% / .6);
}

html { scroll-behavior: smooth; }
body { background: var(--bg); color: var(--text); font-family: "Inter", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
[x-cloak] { display: none !important; }
::selection { background: hsl(var(--p-h) 90% 60% / .25); }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 8px; }
.text-muted { color: var(--muted); }
.bg-surface { background: var(--surface); }
.bg-surface-2 { background: var(--surface-2); }
.border-base { border-color: var(--border); }
.text-primary { color: var(--primary); }
.bg-primary { background: var(--primary); }
.bg-primary-soft { background: var(--primary-soft); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; font-weight: 600; font-size: .9rem;
  padding: .65rem 1.15rem; border-radius: 12px; border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .2s, color .2s, border-color .2s; }
.btn:active { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; pointer-events: none; }
.btn svg { width: 18px; height: 18px; }
.btn-primary { color: #fff; background: linear-gradient(135deg, hsl(var(--p-h) 85% 62%), hsl(calc(var(--p-h) + 25) 80% 55%));
  box-shadow: 0 8px 20px -8px hsl(var(--p-h) 85% 55% / .7); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -8px hsl(var(--p-h) 85% 55% / .8); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.08); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: .4rem .75rem; font-size: .8rem; border-radius: 10px; }
.btn-lg { padding: .9rem 1.6rem; font-size: 1rem; border-radius: 14px; }
.btn-icon { padding: .55rem; border-radius: 12px; }

/* ---------- Cards / glass ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-hover { transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .35s; }
.card-hover:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: hsl(var(--p-h) 70% 70% / .5); }
.glass { background: hsl(0 0% 100% / .65); backdrop-filter: blur(18px) saturate(1.6); -webkit-backdrop-filter: blur(18px) saturate(1.6);
  border: 1px solid hsl(0 0% 100% / .5); }
.dark .glass { background: hsl(240 18% 11% / .7); border-color: hsl(0 0% 100% / .07); }

/* ---------- Forms ---------- */
.label { display: block; font-size: .82rem; font-weight: 600; margin-bottom: .35rem; }
.input, .form-input, input.input, select.input, textarea.input {
  width: 100%; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 12px;
  padding: .7rem .9rem; font-size: .92rem; transition: border-color .2s, box-shadow .2s; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.input::placeholder { color: var(--muted); }
textarea.input { min-height: 120px; resize: vertical; }
.input[type="checkbox"], .input[type="radio"] { width: auto; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 1.05rem; height: 1.05rem; }
.field-error { color: var(--danger); font-size: .78rem; margin-top: .3rem; }
.help-text { color: var(--muted); font-size: .76rem; margin-top: .3rem; }
.input.has-error { border-color: var(--danger); }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; font-weight: 600; padding: .22rem .6rem; border-radius: 999px; }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: hsl(152 60% 40% / .12); color: var(--success); }
.badge-danger { background: hsl(350 75% 55% / .12); color: var(--danger); }
.badge-warning { background: hsl(36 95% 50% / .14); color: hsl(30 90% 40%); }
.dark .badge-warning { color: hsl(40 95% 60%); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.status-pending { background: hsl(36 95% 50% / .14); color: hsl(30 90% 42%); }
.status-confirmed { background: hsl(210 90% 55% / .13); color: hsl(210 80% 45%); }
.status-shipped { background: var(--primary-soft); color: var(--primary); }
.status-delivered, .status-paid, .status-approved, .status-published { background: hsl(152 60% 40% / .12); color: var(--success); }
.status-cancelled, .status-failed, .status-rejected, .status-suspended { background: hsl(350 75% 55% / .12); color: var(--danger); }
.status-draft, .status-unpaid { background: var(--surface-2); color: var(--muted); }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; border-radius: 32px;
  background: radial-gradient(1200px 400px at 10% -10%, hsl(calc(var(--p-h) + 40) 90% 70% / .55), transparent 60%),
              radial-gradient(900px 500px at 110% 10%, hsl(calc(var(--p-h) - 40) 90% 65% / .5), transparent 60%),
              linear-gradient(135deg, hsl(var(--p-h) 70% 22%), hsl(calc(var(--p-h) + 20) 65% 30%)); color: #fff; }
.blob { position: absolute; border-radius: 999px; filter: blur(50px); opacity: .55; animation: float 12s ease-in-out infinite; }
@keyframes float { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(30px,-20px) scale(1.08); } }
.text-gradient { background: linear-gradient(90deg, hsl(calc(var(--p-h) + 40) 100% 80%), hsl(calc(var(--p-h) - 40) 100% 80%));
  -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Product card ---------- */
.product-card .img-wrap { position: relative; aspect-ratio: 1/1; overflow: hidden; border-radius: 18px; background: var(--surface-2); }
.product-card .img-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease); }
.product-card:hover .img-wrap img { transform: scale(1.07); }
.product-card .actions { position: absolute; right: .6rem; top: .6rem; display: flex; flex-direction: column; gap: .4rem;
  opacity: 0; transform: translateX(8px); transition: all .3s var(--ease); }
.product-card:hover .actions, .product-card:focus-within .actions { opacity: 1; transform: none; }
@media (hover: none) { .product-card .actions { opacity: 1; transform: none; } }
.icon-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--surface);
  color: var(--text); box-shadow: var(--shadow); border: 1px solid var(--border); transition: all .2s var(--ease); }
.icon-btn:hover { color: var(--primary); transform: scale(1.08); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.active { color: var(--danger); }
.icon-btn.active svg { fill: currentColor; }

/* ---------- Skeleton ---------- */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 12px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: block; }
.htmx-request .htmx-hide-on-request { display: none; }

/* ---------- Animations ---------- */
.fade-up { animation: fadeUp .6s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
.stagger > * { animation: fadeUp .55s var(--ease) both; }
.stagger > *:nth-child(2) { animation-delay: .05s } .stagger > *:nth-child(3) { animation-delay: .1s }
.stagger > *:nth-child(4) { animation-delay: .15s } .stagger > *:nth-child(5) { animation-delay: .2s }
.stagger > *:nth-child(6) { animation-delay: .25s } .stagger > *:nth-child(7) { animation-delay: .3s }
.stagger > *:nth-child(8) { animation-delay: .35s } .stagger > *:nth-child(n+9) { animation-delay: .4s }
.bump { animation: bump .45s var(--ease); }
@keyframes bump { 30% { transform: scale(1.35); } 60% { transform: scale(.9); } }
.empty-illustration { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- Toasts ---------- */
.toast { min-width: 280px; max-width: 380px; display: flex; gap: .75rem; align-items: flex-start; padding: .85rem 1rem;
  border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); background: var(--surface); }
.toast .bar { width: 4px; align-self: stretch; border-radius: 4px; }

/* ---------- Tables ---------- */
.table { width: 100%; font-size: .88rem; border-collapse: separate; border-spacing: 0; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 600; padding: .75rem 1rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]:hover { color: var(--primary); }
.table td { padding: .85rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .15s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }

/* ---------- Sidebar (dashboards) ---------- */
.side-link { display: flex; align-items: center; gap: .75rem; padding: .62rem .85rem; border-radius: 12px; font-size: .9rem;
  font-weight: 500; color: var(--muted); transition: all .2s; }
.side-link svg { width: 18px; height: 18px; }
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.stat-card { position: relative; overflow: hidden; }
.stat-card::after { content: ""; position: absolute; right: -30px; top: -30px; width: 120px; height: 120px; border-radius: 999px;
  background: radial-gradient(circle, hsl(var(--p-h) 90% 65% / .18), transparent 70%); }

/* ---------- Gallery zoom ---------- */
.zoom-wrap { overflow: hidden; cursor: zoom-in; border-radius: 24px; background: var(--surface-2); aspect-ratio: 1/1; }
.zoom-wrap img { width: 100%; height: 100%; object-fit: cover; transition: transform .25s ease-out; transform-origin: center; }
.zoom-wrap:hover img { transform: scale(1.9); }

/* ---------- Prose (rich text) ---------- */
.prose-mik { line-height: 1.75; color: var(--text); }
.prose-mik p { margin: .75rem 0; } .prose-mik h2 { font-size: 1.3rem; font-weight: 700; margin: 1.25rem 0 .5rem; }
.prose-mik h3 { font-size: 1.1rem; font-weight: 700; margin: 1rem 0 .4rem; }
.prose-mik ul { list-style: disc; padding-left: 1.4rem; } .prose-mik ol { list-style: decimal; padding-left: 1.4rem; }
.prose-mik a { color: var(--primary); text-decoration: underline; }
.prose-mik blockquote { border-left: 3px solid var(--primary); padding-left: 1rem; color: var(--muted); }

/* ---------- Chat ---------- */
.bubble { max-width: 75%; padding: .6rem .9rem; border-radius: 18px; font-size: .9rem; line-height: 1.45; word-wrap: break-word; animation: fadeUp .3s var(--ease); }
.bubble.mine { background: linear-gradient(135deg, hsl(var(--p-h) 85% 62%), hsl(calc(var(--p-h) + 25) 80% 55%)); color: #fff; border-bottom-right-radius: 6px; margin-left: auto; }
.bubble.theirs { background: var(--surface-2); border-bottom-left-radius: 6px; }
.typing span { width: 6px; height: 6px; border-radius: 99px; background: var(--muted); display: inline-block; animation: typing 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .15s } .typing span:nth-child(3) { animation-delay: .3s }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .4 } 30% { transform: translateY(-4px); opacity: 1 } }

/* scrollbar */
.scroll-thin::-webkit-scrollbar { width: 6px; height: 6px; }
.scroll-thin::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
.no-scrollbar::-webkit-scrollbar { display: none; } .no-scrollbar { scrollbar-width: none; }

/* range slider */
input[type=range] { accent-color: var(--primary); width: 100%; }
.star { color: hsl(42 95% 52%); }
.star-empty { color: var(--border); }
