/* ==========================================================================
   20-components.css
   Reusable UI components (no preprocessing)
   Depends on: 00-tokens.css
   ========================================================================== */

/* ==========================================================================
   1) Utilities / layout helpers (small, optional)
   ========================================================================== */
.row { display: flex; align-items: center; }
.wrap { flex-wrap: wrap; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }

/* ==========================================================================
   2) Buttons
   Single source of truth for .btn variants
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);

  padding: 0.55rem 0.85rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;

  font-family: var(--font-family-sans);
  font-weight: 600;
  font-size: var(--font-size-sm);
  line-height: 1;

  cursor: pointer;
  user-select: none;
  text-decoration: none;

  background: var(--color-primary);
  color: var(--color-primary-text);
  box-shadow: var(--shadow-sm);

  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease, filter 120ms ease;
}

.btn:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
  filter: brightness(0.98);
}

.btn:disabled,
.btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Secondary */
.btn-secondary {
  background: var(--color-surface-1);
  color: var(--color-text-primary);
  border-color: var(--color-border-subtle);
}

.btn-secondary:hover {
  background: var(--color-surface-2);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--color-primary);
  border-color: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--color-surface-2);
}

/* Icon inside buttons */
.btn i {
  opacity: 0.9;
}

/* ==========================================================================
   3) Inputs (optional class if you want consistent input styling)
   ========================================================================== */
.input {
  width: 100%;
  max-width: 20rem;
}

/* ==========================================================================
   4) Surfaces / Cards
   ========================================================================== */
.card {
  background: var(--color-surface-1);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}

.card--dense {
  padding: var(--space-3);
}

/* ==========================================================================
   5) Tables + DataTables normalization
   (keep light-touch: style wrappers, not global table semantics)
   ========================================================================== */

/* Wrapper for tables inside cards */
.table-card {
  background: var(--color-surface-1);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden; /* clips header + hover nicely */
}

.table-card__header {
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface-2);
  border-bottom: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.table-card__title {
  font-weight: 700;
  font-size: var(--font-size-md);
  color: var(--color-text-primary);
}

/* ensure table doesn’t create extra spacing */
.table-card table { margin: 0; border: none; }

/* Reduce “double borders” */
.table-card th,
.table-card td {
  border-left: none;
  border-right: none;
}

/* DataTables form controls */
.dataTables_wrapper input,
.dataTables_wrapper select {
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-subtle);
  padding: 0.4rem 0.6rem;
  background: var(--color-surface-1);
  color: var(--color-text-primary);
}

/* DataTables table basics */
table.dataTable {
  width: 100%;
  border-collapse: collapse;
}

table.dataTable tbody tr:first-child td {
  border-top: 1px solid var(--color-border-subtle);
}

table.dataTable th {
  background: var(--color-surface-2);
  font-weight: 700;
  color: var(--color-text-primary);
}

/* DataTables column filters (rendered as a second THEAD row) */
.table--dense.dataTable thead tr.filter-row th {
  background: var(--color-surface-1);
  border-bottom: 1px solid var(--color-border-subtle);
}

.table--dense.dataTable thead tr.filter-row th input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;

  height: 28px;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);

  font-size: var(--font-size-sm);
  background: var(--color-surface-1);
  color: var(--color-text-primary);
}

.table--dense.dataTable thead tr.filter-row th input::placeholder {
  color: var(--color-text-muted);
}

/* Sticky header + sticky filter row
   Note: works best when the table is inside a normal page scroll.
   With scrollX enabled, DataTables uses a separate header table; these rules still apply.
*/
.table--dense.dataTable thead tr:first-child th {
  position: sticky;
  top: 0;
  z-index: 4;
}

/* Filter row sticks just below the first header row.
   Adjust --dt-head-row-h if your header row height differs.
*/
:root {
  --dt-head-row-h: 2.6rem;
}

.table--dense.dataTable thead tr.filter-row th {
  position: sticky;
  top: var(--dt-head-row-h);
  z-index: 3;
}

/* DataTables buttons */
.dt-button {
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-primary-text);
  border: 1px solid transparent;
  padding: 0.45rem 0.7rem;
}


/* Dense modifier for DataTables tables */
.table--dense.dataTable td,
.table--dense.dataTable th {
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-sm);
}

.table--dense.dataTable tfoot input,
.table--dense.dataTable tfoot select {
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  font-size: var(--font-size-sm);
  background: var(--color-surface-1);
  color: var(--color-text-primary);
}


