/**
 * =============================================================================
 *                  SP BOUCHER | SOFTWARE & RESEARCH
 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING
 * =============================================================================
 *
 * Project          : SPIDER — Universal Web Intelligence Engine
 * File             : apps/dashboard/css/components.css
 * Module           : Dashboard
 * Repository       : https://git.spboucher.ai/spider
 * Project Website  : Not specified
 * Created          : 2026-12-04
 * Last Modified    : 2026-12-04
 *
 * Author           : Simon-Pierre Boucher
 * Position         : Professor of Finance
 * Institution      : Université du Québec en Outaouais (UQO)
 * Organization     : SP Boucher
 * Website          : https://spboucher.ai
 * Git              : https://git.spboucher.ai
 *
 * Preferred Contact: contact@spboucher.ai
 * Development      : dev@spboucher.ai
 * Support          : support@spboucher.ai
 * Security/Admin   : admin@spboucher.ai
 *
 * Copyright (c) 2026
 * Simon-Pierre Boucher
 * All rights reserved where applicable. This file is governed by the
 * applicable project license, copyright notices and relevant law.
 * Existing third-party rights and notices remain unaffected.
 *
 * License          : ISC
 *
 * Do not embed credentials, private keys, access tokens,
 * certificates or confidential personal information.
 *
 * =============================================================================
 * END OF SP BOUCHER SOURCE HEADER
 * =============================================================================
 */

/* SPIDER dashboard — components. */

/* ------------------------------------------------------------------ buttons */
.btn {
  appearance: none; font: inherit; font-size: 13px; font-weight: 550; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 12px; border: 1px solid var(--rule-2); border-radius: 2px;
  background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: var(--ink); }
.btn:active { background: var(--sunken); }
.btn[disabled], .btn[aria-disabled="true"] { color: var(--ink-3); border-color: var(--rule); cursor: not-allowed; background: transparent; }
.btn.primary { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
.btn.primary:hover { border-color: var(--ink); }
.btn.primary[disabled] { background: var(--neutral-wash); border-color: var(--rule); color: var(--ink-3); }
.btn.danger { color: var(--failed); border-color: var(--failed); }
.btn.danger.solid { background: var(--failed); color: var(--surface); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink-2); padding: 0 8px; }
.btn.quiet:hover { border-color: var(--rule-2); color: var(--ink); }
.btn.sm { height: 24px; padding: 0 8px; font-size: 12px; }
.btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-row { display: flex; gap: var(--s2); flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ forms */
.field { display: grid; gap: 4px; min-width: 0; }
.field > label, .field > .label, fieldset > legend {
  font-size: 12px; font-weight: 600; color: var(--ink-2);
}
.field .help { font-size: 12px; color: var(--ink-3); }
.field .err { font-size: 12px; color: var(--failed); font-weight: 550; }
.field .err::before { content: "\2715\00a0"; }
.field.invalid input, .field.invalid textarea, .field.invalid select { border-color: var(--failed); border-width: 2px; }

input[type="text"], input[type="url"], input[type="number"], input[type="password"], input[type="search"],
input[type="datetime-local"], select, textarea {
  font: inherit; font-size: 13px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule-2); border-radius: 2px; padding: 5px 8px; min-height: 30px; width: 100%; min-width: 0;
}
textarea { font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; resize: vertical; min-height: 84px; }
input.mono { font-family: var(--font-mono); font-size: 12.5px; }
input::placeholder, textarea::placeholder { color: var(--ink-3); opacity: 0.8; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-2); }
input[disabled], select[disabled], textarea[disabled] { background: var(--sunken); color: var(--ink-3); }
input[type="range"] { accent-color: var(--signal); width: 100%; }

.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; min-height: 24px; }
.check input { width: 15px; height: 15px; accent-color: var(--signal); margin: 0; flex: none; }
.check.locked { color: var(--ink-2); }
.checks { display: flex; flex-wrap: wrap; gap: 6px var(--s4); }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.form-grid { display: grid; gap: var(--s3) var(--s4); grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: start; }
.form-grid .wide { grid-column: 1 / -1; }
.with-unit { display: flex; align-items: center; gap: 6px; }
.with-unit .unit { flex: none; font-family: var(--font-mono); font-size: 12px; }

/* ------------------------------------------------------------------ panels */
.panel { background: var(--surface); border: 1px solid var(--rule); min-width: 0; }
.panel-head {
  display: flex; align-items: center; gap: var(--s3); padding: 9px var(--s4); border-bottom: 1px solid var(--rule);
  min-height: 42px; flex-wrap: wrap;
}
.panel-head h2, .panel-head h3 {
  font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 650; color: var(--ink-2);
}
.panel-head .spacer { flex: 1; }
.panel-head .meta { font-size: 12px; color: var(--ink-3); }
.panel-body { padding: var(--s4); min-width: 0; }
.panel-body.flush { padding: 0; }
.panel-foot { border-top: 1px solid var(--rule); padding: var(--s2) var(--s4); font-size: 12px; color: var(--ink-3); display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }

