/*
 * Ascent Controls base styles and shared components (new UI).
 *
 * Everything here is scoped so it cannot change a page that still uses the old theme:
 *   - element-level rules only apply inside an element with class "asc"
 *     (<body class="asc"> for a whole page, <div class="asc asc-embed"> inside the current app shell)
 *   - component classes start with "a-" (a-btn, a-field, a-alert ...), which Bootstrap does not use
 * Needs tokens.css loaded first.
 */

body.asc { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
.asc, .asc *, .asc *::before, .asc *::after { box-sizing: border-box; }
.asc [hidden] { display: none !important; }
.asc button, .asc input, .asc select, .asc textarea { font: inherit; color: inherit; }
.asc :focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.asc h1 { font-size: 26px; font-weight: 600; margin: 0 0 6px; letter-spacing: -.01em; line-height: 1.25; }

/* A redesigned page inside the current app shell: wrap its content in <div class="asc asc-embed">.
   It sets the new font and colours for that area only. See README ("Inside the current app shell"). */
.asc-embed { font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--ink); -webkit-font-smoothing: antialiased; }
.asc-embed label { font-weight: 500; margin: 0; }
.asc-embed a { color: var(--brand); }
/* The shell's stylesheet squares off every field, removes the arrow from selects and greys fields on focus (with !important). Put those back for the wrapped area. */
.asc-embed input:not([type="checkbox"]):not([type="radio"]), .asc-embed select, .asc-embed textarea { border-radius: 8px !important; border-color: var(--line); color: var(--ink); }
.asc-embed select { -webkit-appearance: menulist; -moz-appearance: menulist; appearance: auto; }
.asc-embed input:focus, .asc-embed select:focus, .asc-embed textarea:focus { background-color: var(--surface) !important; border-color: var(--brand) !important; outline: 2px solid var(--brand); outline-offset: 1px; }

/* Text */
.a-lead { margin: 0 0 22px; color: var(--muted); }
.a-small { font-size: 13.5px; color: var(--muted); }
.a-link { color: var(--brand); text-decoration: none; background: none; border: 0; padding: 0; font: inherit; cursor: pointer; }
.a-link:hover { text-decoration: underline; }
.asc button.a-link { color: var(--brand); } /* ".asc button" above would otherwise make a link-style button the text colour */

/* Buttons. a-btn is full width by default (forms); add a-btn-inline for a normal-width button. */
.a-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 46px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; }
.a-btn:hover { border-color: var(--brand); text-decoration: none; color: var(--ink); }
.a-btn.a-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.a-btn.a-primary:hover { filter: brightness(1.06); color: var(--brand-ink); }
.a-btn:disabled, .a-btn[aria-disabled="true"] { opacity: .7; cursor: progress; }
.a-btn-inline { display: inline-flex; width: auto; }

/* Form fields: <div class="a-field form-group"><label>..</label><div class="a-inp"><input></div></div> */
.a-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.a-field label, .a-field .a-label { font-size: 13.5px; font-weight: 500; margin: 0; }
.a-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.a-inp { position: relative; }
.a-inp input { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 9px; padding: 0 14px; background: var(--surface); color: var(--ink); }
.a-inp input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
.a-inp input[aria-invalid="true"], .has-error .a-inp input { border-color: var(--hi); }
.a-inp input.a-pw { padding-right: 72px; }
.a-eye { position: absolute; right: 6px; top: 6px; height: 32px; padding: 0 10px; border: 0; background: none; color: var(--muted); cursor: pointer; border-radius: 6px; font-size: 13px; }
.a-eye:hover { color: var(--ink); background: var(--brand-soft); }
.a-hint { font-size: 13px; color: var(--muted); }
/* jQuery Validate puts <span class="help-block"> after the input; style it as the field error */
.asc .help-block { display: block; margin: 6px 0 0; color: var(--hi); font-size: 13px; }
.asc .help-block.valid { display: none; }

