/* ──────────────────────────────────────────────────────────────
   Nexta Designportal — implementerar Nexta Admin Design System
   (tokens och komponentmönster från designsystem-handoffen)
   ────────────────────────────────────────────────────────────── */

@font-face { font-family: "Inter"; src: url("/static/fonts/inter-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/static/fonts/inter-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/static/fonts/inter-600.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/static/fonts/inter-700.woff2") format("woff2"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Inter"; src: url("/static/fonts/inter-800.woff2") format("woff2"); font-weight: 800; font-style: normal; font-display: swap; }

:root {
  --background: 0 0% 100%;
  --background-darker: 0 0% 95%;
  --foreground: 222.2 47.4% 11.2%;
  --muted: 219 1% 96%;
  --muted-foreground: 215.4 16.3% 46.9%;
  --border: 214.3 31.8% 91.4%;
  --input: 214.3 31.8% 91.4%;
  --card: 0 0% 100%;
  --primary: 210 64% 48%;
  --primary-foreground: 0 0% 100%;
  --secondary: 210 64% 48%;
  --accent: 220 14% 96%;
  --destructive: 0 100% 50%;
  --error: 342 100% 60%;
  --success: 160 60% 35%;
  --warning: 36 91% 53%;
  --ring: 215 20.2% 65.1%;
  --radius: 0.5rem;
  --sidebar-background: 0 0% 100%;
  --sidebar-border: 214.3 31.8% 91.4%;
  --chart-1: 173 58% 39%;
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

.dark {
  --background: 215 28% 17%;
  --background-darker: 221 39% 11%;
  --foreground: 213 31% 91%;
  --muted: 223 47% 11%;
  --muted-foreground: 215.4 16.3% 56.9%;
  --accent: 216 34% 17%;
  --border: 219 17% 27%;
  --input: 219 17% 27%;
  --card: 215 28% 17%;
  --destructive: 0 63% 31%;
  --ring: 216 34% 17%;
  --success: 160 60% 45%;
  --sidebar-background: 221 39% 11%;
  --sidebar-border: 219 17% 27%;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100vh; }
body {
  font-family: var(--font-sans);
  font-size: 16px;
  color: hsl(var(--foreground));
  background: hsl(var(--background-darker));
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, textarea, select { font: inherit; }

/* ── App-skal: sidopanel + appbar + innehåll ── */
.app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.sidebar {
  position: relative;
  background: hsl(var(--sidebar-background));
  border-right: 1px solid hsl(var(--sidebar-border));
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-header {
  height: 65px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid hsl(var(--sidebar-border));
  flex: none;
}
.sidebar-header img { height: 22px; }
.sidebar-nav { padding: 8px; overflow-y: auto; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  height: 36px; padding: 0 8px;
  border-radius: 6px; font-size: 14px; font-weight: 500;
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: background 0.15s;
}
.nav-item:hover { background: hsl(var(--accent)); }
.nav-item.active { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.nav-item.active:hover { background: hsl(var(--primary)); }
.nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; stroke-width: 1.5; }
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid hsl(var(--sidebar-border));
  display: flex; align-items: center; gap: 10px;
  flex: none;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: hsl(var(--primary)); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 13px; flex: 0 0 32px;
}
.user-info { font-size: 13px; line-height: 1.3; overflow: hidden; }
.user-info .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { color: hsl(var(--muted-foreground)); font-size: 11px; }

.main { display: flex; flex-direction: column; min-width: 0; }
.appbar {
  height: 65px;
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  background: hsl(var(--background-darker));
  border-bottom: 1px solid hsl(var(--border));
  position: sticky; top: 0; z-index: 10;
}
.appbar .crumb { font-size: 13px; color: hsl(var(--muted-foreground)); }
.appbar .spacer { flex: 1; }
.content { padding: 20px 24px 40px; flex: 1; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 20px; gap: 16px; }
.page-head h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; }
.page-head .breadcrumb { font-size: 12px; color: hsl(var(--muted-foreground)); margin-bottom: 6px; }
.page-actions { display: flex; gap: 8px; }

.logo-dark { display: none; }
.dark .logo-light { display: none; }
.dark .logo-dark { display: block; }

/* Grafiskt element: vattenmärke i sidopanelens nedre högra hörn (30 %) */
.sidebar-mark {
  position: absolute;
  bottom: 64px;
  right: -36px;
  width: 170px;
  height: 170px;
  opacity: 0.3;
  color: hsl(var(--border));
  pointer-events: none;
}

.icon-btn {
  width: 40px; height: 40px;
  border: 1px solid hsl(var(--border));
  background: transparent;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  color: hsl(var(--foreground));
}
.icon-btn:hover { background: hsl(var(--accent)); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn .moon { display: none; }
.dark .icon-btn .sun { display: none; }
.dark .icon-btn .moon { display: block; }

/* ── Knappar ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px;
  border-radius: 6px; font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s; white-space: nowrap;
  background: transparent;
}
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn.primary:hover { background: hsl(210 64% 44%); }
.btn.outline { background: hsl(var(--background)); color: hsl(var(--foreground)); border-color: hsl(var(--border)); }
.btn.outline:hover { background: hsl(var(--accent)); }
.btn.ghost { color: hsl(var(--foreground)); }
.btn.ghost:hover { background: hsl(var(--accent)); }
.btn.danger { color: hsl(var(--error)); }
.btn.danger:hover { background: hsl(var(--error) / 0.08); }
.btn.sm { height: 32px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn.sm svg { width: 14px; height: 14px; }
.btn.icon { padding: 0; }
.btn.sm.icon { width: 32px; }
.btn.sm.icon svg { width: 16px; height: 16px; }
.row-actions { gap: 2px; }
.row-actions .btn svg { opacity: 0.75; }
.row-actions .btn:hover svg { opacity: 1; }
/* Power-knappen markerar att designen är avstängd */
.row-actions .btn.is-off { color: hsl(36 91% 40%); }
.row-actions .btn.is-off svg { opacity: 1; }
.btn:disabled { opacity: 0.55; cursor: wait; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px hsl(var(--ring) / 0.5); }

/* ── KPI-widgets ── */
.dash-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.widget {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.widget-top { display: flex; justify-content: space-between; align-items: flex-start; }
.widget-title { font-size: 14px; font-weight: 600; }
.widget-desc { font-size: 11px; color: hsl(var(--muted-foreground)); margin-top: 2px; }
.widget-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: hsl(var(--accent));
  display: flex; align-items: center; justify-content: center;
}
.widget-icon svg { width: 16px; height: 16px; stroke-width: 1.6; }
.widget-value { font-size: 28px; font-weight: 700; line-height: 1.1; margin-top: 16px; font-variant-numeric: tabular-nums; }
.widget-sub { font-size: 11px; color: hsl(var(--muted-foreground)); margin-top: 4px; }

/* ── Tabellkort ── */
.table-card {
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  overflow: hidden;
}
.table-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid hsl(var(--border));
}
.table-head h2 { font-size: 18px; font-weight: 700; }
.table-scroll {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--border)) transparent;
}
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 4px; }
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase; letter-spacing: 0.04em;
  padding: 10px 22px;
  background: hsl(var(--background));
  border-bottom: 1px solid hsl(var(--border));
  white-space: nowrap;
}
.table td { padding: 12px 22px; font-size: 13px; border-bottom: 1px solid hsl(var(--border)); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: hsl(var(--accent)); }
.design-name { font-weight: 600; font-size: 14px; }
.design-url { display: block; font-family: var(--font-mono); font-size: 11px; color: hsl(var(--secondary)); margin-top: 2px; }
.design-url:hover { text-decoration: underline; text-underline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.empty-cell { text-align: center; padding: 48px 22px; color: hsl(var(--muted-foreground)); font-size: 14px; }

/* ── Badge ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge.success { background: hsl(160 60% 35% / 0.12); color: hsl(160 60% 28%); border: 1px solid hsl(160 60% 35% / 0.3); }
.badge.warning { background: hsl(36 91% 53% / 0.16); color: hsl(36 91% 36%); border: 1px solid hsl(36 91% 53% / 0.4); }
.badge.info    { background: hsl(210 64% 48% / 0.12); color: hsl(210 64% 35%); border: 1px solid hsl(210 64% 48% / 0.3); }
.badge.neutral { background: hsl(var(--accent)); color: hsl(var(--foreground)); border: 1px solid hsl(var(--border)); }

.footnote { font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 16px; }

/* ── Dialog och formulär ── */
dialog {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(440px, calc(100vw - 32px));
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  /* återställ webbläsarens centrering som .* { margin:0 }-resetten annars slår ut */
  margin: auto;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
.dialog-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid hsl(var(--border));
}
.dialog-head h2 { font-size: 16px; font-weight: 700; }
.dialog-head button { background: none; border: 0; display: flex; padding: 4px; border-radius: 6px; color: hsl(var(--muted-foreground)); }
.dialog-head button:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.dialog-head button svg { width: 16px; height: 16px; }
.dialog-body { padding: 20px 22px; display: grid; gap: 14px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field input[type="text"] {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid hsl(var(--input));
  border-radius: 6px; font-size: 14px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
}
.field input::placeholder { color: hsl(var(--muted-foreground)); }
.field input:focus { outline: none; box-shadow: 0 0 0 2px hsl(var(--ring) / 0.5); }
.field .help { font-size: 11px; color: hsl(var(--muted-foreground)); margin-top: 5px; }
.slug-row {
  display: flex; align-items: center;
  border: 1px solid hsl(var(--input));
  border-radius: 6px; height: 40px; overflow: hidden;
}
.slug-row:focus-within { box-shadow: 0 0 0 2px hsl(var(--ring) / 0.5); }
.slug-row span { padding-left: 12px; font-family: var(--font-mono); font-size: 12px; color: hsl(var(--muted-foreground)); white-space: nowrap; }
.slug-row input { flex: 1; min-width: 0; border: 0; outline: 0; height: 100%; padding: 0 12px 0 2px; font-family: var(--font-mono); font-size: 12px; background: transparent; color: hsl(var(--foreground)); }
.file-drop {
  display: block;
  border: 1.5px dashed hsl(var(--border));
  border-radius: 6px;
  padding: 18px;
  text-align: center;
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.file-drop:hover, .file-drop.drag { border-color: hsl(var(--secondary)); color: hsl(var(--secondary)); }
.file-drop input { display: none; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check input { accent-color: hsl(var(--primary)); }
.dialog-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 16px 22px;
  border-top: 1px solid hsl(var(--border));
}
.form-error { color: hsl(var(--error)); font-size: 13px; }
.form-warning { color: hsl(36 91% 36%); font-size: 12px; }
.form-success {
  background: hsl(160 60% 35% / 0.08);
  border: 1px solid hsl(160 60% 35% / 0.3);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
}
.form-success code { font-family: var(--font-mono); font-size: 12px; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 13px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
}

/* ── Responsivt (laptop-first, enkel mobilanpassning) ── */
@media (max-width: 1023px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .appbar .crumb { display: inline-flex; align-items: center; gap: 10px; color: hsl(var(--foreground)); font-weight: 600; }
  .dash-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
