/* AI Commander — dashboard-specific styles.
   Reuses shared.css (nav, footer, buttons, vars) and borrows the
   .docs-wrap / sidebar / content patterns from /docs and /howto. */

/* ── Docs-style layout (shared with /docs, /howto) ── */
.docs-wrap {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 0 4rem;
  max-width: 1000px;
  margin: 0 auto;
  padding: 3.5rem 2rem 5rem;
  align-items: start;
}
.docs-sidebar { position: sticky; top: 78px; }
.docs-sidebar-label {
  font-size: 0.68rem; font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--subtle); margin-bottom: 0.65rem;
}
.docs-toc { list-style: none; }
.docs-toc li + li { margin-top: 0.1rem; }
.docs-toc a {
  display: block; font-size: 0.825rem; color: var(--muted); text-decoration: none;
  padding: 0.28rem 0 0.28rem 0.8rem; border-left: 2px solid var(--border);
  line-height: 1.4; transition: color 0.1s, border-color 0.1s;
}
.docs-toc a:hover { color: var(--text); border-left-color: #9ca3af; }
.docs-toc a.toc-active { color: var(--text); font-weight: 600; border-left-color: var(--text); }

.docs-content { min-width: 0; }
.docs-content h1 {
  font-size: clamp(1.9rem, 4vw, 2.6rem); font-weight: 700;
  letter-spacing: -0.04em; line-height: 1.1; margin-bottom: 0.6rem;
}
.docs-lede {
  font-size: 1.05rem; color: var(--muted); line-height: 1.65;
  margin-bottom: 2.5rem; max-width: 560px;
}
.docs-content h2 {
  font-size: 1.3rem; font-weight: 700; letter-spacing: -0.025em;
  margin: 3rem 0 0.6rem; padding-top: 3rem;
  border-top: 1px solid var(--border); scroll-margin-top: 80px;
}
.docs-content h2:first-of-type { margin-top: 0; padding-top: 0; border-top: none; }
.docs-content > p {
  font-size: 0.9375rem; color: var(--muted); line-height: 1.75; margin-bottom: 1.1rem;
}
.docs-content strong { color: var(--text); font-weight: 600; }
.docs-content a { color: var(--text); text-underline-offset: 3px; }
.docs-content a:hover { opacity: 0.7; }
.docs-content code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 0.82em;
  background: #f3f4f6; padding: 0.12em 0.42em; border-radius: 4px; color: var(--text);
}

.mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ── Boot veil / spinner ── */
.boot-veil {
  position: fixed; inset: 58px 0 0 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); z-index: 50;
}
/* The explicit display above otherwise wins over the `hidden` attribute (author
   CSS beats the UA [hidden] rule), so boot()'s `veil.hidden = true` would leave
   the spinner stuck on screen with the dashboard loaded behind it. */
.boot-veil[hidden] { display: none; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--text);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Auth (login) ── */
.auth-wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: 4.5rem 1.5rem 5rem;
}
.auth-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2.25rem 2rem;
  background: #fff;
}
.auth-card h1 {
  font-size: 1.55rem; font-weight: 700; letter-spacing: -0.03em; margin-bottom: 0.55rem;
}
.auth-lede {
  font-size: 0.9rem; color: var(--muted); line-height: 1.6; margin-bottom: 1.5rem;
}
.auth-lede strong { color: var(--text); font-weight: 600; }
.auth-foot {
  font-size: 0.8rem; color: var(--subtle); line-height: 1.55; margin-top: 1.25rem;
}
.auth-foot a { color: var(--muted); text-underline-offset: 2px; }
.auth-foot a:hover { color: var(--text); }
.auth-icon {
  width: 46px; height: 46px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-bg); color: var(--accent);
  border: 1px solid var(--accent-border); margin-bottom: 1.25rem;
}

/* ── Form fields ── */
.field-label {
  display: block; font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.02em; color: var(--text); margin-bottom: 0.35rem;
}
.field-input {
  width: 100%;
  font-family: inherit; font-size: 0.9rem; color: var(--text);
  background: #fff; border: 1.5px solid var(--border); border-radius: 8px;
  padding: 0.6rem 0.75rem; transition: border-color 0.12s, box-shadow 0.12s;
}
.field-input::placeholder { color: var(--subtle); }
.field-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.field-input.mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 0.84rem; }
.field-input-sm { padding: 0.4rem 0.55rem; font-size: 0.84rem; }