/* ==========================================================================
   6) Styleguide shell + Tabs
   ========================================================================== */
.sg {
  padding: var(--space-6);
  max-width: 68.75rem; /* 1100px in rem-ish */
}

.sg-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.sg-header h1 {
  margin: 0;
}

.sg-content {
  margin-top: var(--space-5);
}

/* Tabs */
.sg-tabs {
  display: flex;
  gap: var(--space-2);
  border-bottom: 1px solid var(--color-border-subtle);
  padding-bottom: var(--space-2);
}

.sg-tab {
  appearance: none;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;

  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-secondary);

  transition: background-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.sg-tab:hover {
  background: var(--color-surface-2);
}

.sg-tab.active {
  background: var(--color-surface-1);
  border-color: var(--color-border-subtle);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   7) Notifications / MessageBox (remoteCall.js + layout.hbs)
   Keeps legacy classes, but makes them consistent with tokens.
   ========================================================================== */

/* Icon pill (remoteCall.js HTML: <span class="symbol icon-...">...</span>) */
.symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-size: 0.9em;
  border-radius: 999px;
  padding: 0.1em 0.6em;
  font-weight: 800;

  color: var(--color-primary-text);
  background: var(--color-text-muted);
  margin-right: 0.5rem;

  flex: 0 0 auto;
}

/* Icon variants */
.icon-info  { background: var(--color-info); }
.icon-error { background: var(--color-danger); }
.icon-tick  { background: var(--color-success); }
.icon-excl  { background: var(--color-warning); color: #111; }

/* Icon glyphs */
.icon-info:before  { content: 'i'; }
.icon-error:before { content: 'x'; }
.icon-tick:before  { content: '\002713'; }
.icon-excl:before  { content: '!'; }

/* Base notify look (common styling for both boxes) */
.notify {
  border-radius: var(--radius-lg);
  font-family: var(--font-family-sans);
  font-size: var(--font-size-sm);

  width: auto;     /* prevent legacy 80vw */
  margin: 0;
  padding: 0.65rem 0.75rem;

  cursor: default;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border-subtle);

  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* Variants (match tokens) */
.notify-yellow { background: var(--color-warning-bg); border-color: var(--color-warning-border); color: var(--color-text-primary); }
.notify-red    { background: var(--color-danger-bg);  border-color: var(--color-danger-border);  color: var(--color-text-primary); }
.notify-green  { background: var(--color-success-bg); border-color: var(--color-success-border); color: var(--color-text-primary); }
.notify-blue   { background: var(--color-info-bg);    border-color: var(--color-info-border);    color: var(--color-text-primary); }

/* Toast placement (ONLY when JS adds .toast) */
#messageBox.toast,
#errorBox.toast {
  position: fixed;
  right: var(--space-5);
  top: var(--space-4);
  z-index: var(--z-toast);

  width: min(26.25rem, calc(100vw - (2 * var(--space-5))));
  height: auto;
  max-height: 12.5rem; /* 200px */
  overflow: hidden;

  /* Important: do not override border/background here, variants handle it */
}

#errorBox.toast { top: calc(var(--space-4) + 3.5rem); } /* stack under first */

#messageBox.toast,
#errorBox.toast {
  white-space: normal;
  word-break: break-word;
}

#messageBox.toast *,
#errorBox.toast * {
  box-sizing: border-box;
  max-height: 12.5rem;
}

/* ==========================================================================
   8) Status badge (uses semantic token colors)
   ========================================================================== */
.status-badge {
  display: inline-flex;
  align-items: center;

  padding: 0.15rem 0.6rem;
  border-radius: 999px;

  font-size: var(--font-size-xs);
  font-weight: 700;
  line-height: 1.4;

  white-space: nowrap;

  background-color: var(--color-surface-2);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-subtle);
}

.status-badge--neutral {
  background-color: var(--color-surface-2);
  color: var(--color-text-primary);
  border-color: var(--color-border-subtle);
}

.status-badge--active {
  background-color: var(--color-info-bg);
  border-color: var(--color-info-border);
  color: var(--color-text-primary);
}

.status-badge--success {
  background-color: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: var(--color-text-primary);
}

.status-badge--warning {
  background-color: var(--color-warning-bg);
  border-color: var(--color-warning-border);
  color: var(--color-text-primary);
}

.status-badge--danger {
  background-color: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  color: var(--color-text-primary);
}

/* Dense tables: keep badge from stretching rows */
td .status-badge { vertical-align: middle; }

