/* ---------------------------------------------------------------
   Admin Dashboard design system.
   Palette intentionally echoes the public site's tokens.css (Matte
   Black / Charcoal / Off-White / Soft Gold) for brand cohesion,
   applied here as a dark, data-dense enterprise console.
   --------------------------------------------------------------- */

:root {
  --bg: #0F1115;
  --bg-elevated: #171A21;
  --surface: #1A1D23;
  --surface-hover: #21252D;
  --border: rgba(245, 243, 238, 0.10);
  --text: #F5F3EE;
  --text-muted: #9B968A;
  --gold: #D4AF37;
  --gold-dim: #B8912B;
  --danger: #E5484D;
  --success: #3FB950;
  --radius-s: 6px;
  --radius-m: 10px;
  --radius-l: 16px;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
input, textarea, select, button { font-family: inherit; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  padding: 1.25rem 0.75rem;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 700; font-size: 1.05rem;
  padding: 0.5rem 0.75rem 1.25rem;
}
.sidebar-brand-mark { color: var(--gold); }
.sidebar-group { margin-bottom: 1.25rem; }
.sidebar-group-label {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); padding: 0 0.75rem; margin-bottom: 0.4rem;
}
.sidebar-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0.75rem; border-radius: var(--radius-s);
  color: var(--text-muted); text-decoration: none; font-size: 0.9rem;
}
.sidebar-link:hover { background: var(--surface-hover); color: var(--text); }
.sidebar-link.active { background: var(--surface); color: var(--gold); font-weight: 600; }
.badge {
  background: var(--gold); color: #14161B; font-size: 0.7rem; font-weight: 700;
  border-radius: 999px; padding: 0.05rem 0.45rem; min-width: 1.2rem; text-align: center;
}

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.75rem; border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.topbar-title { font-size: 1.15rem; margin: 0; }
.topbar-user { display: flex; align-items: center; gap: 0.75rem; }
.topbar-email { color: var(--text-muted); font-size: 0.85rem; }
.app-content { flex: 1; padding: 1.75rem; max-width: 980px; }

/* ---------- Cards / stats ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-l); padding: 1.5rem; margin-bottom: 1.25rem;
}
.card h2 { margin-top: 0; font-size: 1rem; }
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem; margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-m); padding: 1.1rem 1.25rem;
}
.stat-card-accent { border-color: var(--gold); }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-label { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.15rem; }
.stat-hint { color: var(--text-muted); font-size: 0.75rem; margin-top: 0.4rem; }
.quick-links { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.field { margin-bottom: 1rem; }
.field-inline { display: flex; align-items: center; gap: 0.6rem; }
.field-inline .field-label { margin: 0; }
.field-label {
  display: block; font-size: 0.8rem; font-weight: 600;
  color: var(--text-muted); margin-bottom: 0.35rem;
}
.field-error { color: var(--danger); font-size: 0.8rem; margin: 0.3rem 0 0; }
.input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-s); padding: 0.55rem 0.7rem;
  font-size: 0.9rem;
}
.input:focus { outline: none; border-color: var(--gold); }
.input-sm { padding: 0.4rem 0.6rem; font-size: 0.82rem; margin-top: 0.4rem; }
textarea.input { resize: vertical; min-height: 2.5rem; }
.muted { color: var(--text-muted); font-size: 0.82rem; }
.subsection-title { font-size: 0.95rem; margin: 1.5rem 0 0.75rem; border-top: 1px solid var(--border); padding-top: 1.25rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.page-description { color: var(--text-muted); font-size: 0.88rem; max-width: 640px; }
.page-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: var(--radius-s);
  padding: 0.55rem 1rem; font-size: 0.85rem; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: filter 0.15s;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--gold); color: #14161B; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-secondary { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--gold); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.78rem; }
.btn-block { width: 100%; }
.icon-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-muted);
  border-radius: var(--radius-s); width: 1.8rem; height: 1.8rem; cursor: pointer;
}
.icon-btn:hover:not(:disabled) { color: var(--text); border-color: var(--gold); }
.icon-btn-danger:hover:not(:disabled) { color: var(--danger); border-color: var(--danger); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ---------- Repeatable list editor ---------- */
.repeatable-row { border: 1px solid var(--border); border-radius: var(--radius-m); margin-bottom: 0.6rem; overflow: hidden; }
.repeatable-row-header { display: flex; align-items: center; justify-content: space-between; padding: 0.6rem 0.9rem; background: var(--bg-elevated); }
.repeatable-row-title { flex: 1; text-align: left; background: none; border: none; color: var(--text); cursor: pointer; font-size: 0.88rem; display: flex; gap: 0.5rem; }
.chevron { color: var(--text-muted); }
.repeatable-row-actions { display: flex; gap: 0.35rem; }
.repeatable-row-body { padding: 1rem; border-top: 1px solid var(--border); }

.string-list-row { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.45rem; }
.string-list-row .input { flex: 1; }

.skill-group { border: 1px solid var(--border); border-radius: var(--radius-m); margin-bottom: 0.9rem; overflow: hidden; }
.skill-group-name { flex: 1; margin-right: 0.75rem; }
.skill-items { padding: 0.9rem; }
.skill-item-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.skill-item-row .input:first-child { flex: 1; }
.skill-percentage { width: 4.5rem; }

