/* sb-style.css — v2 mini framework (generic) */
/* Goals: color-agnostic, 95%+ browser support, forms/tables/buttons/nav/overlay,
   modern layout (Flex/Grid), a11y focus rings, soft shadows, smooth transitions. */

/* Extract from normalize.css by Nicolas Gallagher and Jonathan Neal git.io/normalize */
html{-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}
article,aside,details,figcaption,figure,footer,header,main,menu,nav,section{display:block}summary{display:list-item}
audio,canvas,progress,video{display:inline-block}progress{vertical-align:baseline}
audio:not([controls]){display:none;height:0}[hidden],template{display:none}
a{background-color:transparent}a:active,a:hover{outline-width:0}
abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}
b,strong{font-weight:bolder}dfn{font-style:italic}mark{background:#ff0;color:#000}
small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
sub{bottom:-0.25em}sup{top:-0.5em}figure{margin:1em 40px}img{border-style:none}
code,kbd,pre,samp{font-family:monospace,monospace;font-size:1em}hr{box-sizing:content-box;height:0;overflow:visible}
button,input,select,textarea,optgroup{font:inherit;margin:0}optgroup{font-weight:bold}
button,input{overflow:visible}button,select{text-transform:none}
button,[type=button],[type=reset],[type=submit]{appearance:button;-webkit-appearance:button}
button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0}
button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText}
fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:.35em .625em .75em}
legend{color:inherit;display:table;max-width:100%;padding:0;white-space:normal}textarea{overflow:auto}
[type=checkbox],[type=radio]{padding:0}
[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}
[type=search]{appearance:textfield;-webkit-appearance:textfield;outline-offset:-2px}
[type=search]::-webkit-search-decoration{-webkit-appearance:none}
::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}
/* End extract */

/* ---------- Root tokens (NO colors here — all provided by brand file) ---------- */
:root {
  /* Color tokens (to be defined in ps-color.css) */
  --bg: #fff; --text: #111; --muted: #667085; --border: #e5e7eb;
  --brand: #000; --brand-700: #000; --brand-800: #000;
  --cta: #000;   --cta-700: #000;   --cta-800: #000;
  --danger: #000;--danger-700:#000; --danger-800:#000;
  --success:#000;--warning:#000; --info:#000;

  /* Radii / spacing / typographic rhythm */
  --radius: 12px; --radius-sm: 10px;
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem;
  --space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem;

  /* Shadows (can be overridden in brand file) */
  --shadow-1: 0 1px 2px rgba(0,0,0,.06), 0 1px 1px rgba(0,0,0,.04);
  --shadow-2: 0 2px 10px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);

  /* Focus ring (uses currentColor with alpha so it adapts to theme) */
  --ring-color: rgba(0, 0, 0, .28); /* brand file should override */
  --ring: 0 0 0 1px var(--ring-color);

  /* Motion */
  --elevate: box-shadow .18s ease, transform .06s ease, background-color .18s ease,
             color .18s ease, border-color .18s ease;
}

@media (prefers-reduced-motion: reduce) {
  :root { --elevate: none; }
}

/* ---------- Global layout scaffolding ---------- */
.app-shell { background: var(--surface, var(--bg)); min-height: 100vh; display: flex; flex-direction: column; }
.site-main { flex: 1 0 auto; padding: var(--space-6) 0; }


