/* ============================================================
   kaziOS shell primitives
   Requires tokens.css to be loaded first.
   Covers: reset, topnav, buttons, cards, pills, forms, footer,
   sidebar layout (auth-aware), responsive helpers, mockup note.
   ============================================================ */

/* ------------------------------------------------------------ Reset + base */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-family);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--primary); }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3, h4, h5, h6 {
  color: var(--text);
  letter-spacing: -0.4px;
  margin: 0;
}
h1 { font-size: var(--fs-4xl); font-weight: 700; line-height: 1.1; }
h2 { font-size: var(--fs-2xl); font-weight: 600; line-height: 1.2; }
h3 { font-size: var(--fs-lg); font-weight: 600; }
p  { margin: 0; }

button { font-family: inherit; }

/* ------------------------------------------------------------ Topnav (marketing) */
.topnav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topnav .brand {
  text-decoration: none;
  display: inline-flex; align-items: center;
  width: fit-content;
}
.topnav .brand img { height: 26px; width: auto; border-radius: 6px; }
.topnav .spacer { flex: 1; }
.topnav .nav-links {
  display: flex; align-items: center; gap: 6px;
  flex-wrap: wrap;
}
.topnav .nav-links a {
  color: var(--text-muted); padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: var(--fs-base); font-weight: 500; text-decoration: none;
  transition: background var(--motion-base), color var(--motion-base);
}
.topnav .nav-links a:hover { background: var(--surface-2); color: var(--text); }
.topnav .nav-links a.btn-primary        { color: #fff; }
.topnav .nav-links a.btn-primary:hover  { color: #fff; background: var(--primary-600); }
.topnav .icon-btn {
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative;
  transition: background var(--motion-base), color var(--motion-base);
}
.topnav .icon-btn:hover { background: var(--surface-2); color: var(--text); }
.topnav .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #fff; font-weight: 600; font-size: var(--fs-sm);
  display: inline-flex; align-items: center; justify-content: center;
}

/* ------------------------------------------------------------ Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: var(--fs-base); font-weight: 500;
  padding: 10px 18px; border-radius: 10px;
  cursor: pointer; border: 1px solid transparent;
  transition: all var(--motion-base); text-decoration: none;
  white-space: nowrap; line-height: 1.2;
}
/* Default (bare .btn with no variant modifier) — neutral surface */
.btn:not([class*="btn-"])       { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn:not([class*="btn-"]):hover { background: var(--surface-3); color: var(--text); }

.btn-primary       { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); color: #fff; box-shadow: var(--shadow-md); }
.btn-ghost         { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-ghost:hover   { background: var(--surface-3); color: var(--text); }
.btn-outline       { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-secondary     { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-3); }
.btn-success       { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; box-shadow: var(--shadow-md); }
.btn-danger-ghost  { background: var(--surface); color: var(--danger); border-color: #fecaca; }
.btn-danger-ghost:hover { background: var(--danger-bg); }
.btn.block { display: flex; width: 100%; }
.btn-lg    { padding: 14px 22px; font-size: var(--fs-md); border-radius: 12px; }
.btn-sm    { padding: 6px 12px; font-size: var(--fs-sm); border-radius: 8px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* ------------------------------------------------------------ Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}
.card-flush { padding: 0; }
.card-header {
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-header h3 { font-size: var(--fs-lg); font-weight: 600; }
.card-body { padding: 20px 24px; }

/* ------------------------------------------------------------ Pills / badges */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: 500;
  background: var(--pill-bg); color: var(--pill-text);
  border: 1px solid var(--pill-border);
}
.pill.active  { background: var(--success-bg); color: var(--success-text); border-color: #bbf7d0; }
.pill.warn    { background: var(--warning-bg); color: var(--warning-text); border-color: #fcd34d; }
.pill.danger  { background: var(--danger-bg);  color: var(--danger-text);  border-color: #fecaca; }
.pill.info    { background: var(--info-bg);    color: var(--info-text);    border-color: #bfdbfe; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600;
  background: var(--pill-bg); color: var(--pill-text);
}
.badge.active  { background: var(--success-bg); color: var(--success-text); }
.badge.warn    { background: var(--warning-bg); color: var(--warning-text); }
.badge.danger  { background: var(--danger-bg);  color: var(--danger-text); }

/* ------------------------------------------------------------ Forms */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: var(--fs-sm); font-weight: 500;
  color: var(--text); margin-bottom: 6px;
}
.form-label .optional { color: var(--text-dim); font-weight: 400; margin-left: 4px; }

.form-input,
input[type="text"].form-input,
input[type="email"].form-input,
input[type="password"].form-input,
input[type="url"].form-input,
input[type="search"].form-input,
input[type="tel"].form-input,
input[type="number"].form-input,
textarea.form-input,
select.form-input {
  width: 100%; padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  font-size: var(--fs-base); font-family: inherit;
  background: var(--surface); color: var(--text);
  transition: border-color var(--motion-base), box-shadow var(--motion-base);
}
.form-input::placeholder { color: var(--text-dim); }
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
textarea.form-input { min-height: 96px; resize: vertical; }
.form-hint  { font-size: var(--fs-xs); color: var(--text-muted); margin-top: 6px; }
.form-error { font-size: var(--fs-xs); color: var(--danger);    margin-top: 6px; }

.form-checkbox {
  display: flex; align-items: flex-start; gap: 10px;
  font-size: var(--fs-sm); color: var(--text); cursor: pointer;
}
.form-checkbox input {
  margin-top: 2px; accent-color: var(--primary); cursor: pointer;
}

.password-strength {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px;
  margin-top: 8px;
}
.password-strength span {
  height: 4px; border-radius: 2px; background: var(--border);
}
.password-strength.strength-1 span:nth-child(1)      { background: var(--danger); }
.password-strength.strength-2 span:nth-child(-n+2)   { background: var(--warning); }
.password-strength.strength-3 span:nth-child(-n+3)   { background: var(--accent); }
.password-strength.strength-4 span                   { background: var(--success); }

/* ------------------------------------------------------------ Alerts */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin-bottom: 16px;
  display: flex; align-items: flex-start; gap: 10px;
  font-size: var(--fs-base);
  border: 1px solid transparent;
}
.alert i { margin-top: 2px; }
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: #a7f3d0; }
.alert-warning,
.alert-warn    { background: var(--warning-bg); color: var(--warning-text); border-color: #fde68a; }
.alert-error,
.alert-danger  { background: var(--danger-bg);  color: var(--danger-text);  border-color: #fecaca; border-left: 4px solid var(--danger); }
.alert-info    { background: var(--info-bg);    color: var(--info-text);    border-color: #bfdbfe; }

/* ------------------------------------------------------------ Page shell */
.page {
  min-height: calc(100vh - var(--topnav-height));
  display: flex; flex-direction: column;
}
.container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 40px 28px;
  width: 100%;
}
.container.wide { max-width: var(--container-max-wide); }
.container.narrow { max-width: 720px; }

.section-eyebrow {
  display: inline-block;
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: 1.5px;
  color: var(--accent); text-transform: uppercase;
  margin-bottom: 12px;
}

/* ------------------------------------------------------------ Sidebar layout (authed) */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0;
  height: 100vh; overflow-y: auto;
  z-index: 40;
}
.sidebar-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.sidebar-header .brand {
  font-weight: 700; font-size: 20px; color: var(--primary);
  letter-spacing: -0.3px; text-decoration: none;
  display: inline-flex; align-items: center; gap: 8px;
}
.sidebar-header .brand .dot { color: var(--accent); }
.sidebar-org {
  margin-top: 10px; font-size: var(--fs-xs); color: var(--text-muted);
  display: flex; align-items: center; gap: 6px;
}
.sidebar-nav {
  flex: 1; padding: 14px 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.sidebar-nav .nav-section {
  font-size: 11px; font-weight: 600; letter-spacing: 1px;
  color: var(--text-dim); text-transform: uppercase;
  padding: 14px 14px 6px;
}
.sidebar-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-radius: 10px;
  color: var(--text-muted); font-size: var(--fs-base); font-weight: 500;
  text-decoration: none;
  transition: background var(--motion-base), color var(--motion-base);
}
.sidebar-nav a i { width: 16px; text-align: center; color: var(--text-dim); font-size: 14px; }
.sidebar-nav a:hover {
  background: var(--surface-2); color: var(--text);
}
.sidebar-nav a:hover i { color: var(--accent); }
.sidebar-nav a.active {
  background: #eef2ff; color: var(--primary);
}
.sidebar-nav a.active i { color: var(--primary); }
.sidebar-footer {
  padding: 14px 18px; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  font-size: var(--fs-xs); color: var(--text-muted);
}

.app-main {
  min-width: 0;
  display: flex; flex-direction: column;
}
.app-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 30;
}
.app-topbar .topbar-title {
  font-size: var(--fs-md); font-weight: 600; color: var(--text);
}
.app-topbar .spacer { flex: 1; }
.app-content {
  padding: 28px;
  flex: 1;
}

/* Mobile menu toggle (shown only on small screens) */
.menu-toggle {
  display: none;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer;
  align-items: center; justify-content: center;
}

@media (max-width: 960px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform var(--motion-slow);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: inline-flex; }
  .app-content { padding: 20px; }
}

/* ------------------------------------------------------------ Tables (Django ModelAdmin-like) */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden;
}
table.kazi-table {
  width: 100%; border-collapse: collapse;
}
table.kazi-table th,
table.kazi-table td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-base);
}
table.kazi-table th {
  background: var(--surface-2);
  font-weight: 600; color: var(--text-muted);
  font-size: var(--fs-sm); letter-spacing: 0.3px;
}
table.kazi-table tr:last-child td { border-bottom: none; }
table.kazi-table tbody tr:hover { background: var(--bg); }

@media (max-width: 640px) {
  table.kazi-table thead { display: none; }
  table.kazi-table,
  table.kazi-table tbody,
  table.kazi-table tr,
  table.kazi-table td { display: block; width: 100%; }
  table.kazi-table tr {
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }
  table.kazi-table td {
    border: none; padding: 6px 16px;
    display: flex; justify-content: space-between; gap: 16px;
  }
  table.kazi-table td::before {
    content: attr(data-label);
    color: var(--text-muted); font-weight: 600; font-size: var(--fs-sm);
  }
}

/* ------------------------------------------------------------ Generic .table (module list views)
   Most module list templates use the generic `.table` class instead of `.kazi-table`.
   We give them the same baseline styling and the same 640px card-collapse treatment so
   accounting/inventory/finance/hr/payroll/sales tables render properly on mobile.
   If a row is wrapped in an .table-responsive ancestor it falls back to horizontal
   scroll instead of stacking. */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
table.table {
  width: 100%; border-collapse: collapse;
}
table.table th,
table.table td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-base);
  vertical-align: top;
}
table.table th {
  background: var(--surface-2);
  font-weight: 600; color: var(--text-muted);
  font-size: var(--fs-sm); letter-spacing: 0.3px;
}
table.table tr:last-child td { border-bottom: none; }
table.table tbody tr:hover { background: var(--bg); }

