/*
 * Portal extensions on top of /ekort-onboarding.css.
 *
 * Loaded by the server-rendered admin pages (/handlari, /eigari, etc.) so the
 * shell — fonts, colors, shadows, buttons, side menu — matches the front page.
 * This file ONLY adds widgets the marketing pages don't need: dashboard cards,
 * KPI tiles, tables, forms. Every value here is built on the tokens declared
 * in :root by ekort-onboarding.css. Do not redefine those tokens here.
 */

:root {
  --portal-line: rgba(15, 17, 21, 0.08);
  --portal-warn: #C7783A;
  --portal-good: #6BAF9A;
  --portal-bg-soft: rgba(196, 151, 70, 0.06);
  --portal-bg-row: rgba(15, 17, 21, 0.03);
  --portal-field-bg: #ffffff;
  --portal-field-border: rgba(15, 17, 21, 0.16);
  --portal-field-shadow: inset 0 1px 2px rgba(15, 17, 21, 0.04);
}

[data-theme="dark"] {
  --portal-line: rgba(255, 255, 255, 0.12);
  --portal-bg-soft: rgba(196, 151, 70, 0.10);
  --portal-bg-row: rgba(255, 255, 255, 0.04);
  --portal-field-bg: rgba(255, 255, 255, 0.06);
  --portal-field-border: rgba(255, 255, 255, 0.14);
  --portal-field-shadow: none;
}

/* The portal pages reuse `.page` / `.topbar` / `.brand` from the onboarding
   stylesheet. We just give them a slightly wider canvas for tables and grids. */
.page.portal {
  display: block;
  padding-block: clamp(18px, 3vw, 34px) clamp(56px, 7vw, 96px);
}
.page.portal.portal--handlari {
  position: relative;
  z-index: 1;
  background: transparent;
  isolation: isolate;
}
.page.portal.portal--handlari::before {
  content: none;
}

/* Soft carousel-style ambience for /handlari — blurred slide art from the app,
   kept behind content so dashboards and tables stay the focus. */
.page.portal.portal--handlari > .portal-ambience {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.portal-ambience__orb {
  position: absolute;
  width: min(58vw, 620px);
  aspect-ratio: 1.72;
  border-radius: 32%;
  background-size: cover;
  background-position: center;
  filter: blur(46px) saturate(1.12);
  opacity: 0.34;
  transform: rotate(-7deg);
}
.portal-ambience__orb--a {
  background-image: url("/images/SlideA.png");
  top: -6%;
  right: -4%;
}
.portal-ambience__orb--b {
  background-image: url("/images/SlideB.png");
  bottom: 0;
  left: -8%;
  width: min(50vw, 520px);
  transform: rotate(11deg);
  opacity: 0.28;
}
.portal-ambience__orb--c {
  background-image: url("/images/SlideC.png");
  top: 36%;
  left: 34%;
  width: min(38vw, 420px);
  transform: rotate(-4deg);
  opacity: 0.22;
}
.portal-ambience__veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(
      ellipse 72% 58% at 50% 40%,
      rgba(253, 251, 247, 0.78) 0%,
      rgba(253, 251, 247, 0.52) 52%,
      rgba(253, 251, 247, 0.18) 100%
    );
}
[data-theme="dark"] .portal-ambience__orb {
  opacity: 0.22;
  filter: blur(52px) saturate(1.05) brightness(0.9);
}
[data-theme="dark"] .portal-ambience__orb--b {
  opacity: 0.18;
}
[data-theme="dark"] .portal-ambience__orb--c {
  opacity: 0.14;
}
[data-theme="dark"] .portal-ambience__veil {
  background:
    radial-gradient(
      ellipse 74% 60% at 50% 38%,
      rgba(8, 9, 12, 0.82) 0%,
      rgba(8, 9, 12, 0.58) 52%,
      rgba(8, 9, 12, 0.22) 100%
    );
}
@media (prefers-reduced-motion: reduce) {
  .portal-ambience__orb {
    filter: blur(40px) saturate(1.04);
  }
}
@media (max-width: 860px) {
  .portal-ambience__orb--c {
    left: 10%;
    top: 48%;
    opacity: 0.16;
  }
}