/* ---------- Base & Typography ---------- */
/* Hide any element toggled by ws.js using the [hidden] attribute */
[hidden] { display: none !important; }
* { box-sizing: border-box; }
html, body { height: 100%; }
html { font-size: 16px; }
body {
  margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, Arial, sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.5;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
img, video { max-width: 100%; height: auto; display: block; }
a { color: var(--brand); text-underline-offset: 3px; }
a:hover { color: var(--brand-700); text-decoration: underline; }
a:focus-visible { outline: 3px solid transparent; box-shadow: var(--ring); border-radius: 4px; }
small { font-size: .875rem; color: var(--muted); }

/* ---------- Layout Utilities ---------- */
.container { max-width: 1140px; margin-inline: auto; padding-inline: var(--space-4); }
.container.narrow { max-width: 840px; }

.row { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.stack { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.center { display: grid; place-items: center; }

.grid { display: grid; gap: var(--space-4); }
.grid-2 { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { display: grid; gap: var(--space-4); grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

.v-stack { display: flex; flex-direction: column; gap: var(--space-3); }
.v-stack-sm { display: flex; flex-direction: column; gap: var(--space-2); }

.text-muted { color: var(--muted); }
.text-center { text-align: center; }
.justify-between { display: flex; justify-content: space-between; align-items: center; }
.gap-sm { gap: var(--space-2); }
.gap-md { gap: var(--space-3); }

.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 999px; background: rgba(0,0,0,.08); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.hide { display: none !important; }
.w-100 { width: 100%; }
.max-w { max-width: 100%; }
.rounded { border-radius: var(--radius); }
.rounded-sm { border-radius: var(--radius-sm); }
.shadow-1 { box-shadow: var(--shadow-1); }
.shadow-2 { box-shadow: var(--shadow-2); }
.border { border: 1px solid var(--border); }

/* ---------- Cards / Panels ---------- */
.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-1); transition: var(--elevate);
}
.card:hover { box-shadow: var(--shadow-2); }

/* ---------- Forms ---------- */
label { display: inline-block; margin-bottom: .35rem; font-weight: 600; color: #334155; }
.form-hint { font-size: .85rem; color: var(--muted); }

.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .65rem .8rem; background: #fff; color: var(--text);
  box-shadow: var(--shadow-1); transition: var(--elevate);
}
.input:hover, .select:hover, .textarea:hover { box-shadow: var(--shadow-2); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--shadow-2), var(--ring);
}
.input[disabled], .select[disabled], .textarea[disabled] { opacity: .6; box-shadow: none; }

/* Inline controls */
.checkbox, .radio { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; }
.checkbox input, .radio input { inline-size: 1.1rem; block-size: 1.1rem; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px;
  transition: background .25s ease, box-shadow .25s ease; box-shadow: var(--shadow-1);
}
.slider:before {
  content: ""; position: absolute; height: 20px; width: 20px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: transform .25s ease; box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider:before { transform: translateX(18px); }
.switch input:focus + .slider { box-shadow: var(--ring); }

/* ---------- Buttons ---------- */
.button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .7rem 1rem; font-weight: 600; line-height: 1; cursor: pointer;
  background: transparent; color: inherit; text-decoration: none; user-select: none;
  box-shadow: var(--shadow-1); transition: var(--elevate);
}
.button:hover, .btn:hover { box-shadow: var(--shadow-2); text-decoration: none; }
.button:focus-visible, .btn:focus-visible { outline: none; box-shadow: var(--shadow-2), var(--ring); }
.button:disabled, .btn:disabled { opacity: .55; pointer-events: none; }

/* Variants (colors supplied by brand file) */
.btn-primary, .button.primary { color: #fff; background: var(--brand); }
.btn-primary:hover, .button.primary:hover { background: var(--brand-700); }
.btn-primary:active, .button.primary:active { background: var(--brand-800); }

.btn-cta, .button.cta { color: #fff; background: var(--cta); }
.btn-cta:hover, .button.cta:hover { background: var(--cta-700); }
.btn-cta:active, .button.cta:active { background: var(--cta-800); }

.btn-danger, .button.danger { color: #fff; background: var(--danger); }
.btn-danger:hover, .button.danger:hover { background: var(--danger-700); }
.btn-danger:active, .button.danger:active { background: var(--danger-800); }

.btn-secondary, .button.secondary { color: var(--text); background: #fff; border-color: var(--border); box-shadow: none; }
.btn-secondary:hover, .button.secondary:hover { background: #f9fafb; }

.btn-ghost, .button.ghost { color: var(--brand); background: transparent; box-shadow: none; }
.btn-ghost:hover, .button.ghost:hover { background: rgba(0,0,0,.04); }

/* Loading (spinner) — add aria-busy="true", optional .label / .label-busy spans */
.button[aria-busy="true"], .btn[aria-busy="true"] { position: relative; pointer-events: none; }
.button[aria-busy="true"]::after, .btn[aria-busy="true"]::after {
  content: ""; position: absolute; right: 10px; width: 1em; height: 1em; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.5); border-top-color: #fff; animation: ws-spin .8s linear infinite;
}
.button.secondary[aria-busy="true"]::after, .btn-secondary[aria-busy="true"]::after {
  border: 2px solid rgba(0,0,0,.25); border-top-color: currentColor;
}
@keyframes ws-spin { to { transform: rotate(360deg); } }
.button[aria-busy="true"] > .label-busy, .btn[aria-busy="true"] > .label-busy { display: inline; }
.button[aria-busy="true"] > .label, .btn[aria-busy="true"] > .label { display: none; }
.button > .label-busy, .btn > .label-busy { display: none; }

/* ---------- Navigation & Menus ---------- */
.nav { display: flex; gap: .5rem; align-items: center; }
.nav a { color: var(--brand); padding: .5rem .7rem; border-radius: 8px; }
.nav a:hover { background: rgba(0,0,0,.04); }

/* Elements used as dropdown menus with data-ws-menu can be hidden via [hidden] */
[data-ws-menu][hidden] { display: none !important; }
.menu {
  min-width: 200px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-2); padding: .25rem;
}
.menu a { display: block; padding: .5rem .75rem; border-radius: 8px; color: var(--text); }
.menu a:hover { background: #f3f4f6; }

/* ---------- Overlay / Dialog ---------- */
.overlay {
  position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,.5);
}
.dialog {
  background: #fff; border-radius: 12px; box-shadow: var(--shadow-2);
  width: min(560px, 92vw); margin: 0; padding: 1rem; border: 1px solid var(--border);
}

/* ---------- Tables ---------- */
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-all {
  width: 100%; border-collapse: separate; border-spacing: 0;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
}
.table-all thead th {
  background: #eef2f7; color: #0f172a; font-weight: 600;
  padding: .6rem .8rem; border-bottom: 1px solid var(--border);
}
.table-all tbody td { padding: .75rem .8rem; border-bottom: 1px solid var(--border); }
.table-all tbody tr:last-child td { border-bottom: none; }
.table-all tbody tr:hover { background: #f8fafc; }

/* ---------- Alerts ---------- */
.alert { padding: .8rem 1rem; border-radius: 10px; border: 1px solid var(--border); box-shadow: var(--shadow-1); }
.alert-ok    { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.alert-warn  { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-err   { background: #fef2f2; color: #991b1b; border-color: #fca5a5; }