.cta-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.gallery-row { border-top: 1px dashed var(--border); padding-top: 0.75rem; margin-top: 0.75rem; }

/* ---------- Image uploader ---------- */
.image-uploader { margin-bottom: 1.1rem; }
.image-uploader-row { display: flex; align-items: center; gap: 1rem; }
.image-preview {
  width: 88px; height: 88px; border-radius: var(--radius-m); background: var(--bg);
  border: 1px dashed var(--border); display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.image-preview img { width: 100%; height: 100%; object-fit: cover; }
.image-preview-empty { color: var(--text-muted); font-size: 0.7rem; text-align: center; }
.image-uploader-actions { display: flex; gap: 0.5rem; }
.upload-progress { height: 4px; background: var(--bg); border-radius: 999px; margin-top: 0.6rem; overflow: hidden; }
.upload-progress-bar { height: 100%; background: var(--gold); transition: width 0.15s; }

/* ---------- Editor savebar / toast / modal ---------- */
.editor-savebar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1rem; padding: 0.15rem 0.25rem;
}
.dirty-indicator { font-size: 0.82rem; color: var(--text-muted); }
.dirty-indicator.dirty { color: var(--gold); }
.editor-savebar-actions { display: flex; gap: 0.6rem; }

.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 100;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-m); padding: 0.75rem 1.1rem; box-shadow: var(--shadow);
  font-size: 0.85rem;
}
.toast-error { border-color: var(--danger); color: var(--danger); }
.toast-success { border-color: var(--success); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center; z-index: 200;
}
.modal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); padding: 1.5rem; max-width: 380px; box-shadow: var(--shadow); }
.modal-card h3 { margin-top: 0; }
.modal-message { color: var(--text-muted); font-size: 0.88rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.25rem; }

/* ---------- Loading / empty ---------- */
.loading-fullscreen, .loading-inline { display: flex; align-items: center; gap: 0.6rem; color: var(--text-muted); padding: 2rem; }
.spinner {
  width: 1.1rem; height: 1.1rem; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--gold);
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state h3 { color: var(--text); }

/* ---------- Tables ---------- */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.data-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 0.87rem; }
.data-table th { text-align: left; padding: 0.75rem 1rem; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 1px solid var(--border); }
.data-table td { padding: 0.65rem 1rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.reorder-cell { display: flex; gap: 0.25rem; }
.table-project-name { display: flex; align-items: center; gap: 0.6rem; }
.table-project-name img { width: 32px; height: 32px; border-radius: var(--radius-s); object-fit: cover; }
.table-project-monogram { width: 32px; height: 32px; border-radius: var(--radius-s); background: var(--bg-elevated); display: flex; align-items: center; justify-content: center; color: var(--text-muted); }
.table-actions { display: flex; gap: 0.5rem; }
.status-pill { border: none; border-radius: 999px; padding: 0.25rem 0.7rem; font-size: 0.75rem; font-weight: 600; cursor: pointer; }
.status-published { background: rgba(63, 185, 80, 0.18); color: var(--success); }
.status-draft { background: rgba(155, 150, 138, 0.18); color: var(--text-muted); }

/* ---------- Messages ---------- */
.message-list { display: flex; flex-direction: column; gap: 0.5rem; }
.message-row { border: 1px solid var(--border); border-radius: var(--radius-m); background: var(--surface); }
.message-row.unread { border-color: var(--gold); }
.message-row-summary {
  width: 100%; display: flex; align-items: center; gap: 0.75rem;
  background: none; border: none; color: var(--text); cursor: pointer;
  padding: 0.75rem 1rem; text-align: left; font-size: 0.87rem;
}
.message-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); opacity: 0; flex-shrink: 0; }
.message-row.unread .message-dot { opacity: 1; }
.message-from { font-weight: 600; min-width: 140px; }
.message-subject { flex: 1; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message-date { color: var(--text-muted); font-size: 0.78rem; flex-shrink: 0; }
.message-body { padding: 0 1rem 1rem; border-top: 1px solid var(--border); }
.message-text { white-space: pre-wrap; color: var(--text); }
.message-actions { display: flex; gap: 0.6rem; margin-top: 0.75rem; }

/* ---------- Auth screen ---------- */
.auth-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-l); padding: 2rem; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.15rem; margin-bottom: 0.4rem; }
.auth-subtitle { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.5rem; }
.auth-footnote { color: var(--text-muted); font-size: 0.76rem; margin-top: 1.25rem; line-height: 1.5; }
.auth-footnote code { background: var(--bg); padding: 0.1rem 0.3rem; border-radius: 4px; }

.alert { border-radius: var(--radius-s); padding: 0.65rem 0.85rem; font-size: 0.82rem; margin-bottom: 1rem; }
.alert-error { background: rgba(229, 72, 77, 0.12); color: var(--danger); border: 1px solid rgba(229, 72, 77, 0.3); }
.alert-warning { background: rgba(212, 175, 55, 0.12); color: var(--gold); border: 1px solid rgba(212, 175, 55, 0.3); }
