/* UdstillerGuide v3 — Minimal Theme (WA-first)
   Layout handled by WA utilities (wa-stack, wa-cluster, wa-grid, wa-split, wa-flank).
   This file: brand tokens, visual styling, WA slot overrides, data tables. */

/* WA utility classes (wa-stack, wa-cluster, wa-grid) set display:flex/grid which
   overrides the [hidden] attribute. Ensure [hidden] always wins so JS can
   show/hide elements with element.hidden = true/false reliably. */
[hidden] {
  display: none !important;
}

/* == Brand tokens == */
:root {
  --brand-primary-base: #314F59;
  --brand-primary-hover: #428B98;
  --brand-primary-active: #2D444C;
  --brand-highlight: #7FBEC6;
  --brand-accent: #E07A5F;
  --brand-accent-hover: #c96a50;
  --brand-warning: #D4A017;
  --brand-success: #00883C;
  --brand-danger: #DC2626;
  --brand-info: #2563EB;
  --bg: #f8f9fa; --surface: #fff; --surface-hover: #f1f5f9;
  --border: #e2e8f0; --text: #1d2327; --text-muted: #64748b;
  --sidebar-bg: #fff; --sidebar-active-bg: #e6f0f3; --sidebar-active-text: #314F59;
  --sidebar-hover-bg: #f1f5f9; --topbar-bg: #314F59; --topbar-text: #fff;
  --duotone-primary: var(--brand-primary-base);
  --duotone-secondary: var(--brand-accent);
  font-family: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --wa-color-brand-95: #dce8ec; --wa-color-brand-90: #b0c8d1;
  --wa-color-brand-80: #7fa8b6; --wa-color-brand-70: #528898;
  --wa-color-brand-60: #3a6878; --wa-color-brand-50: #314F59;
  --wa-color-brand-40: #2a4049; --wa-color-brand-30: #1e2f36;
  --wa-color-brand-20: #141f24; --wa-color-brand-10: #0a1114;
  --wa-color-brand-05: #050a0d;
  --wa-color-success-95: #f2f6f3; --wa-color-success-90: #e0e8e1;
  --wa-color-success-80: #bacdbd; --wa-color-success-70: #8bb693;
  --wa-color-success-60: #55a066; --wa-color-success-50: #00883C;
  --wa-color-success-40: #006b2c; --wa-color-success-30: #004f1d;
  --wa-color-success-20: #00350e; --wa-color-success-10: #001d01;
  --wa-color-success-05: #001200;
  --wa-color-warning-95: #f9f5ec; --wa-color-warning-90: #f0ece4;
  --wa-color-warning-80: #e2dacb; --wa-color-warning-70: #d8c9aa;
  --wa-color-warning-60: #d2b67d; --wa-color-warning-50: #D4A017;
  --wa-color-warning-40: #a27b18; --wa-color-warning-30: #775600;
  --wa-color-warning-20: #4c3500; --wa-color-warning-10: #281500;
  --wa-color-warning-05: #190600;
  --wa-color-danger-95: #fff2ef; --wa-color-danger-90: #fcdfdb;
  --wa-color-danger-80: #f2bbb3; --wa-color-danger-70: #f09085;
  --wa-color-danger-60: #ea6156; --wa-color-danger-50: #DC2626;
  --wa-color-danger-40: #b4000c; --wa-color-danger-30: #870003;
  --wa-color-danger-20: #5d0000; --wa-color-danger-10: #380000;
  --wa-color-danger-05: #290000;
  --wa-color-info-95: #f0f5ff; --wa-color-info-90: #dae6fc;
  --wa-color-info-80: #b1c7f2; --wa-color-info-70: #81a8f4;
  --wa-color-info-60: #5287f3; --wa-color-info-50: #2563EB;
  --wa-color-info-40: #0846cc; --wa-color-info-30: #0025ae;
  --wa-color-info-20: #001b72; --wa-color-info-10: #000b44;
  --wa-color-info-05: #000037;
}
.wa-dark {
  --bg: #182028; --surface: #243440; --surface-hover: #2a3e4c;
  --border: #354A56; --text: #d0dce4; --text-muted: #a8b5c4;
  --sidebar-bg: #1a2430; --sidebar-active-bg: #1A2E38;
  --sidebar-active-text: #7FBEC6; --sidebar-hover-bg: #16202a;
  --topbar-bg: #1a2430; --topbar-text: #d0dce4;
  --duotone-primary: var(--brand-highlight);
  --duotone-secondary: var(--brand-accent);
}

