/* InfraTally Admin UI — shared styles */

:root {
  --bg:      #0f1117;
  --surface: #181c27;
  --surface2:#1f2436;
  --border:  #252d42;
  --accent:  #f97316;
  --accent2: #6366f1;
  --green:   #22c55e;
  --red:     #ef4444;
  --yellow:  #eab308;
  --text:    #eef0f6;
  --muted:   #7280a0;
  --mono:    'JetBrains Mono', monospace;
  --sans:    'Outfit', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--accent2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ─────────────────────────────────────────────────────────────────── */

.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 62px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  background: rgba(15,17,23,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  gap: 32px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}
.logo-badge {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  background: var(--accent);
  color: #0f1117;
  padding: 2px 6px;
  border-radius: 4px;
}
.logo-text { font-size: 1.05rem; font-weight: 800; }
.logo-tally { color: var(--accent2); }

.nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}
.nav-link {
  font-size: 0.875rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav-link.active { color: var(--text); background: var(--surface2); }

/* ── Layout ──────────────────────────────────────────────────────────────── */

.page { padding: 32px 24px; max-width: 1100px; margin: 0 auto; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.page-title { font-size: 1.5rem; font-weight: 700; }

.section-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent2);
}

/* ── Cards / Panels ──────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.card + .card { margin-top: 16px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 8px;
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: opacity 0.15s, box-shadow 0.15s;
}
.btn:hover { opacity: 0.88; text-decoration: none; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--accent); color: #0f1117; }
.btn-primary:hover { box-shadow: 0 0 0 3px rgba(249,115,22,0.3); opacity: 1; }

.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }

.btn-ghost { background: transparent; color: var(--accent2); border: 1px solid var(--accent2); }
.btn-ghost:hover { background: rgba(99,102,241,0.08); opacity: 1; }

.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover { background: rgba(239,68,68,0.1); opacity: 1; }

.btn-sm { padding: 5px 12px; font-size: 0.8rem; }

/* ── Forms ───────────────────────────────────────────────────────────────── */

.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 0.8rem; font-weight: 600; color: var(--muted); font-family: var(--mono); }

.form-input,
.form-select,
.form-textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.9rem;
  padding: 10px 14px;
  width: 100%;
  transition: border-color 0.15s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent2);
}
.form-textarea { resize: vertical; min-height: 120px; }

/* ── Tables ──────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background 0.12s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface2); }
tbody td { padding: 12px 14px; vertical-align: middle; }

/* ── Badges ──────────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: lowercase;
}
.badge-pending  { background: rgba(234,179,8,0.15);  color: var(--yellow); }
.badge-generating { background: rgba(99,102,241,0.15); color: var(--accent2); }
.badge-generated { background: rgba(99,102,241,0.25); color: var(--accent2); }
.badge-published { background: rgba(34,197,94,0.15);  color: var(--green); }
.badge-discarded { background: rgba(239,68,68,0.12);  color: var(--red); }
.badge-active   { background: rgba(34,197,94,0.15);  color: var(--green); }
.badge-inactive { background: rgba(114,128,160,0.15); color: var(--muted); }

/* ── Alerts / toasts ─────────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 16px;
}
.alert-error   { background: rgba(239,68,68,0.12); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,0.12); border: 1px solid rgba(34,197,94,0.3);  color: #86efac; }
.alert-info    { background: rgba(99,102,241,0.12); border: 1px solid rgba(99,102,241,0.3); color: #a5b4fc; }

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }

/* ── Editor ──────────────────────────────────────────────────────────────── */

.editor {
  font-family: var(--mono);
  font-size: 0.82rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 16px;
  width: 100%;
  resize: vertical;
  min-height: 480px;
  line-height: 1.6;
}
.editor:focus { outline: none; border-color: var(--accent2); }

/* ── Loading spinner ─────────────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ─────────────────────────────────────────────────────────── */

.empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
  font-size: 0.9rem;
}
.empty-icon { font-size: 2.5rem; margin-bottom: 12px; }

/* ── Tag pills ───────────────────────────────────────────────────────────── */

.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-family: var(--mono);
  font-size: 0.72rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--muted);
}

/* ── Detail meta row ─────────────────────────────────────────────────────── */

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--mono);
  margin-bottom: 20px;
}

/* ── Two-col layout ──────────────────────────────────────────────────────── */

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) { .two-col { grid-template-columns: 1fr; } }

/* ── Login page ──────────────────────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}
.login-logo { margin-bottom: 24px; }
.login-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; }
.login-sub { color: var(--muted); font-size: 0.875rem; margin-bottom: 28px; }

/* ── Dot grid background ─────────────────────────────────────────────────── */

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, rgba(99,102,241,0.07) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
}
.nav, .page, .login-wrap { position: relative; z-index: 1; }
