/* CMS mock admin chrome — site style.css handles preview sections */
:root {
  --cms-bg: #0f1724;
  --cms-panel: #161f2e;
  --cms-border: #243044;
  --cms-text: #e8eef7;
  --cms-muted: #8fa0b8;
  --cms-accent: #2f9e6b;
  --cms-accent-2: #3b82c4;
  --cms-danger: #d45656;
  --cms-warn: #c9a227;
  --cms-radius: 10px;
  --cms-font: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--cms-bg);
  color: var(--cms-text);
  font-family: var(--cms-font);
}

.cms-app { min-height: 100vh; display: flex; flex-direction: column; }

.cms-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--cms-border);
  background: var(--cms-panel);
  position: sticky;
  top: 0;
  z-index: 20;
}

.cms-brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--cms-text);
  text-decoration: none;
  white-space: nowrap;
}

.cms-brand span { color: var(--cms-accent); }

.cms-nav {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}

.cms-nav button, .cms-btn {
  appearance: none;
  border: 1px solid var(--cms-border);
  background: transparent;
  color: var(--cms-text);
  padding: 8px 12px;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.cms-nav button.active, .cms-btn.primary {
  background: var(--cms-accent);
  border-color: var(--cms-accent);
  color: #fff;
}

.cms-btn:disabled, .cms-nav button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.cms-btn.danger { border-color: var(--cms-danger); color: #ffb4b4; }
.cms-btn.ghost { border-color: transparent; color: var(--cms-muted); }

.cms-session {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--cms-muted);
  white-space: nowrap;
}

.cms-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: #243044;
  color: var(--cms-muted);
}

.cms-badge.admin { background: rgba(47, 158, 107, 0.2); color: #7ddea8; }
.cms-badge.user { background: rgba(59, 130, 196, 0.2); color: #9bc4ea; }

.cms-body {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 0;
}

/* style.css / .cms-body display:grid would otherwise ignore the hidden attribute */
.cms-body[hidden],
#cms-workspace[hidden],
.cms-login[hidden],
#cms-login-view[hidden],
#cms-set-password-view[hidden] {
  display: none !important;
}

body.cms-auth-page .cms-nav,
body.cms-auth-page #btn-logout,
body.cms-auth-page #btn-reset,
body.cms-auth-page #btn-change-password,
body.cms-auth-page #btn-totp,
body.cms-auth-page #cms-session {
  display: none !important;
}

.cms-side {
  border-right: 1px solid var(--cms-border);
  background: #121a27;
  padding: 16px;
  overflow: auto;
}

.cms-main {
  padding: 20px 24px 48px;
  overflow: auto;
}

.cms-h1 { margin: 0 0 6px; font-size: 22px; }
.cms-sub { margin: 0 0 20px; color: var(--cms-muted); font-size: 14px; }