.grid-2 { display: grid; gap: var(--s5); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: var(--s5); grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; gap: var(--s5); grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); align-items: start; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); gap: var(--s4); } }

/* figures: one measured quantity with its unit */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
.figure { padding: var(--s3) var(--s4); border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); min-width: 0; margin-right: -1px; margin-bottom: -1px; }
.figure .k { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.figure .v { font-family: var(--font-mono); font-size: 22px; line-height: 1.25; font-weight: 500; letter-spacing: -0.02em; white-space: nowrap; }
.figure .v .unit { font-size: 12px; letter-spacing: 0; }
.figure .d { font-size: 12px; color: var(--ink-3); }
.figures-wrap { overflow: hidden; }

/* key/value specification list */
.kv { display: grid; grid-template-columns: minmax(96px, max-content) minmax(0, 1fr); gap: 5px var(--s4); font-size: 13px; }
.kv dt { color: var(--ink-3); font-size: 12px; padding-top: 1px; }
.kv dd { min-width: 0; overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; max-width: 100%; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data caption { text-align: left; padding: var(--s2) var(--s4); color: var(--ink-3); font-size: 12px; caption-side: bottom; border-top: 1px solid var(--rule); }
table.data th {
  text-align: left; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 650; color: var(--ink-3);
  padding: 7px var(--s3); border-bottom: 1px solid var(--rule-2); white-space: nowrap; background: var(--surface);
}
table.data td { padding: 6px var(--s3); border-bottom: 1px solid var(--rule); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data th:first-child, table.data td:first-child { padding-left: var(--s4); }
table.data th:last-child, table.data td:last-child { padding-right: var(--s4); }
table.data td.r, table.data th.r { text-align: right; }
table.data td.num, table.data td.mono { font-family: var(--font-mono); font-size: 12.5px; }
table.data td.clip { max-width: 38ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.data td.url { max-width: 46ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 12.5px; }
table.data tbody tr:hover td { background: var(--sunken); }
table.data tr.selected td { background: var(--signal-wash); }
table.data td .btn-row { flex-wrap: nowrap; }
table.data a.rowlink { font-weight: 600; }

/* ------------------------------------------------------------------ status */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1; }
.status svg { width: 11px; height: 11px; flex: none; }
.status.badge { padding: 4px 8px 4px 7px; border: 1px solid currentColor; border-radius: 2px; }
.tone-ok { color: var(--ok); } .tone-partial { color: var(--partial); } .tone-blocked { color: var(--blocked); }
.tone-failed { color: var(--failed); } .tone-neutral { color: var(--neutral); } .tone-signal { color: var(--signal); }
.status.badge.tone-ok { background: var(--ok-wash); } .status.badge.tone-partial { background: var(--partial-wash); }
.status.badge.tone-blocked { background: var(--blocked-wash); } .status.badge.tone-failed { background: var(--failed-wash); }
.status.badge.tone-neutral { background: var(--neutral-wash); } .status.badge.tone-signal { background: var(--signal-wash); }

.chip { display: inline-flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 11.5px; padding: 1px 6px; border: 1px solid var(--rule-2); border-radius: 2px; color: var(--ink-2); white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }

/* stacked proportion bar with a legend (never colour alone: each segment is listed with a label) */
.bar-stack { display: flex; height: 10px; border: 1px solid var(--rule-2); background: var(--sunken); overflow: hidden; }
.bar-stack span { display: block; height: 100%; min-width: 2px; background: currentColor; border-right: 1px solid var(--surface); }
.legend { display: flex; flex-wrap: wrap; gap: 6px var(--s4); margin-top: var(--s2); }
.legend .status .n { font-family: var(--font-mono); font-weight: 500; color: var(--ink); }

.meter { height: 6px; background: var(--sunken); border: 1px solid var(--rule-2); min-width: 60px; }
.meter > span { display: block; height: 100%; background: var(--ink-2); }

/* ------------------------------------------------------------------ notes and states */
.note { border: 1px solid var(--rule-2); border-left: 3px solid var(--ink-3); padding: var(--s2) var(--s3); font-size: 13px; background: var(--surface); }
.note.info { border-left-color: var(--signal); }
.note.warn { border-left-color: var(--partial); background: var(--partial-wash); }
.note.bad { border-left-color: var(--failed); background: var(--failed-wash); }
.note.good { border-left-color: var(--ok); background: var(--ok-wash); }
.note strong { font-weight: 650; }
.note .mono { font-size: 12px; }

.state { padding: var(--s5) var(--s4); text-align: left; color: var(--ink-2); display: grid; gap: var(--s2); justify-items: start; }
.state .state-title { font-weight: 650; color: var(--ink); }
.state.loading { color: var(--ink-3); font-family: var(--font-mono); font-size: 12px; }
.state.loading::before { content: ""; width: 28px; height: 2px; background: var(--signal); animation: scan 1.1s linear infinite alternate; }
@keyframes scan { from { transform: translateX(0); } to { transform: translateX(40px); } }
.state.error { border-left: 3px solid var(--failed); }
.state.forbidden { border-left: 3px solid var(--blocked); }

/* ------------------------------------------------------------------ tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--rule-2); overflow-x: auto; scrollbar-width: thin; }
.tabs [role="tab"] {
  appearance: none; background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  font: inherit; font-size: 13px; font-weight: 550; color: var(--ink-3); padding: 8px 12px; cursor: pointer; white-space: nowrap;
}
.tabs [role="tab"]:hover { color: var(--ink); }
.tabs [role="tab"][aria-selected="true"] { color: var(--ink); border-bottom-color: var(--signal); }
.tabs [role="tab"]:focus-visible { outline-offset: -2px; }
.tabs [role="tab"] .count { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); margin-left: 4px; }
[role="tabpanel"] { min-width: 0; }
[role="tabpanel"]:focus-visible { outline-offset: -2px; }

/* ------------------------------------------------------------------ dialog and toast */
dialog.dlg {
  border: 1px solid var(--ink); background: var(--surface); color: var(--ink); padding: 0; border-radius: 2px;
  width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 48px);
}
dialog.dlg.wide { width: min(760px, calc(100vw - 24px)); }
dialog.dlg::backdrop { background: rgba(10, 12, 14, 0.55); }
.dlg-head { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--rule); display: flex; align-items: center; gap: var(--s3); }
.dlg-head h2 { flex: 1; }
.dlg-body { padding: var(--s4); display: grid; gap: var(--s3); overflow-y: auto; }
.dlg-foot { padding: var(--s3) var(--s4); border-top: 1px solid var(--rule); display: flex; gap: var(--s2); justify-content: flex-end; flex-wrap: wrap; }

.toasts { position: fixed; right: var(--s4); bottom: var(--s4); display: grid; gap: var(--s2); z-index: 60; width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--paper); padding: var(--s2) var(--s3); font-size: 13px; border-left: 4px solid var(--signal); display: flex; gap: var(--s3); align-items: flex-start; }
.toast.bad { border-left-color: var(--failed); }
.toast.good { border-left-color: var(--ok); }
.toast .toast-msg { flex: 1; overflow-wrap: anywhere; }
.toast button { appearance: none; background: none; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0 2px; text-decoration: underline; }

