/* Klarsignal – felles designsystem */

:root {
  --pink: #ff36a2;
  --pink-600: #e0168a;
  --pink-100: #ffe1f1;
  --pink-50: #fff3f9;
  --ink: #1b1620;
  --ink-2: #4b4552;
  --muted: #8b8492;
  --line: #ebe6ee;
  --line-2: #f3eff5;
  --bg: #f7f4f8;
  --card: #ffffff;
  --ok: #17865c;
  --ok-bg: #e3f6ee;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --info: #1f5a8a;
  --info-bg: #e2effa;
  --orange: #8f4a00;
  --orange-bg: #ffe9d4;
  --danger: #c93636;
  --danger-bg: #fdecec;

  --r-sm: 10px;
  --r: 14px;
  --r-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(27, 22, 32, .06);
  --shadow: 0 1px 2px rgba(27, 22, 32, .05), 0 6px 20px rgba(27, 22, 32, .06);
  --shadow-lg: 0 20px 60px rgba(27, 22, 32, .22);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --header-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; }
a { color: inherit; }
img, svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--pink) 45%, transparent); outline-offset: 2px; }
body.no-scroll { overflow: hidden; }

/* ── Header ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 1240px; height: 100%; margin: 0 auto;
  padding: 0 16px; display: flex; align-items: center; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; margin-right: auto; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px; flex-shrink: 0;
  background: var(--pink); color: #fff; display: grid; place-items: center;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--pink) 35%, transparent);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name { font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.brand-tag { font-size: 12px; color: var(--muted); font-weight: 600; }
.nav-links { display: flex; align-items: center; gap: 2px; }
.nav-link {
  padding: 8px 12px; border-radius: 999px; text-decoration: none;
  font-size: 14px; font-weight: 600; color: var(--ink-2);
}
.nav-link:hover { background: var(--line-2); color: var(--ink); }
.nav-link.active { background: var(--ink); color: #fff; }
.icon-btn {
  position: relative; width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center; color: var(--ink);
}
.icon-btn:hover { background: var(--line-2); }
.icon-btn svg { width: 22px; height: 22px; }
.cart-btn {
  display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px 0 12px;
  border-radius: 999px; background: var(--ink); color: #fff; font-weight: 700; font-size: 14px;
}
.cart-btn:hover { background: #2d2633; }
.cart-btn svg { width: 20px; height: 20px; }
.count-badge {
  min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px;
  background: var(--pink); color: #fff; font-size: 12px; font-weight: 800;
  display: inline-grid; place-items: center;
}
.count-badge.bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.35); } }
.menu-btn { display: none; }

@media (max-width: 760px) {
  .nav-links { display: none; }
  .menu-btn { display: grid; }
  .brand-tag { display: none; }
  .cart-label { display: none; }
  .cart-btn { padding: 0 12px; }
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.page { max-width: 1240px; margin: 0 auto; padding: 24px 16px 48px; }
.page-narrow { max-width: 820px; }
.page-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.page-sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.page-head .spacer { flex: 1; }
@media (max-width: 760px) {
  .page { padding: 16px 12px 40px; }
  .page-title { font-size: 23px; }
}

.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 800; }
.eyebrow {
  font-size: 11.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.divider { height: 1px; background: var(--line); margin: 14px 0; border: 0; }

/* ── Knappar ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  font-weight: 700; font-size: 15px; text-decoration: none; white-space: nowrap;
  transition: background .15s, transform .1s, box-shadow .15s;
  border: 1.5px solid transparent;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary { background: var(--pink); color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--pink) 30%, transparent); }
.btn-primary:hover:not(:disabled) { background: var(--pink-600); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover:not(:disabled) { background: #2d2633; }
.btn-soft { background: var(--line-2); color: var(--ink); }
.btn-soft:hover:not(:disabled) { background: var(--line); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-outline:hover:not(:disabled) { border-color: #d8d1dc; background: var(--line-2); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: var(--line-2); color: var(--ink); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #fadcdc; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13.5px; border-radius: 10px; }
.btn-lg { min-height: 54px; font-size: 16px; border-radius: 14px; padding: 0 22px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; min-height: 40px; padding: 0; }

/* ── Skjemaelement ──────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.hint { font-size: 12.5px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 13px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff;
  font-size: 16px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.textarea { min-height: 90px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--pink);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--pink) 14%, transparent);
}
.input.error { border-color: var(--danger); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5l5 5 5-5' stroke='%234b4552' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center;
}
.input-suffix { position: relative; }
.input-suffix .input { padding-right: 44px; }
.input-suffix span {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  font-size: 14px; color: var(--muted); font-weight: 600; pointer-events: none;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 520px) { .grid-3 { grid-template-columns: 1fr 1fr; } }

.check { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; font-size: 14.5px; line-height: 1.4; }
.check input { position: absolute; opacity: 0; pointer-events: none; }
.check-box {
  width: 24px; height: 24px; flex-shrink: 0; border-radius: 7px; border: 2px solid #d4ccd8;
  display: grid; place-items: center; background: #fff; transition: all .15s;
}
.check-box svg { width: 14px; height: 14px; color: #fff; opacity: 0; }
.check input:checked + .check-box { background: var(--pink); border-color: var(--pink); }
.check input:checked + .check-box svg { opacity: 1; }
.check input:focus-visible + .check-box { outline: 3px solid color-mix(in srgb, var(--pink) 45%, transparent); outline-offset: 2px; }

/* Brytar (på/av) */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; font-weight: 600; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  width: 44px; height: 26px; border-radius: 999px; background: #d9d2dd; position: relative; transition: background .15s; flex-shrink: 0;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .18s;
}
.switch input:checked + .switch-track { background: var(--ok); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 3px solid color-mix(in srgb, var(--pink) 45%, transparent); outline-offset: 2px; }

