/* ============================================================
   SiteForge Admin Panel
   ============================================================ */
:root {
  --blue:     #0071e3;
  --blue-dk:  #005bb5;
  --green:    #34c759;
  --red:      #ff3b30;
  --orange:   #ff9500;
  --yellow:   #ffd60a;
  --bg:       #f5f5f7;
  --surface:  #ffffff;
  --border:   #e2e2e5;
  --text:     #1d1d1f;
  --muted:    #86868b;
  --sidebar:  220px;
  --radius:   10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ── Screens ──────────────────────────────────────────────── */
.screen { display: none; height: 100%; }
.screen--active { display: flex; }

/* ── Login ────────────────────────────────────────────────── */
#login-screen { align-items: center; justify-content: center; background: linear-gradient(135deg, #001f5b 0%, #0071e3 100%); }
.login-card { background: #fff; border-radius: 20px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 24px 64px rgba(0,0,0,0.2); }
.login-logo { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; margin-bottom: 24px; }
.login-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 24px; }

/* ── Sidebar ──────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; height: 100%; padding: 20px 0;
}
.admin-sidebar__logo { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 700; padding: 0 16px 20px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.admin-sidebar__logout { margin-top: auto; background: none; border: none; color: var(--muted); font-size: 13px; padding: 16px 16px 8px; cursor: pointer; text-align: left; }
.admin-sidebar__logout:hover { color: var(--red); }

/* ── Nav ──────────────────────────────────────────────────── */
.admin-nav { display: flex; flex-direction: column; gap: 1px; padding: 0 8px; }
.admin-nav__item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; color: var(--muted); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all 0.1s; text-decoration: none;
}
.admin-nav__item:hover { background: var(--bg); color: var(--text); }
.admin-nav__item--active { background: var(--blue); color: #fff; }
.admin-nav__item--active:hover { background: var(--blue-dk); color: #fff; }

/* ── Content ──────────────────────────────────────────────── */
.admin-content { flex: 1; overflow: auto; }
.page { display: none; padding: 32px; }
.page--active { display: block; }

/* ── Page header ──────────────────────────────────────────── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.page-header h1 { font-size: 26px; font-weight: 700; }

/* ── Stat cards ───────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 24px;
}
.stat-card__label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 8px; }
.stat-card__value { font-size: 36px; font-weight: 800; line-height: 1; margin-bottom: 6px; }
.stat-card__sub   { font-size: 12px; color: var(--muted); }
.stat-card--blue   .stat-card__value { color: var(--blue); }
.stat-card--green  .stat-card__value { color: var(--green); }
.stat-card--orange .stat-card__value { color: var(--orange); }
.stat-card--red    .stat-card__value { color: var(--red); }

/* ── Cards ────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
.card__header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card__title  { font-size: 15px; font-weight: 700; }
.card__body   { padding: 20px; }

/* ── Table ────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 14px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ── Badges ───────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge--green  { background: #e4f7ec; color: #1a7f40; }
.badge--blue   { background: #e3f0ff; color: #0055cc; }
.badge--orange { background: #fff4e8; color: #c05c00; }
.badge--red    { background: #ffe8e7; color: #cc2200; }
.badge--gray   { background: var(--bg); color: var(--muted); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ── Health checks ────────────────────────────────────────── */
.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.health-item { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; background: var(--bg); border-radius: 8px; }
.health-item__name  { font-size: 13px; font-weight: 600; }
.health-item__check { font-size: 12px; }
.health-item--ok     { border-left: 3px solid var(--green); }
.health-item--warn   { border-left: 3px solid var(--orange); }
.health-item--error  { border-left: 3px solid var(--red); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group  { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.form-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 14px; color: var(--text); background: var(--bg);
  transition: border-color 0.15s;
}
.form-input:focus { outline: none; border-color: var(--blue); background: #fff; }
select.form-input { cursor: pointer; }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px;
  border-radius: 8px; font-family: inherit; font-size: 13px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; transition: all 0.15s;
  text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn--primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn--primary:hover:not(:disabled) { background: var(--blue-dk); }
.btn--danger  { background: var(--red); color: #fff; border-color: var(--red); }
.btn--outline { background: transparent; color: var(--blue); border-color: var(--blue); }
.btn--outline:hover:not(:disabled) { background: var(--blue); color: #fff; }
.btn--ghost   { background: transparent; border-color: var(--border); color: var(--text); }
.btn--ghost:hover:not(:disabled) { background: var(--bg); }
.btn--sm { padding: 6px 12px; font-size: 12px; }
.btn--full { width: 100%; justify-content: center; }

/* ── Alert ────────────────────────────────────────────────── */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 13px; margin-top: 12px; }
.alert--error   { background: #fff2f2; color: var(--red); border: 1px solid #ffd0cf; }
.alert--success { background: #f2fff5; color: var(--green); border: 1px solid #c8f0d1; }
.hidden { display: none !important; }

/* ── Log output ───────────────────────────────────────────── */
.log-output {
  background: #1d1d1f; color: #a8e6cf; font-family: 'Courier New', monospace;
  font-size: 12px; line-height: 1.7; padding: 16px; border-radius: 8px;
  max-height: 320px; overflow-y: auto; white-space: pre-wrap; word-break: break-all;
}

/* ── Template factory ─────────────────────────────────────── */
.factory-options { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.factory-option { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--bg); border-radius: 8px; cursor: pointer; }
.factory-option input { width: 16px; height: 16px; cursor: pointer; }
.factory-option span { font-size: 13px; font-weight: 500; }

/* ── Secrets manager ──────────────────────────────────────── */
.secret-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.secret-row:last-child { border: none; }
.secret-row__name { font-weight: 600; font-size: 13px; min-width: 220px; }
.secret-row__status { flex: 1; font-size: 12px; color: var(--muted); }
.secret-row__input { flex: 2; }

/* ── Toast & loading ──────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #1d1d1f; color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 500; box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 9999; max-width: 90vw; text-align: center;
}
.toast--success { background: var(--green); }
.toast--error   { background: var(--red); }

.loading-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.3);
  display: flex; align-items: center; justify-content: center; z-index: 9998;
}
.loading-spinner {
  width: 32px; height: 32px; border: 3px solid rgba(255,255,255,0.3);
  border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar: 0px; }
  .admin-sidebar { display: none; }
  .page { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .factory-options { grid-template-columns: 1fr; }
}