/* .table.key-value — labelled rows where each <tr> has one <th> (label) and one <td> (value).
   The header column is sized once at desktop so labels don't take half the table; on mobile
   the standard responsive rule below stacks them. */
table.table.key-value th {
  width: 220px;
  background: transparent;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 640px) {
  /* 1. Default behaviour for any .table at <=640px: stack rows into a card layout
     (same trick as .kazi-table). Cells without a data-label render flush-left. */
  table.table thead { display: none; }
  table.table,
  table.table tbody,
  table.table tr,
  table.table th,
  table.table td { display: block; width: 100%; }
  table.table tr {
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
  }
  table.table th {
    background: transparent;
    border: none;
    padding: 8px 16px 2px;
    color: var(--text-muted);
    font-size: var(--fs-sm);
  }
  table.table td {
    border: none; padding: 6px 16px;
  }
  /* Cells that opt in with data-label get the label/value split. */
  table.table td[data-label] {
    display: flex; justify-content: space-between; gap: 16px;
    text-align: right;
  }
  table.table td[data-label]::before {
    content: attr(data-label);
    color: var(--text-muted); font-weight: 600; font-size: var(--fs-sm);
    text-align: left;
  }

  /* 2. Override: when wrapped in .table-responsive, restore native table layout
     and let the wrapper handle horizontal scroll. Use higher specificity so this
     beats the rules above without resorting to :not() with combinators. */
  .table-responsive { width: 100%; }
  .table-responsive table.table { min-width: 640px; display: table; }
  .table-responsive table.table thead { display: table-header-group; }
  .table-responsive table.table tbody { display: table-row-group; }
  .table-responsive table.table tr { display: table-row; padding: 0; border-bottom: none; }
  .table-responsive table.table th,
  .table-responsive table.table td {
    display: table-cell; width: auto;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
  }
  .table-responsive table.table th {
    background: var(--surface-2); color: var(--text-muted); font-size: var(--fs-sm);
  }
  .table-responsive table.table td[data-label] {
    display: table-cell; text-align: left;
  }
  .table-responsive table.table td[data-label]::before { content: none; }
}