/* ── Chips / segment ────────────────────────────────────────────────────── */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; min-height: 40px; padding: 0 16px; border-radius: 999px;
  background: #fff; border: 1.5px solid var(--line); font-weight: 700; font-size: 14px; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.chip:hover { border-color: #d8d1dc; color: var(--ink); }
.chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip .count { font-size: 12px; opacity: .65; }

.seg { display: flex; background: var(--line-2); padding: 4px; border-radius: 12px; gap: 4px; }
.seg button {
  flex: 1; min-height: 38px; border-radius: 9px; font-weight: 700; font-size: 14px; color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.seg button.active { background: #fff; color: var(--ink); box-shadow: var(--shadow-sm); }

/* ── Status-merke ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; white-space: nowrap; background: var(--line-2); color: var(--ink-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge-pending { background: var(--warn-bg); color: var(--warn); }
.badge-payment_received { background: var(--info-bg); color: var(--info); }
.badge-in_production { background: var(--orange-bg); color: var(--orange); }
.badge-shipped, .badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-cancelled { background: var(--line-2); color: var(--muted); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-pink { background: var(--pink-50); color: var(--pink-600); }

/* ── Ark (modal / skuff / bunnark på mobil) ─────────────────────────────── */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 300; background: rgba(27, 22, 32, .45);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: auto; }
.sheet {
  position: fixed; z-index: 301; background: #fff; display: flex; flex-direction: column;
  left: 50%; top: 50%; width: min(560px, calc(100vw - 32px)); max-height: min(88dvh, 860px);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  transform: translate(-50%, -46%) scale(.98); opacity: 0; pointer-events: none;
  transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .18s;
}
.sheet.open { transform: translate(-50%, -50%); opacity: 1; pointer-events: auto; }
.sheet-wide { width: min(760px, calc(100vw - 32px)); }
.sheet-right {
  left: auto; right: 0; top: 0; bottom: 0; width: min(440px, 100vw); max-height: none;
  border-radius: var(--r-lg) 0 0 var(--r-lg); transform: translateX(100%); opacity: 1;
}
.sheet-right.open { transform: translateX(0); }
.sheet-head {
  display: flex; align-items: center; gap: 10px; padding: 16px 16px 12px 20px;
  border-bottom: 1px solid var(--line-2); flex-shrink: 0;
}
.sheet-title { font-size: 19px; font-weight: 800; flex: 1; letter-spacing: -.01em; }
.sheet-body { padding: 18px 20px; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.sheet-foot { padding: 14px 20px calc(14px + var(--safe-b)); border-top: 1px solid var(--line-2); flex-shrink: 0; background: #fff; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.sheet-handle { display: none; }

@media (max-width: 760px) {
  .sheet, .sheet-right, .sheet-wide {
    left: 0; right: 0; top: auto; bottom: 0; width: 100%; max-height: 94dvh;
    border-radius: 22px 22px 0 0; transform: translateY(100%); opacity: 1;
  }
  .sheet.open, .sheet-right.open { transform: translateY(0); }
  .sheet-full { height: 94dvh; }
  .sheet-handle { display: block; width: 40px; height: 5px; border-radius: 99px; background: #ddd5e0; margin: 8px auto 0; flex-shrink: 0; }
  .sheet-head { padding: 8px 12px 10px 18px; }
  .sheet-body { padding: 16px 16px; }
  .sheet-foot { padding: 12px 16px calc(12px + var(--safe-b)); border-radius: 0; }
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast-wrap {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translateX(-50%);
  z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: max-content; max-width: calc(100vw - 24px); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px 12px 16px; border-radius: 14px;
  background: var(--ink); color: #fff; font-size: 14.5px; font-weight: 600; box-shadow: var(--shadow-lg);
  pointer-events: auto; animation: toast-in .22s cubic-bezier(.2, .8, .2, 1);
}
.toast.err { background: var(--danger); }
.toast.leaving { animation: toast-out .18s ease forwards; }
.toast-icon { width: 22px; height: 22px; border-radius: 50%; background: var(--ok); display: grid; place-items: center; flex-shrink: 0; }
.toast.err .toast-icon { background: rgba(255,255,255,.2); }
.toast-icon svg { width: 13px; height: 13px; }
.toast button { color: var(--pink-100); font-weight: 800; padding: 4px 6px; border-radius: 8px; white-space: nowrap; }
.toast button:hover { background: rgba(255,255,255,.1); }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); } }

/* ── Diverse ────────────────────────────────────────────────────────────── */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-icon {
  width: 64px; height: 64px; border-radius: 20px; background: var(--pink-50); color: var(--pink);
  display: grid; place-items: center; margin: 0 auto 14px;
}
.empty-icon svg { width: 30px; height: 30px; }
.empty h3 { color: var(--ink); font-size: 17px; margin-bottom: 4px; }
.empty .btn { margin-top: 16px; }

.alert { padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.45; }
.alert-err { background: var(--danger-bg); color: var(--danger); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-pink { background: var(--pink-50); color: #9c0b5c; border: 1px solid var(--pink-100); }

.skeleton { background: linear-gradient(90deg, var(--line-2), #fbf9fc, var(--line-2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 12px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.swatch-dot { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); flex-shrink: 0; }
.dots { display: flex; gap: 3px; }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Meny-ark (mobil) */
.menu-list { display: flex; flex-direction: column; }
.menu-user { padding: 4px 4px 14px; border-bottom: 1px solid var(--line-2); margin-bottom: 6px; }
.menu-user strong { display: block; font-size: 16px; }
.menu-item {
  display: flex; align-items: center; gap: 14px; min-height: 54px; padding: 0 8px;
  border-radius: 12px; text-decoration: none; font-weight: 700; font-size: 16px; width: 100%; text-align: left;
}
.menu-item:hover, .menu-item.active { background: var(--line-2); }
.menu-item svg { width: 22px; height: 22px; color: var(--muted); }
.menu-item.active svg { color: var(--pink); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger svg { color: var(--danger); }

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