/* ============================================================================
   Complio design system
   ----------------------------------------------------------------------------
   Adapted from the house UX/UI guide (uxui.md). The guide describes a
   token-driven system with a shared component vocabulary; this file is that
   system, using Complio's own palette rather than the reference product's
   orange-and-dark-slate identity.

   Two rules for anyone extending this:
     * Never hardcode a colour in a new screen. Use a token.
     * Never invent a component style that already exists here.

   Loaded on every page, before each page's own <style> block, so a page can
   still override where it genuinely must.
   ========================================================================= */

:root {
  /* --- surfaces and ink ------------------------------------------------- */
  --bg:            #f1f5f9;   /* page background */
  --surface:       #ffffff;   /* cards, dialogs, inputs */
  --surface-2:     #f8fafc;   /* subtle fills, table headers, hover */
  --surface-3:     #f1f5f9;   /* chips, inactive pills */

  --ink:           #0f172a;   /* primary text */
  --ink-strong:    #1e293b;   /* table primary values */
  --ink-soft:      #475569;   /* secondary text */
  --ink-mute:      #64748b;   /* hints, labels */
  --ink-faint:     #94a3b8;   /* counts, empty states, placeholders */
  --ink-ghost:     #cbd5e1;   /* disabled, dividers in text */

  --border:        #e2e8f0;   /* hairline borders */
  --border-strong: #cbd5e1;   /* input borders, emphasised dividers */

  /* --- brand ------------------------------------------------------------
     --accent is overwritten at runtime by Theme.apply() from the user's
     Appearance preference, so anything built on it follows that choice. */
  --accent:        #6366f1;
  --accent-hover:  #4f46e5;
  --accent-soft:   #eef2ff;
  --accent-border: #c7d2fe;

  /* --- status ----------------------------------------------------------- */
  --good:          #16a34a;  --good-soft:   #f0fdf4;  --good-border:   #bbf7d0;
  --warn:          #d97706;  --warn-soft:   #fffbeb;  --warn-border:   #fde68a;
  --danger:        #dc2626;  --danger-soft: #fef2f2;  --danger-border: #fecaca;
  --info:          #2563eb;  --info-soft:   #f0f9ff;  --info-border:   #bae6fd;

  /* --- shape and motion -------------------------------------------------- */
  --radius-sm: 7px;
  --radius:    10px;
  --radius-lg: 14px;
  --shadow-card:  0 1px 2px rgba(15, 23, 42, .04);
  --shadow-pop:   0 12px 32px rgba(15, 23, 42, .14);
  --shadow-modal: 0 24px 64px rgba(15, 23, 42, .24);

  /* --- type -------------------------------------------------------------- */
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Appearance → density/font-size sets this; layout that wants to respond
     multiplies against it rather than hardcoding pixel steps. */
  --ui-scale: 1;
}

/* ============================================================================
   Base
   ========================================================================= */
body {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  background: var(--bg);
  color: var(--ink);
}

/* Numbers compared down a column line up. */
.tnum, .data-table td.num, .data-table th.num { font-variant-numeric: tabular-nums; }

/* Identifiers, codes and MACs. */
.mono, .data-table .mono { font-family: var(--font-mono); font-size: 12px; }

/* ============================================================================
   Page anatomy  (guide §4)
   ========================================================================= */
.rp-panel        { padding: 28px 36px 48px; max-width: 1280px; }
.rp-panel--wide  { max-width: none; }

.panel-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.breadcrumb    { font-size: 12px; color: var(--ink-faint); margin-bottom: 3px; }
.breadcrumb strong { color: var(--ink-soft); font-weight: 700; }
.panel-title   { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
.panel-actions { display: flex; gap: 8px; flex-shrink: 0; margin-top: 6px; }

.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 22px;
}
.section-card--flush { padding: 0; }          /* tables run edge to edge */
.section-title { font-size: 15px; font-weight: 700; color: var(--ink-strong); }

/* Load-failure banner (guide §9) — the screen still renders behind it. */
.lg-error {
  background: var(--danger-soft); border: 1px solid var(--danger-border);
  color: #991b1b; border-radius: var(--radius);
  padding: 10px 14px; font-size: 13px; margin-bottom: 16px;
}

/* ============================================================================
   Toolbar  (guide §5)
   ========================================================================= */
.rp-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.rp-search { position: relative; flex: 1 1 260px; max-width: 420px; }
.rp-search input {
  width: 100%; padding: 8px 12px 8px 32px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-size: 13px; outline: none;
  font-family: inherit;
}
.rp-search input:focus { border-color: var(--accent); }
.rp-search .rp-search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--ink-faint); font-size: 13px; pointer-events: none;
}
.rp-count { margin-left: auto; font-size: 12px; color: var(--ink-faint); }