/* Fixed, non-removable "aic-" prefix glued to an alias input. The wrapper owns
   the border + focus ring; the inner input is borderless so the tag and the
   typed suffix read as a single identifier. */
.input-prefix {
  display: inline-flex; align-items: stretch; width: 100%; min-width: 160px;
  background: #fff; border: 1.5px solid var(--border); border-radius: 8px;
  overflow: hidden; transition: border-color 0.12s, box-shadow 0.12s;
}
.input-prefix:focus-within {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg);
}
.input-prefix-tag {
  display: inline-flex; align-items: center;
  padding: 0 0.1rem 0 0.75rem; color: var(--muted);
  font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 0.84rem;
  user-select: none; white-space: nowrap;
}
.input-prefix .field-input {
  border: none; border-radius: 0; box-shadow: none; min-width: 0; flex: 1;
  background: transparent; padding-left: 0;
  font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 0.84rem;
}
.input-prefix .field-input:focus { box-shadow: none; border-color: transparent; }

.field-error {
  font-size: 0.82rem; color: var(--term-red); margin: 0.5rem 0 0; line-height: 1.5;
}

.btn-block { width: 100%; justify-content: center; margin-top: 1rem; padding: 0.6rem 1rem; }
.btn:disabled { opacity: 0.6; cursor: default; }