.a-check { display: flex; align-items: center; gap: 10px; margin: 2px 0 18px; font-size: 14px; font-weight: 400; }
.a-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }

/* Messages */
.a-alert { border-radius: 10px; padding: 10px 14px; font-size: 14px; margin-bottom: 16px; }
.a-alert.a-bad { background: var(--hi-soft); color: var(--hi); }
.a-alert.a-good { background: var(--lo-soft); color: var(--lo); }
.a-alert.a-warn { background: var(--md-soft); color: var(--md); }

/* Small pieces */
.a-sep { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.a-sep::before, .a-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.a-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; animation: a-spin .7s linear infinite; }
@keyframes a-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .a-spin { animation-duration: 2s; } }

/* Logo that follows the theme: put both images in the page, one with a-logo-light and one with a-logo-dark */
.a-logo-dark { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .a-logo-dark { display: block; } :root:not([data-theme="light"]) .a-logo-light { display: none; } }
:root[data-theme="dark"] .a-logo-dark { display: block; }
:root[data-theme="dark"] .a-logo-light { display: none; }

/* ---------- Tooltip (js/ui.js): made from title attributes ---------- */
.a-tip { position: fixed; z-index: 2100; max-width: min(280px, calc(100vw - 12px)); padding: 5px 9px; border-radius: 6px; background: #0f1b2d; color: #fff; font-family: var(--font); font-size: 12.5px; font-weight: 500; line-height: 1.35; white-space: pre-line; overflow-wrap: anywhere; border: 1px solid rgba(255, 255, 255, .16); box-shadow: 0 6px 18px rgba(0, 0, 0, .28); pointer-events: none; animation: a-tip-in .1s ease-out; }
.a-tip[hidden] { display: none; }
:root[data-theme="dark"] .a-tip { background: #2b3b54; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .a-tip { background: #2b3b54; } }
@keyframes a-tip-in { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .a-tip { animation: none; } }

/* ---------- Toast and dialog (js/ui.js) ---------- */
.a-toast-host { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 2000; max-width: calc(100vw - 24px); font-family: var(--font); }
.a-toast { display: flex; align-items: center; gap: 12px; background: #0f1b2d; color: #fff; border-radius: 10px; padding: 10px 12px 10px 16px; font-size: 14px; line-height: 1.4; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); animation: a-rise .16s ease-out; }
:root[data-theme="dark"] .a-toast { background: #223044; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .a-toast { background: #223044; } }
.a-toast.a-toast-bad { background: #a82a2a; }
.a-toast-btn { border: 0; background: none; color: #8fb8ff; font: inherit; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0 2px; }
.a-toast-bad .a-toast-btn { color: #fff; }
.a-toast-x { border: 0; background: none; color: rgba(255, 255, 255, .7); font-size: 18px; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 4px; }
.a-toast-x:hover { color: #fff; }
.a-toast-btn:focus-visible, .a-toast-x:focus-visible { outline: 2px solid #8fb8ff; outline-offset: 2px; }

.a-scrim { position: fixed; inset: 0; z-index: 1990; background: rgba(8, 14, 24, .5); display: grid; place-items: center; padding: 16px; font-family: var(--font); }
.a-dialog { width: 100%; max-width: 440px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); padding: 20px 20px 16px; animation: a-rise .16s ease-out; box-sizing: border-box; }
.a-dialog h2 { margin: 0 0 6px; font-size: 18px; font-weight: 600; line-height: 1.3; color: var(--ink); }
.a-dialog p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--muted); }
.a-dialog-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.a-dialog .a-btn-inline { min-height: 38px; padding: 0 16px; border-radius: 8px; font-size: 14px; }
.a-btn.a-danger { background: var(--bar-hi); border-color: var(--bar-hi); color: #fff; }
.a-btn.a-danger:hover { filter: brightness(1.06); color: #fff; }
@keyframes a-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .a-toast, .a-dialog { animation: none; } }