body { background: var(--bg); color: var(--text); }

/* == Duotone icon colors == */
wa-icon[family="sharp-duotone"] {
  --primary-color: var(--duotone-primary);
  --secondary-color: var(--duotone-secondary);
  --secondary-opacity: 1;
}
wa-button:not([appearance="outlined"]):not([appearance="plain"]) wa-icon[family="sharp-duotone"],
header[slot="header"] wa-icon[family="sharp-duotone"] {
  --primary-color: var(--topbar-text);
  --secondary-color: var(--brand-accent);
  --secondary-opacity: 1;
}
.stat-icon wa-icon[family="sharp-duotone"],
.activity-icon wa-icon[family="sharp-duotone"],
.team-mini wa-icon[family="sharp-duotone"],
.attention-item wa-icon[family="sharp-duotone"],
.perm-matrix wa-icon[family="sharp-duotone"] {
  --primary-color: currentColor;
  --secondary-color: currentColor;
  --secondary-opacity: 0.5;
}
.topbar-action wa-icon[family="sharp-duotone"] {
  --primary-color: var(--topbar-text);
  --secondary-color: var(--topbar-text);
  --secondary-opacity: 0.5;
}
.topbar-action:hover wa-icon[family="sharp-duotone"] {
  --primary-color: var(--brand-primary-base);
  --secondary-color: var(--brand-accent);
  --secondary-opacity: 1;
}
.nav-link.active wa-icon[family="sharp-duotone"] {
  --primary-color: var(--sidebar-active-text);
}

/* == wa-page header slot == */
wa-page > [slot="header"] {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; background: var(--topbar-bg); color: var(--topbar-text);
  padding: 0 var(--wa-space-m); min-height: 52px;
}
.header-user { font-size: 0.85rem; opacity: 0.8; }
[slot="header"] wa-button[appearance="plain"] span { color: var(--topbar-text) !important; }
[slot="header"] wa-button[appearance="plain"]:hover { color: var(--brand-primary-base); }
[slot="header"] wa-button[appearance="plain"]:hover wa-icon { --primary-color: var(--brand-primary-base); }
[slot="header"] wa-button[appearance="plain"]:hover span { color: var(--brand-primary-base) !important; }
.brand, .topbar-brand { text-decoration: none; color: inherit; font-size: 1.1rem; display: flex; align-items: center; gap: var(--wa-space-xs); }
.brand-icon { display: inline-flex; align-items: center; }
.brand-icon-svg { height: 1.1em; width: auto; }
.brand-icon-svg path { fill: var(--duotone-primary); }
.brand-icon-svg path[opacity] { fill: var(--duotone-secondary); opacity: 1; }
[slot="header"] .brand-icon-svg path { fill: var(--topbar-text); }
[slot="header"] .brand-icon-svg path[opacity] { fill: var(--brand-accent); opacity: 1; }
.brand-text { font-size: 1.1rem; }
.brand-light { font-weight: 300; }
.brand-bold { font-weight: 700; color: var(--brand-accent); }
.instance-badge {
  font-size: 0.7rem; background: rgba(255,255,255,0.15); color: rgba(255,255,255,0.9);
  padding: 0.15em 0.6em; border-radius: 99px; font-weight: 500;
}
.header-service-link { color: inherit; text-decoration: none; }

/* == wa-page navigation slot == */
[slot="navigation"] { background: var(--sidebar-bg); }
.nav-header { padding: var(--wa-space-s); }
.nav-section {
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--text-muted); padding: var(--wa-space-m) var(--wa-space-m) 0.4rem;
}
.nav-link {
  display: flex; align-items: center; gap: var(--wa-space-xs); padding: var(--wa-space-xs) var(--wa-space-m);
  color: var(--text); text-decoration: none; font-size: 0.9rem;
  border-left: 3px solid transparent; transition: all 0.15s;
}
.nav-link:hover { background: var(--sidebar-hover-bg); }
.nav-link.active {
  background: var(--sidebar-active-bg); color: var(--sidebar-active-text);
  border-left-color: var(--brand-primary-base); font-weight: 500;
}

/* == wa-page subheader slot == */
[slot="subheader"] { padding: var(--wa-space-xs) var(--wa-space-l); background: var(--bg); border-bottom: 1px solid var(--border); }