/* ------------------------------------------------------------ Form grid
   Used by module config and CRUD pages. Defaults to a 2-column auto-fit
   that gracefully collapses to a single column on phones. Variants let
   callers force 3-column or single-column layouts. */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.form-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.form-grid .full   { grid-column: 1 / -1; }

@media (max-width: 768px) {
  .form-grid,
  .form-grid.cols-2,
  .form-grid.cols-3,
  .form-grid.cols-4 { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------ Dashboard grid helper
   Reusable responsive row for dashboard tiles/cards. Replaces hand-rolled
   `grid-template-columns: 1fr 1fr 1fr` blocks in module dashboards. */
.dash-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

/* Make chart containers behave on narrow screens — anything declared with
   inline `height: NNNpx` still respects max-width and wraps cleanly. */
.chart-container,
.chart-wrap {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}
.chart-container canvas,
.chart-wrap canvas { max-width: 100% !important; }

@media (max-width: 640px) {
  .chart-container,
  .chart-wrap { min-height: 220px; }
}

/* ------------------------------------------------------------ Inline-grid mobile safety net
   Many legacy module pages set `display: grid; grid-template-columns: ...` inline
   without media queries (form rows, detail-page sidebars, line-item tables, etc.).
   These rules force such grids to collapse on small screens so content doesn't get
   crushed. Auto-fit / auto-fill grids are excluded — they're already responsive.
   Any element can opt out by adding the class `keep-grid` to itself. */

/* 1) Sidebar-style 2-col layouts (e.g. detail page main + sidebar) collapse below
      960px, the same breakpoint at which the app shell sidebar collapses. */
@media (max-width: 960px) {
  [style*="grid-template-columns: 2fr 1fr"]:not(.keep-grid),
  [style*="grid-template-columns: 1fr 2fr"]:not(.keep-grid),
  [style*="grid-template-columns: 1fr 380px"]:not(.keep-grid),
  [style*="grid-template-columns:2fr 1fr"]:not(.keep-grid),
  [style*="grid-template-columns:1fr 2fr"]:not(.keep-grid) {
    grid-template-columns: 1fr !important;
  }
}

/* 2) Catch-all for any remaining inline `display: grid` block on tablet/phone.
      Excludes auto-fit / auto-fill (which scale naturally) and the .keep-grid
      opt-out. Below 768px every fixed-track inline grid stacks to one column. */
@media (max-width: 768px) {
  [style*="display: grid"]:not([style*="auto-fit"]):not([style*="auto-fill"]):not(.keep-grid),
  [style*="display:grid"]:not([style*="auto-fit"]):not([style*="auto-fill"]):not(.keep-grid) {
    grid-template-columns: 1fr !important;
  }
}

/* ------------------------------------------------------------ Page header (section) */
.page-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 24px; flex-wrap: wrap;
}
.page-header h2 { font-size: var(--fs-2xl); font-weight: 700; }
.page-header .sub { color: var(--text-muted); margin-top: 4px; font-size: var(--fs-base); }

/* ------------------------------------------------------------ Footer */
.site-footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 48px 28px 24px;
  margin-top: auto;
}
.site-footer .footer-inner {
  max-width: var(--container-max); margin: 0 auto;
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: 32px;
}
.site-footer h4 {
  color: #f1f5f9; font-size: var(--fs-sm); font-weight: 600;
  letter-spacing: 0.8px; text-transform: uppercase; margin: 0 0 14px;
}
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li { margin: 8px 0; }
.site-footer a {
  color: #94a3b8; text-decoration: none; font-size: var(--fs-sm);
}
.site-footer a:hover { color: #fff; }
.site-footer .brand-col p { font-size: var(--fs-sm); margin-top: 10px; max-width: 280px; line-height: 1.6; }
.site-footer .brand-col .brand {
  font-size: 20px; font-weight: 700; color: #fff;
}
.site-footer .brand-col .brand .dot { color: var(--accent); }
.site-footer .socials {
  display: flex; gap: 8px; margin-top: 14px;
}
.site-footer .socials a {
  width: 34px; height: 34px; border-radius: 50%;
  background: rgba(255,255,255,0.06);
  display: inline-flex; align-items: center; justify-content: center;
  color: #cbd5e1;
}
.site-footer .socials a:hover { background: var(--accent); color: #fff; }
.site-footer .bottom {
  max-width: var(--container-max); margin: 36px auto 0;
  padding-top: 18px; border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  font-size: var(--fs-xs);
}
@media (max-width: 780px) {
  .site-footer .footer-inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .site-footer .footer-inner { grid-template-columns: 1fr; }
  .site-footer .bottom { justify-content: center; text-align: center; }
}

/* ------------------------------------------------------------ Utility */
.text-muted { color: var(--text-muted); }
.text-dim   { color: var(--text-dim); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger  { color: var(--danger); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; } .gap-2 { gap: 16px; } .gap-3 { gap: 24px; }
.hidden { display: none !important; }

.mono { font-family: var(--font-mono); font-size: 0.92em; }

/* ------------------------------------------------------------ Assistant popup (preserves legacy structure) */
.assistant-launcher {
  position: fixed; bottom: 20px; right: 20px; z-index: 90;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary);
  color: #fff; border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-lg);
  transition: transform var(--motion-base), background var(--motion-base);
}
.assistant-launcher:hover {
  background: var(--primary-600);
  transform: translateY(-2px);
}
.assistant-popup {
  position: fixed; bottom: 92px; right: 20px; z-index: 95;
  width: 380px; max-width: calc(100vw - 40px);
  max-height: 620px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: none; flex-direction: column; overflow: hidden;
}
.assistant-popup.open { display: flex; }
.assistant-popup .ap-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
}
.assistant-popup .ap-header .title { font-weight: 600; font-size: var(--fs-base); }
.assistant-popup .ap-header .spacer { flex: 1; }
.assistant-popup .ap-header button {
  background: rgba(255,255,255,0.12); color: #fff; border: none;
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: var(--fs-xs);
}
.assistant-popup .ap-body {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
  background: var(--bg);
}
.assistant-popup .ap-msg {
  padding: 10px 12px; border-radius: 12px; font-size: var(--fs-base);
  max-width: 85%;
  line-height: 1.45;
}
.assistant-popup .ap-msg.user {
  align-self: flex-end;
  background: var(--primary); color: #fff;
  border-bottom-right-radius: 4px;
}
.assistant-popup .ap-msg.assistant {
  align-self: flex-start;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.assistant-popup .ap-footer {
  padding: 10px 12px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; background: var(--surface);
}
.assistant-popup .ap-footer input {
  flex: 1; padding: 9px 12px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  font-size: var(--fs-base); font-family: inherit;
}
.assistant-popup .ap-footer input:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--focus-ring);
}
.assistant-popup .ap-footer button {
  padding: 9px 14px; border-radius: 10px;
  background: var(--primary); color: #fff; border: none; cursor: pointer;
  font-weight: 500;
}
.assistant-popup .ap-footer button:hover { background: var(--primary-600); }
.assistant-popup .ap-chats {
  display: flex; flex-direction: column; gap: 6px;
}
.assistant-popup .ap-chat-item {
  padding: 10px 12px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border);
  cursor: pointer; font-size: var(--fs-sm);
  display: flex; justify-content: space-between; gap: 10px;
}
.assistant-popup .ap-chat-item:hover { background: var(--surface-2); }
.assistant-popup .ap-chat-item .when { color: var(--text-muted); font-size: var(--fs-xs); }

/* ------------------------------------------------------------ Mockup note (dev banner) */
.mockup-note {
  max-width: var(--container-max); margin: 0 auto; padding: 10px 28px;
  font-size: var(--fs-xs); color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px dashed var(--border);
}
.mockup-note i { color: var(--accent); }