.page.portal .topbar {
  margin-bottom: clamp(20px, 4vw, 36px);
}

/* Buttons inside portal panels match the canonical `.auth` pill but support a
   secondary, ghost variant and tighter sizing for inline tools. */
.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 18px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--surface);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 14px 24px var(--shadow);
  transition: transform 120ms ease, opacity 120ms ease;
}
.btn:hover { opacity: 0.92; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.btn.ghost {
  background: var(--surface-elevated);
  color: var(--ink);
  border-color: var(--portal-field-border);
  box-shadow: none;
}
.btn.small { min-height: 36px; padding: 0 14px; font-size: 13px; }

/* Inputs / selects share the soft surface look. */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.field input,
.field select,
.field textarea,
.field input[type="file"] {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
  background: var(--portal-field-bg);
  border: 1px solid var(--portal-field-border);
  box-shadow: var(--portal-field-shadow);
  border-radius: 16px;
  padding: 12px 16px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.field input:focus-visible,
.field select:focus-visible,
.field textarea:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(196, 151, 70, 0.18);
}
.field input:disabled,
.field input.readonly {
  color: var(--ink-muted);
  background: var(--portal-bg-row);
  cursor: not-allowed;
}
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent);
  width: 18px;
  height: 18px;
  margin: 0;
}

/* Card layout used everywhere in the portal. */
.card {
  border-radius: 30px;
  border: 1px solid var(--surface-border);
  background: var(--surface-elevated);
  box-shadow: 0 16px 28px var(--shadow);
  padding: clamp(18px, 3vw, 28px);
}
.card + .card { margin-top: 18px; }
.card h2 {
  margin: 0 0 14px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
}
.card .lead {
  margin: 0 0 18px;
  color: var(--ink-muted);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
}
.card .lead a { color: var(--ink); font-weight: 800; }

/* Hero band on the dashboard top. */
.dash-hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
  align-items: stretch;
}
.dash-hero h1 {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: clamp(38px, 6vw, 64px);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: 0;
}
.dash-hero p {
  margin: 12px 0 0;
  color: var(--ink-muted);
  font-size: 16px;
  line-height: 1.45;
  font-weight: 600;
}
@media (max-width: 860px) { .dash-hero { grid-template-columns: 1fr; } }

/* KPI tiles row. */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0;
}
.kpi {
  border-radius: 22px;
  border: 1px solid var(--surface-border);
  background: var(--surface-elevated);
  box-shadow: 0 14px 24px var(--shadow);
  padding: 18px;
}
.kpi span {
  display: block;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.kpi strong {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0;
}
@media (max-width: 860px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Two-column section. */
.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: stretch;
}
.cols > .card {
  display: flex;
  flex-direction: column;
  height: 100%;
}
/* `.card + .card { margin-top }` is for stacked cards; in a two-column row the
   second column is also `.card + .card` and would get an unwanted top nudge.
   Spacing here comes from `gap` only. */
.cols > .card + .card {
  margin-top: 0;
}
@media (max-width: 860px) { .cols { grid-template-columns: 1fr; } }

/* Tables inside cards. */
table.t {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.t th, table.t td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--portal-line);
  vertical-align: middle;
}
table.t th.num,
table.t td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
table.t th {
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
table.t tr.row.warn td:first-child { opacity: 0.4; }
table.t tr.settings-row > td { background: var(--portal-bg-row); }

/* Útgjøld: merchant table — checkbox + link columns so headers align with data. */
table.t-payout-merchants {
  table-layout: fixed;
}
table.t-payout-merchants thead th:first-child,
table.t-payout-merchants tbody td:first-child {
  width: 44px;
  text-align: center;
  padding-inline: 8px;
  vertical-align: middle;
}
table.t-payout-merchants thead th:nth-child(2),
table.t-payout-merchants tbody td:nth-child(2) {
  width: 28%;
  word-break: break-word;
}
table.t-payout-merchants th.t-col-link,
table.t-payout-merchants td.t-col-link {
  text-align: right;
  white-space: nowrap;
  width: 7rem;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid .actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 10px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* Member-invite row: P-tal field full width, then Leiklutur + "Legg persón"
 * on one line (default `.actions { grid-column: 1 / -1 }` forced the
 * button onto its own row). */
.form-grid--member-invite .actions {
  grid-column: auto;
  align-self: end;
}
.form-grid--member-invite .field select {
  min-height: 44px; /* match .btn */
}

/* Notices. */
.notice {
  border-radius: 18px;
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 14px;
  font-weight: 700;
  background: rgba(107, 175, 154, 0.16);
  color: var(--ink);
  border: 1px solid rgba(107, 175, 154, 0.32);
}
.notice.error {
  background: rgba(199, 120, 58, 0.14);
  border-color: rgba(199, 120, 58, 0.34);
}

/* Misc helpers. */
.muted { color: var(--ink-muted); font-weight: 600; }
.code { color: var(--ink); font-family: "SF Mono", ui-monospace, monospace; font-size: 13px; font-weight: 700; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--surface-border);
  background: var(--surface-elevated);
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 14px 24px var(--shadow);
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(199, 120, 58, 0.18);
  color: var(--portal-warn);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}
.link:hover { text-decoration: underline; }

/* Logo upload preview row. */
.logo-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0 14px;
}
.logo-preview {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  background: var(--surface-elevated);
  border: 1px solid var(--surface-border);
  box-shadow: 0 14px 24px var(--shadow);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.logo-preview img { width: 100%; height: 100%; object-fit: cover; }
.logo-preview .empty { font-size: 11px; color: var(--ink-muted); font-weight: 800; }

/* File input: hide native "Choose file" chrome; use pill button + filename. */
.file-picker-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.file-picker-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  cursor: pointer;
}
.file-picker-btn .file-picker-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  font-size: 2rem;
  cursor: pointer;
}
.file-picker-status {
  font-size: 14px;
  word-break: break-word;
}