/* ------------------------------------------------------------------ code, json, log */
.code { background: var(--sunken); border: 1px solid var(--rule); padding: var(--s3); font-family: var(--font-mono); font-size: 12.5px; line-height: 1.5; overflow: auto; max-height: 420px; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; }
.code.tall { max-height: 640px; }
.code.nowrap { white-space: pre; overflow-wrap: normal; }
.json .k { color: var(--ink); font-weight: 600; }
.json .s { color: var(--ok); }
.json .n { color: var(--signal); }
.json .b { color: var(--blocked); }
.json .z { color: var(--ink-3); }
.code-head { display: flex; align-items: center; gap: var(--s2); justify-content: space-between; margin-bottom: 4px; }
.code-head .label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; font-weight: 650; color: var(--ink-3); }

.log { font-family: var(--font-mono); font-size: 12px; line-height: 1.55; max-height: 520px; overflow: auto; background: var(--sunken); border-top: 1px solid var(--rule); }
.log-row { display: grid; grid-template-columns: 54px 96px 132px minmax(0, 1fr); gap: var(--s3); padding: 2px var(--s4); border-bottom: 1px solid var(--rule); }
.log-row .t { color: var(--ink-3); }
.log-row .ty { font-weight: 600; }
.log-row .d { overflow-wrap: anywhere; color: var(--ink-2); }
@media (max-width: 700px) { .log-row { grid-template-columns: 40px minmax(0, 1fr); } .log-row .t { display: none; } .log-row .d { grid-column: 1 / -1; } }

.toolbar { display: flex; gap: var(--s2) var(--s3); align-items: end; flex-wrap: wrap; }
.toolbar .field { min-width: 120px; }
.toolbar .grow { flex: 1; min-width: 180px; }

details.disc { border-top: 1px solid var(--rule); }
details.disc > summary { cursor: pointer; padding: var(--s2) var(--s4); font-weight: 600; font-size: 13px; list-style-position: inside; }
details.disc > summary:hover { background: var(--sunken); }
details.disc > .disc-body { padding: var(--s3) var(--s4) var(--s4); }
details.disc:first-child { border-top: 0; }