.status-badge.is-compact {
  padding: 0.1rem 0.5rem;
  font-size: 0.72rem;
}

/* ==========================================================================
   9) Process bar
   ========================================================================== */
.process-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);

  background: var(--color-surface-1);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);

  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
}

.process-step {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);

  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text-muted);

  white-space: nowrap;
}

.process-step::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--color-border-strong);
}

/* separator line between steps */
.process-separator {
  flex: 1;
  height: 1px;
  background: var(--color-border-subtle);
}

/* states */
.process-step--done {
  color: var(--color-text-primary);
}

.process-step--done::before {
  background: var(--color-success);
}

.process-step--active {
  color: var(--color-text-primary);
}

.process-step--active::before {
  background: var(--color-primary);
}

/* ==========================================================================
   9b) Process stepper (simple, clear – replaces “fish” pills)
   Markup suggestion:
   <nav class="process-stepper" aria-label="Process">
     <ol class="process-steps">
       <li><button class="process-stepbtn is-done">…</button></li>
       <li><button class="process-stepbtn is-current" aria-current="step">…</button></li>
       <li><button class="process-stepbtn is-todo" disabled>…</button></li>
     </ol>
   </nav>
   ========================================================================== */

.process-stepbtn.is-active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-primary-text);
  box-shadow: var(--shadow-sm);
}

.process-stepper {
  width: 100%;
}

.process-steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);

  list-style: none;
  padding: 0;
  margin: 0;
}

.process-stepbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);

  padding: 0.55rem 0.85rem;
  min-height: 2.6rem;

  border-radius: 999px;
  border: 1px solid var(--color-border-subtle);

  background: var(--color-surface-1);
  color: var(--color-text-primary);

  font-family: var(--font-family-sans);
  font-weight: 800;
  font-size: var(--font-size-sm);
  line-height: 1;

  cursor: pointer;
  user-select: none;

  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.process-stepbtn:hover {
  background: var(--color-surface-2);
  transform: translateY(-1px);
}

.process-stepbtn:active {
  transform: translateY(0);
}

.process-stepbtn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 35%, transparent);
  border-color: color-mix(in srgb, var(--color-primary) 55%, var(--color-border-subtle));
}

.process-stepbtn:disabled,
.process-stepbtn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Visual separators between steps */
.process-steps > li {
  display: inline-flex;
  align-items: center;
}

.process-steps > li + li::before {
  content: "";
  display: inline-block;
  width: 1.1rem;
  height: 1px;
  background: var(--color-border-subtle);
  margin-inline: var(--space-1);
}

/* States */
.process-stepbtn.is-todo {
  background: var(--color-surface-1);
  color: var(--color-text-muted);
}

.process-stepbtn.is-done {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: var(--color-text-primary);
}

.process-stepbtn.is-current {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-primary-text);
  box-shadow: var(--shadow-sm);
}

/* Compact mode for dense UIs */
.process-stepper.is-compact .process-stepbtn {
  padding: 0.4rem 0.65rem;
  min-height: 2.2rem;
  font-size: var(--font-size-xs);
}

@media (max-width: 520px) {
  .process-steps {
    gap: var(--space-1);
  }
  .process-steps > li + li::before {
    width: 0.9rem;
  }
}

/* ==========================================================================
   9c) Process strip (filter/view buttons)
   ========================================================================== */

.process-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.process-strip__btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  padding: 0.45rem 0.75rem;
  min-height: 2.4rem;

  border-radius: 999px;
  border: 1px solid var(--color-border-subtle);

  background: var(--color-surface-1);
  color: var(--color-text-primary);

  font-family: var(--font-family-sans);
  font-weight: 800;
  font-size: var(--font-size-sm);
  line-height: 1;

  cursor: pointer;
  user-select: none;

  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease, border-color 120ms ease;
}

.process-strip__btn:hover {
  background: var(--color-surface-2);
  transform: translateY(-1px);
}

.process-strip__btn:active {
  transform: translateY(0);
}

.process-strip__btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary) 35%, transparent);
  border-color: color-mix(in srgb, var(--color-primary) 55%, var(--color-border-subtle));
}

.process-strip__btn.is-active,
.process-strip__btn[aria-pressed="true"],
.process-strip__btn[aria-current="true"] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-primary-text);
  box-shadow: var(--shadow-sm);
}

.process-strip__btn:disabled,
.process-strip__btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   10) Toolbar
   ========================================================================== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);

  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  background: var(--color-surface-1);
  box-shadow: var(--shadow-sm);

  margin-bottom: var(--space-5);
}