/* Toolbar (filter + button row inside a card). */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  /* Bottom-align so a `.field` column (label + select) lines up with the
   * adjacent pill button — `center` left the button floating mid-air next
   * to the "Vel handil" caption. */
  align-items: flex-end;
  justify-content: space-between;
}

.toolbar .field select {
  min-height: 44px; /* same as .btn — keeps the row visually even */
}

/* Portal-styled modal (replaces window.confirm for destructive / batch
 * actions). Matches the card aesthetic: rounded surface, soft shadow,
 * tinted backdrop. Hidden by default; the [hidden] attribute toggles it. */
.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 17, 21, 0.55);
  backdrop-filter: blur(6px);
  z-index: 9999;
  padding: 24px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: min(440px, 100%);
  background: var(--surface-elevated);
  color: var(--ink);
  border: 1px solid var(--surface-border);
  border-radius: 26px;
  box-shadow: 0 30px 60px var(--shadow);
  padding: clamp(20px, 3vw, 28px);
}
.modal-title {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
}
.modal-body {
  margin: 0 0 20px;
  color: var(--ink-muted);
  font-size: 15px;
  font-weight: 600;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.modal-actions .btn.danger {
  background: var(--portal-warn);
  color: var(--surface);
  border-color: transparent;
}
.modal-actions .btn.danger:hover { opacity: 0.92; }

.status-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  vertical-align: middle;
  margin-left: 10px;
  text-transform: uppercase;
}
.status-pill.status-active {
  background: rgba(74, 145, 96, 0.15);
  color: #2e6b41;
}
.status-pill.status-suspended {
  background: rgba(199, 120, 58, 0.18);
  color: #8a4a18;
}
.status-pill.status-archived {
  background: rgba(120, 120, 120, 0.18);
  color: #555;
}
[data-theme="dark"] .status-pill.status-active {
  color: #8fd4a4;
}
[data-theme="dark"] .status-pill.status-suspended {
  color: #e8b07a;
}
[data-theme="dark"] .status-pill.status-archived {
  color: #b8b8b8;
}

/* Legal document pages (/treytir, /privatlivspolitikkur). */
html:has(main.terms),
html:has(main.privacy) {
  background: var(--surface);
  color: var(--ink);
}

main.terms,
main.privacy {
  color: var(--ink);
}

main.terms h1,
main.terms h2,
main.terms h3,
main.privacy h1,
main.privacy h2,
main.privacy h3 {
  color: var(--ink);
}