.cms-flash {
  position: fixed;
  top: 64px;
  right: 20px;
  z-index: 40;
  max-width: 420px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  display: none;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.cms-flash.show { display: block; }
.cms-flash.ok { background: rgba(47, 158, 107, 0.15); color: #9ee0bd; }
.cms-flash.err { background: rgba(212, 86, 86, 0.15); color: #ffb4b4; }
.cms-flash.warn { background: rgba(201, 162, 39, 0.15); color: #f0d878; }

.cms-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.cms-list-item {
  border: 1px solid var(--cms-border);
  border-radius: var(--cms-radius);
  padding: 10px 12px;
  background: var(--cms-panel);
  cursor: pointer;
}

.cms-list-item:hover, .cms-list-item.active {
  border-color: var(--cms-accent);
}

.cms-list-item .meta {
  font-size: 12px;
  color: var(--cms-muted);
  margin-top: 4px;
}

.cms-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.cms-side-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.cms-side-filters .cms-field {
  margin: 0;
}

.cms-side-filters label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--cms-muted);
}

.cms-side-filters input,
.cms-side-filters select {
  width: 100%;
  font-size: 13px;
  padding: 8px 10px;
}

.cms-filter-count {
  font-size: 12px;
  color: var(--cms-muted);
  margin-left: auto;
}

.cms-list-empty {
  list-style: none;
  padding: 12px 8px;
  color: var(--cms-muted);
  font-size: 13px;
}

.cms-card {
  border: 1px solid var(--cms-border);
  border-radius: var(--cms-radius);
  background: var(--cms-panel);
  padding: 16px;
  margin-bottom: 16px;
}

.cms-card h3 { margin: 0 0 12px; font-size: 15px; }

.cms-field { margin-bottom: 12px; }
.cms-name-field { margin-bottom: 10px; }
.cms-name-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.cms-name-row input { flex: 1; margin: 0; }
.cms-name-row .cms-btn { flex-shrink: 0; white-space: nowrap; }
.cms-field label {
  display: block;
  font-size: 12px;
  color: var(--cms-muted);
  margin-bottom: 4px;
}

.cms-field input,
.cms-field textarea,
.cms-field select {
  width: 100%;
  background: #0d1420;
  border: 1px solid var(--cms-border);
  color: var(--cms-text);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
}

.cms-field textarea {
  min-height: 72px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
}

.cms-field textarea.json { min-height: 120px; }

.cms-login {
  max-width: 520px;
  width: min(520px, calc(100% - 32px));
  margin: 64px auto;
  padding: 36px 40px;
  border: 1px solid var(--cms-border);
  border-radius: 12px;
  background: var(--cms-panel);
}

.cms-login h1,
.cms-login .cms-login-title {
  margin: 0 0 24px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
  color: #fff; /* override site style.css navy h1 */
}
.cms-login-title .cms-login-cms {
  color: var(--cms-accent);
}
.cms-login-title .cms-login-word {
  color: #fff;
}
.cms-login p { color: var(--cms-muted); font-size: 13px; margin: 0 0 20px; }

.cms-totp-qr-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin: 4px 0 8px;
}
.cms-totp-qr-wrap img {
  width: 220px;
  height: 220px;
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  box-sizing: border-box;
}
.cms-totp-secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
  text-align: center;
  color: var(--cms-muted);
}
.cms-hint {
  margin-top: 16px;
  padding: 10px;
  background: #0d1420;
  border-radius: 8px;
  font-size: 12px;
  color: var(--cms-muted);
  line-height: 1.5;
}
.cms-hint code { color: #9ee0bd; }

.cms-slot {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px dashed var(--cms-border);
  border-radius: 8px;
  margin-bottom: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.cms-slot.is-pending {
  border: 2px solid var(--cms-danger);
  box-shadow: 0 0 0 3px rgba(212, 86, 86, 0.25);
  background: rgba(212, 86, 86, 0.08);
}

.cms-slot-pending-msg {
  margin: 8px 0 0;
  font-size: 12px;
  color: #ffb4b4;
}

.cms-pending-banner {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--cms-danger);
  border-radius: 8px;
  background: rgba(212, 86, 86, 0.12);
  color: #ffb4b4;
  font-size: 13px;
  line-height: 1.45;
}

.cms-slot .slot-title { font-weight: 600; font-size: 14px; }
.cms-slot .slot-meta { font-size: 12px; color: var(--cms-muted); margin-top: 4px; }

.cms-slot-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  min-width: 110px;
}

.cms-preview-wrap {
  background: #f4f6f9;
  color: #111;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #d7dde8;
}

.cms-preview-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #1a2332;
  color: #c5d0e0;
  font-size: 12px;
}

.cms-preview-frame {
  max-height: 70vh;
  overflow: auto;
}

/* When previewing fullscreen route */
.cms-preview-page .cms-body { display: block; }
.cms-preview-page .cms-side { display: none; }
.cms-preview-page .cms-main { padding: 0; }
.cms-preview-page .cms-preview-wrap {
  border: none;
  border-radius: 0;
  min-height: calc(100vh - 56px);
}
.cms-preview-page .cms-preview-frame { max-height: none; }

.cms-empty {
  color: var(--cms-muted);
  font-size: 14px;
  padding: 24px 0;
}

body.cms-dialog-open { overflow: hidden; }

.cms-dialog-root {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.cms-dialog-root[hidden] { display: none !important; }

.cms-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 10, 18, 0.72);
}

.cms-dialog {
  position: relative;
  width: min(440px, 100%);
  background: var(--cms-panel);
  border: 1px solid var(--cms-border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.cms-dialog-title {
  margin: 0 0 8px;
  font-size: 18px;
}

.cms-dialog-body {
  margin: 0 0 16px;
  color: var(--cms-muted);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}
.cms-dialog-body:has(.cms-totp-qr-wrap) {
  white-space: normal;
}

.cms-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.cms-dialog .cms-btn.danger {
  background: var(--cms-danger);
  border-color: var(--cms-danger);
  color: #fff;
}

.cms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.cms-table th, .cms-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--cms-border);
}
.cms-table th { color: var(--cms-muted); font-weight: 600; }

@media (max-width: 900px) {
  .cms-body { grid-template-columns: 1fr; }
  .cms-side { border-right: none; border-bottom: 1px solid var(--cms-border); max-height: 220px; }
}