.toolbar__title {
  font-size: var(--font-size-lg);
  font-weight: 800;
  line-height: 1.2;
  color: var(--color-text-primary);
}

.toolbar__subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.toolbar__right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.table--dense {
  --table-padding: var(--space-1) var(--space-2);
  --table-font-size: var(--font-size-sm);
}

.table--dense.dataTable td,
.table--dense.dataTable th {
  padding: var(--table-padding);
  font-size: var(--table-font-size);
}

.table--dense.dataTable tfoot input {
  height: 24px;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  font-size: var(--table-font-size);
}
/* ==========================================================================
   20) Details & Metadata
   ========================================================================== */
.detail-row {
  display: flex;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border-subtle);
  gap: var(--space-4);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  flex: 0 0 120px;
  font-weight: 600;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.detail-value {
  flex: 1;
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
}

/* Navigeringslistor (t.ex. för admin-hubbar) */
.nav-list {
    list-style: none;
    padding: 0;
    margin: var(--space-4) 0;
}

.nav-list li {
    margin-bottom: var(--space-2);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    transition: background 0.15s ease;
}

.nav-link:hover {
    background: var(--color-bg-muted);
    text-decoration: none;
    color: var(--color-primary);
}


.nav-link i {
    width: 20px;
    text-align: center;
    color: var(--color-text-secondary);
}

/* ==========================================================================
   21) Diff details (import preview: old/new values)
   ========================================================================== */

.diff-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.diff-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.diff-field {
  flex: 0 0 auto;
  min-width: 9rem;

  font-size: var(--font-size-xs);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;

  color: var(--color-text-secondary);
}

.diff-value {
  display: inline-flex;
  align-items: center;

  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--color-border-subtle);

  font-size: var(--font-size-sm);
  font-weight: 700;
  line-height: 1.4;

  background: var(--color-surface-2);
  color: var(--color-text-primary);
  max-width: 100%;
  word-break: break-word;
}

.diff-old {
  background: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  color: var(--color-danger);
  text-decoration: line-through;
}

.diff-new {
  background: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: var(--color-success);
}

.diff-arrow {
  color: var(--color-text-muted);
  font-weight: 900;
}

/* For nested values we render as a small list */
.diff-sublist {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding-left: var(--space-4);
}

.diff-subrow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.diff-subkey {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-text-muted);
  min-width: 6.5rem;
}

.toolbar--sticky {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--color-surface-1);
  padding-top: var(--space-2);
  padding-bottom: var(--space-2);
}

.article-needed-cost {
  --badge-char: "c";
  --badge-bg: var(--color-accent, #0d6efd);
}

.article-needed-specification {
  --badge-char: "s";
  --badge-bg: var(--color-warning, #f0ad4e);
}

.article-needed-cost > label,
.article-needed-specification > label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.article-needed-cost > label::before,
.article-needed-specification > label::before {
  content: var(--badge-char, "?");

  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 1.2em;
  height: 1.2em;
  border-radius: 50%;

  font-size: 0.75em;
  font-weight: 600;
  text-transform: uppercase;

  background-color: var(--badge-bg, #999);
  color: #fff;
}

div.DTED_Lightbox_Wrapper{
  display: flex;
  justify-content: center;
  align-items: flex-start; /* eller center om du vill */
}

div.DTED_Lightbox_Content{
  width: clamp(45rem, 92vw, 85rem);
  max-width: 92vw;
  box-sizing: border-box;
}


/* --------------------------------------------------------------------------
   Hamburger / dropdown – ensure selected item is visible in Light theme
   Markup: <ul class="menu-bar"> ... <a class="menu-button active" ...>
   -------------------------------------------------------------------------- */

/* Active / current item */
ul.menu-bar a.menu-button.active,
ul.menu-bar a.menu-button[aria-current="page"],
ul.menu-bar li.active > a.menu-button,
ul.menu-bar li[aria-current="page"] > a.menu-button {
  background-color: var(--color-primary) !important;
  color: var(--color-primary-text) !important;
}

/* Hover ONLY for active item */
ul.menu-bar a.menu-button.active:hover,
ul.menu-bar li.active > a.menu-button:hover {
  background-color: var(--color-primary-hover) !important;
  color: var(--color-primary-text) !important;
}

/* Hover for non-active items */
ul.menu-bar a.menu-button:hover {
  background-color: var(--color-surface-2);
  color: var(--color-text-primary);
}