main.terms code,
main.privacy code {
  background: var(--portal-bg-row);
  color: var(--ink);
}

main.terms .toc,
main.privacy .toc,
main.terms .controller-box,
main.privacy .controller-box,
main.terms .callout {
  background: var(--portal-bg-soft);
  border-color: var(--surface-border);
}

main.terms .part-heading {
  background: var(--ink);
  color: var(--surface);
}

main.terms .part-heading h2 {
  color: var(--surface);
}

main.terms .part-heading p {
  color: var(--ink-muted);
}

main.terms .updated,
main.privacy .updated {
  color: var(--ink-muted);
}

main.terms a,
main.privacy a {
  color: var(--accent);
}

main.terms hr,
main.privacy hr {
  border-top-color: var(--portal-line);
}
.btn.danger {
  background: var(--portal-warn, #b94a3a);
  color: var(--surface, #fff);
  border-color: transparent;
}
.btn.danger:hover { opacity: 0.92; }
.btn.warn {
  background: rgba(199, 120, 58, 0.18);
  color: #8a4a18;
  border-color: rgba(199, 120, 58, 0.4);
}

/* Handlari product catalog (/handlari/products) */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.product-card {
  background: var(--surface-elevated);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.product-card--estig {
  border-color: rgba(199, 160, 58, 0.35);
  box-shadow: inset 0 0 0 1px rgba(199, 160, 58, 0.08);
}
.product-card-media {
  aspect-ratio: 1;
  background: var(--portal-bg-soft, #f4f5f7);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.product-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.product-card-empty {
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 700;
}
.product-card-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.product-card-body h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
}
.product-card-price {
  margin: 0;
  font-weight: 800;
  font-size: 16px;
}
.product-card-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
}
.source-pill {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(15, 17, 21, 0.06);
  color: var(--ink-muted);
}
.product-card--estig .source-pill {
  background: rgba(199, 160, 58, 0.16);
  color: #8a6a12;
}
.order-source-cell {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
/* Per-source revenue split row under the headline KPIs. Mirrors the
   pill colours used on each order row so the eye links the chip back
   to the table immediately. */
.kpi-breakdown {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}
.kpi-breakdown__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-muted, rgba(15, 17, 21, 0.04));
  border-radius: 12px;
  border: 1px solid var(--surface-border, rgba(15, 17, 21, 0.08));
  font-size: 13px;
}
.kpi-breakdown__value {
  font-weight: 800;
  color: var(--ink);
  margin-left: auto;
}
.kpi-breakdown__meta {
  flex-basis: 100%;
  font-size: 11px;
}
@media (min-width: 640px) {
  .kpi-breakdown__meta {
    flex-basis: auto;
  }
}

/* Filter chip row above the "Seinastu transaktiónir" table. */
.txn-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 14px;
}
.txn-filter__chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-muted);
  background: rgba(15, 17, 21, 0.04);
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.txn-filter__chip:hover {
  background: rgba(15, 17, 21, 0.07);
  color: var(--ink);
}
.txn-filter__chip--active {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
}
.txn-filter__chip--active:hover {
  background: var(--ink);
  color: var(--surface);
}

.order-source-pill--etorg {
  background: rgba(15, 17, 21, 0.06);
  color: var(--ink-muted);
}
.order-source-pill--counter {
  /* Counter (in-store) eKort purchase — calm trust-blue tint distinct
     from the online-order tone. Same family as the customer app's
     accentTrust. */
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}
.order-source-pill--woocommerce {
  background: rgba(124, 58, 237, 0.12);
  color: #5b21b6;
}
.order-source-pill--estig {
  background: rgba(199, 160, 58, 0.16);
  color: #8a6a12;
}
.order-new-pill {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(220, 38, 38, 0.12);
  color: #b91c1c;
}
.order-row--new td {
  background: rgba(220, 38, 38, 0.04);
}
.order-unread-banner {
  margin: 0 0 12px;
  background: rgba(220, 38, 38, 0.08);
  border-color: rgba(220, 38, 38, 0.18);
  color: #991b1b;
}
.product-manage summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  margin-top: 4px;
}
.product-manage .form-grid {
  gap: 8px;
}
.btn.warn:hover { opacity: 0.92; }