/* == Page header (layout via wa-split in templates) == */
.page-header { margin-bottom: var(--wa-space-l); }
.page-header h1 { font-size: 1.5rem; font-weight: 700; }
.page-header-sub { color: var(--text-muted); font-size: 0.85rem; }

/* == Data table (no WA equivalent) == */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.data-table th {
  text-align: left; padding: var(--wa-space-xs) var(--wa-space-s); border-bottom: 2px solid var(--border);
  font-weight: 600; font-size: 0.8rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.data-table td { padding: var(--wa-space-xs) var(--wa-space-s); border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:hover td { background: var(--surface-hover); }
.data-table .actions { text-align: right; white-space: nowrap; }

/* == Filter chips (category/source filter tabs above tables) == */
.filter-chips { display: flex; flex-wrap: wrap; gap: var(--wa-space-xs); margin-bottom: var(--wa-space-m); }
.filter-chip {
  background: transparent; border: 1px solid var(--border); border-radius: 999px;
  padding: var(--wa-space-2xs) var(--wa-space-s); font-size: 0.8rem; color: var(--text-muted);
  cursor: pointer; transition: all 0.15s;
}
.filter-chip:hover { border-color: var(--brand-primary-hover); }
.filter-chip.active {
  background: var(--brand-primary-base); color: #fff; border-color: var(--brand-primary-base);
}

/* == Sharing badges (required/optional/pending source labels) == */
.sharing-badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: 0.72rem; font-weight: 600; padding: 0.15rem 0.5rem; border-radius: 4px;
}
.sharing-badge.required { background: rgba(220,38,38,0.08); color: var(--brand-danger); }
.sharing-badge.optional { background: rgba(37,99,235,0.08); color: var(--brand-info); }
.sharing-badge.pending { background: rgba(212,160,23,0.1); color: var(--brand-warning); }
.sharing-badge.accepted { background: rgba(0,136,60,0.08); color: var(--brand-success); }

/* == Locked/pending rows for shared content == */
.locked-row td { background: rgba(220,38,38,0.03) !important; }
.locked-row:hover td { background: rgba(220,38,38,0.06) !important; }
.lock-icon { color: var(--brand-danger); font-size: 0.75rem; margin-right: 0.3rem; }
.pending-row td { background: rgba(212,160,23,0.04) !important; }
.pending-row:hover td { background: rgba(212,160,23,0.07) !important; }

/* == Empty states == */
.empty-state { text-align: center; color: var(--text-muted); padding: var(--wa-space-xl); font-size: 0.85rem; }

/* == Stat cards (layout via wa-grid + wa-cluster in templates) == */
.stat-grid { margin-bottom: var(--wa-space-l); }
.stat-icon {
  width: 2.5rem; height: 2.5rem; border-radius: 8px; display: flex;
  align-items: center; justify-content: center; background: rgba(49,79,89,0.1);
  color: var(--brand-primary-base); font-size: 1.1rem; flex-shrink: 0;
}
.stat-icon.warning { background: rgba(212,160,23,0.1); color: var(--brand-warning); }
.stat-icon.success { background: rgba(0,136,60,0.1); color: var(--brand-success); }
.stat-icon.danger { background: rgba(220,38,38,0.1); color: var(--brand-danger); }
.stat-card-link { cursor: pointer; transition: transform 0.1s; }
.stat-card-link:hover { transform: translateY(-2px); }
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 0.75rem; color: var(--text-muted); }

/* == Dashboard grid (layout via wa-grid in templates) == */
.dashboard-grid { margin-bottom: var(--wa-space-l); }

/* == Activity feed == */
.activity-item { padding: var(--wa-space-xs) 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 2rem; height: 2rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.85rem; flex-shrink: 0; }
.activity-icon.login { background: rgba(49,79,89,0.1); color: var(--brand-primary-base); }
.activity-icon.invite { background: rgba(224,122,95,0.1); color: var(--brand-accent); }
.activity-icon.mail { background: rgba(0,136,60,0.1); color: var(--brand-success); }
.activity-icon.mail-fail { background: rgba(220,38,38,0.1); color: var(--brand-danger); }
.activity-icon.user { background: rgba(49,79,89,0.1); color: var(--brand-primary-base); }
.activity-icon.team { background: rgba(212,160,23,0.1); color: var(--brand-warning); }
.activity-icon.company { background: rgba(49,79,89,0.1); color: var(--brand-primary-base); }
.activity-icon.access-code { background: rgba(212,160,23,0.1); color: var(--brand-warning); }
.activity-icon.config { background: rgba(37,99,235,0.1); color: var(--brand-info); }
.activity-content { flex: 1; }
.activity-time { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }

/* == Attention items == */
.attention-item { padding: var(--wa-space-xs) 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.attention-item:last-child { border-bottom: none; }

/* == Team mini cards == */
.team-mini { padding: var(--wa-space-xs) 0; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s; }
.team-mini:hover { background: var(--surface-hover); }
.team-mini:last-child { border-bottom: none; }
.team-mini-name { font-weight: 600; font-size: 0.9rem; }
.team-mini-meta { font-size: 0.78rem; color: var(--text-muted); }

/* == Universe cards == */
.universe-card { padding: var(--wa-space-s) 0; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.1s; }
.universe-card:hover { background: var(--surface-hover); }
.universe-card:last-child { border-bottom: none; }
.universe-icon { width: 2.5rem; height: 2.5rem; border-radius: 8px; display: flex; align-items: center; justify-content: center; background: rgba(49,79,89,0.1); color: var(--brand-primary-base); font-size: 1.1rem; }
.universe-name { font-weight: 600; font-size: 0.95rem; }
.universe-meta { font-size: 0.78rem; color: var(--text-muted); }

/* == Function cards == */
.function-card { padding: var(--wa-space-s) 0; border-bottom: 1px solid var(--border); }
.function-card:last-child { border-bottom: none; }
.function-icon { width: 2.5rem; height: 2.5rem; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }

/* == Info rows/grid == */
.info-row { padding: var(--wa-space-xs) 0; border-bottom: 1px solid var(--border); font-size: 0.875rem; }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); min-width: 140px; font-size: 0.8rem; font-weight: 600; }
.info-value { font-weight: 500; flex: 1; }
.info-grid { display: grid; grid-template-columns: auto 1fr; gap: var(--wa-space-xs) var(--wa-space-m); font-size: 0.875rem; padding: var(--wa-space-s); }
.info-grid dt { color: var(--text-muted); font-weight: 600; }
.info-grid dd { margin: 0; }

/* == Module chips + type dots == */
.module-chip { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.72rem; padding: 0.15em 0.5em; border-radius: 4px; background: rgba(49,79,89,0.08); color: var(--brand-primary-base); font-weight: 500; }
.type-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 0.4rem; }
.type-dot.stor, .type-dot.storpartner { background: var(--brand-primary-base); }
.type-dot.mini, .type-dot.minipartner { background: var(--brand-warning); }

/* == Wizard steps == */
.wizard-steps { display: flex; margin-bottom: var(--wa-space-l); border-bottom: 2px solid var(--border); }
.wizard-step { padding: var(--wa-space-s) var(--wa-space-l); font-size: 0.9rem; font-weight: 500; color: var(--text-muted); border-bottom: 3px solid transparent; margin-bottom: -2px; display: flex; align-items: center; gap: var(--wa-space-xs); }
.wizard-step.active { color: var(--brand-primary-base); border-bottom-color: var(--brand-primary-base); font-weight: 600; }
.wizard-step.done { color: var(--brand-success); border-bottom-color: var(--brand-success); }
.step-num { width: 1.5rem; height: 1.5rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; background: var(--border); color: var(--text-muted); }
.wizard-step.active .step-num { background: var(--brand-primary-base); color: white; }
.wizard-step.done .step-num { background: var(--brand-success); color: white; }
.wizard-content { max-width: 640px; }
.wizard-step-header { display: flex; align-items: center; gap: var(--wa-space-xs); margin-bottom: var(--wa-space-m); }
.wizard-step-number { width: 1.5rem; height: 1.5rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; background: var(--brand-primary-base); color: white; }
.wizard-step-label { font-size: 1rem; font-weight: 600; }
.wizard-step-context { font-size: 0.82rem; color: var(--text-muted); margin-left: auto; }
.wizard-summary { margin-bottom: var(--wa-space-l); }
.summary-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.summary-table th { text-align: left; padding: var(--wa-space-xs) var(--wa-space-s); font-weight: 600; color: var(--text-muted); min-width: 140px; border-bottom: 1px solid var(--border); }
.summary-table td { padding: var(--wa-space-xs) var(--wa-space-s); border-bottom: 1px solid var(--border); }