/* Filter chips */
.trb-chip {
  padding: 6px 13px; border-radius: 20px; font-size: 12px; font-weight: 600;
  background: var(--surface); color: var(--ink-soft);
  border: 1px solid var(--border); cursor: pointer; font-family: inherit;
}
.trb-chip:hover { border-color: var(--accent); color: var(--accent); }
.trb-chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Segmented toggle */
.rp-segment {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 8px;
}
.rp-segment button {
  padding: 5px 12px; border: none; background: transparent; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--ink-soft);
  border-radius: 6px; font-family: inherit;
}
.rp-segment button.on { background: var(--accent); color: #fff; }

/* ============================================================================
   Tables  (guide §6)
   ========================================================================= */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 11px 16px;
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-faint); background: var(--surface-2);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--accent); }
.data-table th.on { color: var(--accent); background: var(--accent-soft); }
.data-table td {
  padding: 12px 16px; font-size: 13px; color: var(--ink-soft);
  border-bottom: 1px solid #f1f5f9;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table td.primary { font-weight: 600; color: var(--ink-strong); }
.data-table .sub { font-size: 11px; color: var(--ink-faint); margin-top: 2px; }
.data-table tr.inactive { opacity: 0.55; }
.data-table td.actions { text-align: right; white-space: nowrap; }
.data-table td.empty {
  text-align: center; padding: 24px; color: var(--ink-faint); font-size: 13px;
}

/* ============================================================================
   Status pills  (guide §6)
   ========================================================================= */
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 3px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  white-space: nowrap;
}
.pill.ok     { background: var(--good-soft);   color: var(--good);   border: 1px solid var(--good-border); }
.pill.warn   { background: var(--warn-soft);   color: var(--warn);   border: 1px solid var(--warn-border); }
.pill.danger { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger-border); }
.pill.info   { background: var(--info-soft);   color: var(--info);   border: 1px solid var(--info-border); }
.pill.accent { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-border); }
.pill.muted  { background: var(--surface-3);   color: var(--ink-mute); border: 1px solid var(--border); }

/* ============================================================================
   Buttons  (guide §7)
   ========================================================================= */
.rp-btn-primary, .rp-btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  border-radius: var(--radius-sm); cursor: pointer; font-family: inherit;
  white-space: nowrap;
}
.rp-btn-primary {
  padding: 8px 18px; border: none; background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 600;
}
.rp-btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.rp-btn-primary:disabled { opacity: .45; cursor: default; }

.rp-btn-ghost {
  padding: 8px 16px; border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-soft); font-size: 12.5px; font-weight: 600;
}
.rp-btn-ghost:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.rp-btn-ghost:disabled { opacity: .45; cursor: default; }
.rp-btn-ghost.danger { border-color: var(--danger-border); color: var(--danger); }
.rp-btn-ghost.danger:hover:not(:disabled) { background: var(--danger-soft); }

.rp-icon-btn {
  width: 30px; height: 30px; padding: 0; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; cursor: pointer;
}
.rp-icon-btn:hover  { background: var(--surface-2); }
.rp-icon-btn.danger { border-color: var(--danger-border); }

/* ============================================================================
   Forms and dialogs  (guide §8)
   ========================================================================= */
.rp-field { margin-bottom: 14px; }
.rp-field label {
  display: block; font-size: 11px; font-weight: 600; color: var(--ink-mute);
  margin-bottom: 5px; letter-spacing: .02em;
}
.rp-field .req { color: var(--danger); }
.rp-field input, .rp-field select, .rp-field textarea {
  width: 100%; padding: 8px 12px; font-size: 13px; font-family: inherit;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); outline: none;
}
.rp-field input:focus, .rp-field select:focus, .rp-field textarea:focus {
  border-color: var(--accent);
}
.rp-field .hint  { font-size: 11px; color: var(--ink-faint); margin-top: 4px; }
.rp-field .error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.rp-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.wiz-overlay {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.wiz {
  background: var(--surface); border-radius: var(--radius-lg); padding: 24px;
  width: 460px; max-width: 100%; box-shadow: var(--shadow-modal);
  animation: complioConfirmIn .16s ease;
}
.wiz-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.wiz-title  { font-size: 16px; font-weight: 700; color: var(--ink); }
.wiz-sub    { font-size: 12px; color: var(--ink-faint); margin-top: 2px; }
.wiz-body   { margin-top: 14px; }
.wiz-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ============================================================================
   Empty and loading states  (guide §6)
   ========================================================================= */
.rp-empty {
  padding: 40px; text-align: center; color: var(--ink-faint); font-size: 13px;
}
.rp-empty .rp-empty-icon { font-size: 32px; display: block; margin-bottom: 10px; }
.rp-empty .rp-empty-title { font-size: 14px; font-weight: 600; color: var(--ink-mute); }

/* ============================================================================
   Dark theme
   ----------------------------------------------------------------------------
   Only the tokens change. Any surface built from tokens follows automatically;
   the older screens still carry inline hex and are handled separately by
   Theme.apply(). Every new screen built on this file needs nothing here.
   ========================================================================= */
:root[data-theme="dark"] {
  --bg:            #0f172a;
  --surface:       #1e293b;
  --surface-2:     #263449;
  --surface-3:     #334155;

  --ink:           #f1f5f9;
  --ink-strong:    #e2e8f0;
  --ink-soft:      #cbd5e1;
  --ink-mute:      #94a3b8;
  --ink-faint:     #64748b;
  --ink-ghost:     #475569;

  --border:        #334155;
  --border-strong: #475569;

  --accent-soft:   #312e81;
  --accent-border: #4338ca;

  /* The status bases are lifted a step on dark surfaces: the light-mode
     values are mid-tones chosen against white and go muddy on #0f172a. */
  --good:   #34d399;  --good-soft:   #052e16;  --good-border:   #166534;
  --warn:   #fbbf24;  --warn-soft:   #2c1a05;  --warn-border:   #92400e;
  --danger: #f87171;  --danger-soft: #300f0f;  --danger-border: #991b1b;
  --info:   #38bdf8;  --info-soft:   #0c1e3d;  --info-border:   #1e40af;

  --shadow-card:  0 1px 2px rgba(0, 0, 0, .3);
  --shadow-pop:   0 12px 32px rgba(0, 0, 0, .45);
  --shadow-modal: 0 24px 64px rgba(0, 0, 0, .55);
}
