/* ==========================================================================
   Legacy bridge: TEMPORARY, delete when the migration finishes
   ==========================================================================

   59 templates were written against variables and class names that lived in a
   single inline <style> block in base.html: --bg-deep, --accent-green,
   .sidebar, .api-key-display, .status-dot.active and so on. Moving to
   codexbase.css in one commit would have broken every dashboard and admin
   page at once.

   So this file re-expresses those old names in terms of the new tokens.
   Nothing here introduces a colour of its own: every value is a var() onto
   codexbase.css, which means the legacy pages inherit light mode and the new
   palette for free, without being rewritten first.

   It is a ramp, not a layer to build on. Rules to keep it shrinking:

     * Never add a new name here. New markup uses the real design system.
     * When a template is migrated, delete the rules it was the last user of.
     * This file is done when it is empty, and then it goes.

   Check what still depends on it before deleting any section:
     grep -rn "sidebar-collapsed\|api-key-display" app/templates/
   ========================================================================== */

/* ---- Old variable names -------------------------------------------------
   Aliases only. The old palette was blue-accented and dark-only; pointing
   these at the tokens is what converts the legacy pages to the green brand
   and gives them a light theme they were never written for. ------------- */
:root {
  --bg-deep:      var(--bg);
  --bg-surface:   var(--bg-subtle);
  --bg-card:      var(--surface);
  --bg-elevated:  var(--surface-raised);
  --border-bright:var(--accent);
  --accent-hot:   var(--warn);
  --accent-green: var(--accent);
  --accent-pink:  var(--danger);
  --text-primary: var(--text);
  --text-secondary: var(--text-muted);

  /* These were glows on a dark-only UI. On a light surface a coloured glow
     reads as a smudge, so they resolve to a real focus ring instead. */
  --glow-blue: 0 0 0 3px var(--accent-ring);
  --glow-hot:  0 0 0 3px var(--warn-soft);
}

/* ---- Legacy buttons -----------------------------------------------------
   The old sheet defined .btn-primary / .btn-outline / .btn-ghost on top of
   Bootstrap. Re-pointed at the tokens so they stop being blue. ---------- */
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: var(--weight-semi);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--accent-contrast);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-control);
  color: var(--text);
}
.btn-outline:hover { background: var(--surface-hover); border-color: var(--text-subtle); color: var(--text); }

.btn-ghost { background: transparent; border: 1px solid transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }

/* Bootstrap's own .btn-sm sets a 12px font, which is under the 16px floor on
   inputs but acceptable on a button; the min-height is what matters for the
   touch target. */
.btn-sm { min-height: 36px; }

/* ---- Legacy navbar ------------------------------------------------------
   base.html now renders .nav-cb, but admin/_layout.html and
   dashboard/base_dashboard.html still emit Bootstrap's .navbar. ---------- */
.navbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.navbar .nav-link { color: var(--text-muted); }
.navbar .nav-link:hover, .navbar .nav-link.active { color: var(--text); }
.navbar-brand { color: var(--text); font-weight: var(--weight-semi); }
.brand-dot { color: var(--accent); }

/* ---- Legacy sidebar (dashboard + admin) -------------------------------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.sidebar-nav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.sidebar-nav a.active { background: var(--accent-soft); color: var(--accent-text); }
.sidebar-nav .nav-section {
  margin: var(--space-5) 0 var(--space-2);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
}
.sidebar-toggle {
  background: var(--surface-raised);
  border: 1px solid var(--border-control);
  color: var(--text-muted);
}
.sidebar-toggle:hover { color: var(--accent-text); border-color: var(--accent); }

/* ---- Classes the first draft of this bridge missed ----------------------
   Found by scripts/check-orphans.py, which enumerates every class the old
   base.html defined and reports the ones still used in markup that nothing
   defines any more. That check is the one that should have gated this file.
   Building it by re-expressing the old variables plus a set of components
   chosen by eye let two regressions through: the console layout, and the
   stat card on dashboard/index.html, which rendered its icon, value and
   label as three loose lines of unstyled text.

   Each of these is still referenced by at least one unmigrated template, so
   they stay until the last caller is converted. Run the script before
   deleting anything here. ------------------------------------------------ */