/* == Confirm == */
.confirm-label { font-weight: 600; min-width: 120px; color: var(--text-muted); }

/* == Perm matrix == */
.perm-matrix { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.perm-matrix th { text-align: center; padding: var(--wa-space-xs); border-bottom: 2px solid var(--border); font-weight: 600; font-size: 0.75rem; color: var(--text-muted); }
.perm-matrix th:first-child { text-align: left; }
.perm-matrix td { padding: var(--wa-space-xs); border-bottom: 1px solid var(--border); text-align: center; }
.perm-matrix td:first-child { text-align: left; font-weight: 500; }
.perm-matrix tr:hover td { background: var(--surface-hover); }

/* == Auth pages == */
.centered-content { display: flex; align-items: center; justify-content: center; min-height: 500px; padding: var(--wa-space-xl); }
.auth-card h1 { text-align: center; }
.auth-footer { text-align: center; font-size: 0.85rem; color: var(--text-muted); }
.auth-footer a { color: var(--brand-primary-base); }

/* == View-as banner == */
.view-as-banner { background: rgba(224,122,95,0.12); border-bottom: 2px solid var(--brand-accent); padding: 0.4rem var(--wa-space-m); display: flex; align-items: center; justify-content: space-between; font-size: 0.82rem; }

/* == Card header == */
.card-header { font-weight: 600; }
.card-header-link { margin-left: auto; font-size: var(--wa-font-size-xs); font-weight: 400; color: var(--brand-primary-base); text-decoration: none; }
.card-header-link:hover { text-decoration: underline; }

/* == Misc == */
.main-pad { padding: var(--wa-space-l); }


/* == Portal card grid == */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--wa-space-m); }

/* == Image preview == */
.img-preview { aspect-ratio: 4/3; background: var(--wa-color-neutral-100); display: flex; align-items: center; justify-content: center; border-radius: var(--wa-border-radius-medium); overflow: hidden; margin-bottom: var(--wa-space-s); }
.img-preview img { max-width: 100%; max-height: 100%; object-fit: cover; }

/* == Image list view == */
.card-grid.list-view { grid-template-columns: 1fr; }
.card-grid.list-view wa-card { display: grid; grid-template-columns: 80px 1fr auto; align-items: center; gap: var(--wa-space-m); }
.card-grid.list-view .img-preview { aspect-ratio: 1; width: 80px; margin-bottom: 0; }

/* == Universe tree in portal sidebar == */
.universe-tree-wrap {
  margin: 0 var(--wa-space-xs);
  padding: var(--wa-space-2xs) var(--wa-space-2xs);
  background: var(--surface-hover);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.universe-tree-wrap wa-tree {
  font-size: 0.82rem;
  --indent-size: var(--wa-space-s);
  --indent-guide-width: 1px;
  --indent-guide-color: var(--border);
}
.universe-tree-wrap wa-tree-item.universe-node::part(item) { font-weight: 600; font-size: 0.85rem; }
.universe-tree-wrap wa-tree-item.site-node::part(item) { font-size: 0.82rem; color: var(--text-muted); }
.universe-tree-wrap wa-tree-item.version-node::part(item) { font-size: 0.8rem; border-radius: 4px; padding-top: 0.15em; padding-bottom: 0.15em; }
.version-status { display: inline-flex; align-items: center; gap: 0.3rem; margin-left: auto; font-size: 0.7rem; font-weight: 500; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.status-dot.live { background: var(--brand-success); }
.status-dot.dev { background: var(--brand-warning); }
.status-dot.archive { background: var(--text-muted); }
.status-label.live { color: var(--brand-success); }
.status-label.dev { color: var(--brand-warning); }
.status-label.archive { color: var(--text-muted); }
.nav-link.disabled { opacity: 0.4; pointer-events: none; cursor: default; }
.nav-external { margin-left: auto; font-size: 0.7rem; opacity: 0.4; }

/* == Sammenlign (version compare) termer-diff == */
.term-diff h4 { margin: 0; }
.diff-output {
  background: var(--wa-color-neutral-50);
  border: 1px solid var(--wa-color-neutral-200);
  border-radius: var(--wa-border-radius-s);
  padding: var(--wa-space-s);
  font-family: var(--wa-font-family-mono);
  font-size: var(--wa-font-size-small);
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}

/* == Responsive == */
@media (max-width: 768px) {
  wa-dialog::part(panel) { width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; border-radius: 0; }
}
