@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
  --bg: #0a0a0f;
  --surface: #111118;
  --surface2: #16161f;
  --border: #1e1e2e;
  --border-hover: #2e2e4e;
  --accent: #7C3AED;
  --accent-hover: #6d28d9;
  --cyan: #06b6d4;
  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
}

body {
  font-family: 'Space Grotesk', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ── Login ── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-card .logo {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 32px;
}

.login-card h1 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 8px;
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 13px;
}

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="color"],
textarea,
select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 14px;
  padding: 9px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="color"] {
  padding: 4px 6px;
  height: 38px;
  cursor: pointer;
}

input:focus-visible, textarea:focus-visible, select:focus-visible {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.25);
}

textarea { resize: vertical; min-height: 80px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; }

.error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
  min-height: 20px;
}

/* ── Dashboard ── */
#dashboard { display: none; min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar .brand {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar .tabs {
  display: flex;
  gap: 4px;
}

.tab-btn {
  padding: 6px 16px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab-btn:hover { color: var(--text); background: var(--surface2); }
.tab-btn.active { background: var(--accent); color: #fff; }

.topbar .actions { display: flex; gap: 8px; align-items: center; }

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

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
}

/* ── Tab panels ── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Projects table ── */
.projects-table {
  width: 100%;
  border-collapse: collapse;
}

.projects-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.projects-table td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.projects-table tr:last-child td { border-bottom: none; }

.projects-table tr:hover td { background: var(--surface2); }

.project-thumb {
  width: 52px;
  height: 36px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.thumb-placeholder {
  width: 52px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, var(--cyan) 100%);
  opacity: 0.4;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.status-published { background: rgba(34,197,94,0.15); color: var(--success); }
.status-draft { background: rgba(245,158,11,0.15); color: var(--warning); }

.cat-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  margin: 1px;
}

.action-btns { display: flex; gap: 6px; }

.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ── Overlay / Modal ── */
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  overflow-y: auto;
  padding: 40px 16px;
}

.overlay.open { display: flex; align-items: flex-start; justify-content: center; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 16px; font-weight: 600; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ── Project form ── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group.full { grid-column: 1 / -1; }

.checkbox-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 44px;
}

.checkbox-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-dim);
  padding: 4px 8px;
  border-radius: 20px;
  border: 1px solid var(--border);
  transition: border-color 0.15s;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
}

.checkbox-grid input[type="checkbox"] {
  width: auto;
  cursor: pointer;
}

.checkbox-grid label:has(input:checked) {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(124,58,237,0.1);
}

/* ── Image upload ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s;
  position: relative;
}
.upload-zone:hover { border-color: var(--accent); }
.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}
.upload-zone p { color: var(--text-muted); font-size: 13px; }
.upload-zone .upload-icon { display:flex; justify-content:center; margin-bottom: 10px; color: var(--text-muted); }
.upload-zone.uploading { opacity: 0.6; pointer-events: none; }

.image-preview {
  margin-top: 12px;
  display: none;
}
.image-preview img {
  max-height: 160px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: block;
  margin: 0 auto;
}
.image-preview .remove-img {
  display: block;
  text-align: center;
  margin-top: 8px;
  color: var(--danger);
  font-size: 12px;
  cursor: pointer;
  background: none;
  border: none;
}

/* ── Categories tab ── */
.cat-add-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 24px;
}

.cat-add-form .form-group { margin-bottom: 0; flex: 1; }
.cat-add-form .form-group:last-of-type { flex: 0 0 80px; }

.cat-list { display: flex; flex-direction: column; gap: 8px; }

.cat-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}

.cat-swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-name { font-weight: 500; flex: 1; }
.cat-slug { color: var(--text-muted); font-size: 12px; font-family: 'JetBrains Mono', monospace; }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  z-index: 999;
  transform: translateY(80px);
  opacity: 0;
  transition: transform 0.25s, opacity 0.25s;
  pointer-events: none;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: #15803d; }
.toast.error { background: var(--danger); }

/* ── Confirm dialog ── */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
.confirm-overlay.open { display: flex; }
.confirm-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 28px 20px;
  max-width: 380px;
  width: 90%;
  box-shadow: var(--shadow);
}
.confirm-box h4 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.confirm-box p { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
.confirm-btns { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .topbar .tabs { display: none; }
  .content { padding: 20px 16px; }
  .cat-add-form { flex-direction: column; }
}

/* ── Focus visible ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