/* Small inline label. badge-cb supersedes it; these remain for the pages
   that still emit the old name. */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.15em 0.5em;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}
.tag-accent {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* Plan name beside a user or engine row. */
.badge-plan {
  display: inline-block;
  padding: 0.15em 0.6em;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--accent-text);
  white-space: nowrap;
}

/* Destructive action that is not the primary button on the page. */
.btn-danger-soft {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger);
  min-height: 44px;
}
.btn-danger-soft:hover { background: var(--danger); color: var(--white); }

/* Was the amber "hot" call to action. The brand now carries emphasis with
   one accent, so this resolves to the primary button rather than a second
   competing colour. */
.btn-hot {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: var(--accent-contrast);
  font-weight: var(--weight-semi);
  min-height: 44px;
}
.btn-hot:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-contrast); }

/* ---- Legacy odds and ends --------------------------------------------- */
.api-key-display {
  font-family: var(--font-mono);
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--accent-text);
  letter-spacing: 0.03em;
  /* An API key is long and must wrap rather than widen the page. */
  overflow-wrap: anywhere;
}

/* The old .status-dot took .active / .inactive; the new one takes
   --ok / --warn / --danger. Both spellings work until the markup is updated. */
.status-dot.active   { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.status-dot.inactive { background: var(--text-subtle); box-shadow: none; }

.pagination .page-link {
  background: var(--surface-raised);
  border-color: var(--border);
  color: var(--text-muted);
  font-size: var(--text-sm);
}
.pagination .page-link:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-control); }
.pagination .page-item.active .page-link {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}

/* Bootstrap form controls, themed so legacy forms match the new inputs. */
.form-control, .form-select {
  background: var(--surface-sunken);
  border: 1px solid var(--border-control);
  color: var(--text);
  min-height: 44px;
  /* 16px, or iOS Safari zooms the viewport the moment the field is focused. */
  font-size: var(--text-base);
}
.form-control:focus, .form-select:focus {
  background: var(--surface-sunken);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
  color: var(--text);
}
.form-control::placeholder { color: var(--text-subtle); }
.form-label { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text); }
.form-text { color: var(--text-muted); }

.table { color: var(--text); --bs-table-bg: transparent; }
.table > :not(caption) > * > * { border-bottom-color: var(--border); }
.table thead th { color: var(--text-muted); font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.06em; }

.card { background: var(--surface); border: 1px solid var(--border); }
.card-header { background: var(--surface-sunken); border-bottom-color: var(--border); }
.card-footer { background: var(--surface-sunken); border-top-color: var(--border); }

.modal-content { background: var(--surface); border: 1px solid var(--border); }
.modal-header, .modal-footer { border-color: var(--border); }
.dropdown-menu {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.dropdown-item { color: var(--text-muted); }
.dropdown-item:hover { background: var(--surface-hover); color: var(--text); }

.alert { border: 1px solid var(--border); border-left-width: 3px; }
.alert-success { background: var(--accent-soft); border-left-color: var(--accent); color: var(--text); }
.alert-danger  { background: var(--danger-soft); border-left-color: var(--danger); color: var(--text); }
.alert-warning { background: var(--warn-soft);   border-left-color: var(--warn);   color: var(--text); }
.alert-info    { background: var(--info-soft);   border-left-color: var(--info);   color: var(--text); }

/* Bootstrap renders .btn-close as a dark SVG, invisible on a dark surface.
   The filter was previously applied inline per template. */
.btn-close { filter: invert(1) grayscale(1) brightness(1.6); opacity: 0.6; }
:root[data-theme="light"] .btn-close { filter: none; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .btn-close { filter: none; }
}

/* Legacy mobile rule. The real responsive work lives in codexbase.css; this
   only stops the old sidebar overlapping content on a phone. */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: var(--space-4); }
  .sidebar-toggle { display: none; }
}