.link-btn {
  background: none; border: none; padding: 0; font: inherit; cursor: pointer;
  color: var(--accent); text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { opacity: 0.8; }

/* ── Inline add forms (machines / keys) ── */
.inline-form {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem;
  margin: 0.5rem 0 0.4rem;
}
.inline-field { display: flex; flex-direction: column; }
.inline-field-grow { flex: 1; min-width: 200px; }
.inline-form .field-input { min-width: 160px; }
.inline-form .btn { margin-bottom: 1px; }

/* ── Data tables (machines / keys) ── */
.table-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
  margin: 1rem 0 1.25rem;
  -webkit-overflow-scrolling: touch;
}
.data-table {
  width: 100%; border-collapse: collapse; background: #fff; font-size: 0.875rem;
}
.data-table thead th {
  padding: 0.7rem 1.1rem; text-align: left;
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); background: var(--surface);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td {
  padding: 0.75rem 1.1rem; border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table .cell-muted { color: var(--muted); white-space: nowrap; }
.data-table .cell-alias { font-weight: 600; }
.col-actions { text-align: right; white-space: nowrap; width: 1%; }

.row-empty td {
  color: var(--muted); font-size: 0.875rem; text-align: center;
  padding: 1.5rem 1.1rem; font-weight: 400;
}
.row-error td { color: var(--term-red); }

/* ── Status pills ── */
.status-pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.78rem; font-weight: 600;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.status-online { color: #16a34a; }
.status-online .status-dot { background: #16a34a; }
.status-linked { color: #d97706; }
.status-linked .status-dot { background: #d97706; }
.status-offline { color: var(--subtle); }
.status-offline .status-dot { background: var(--subtle); }
.status-noaccess { color: #dc2626; }
.status-noaccess .status-dot { background: #dc2626; }

/* Note shown under the machines table when one is awaiting operator approval. */
.machines-note {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.55;
  margin: 0.75rem 0 0;
  padding: 0.7rem 0.9rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
}
.machines-note strong { color: #b91c1c; }

/* ── Row action buttons ── */
.row-btn {
  background: none; border: 1px solid var(--border); border-radius: 6px;
  font-family: inherit; font-size: 0.78rem; font-weight: 500; color: var(--text);
  padding: 0.28rem 0.6rem; cursor: pointer; transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.row-btn + .row-btn { margin-left: 0.4rem; }
.row-btn:hover { border-color: #9ca3af; background: var(--surface); }
.row-btn-danger { color: var(--term-red); }
.row-btn-danger:hover { border-color: var(--term-red); background: #fef2f2; }

/* ── Inline rename ── */
.rename-form { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.rename-form .field-input { min-width: 140px; }
.inline-note { font-size: 0.78rem; margin-top: 0.35rem; }
.inline-note-error { color: var(--term-red); }

/* ── API key prefix ── */
.key-prefix {
  font-size: 0.82rem; background: #f3f4f6; padding: 0.15em 0.5em;
  border-radius: 5px; color: var(--text);
}

/* ── One-time key reveal box ── */
.reveal-box {
  border: 1px solid var(--accent-border);
  background: var(--accent-bg);
  border-radius: 11px;
  padding: 1rem 1.1rem;
  margin: 0.75rem 0 1.25rem;
}
.reveal-warn {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.85rem; color: var(--text); margin-bottom: 0.75rem;
}
.reveal-warn svg { color: var(--accent); flex-shrink: 0; }
.reveal-warn strong { color: var(--accent); }
.reveal-row {
  display: flex; align-items: stretch; gap: 0.5rem; margin-bottom: 0.6rem;
}
.reveal-key {
  flex: 1; min-width: 0;
  background: #fff; border: 1px solid var(--accent-border); border-radius: 7px;
  padding: 0.55rem 0.7rem; font-size: 0.82rem; color: var(--text);
  overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch;
  display: flex; align-items: center;
}
.copy-pill {
  flex-shrink: 0;
  background: var(--text); color: #fff; border: none; border-radius: 7px;
  font-family: inherit; font-size: 0.8rem; font-weight: 600;
  padding: 0 0.85rem; cursor: pointer; transition: background 0.12s;
}
.copy-pill:hover { background: #2a2a2a; }
.reveal-box .link-btn { font-size: 0.8rem; color: var(--muted); }
.reveal-box .link-btn:hover { color: var(--text); }

/* ── Key access window (daily re-activation) ── */
.reactivate-card {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 11px;
  background: var(--surface);
  padding: 0.75rem 1rem; margin: 0.75rem 0 1.25rem;
}
.reactivate-main {
  display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; min-width: 0;
}
.reactivate-detail { font-size: 0.82rem; color: var(--muted); }
.reactivate-card .btn-outline { flex-shrink: 0; }

/* ── Re-activation toggle (account settings) ── */
.account-row-toggle { align-items: flex-start; }
.reactivate-toggle {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.85rem; color: var(--text); cursor: pointer;
}
.reactivate-toggle input { cursor: pointer; }
.account-risk {
  font-size: 0.82rem; color: var(--term-red);
  margin: 0.4rem 0 0; padding: 0 1.1rem 0.85rem;
}
.account-risk strong { color: var(--term-red); }

/* ── Account card ── */
.account-card {
  border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-top: 1rem;
}
.account-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.85rem 1.1rem; border-bottom: 1px solid var(--border);
}
.account-row:last-child { border-bottom: none; }
.account-label {
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted);
}
.account-value { font-size: 0.9rem; color: var(--text); font-weight: 500; }
.account-links { display: flex; gap: 1.1rem; align-items: center; flex-wrap: wrap; }
.account-links a {
  font-size: 0.85rem; color: var(--text); text-decoration: underline; text-underline-offset: 3px;
}
.account-links a:hover { opacity: 0.7; }
.account-feedback-btn {
  background: none; border: none; padding: 0; font: inherit; font-size: 0.85rem;
  color: var(--text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.account-feedback-btn:hover { opacity: 0.7; }
.plan-badge {
  display: inline-flex; align-items: center;
  font-size: 0.74rem; font-weight: 600; letter-spacing: 0.02em;
  padding: 0.2rem 0.65rem; border-radius: 100px;
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
}
.plan-badge[data-plan="pro"],
.plan-badge[data-plan="team"] {
  background: var(--accent-bg); color: var(--accent); border-color: var(--accent-border);
}

/* ── Passkeys ── */
.section-lede {
  font-size: 0.9375rem; color: var(--muted); line-height: 1.7; margin: 0 0 1rem;
}
.passkey-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-bottom: 1rem;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 1.25rem;
  background: rgba(15, 18, 24, 0.55); backdrop-filter: blur(2px);
}
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: var(--card, #fff); border: 1px solid var(--border); border-radius: 14px;
  max-width: 26rem; width: 100%; padding: 1.5rem 1.6rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.modal-card h3 { margin: 0 0 0.6rem; font-size: 1.15rem; color: var(--text); }
.modal-card p { font-size: 0.9rem; color: var(--muted); line-height: 1.6; margin: 0 0 0.85rem; }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.25rem;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .docs-wrap { grid-template-columns: 1fr; padding: 2rem 1.25rem 4rem; }
  .docs-sidebar { display: none; }
  .docs-content h2 { padding-top: 2rem; margin-top: 2rem; }
  .inline-form { flex-direction: column; align-items: stretch; }
  .inline-form .field-input { width: 100%; }
  .inline-form .btn { width: 100%; justify-content: center; }
  .auth-wrap { padding: 2.5rem 1.25rem 4rem; }
}
