/* ============================================================
   BuildHawk CMS Admin — Design System
   Dark sidebar premium CMS layout
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --a-bg:       #0d0d0c;
  --a-surface:  #161614;
  --a-surface2: #1e1e1b;
  --a-surface3: #252522;
  --a-border:   rgba(255,255,255,0.08);
  --a-border2:  rgba(255,255,255,0.05);
  --a-text:     #e8e7e3;
  --a-muted:    #7a7a74;
  --a-orange:   #de5123;
  --a-orange-h: #f06035;
  --a-green:    #22c55e;
  --a-red:      #ef4444;
  --a-yellow:   #eab308;
  --a-blue:     #3b82f6;
  --sidebar-w:  260px;
  --radius:     6px;
  --ease:       cubic-bezier(0.2,0.7,0.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--a-bg);
  color: var(--a-text);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; background: none; border: none; font: inherit; }
ul, ol { list-style: none; }
img { max-width: 100%; display: block; }

/* ── Layout ─────────────────────────────────────────────────── */
.admin-wrap { display: flex; min-height: 100vh; }

/* ── Sidebar ────────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--a-surface);
  border-right: 1px solid var(--a-border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 200;
  transition: transform 0.3s var(--ease);
  overflow-y: auto;
}
.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-track { background: transparent; }
.admin-sidebar::-webkit-scrollbar-thumb { background: var(--a-border); border-radius: 2px; }

@media (max-width: 1023px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); box-shadow: 20px 0 60px rgba(0,0,0,0.5); }
}

.sidebar-brand {
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid var(--a-border);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.sidebar-brand-emblem {
  width: 24px; height: 18px; flex-shrink: 0;
  background: var(--a-orange);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}
.sidebar-brand-name {
  font-size: 13px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--a-text);
}
.sidebar-brand-sub { font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--a-muted); }

.sidebar-nav { padding: 1rem 0.75rem; flex: 1; }
.nav-section-label {
  font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--a-muted); padding: 0.5rem 0.5rem; margin-top: 1rem;
}
.nav-section-label:first-child { margin-top: 0; }
.sidebar-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.75rem; border-radius: var(--radius);
  font-size: 13.5px; color: var(--a-muted);
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
}
.sidebar-link:hover { background: var(--a-surface2); color: var(--a-text); }
.sidebar-link.active { background: rgba(222,81,35,0.15); color: var(--a-orange); }
.sidebar-link svg { flex-shrink: 0; opacity: 0.7; }
.sidebar-link.active svg { opacity: 1; }
.sidebar-badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 100px; font-size: 10px; font-weight: 600;
  background: var(--a-orange); color: var(--a-text);
  display: flex; align-items: center; justify-content: center;
}

.sidebar-footer {
  padding: 0.75rem; border-top: 1px solid var(--a-border);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.625rem 0.75rem; border-radius: var(--radius);
  transition: background 0.15s;
}
.sidebar-user:hover { background: var(--a-surface2); }
.sidebar-user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--a-orange); display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: white; flex-shrink: 0;
}
.sidebar-user-name { font-size: 13px; font-weight: 500; }
.sidebar-user-role { font-size: 11px; color: var(--a-muted); }

/* ── Main Content ───────────────────────────────────────────── */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  min-height: 100vh;
}
@media (max-width: 1023px) { .admin-main { margin-left: 0; } }

/* ── Topbar ─────────────────────────────────────────────────── */
.admin-topbar {
  height: 60px; flex-shrink: 0;
  background: var(--a-surface);
  border-bottom: 1px solid var(--a-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1.5rem; gap: 1rem;
  position: sticky; top: 0; z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.sidebar-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius);
  color: var(--a-muted); transition: background 0.15s, color 0.15s;
}
.sidebar-toggle:hover { background: var(--a-surface2); color: var(--a-text); }
@media (min-width: 1024px) { .sidebar-toggle { display: none; } }
.topbar-breadcrumb {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 13px; color: var(--a-muted);
}
.topbar-breadcrumb a { transition: color 0.15s; }
.topbar-breadcrumb a:hover { color: var(--a-text); }
.topbar-breadcrumb .sep { opacity: 0.4; }
.topbar-breadcrumb .current { color: var(--a-text); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; }
.topbar-view-site {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 0.875rem; border-radius: var(--radius);
  border: 1px solid var(--a-border); font-size: 12px; color: var(--a-muted);
  transition: all 0.15s;
}
.topbar-view-site:hover { border-color: var(--a-orange); color: var(--a-orange); }

/* ── Page Content ───────────────────────────────────────────── */
.admin-page { padding: 2rem 2rem 3rem; flex: 1; }
@media (max-width: 640px) { .admin-page { padding: 1.25rem; } }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.75rem;
}
.page-header-title { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.page-header-sub { font-size: 13px; color: var(--a-muted); margin-top: 4px; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 0.875rem 1.25rem; border-radius: var(--radius);
  font-size: 13.5px; margin-bottom: 1.25rem;
  border-left: 3px solid;
}
.alert-success { background: rgba(34,197,94,0.08); border-color: var(--a-green); color: #86efac; }
.alert-error   { background: rgba(239,68,68,0.08);  border-color: var(--a-red);   color: #fca5a5; }
.alert-warning { background: rgba(234,179,8,0.08);  border-color: var(--a-yellow); color: #fde68a; }
.alert-info    { background: rgba(59,130,246,0.08); border-color: var(--a-blue);  color: #93c5fd; }

/* ── Stats Cards ────────────────────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem;
  margin-bottom: 2rem;
}
@media (min-width: 640px) { .stats-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .stats-grid { grid-template-columns: repeat(6, 1fr); } }
.stat-card {
  background: var(--a-surface);
  border: 1px solid var(--a-border);
  border-radius: var(--radius); padding: 1.25rem;
}
.stat-label { font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--a-muted); }
.stat-value { font-size: 32px; font-weight: 600; letter-spacing: -0.03em; margin-top: 0.25rem; }
.stat-value.orange { color: var(--a-orange); }
.stat-desc { font-size: 11px; color: var(--a-muted); margin-top: 4px; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-card {
  background: var(--a-surface);
  border: 1px solid var(--a-border);
  border-radius: var(--radius); overflow: hidden;
}
.table-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--a-border);
  display: flex; align-items: center; justify-content: space-between;
}
.table-card-title { font-size: 14px; font-weight: 600; }
.table-card-action { font-size: 12px; color: var(--a-muted); }
.table-card-action:hover { color: var(--a-orange); }
.bh-table { width: 100%; border-collapse: collapse; }
.bh-table th {
  padding: 0.75rem 1.25rem; text-align: left;
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--a-muted); border-bottom: 1px solid var(--a-border);
  white-space: nowrap;
}
.bh-table td { padding: 0.875rem 1.25rem; border-bottom: 1px solid var(--a-border2); font-size: 13.5px; }
.bh-table tr:last-child td { border-bottom: none; }
.bh-table tr:hover td { background: var(--a-surface2); }
.bh-table .td-muted { color: var(--a-muted); font-size: 12px; }
.bh-table .td-actions { display: flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.bh-table a.td-link { color: var(--a-muted); transition: color 0.15s; }
.bh-table a.td-link:hover { color: var(--a-orange); }
.table-empty { padding: 3rem; text-align: center; color: var(--a-muted); font-size: 14px; }
.table-overflow { overflow-x: auto; }

/* ── Status Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
  border-radius: 100px; font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
}
.badge-new      { background: rgba(222,81,35,0.18); color: #f0845a; }
.badge-reviewed { background: rgba(59,130,246,0.18); color: #93c5fd; }
.badge-contacted{ background: rgba(34,197,94,0.18);  color: #86efac; }
.badge-archived { background: rgba(122,122,116,0.2); color: var(--a-muted); }
.badge-published{ background: rgba(34,197,94,0.18); color: #86efac; }
.badge-draft    { background: rgba(234,179,8,0.18);  color: #fde68a; }
.badge-active   { background: rgba(34,197,94,0.18); color: #86efac; }
.badge-inactive { background: rgba(239,68,68,0.18);  color: #fca5a5; }
.badge-recommended { background: rgba(222,81,35,0.18); color: #f0845a; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 1rem; border-radius: var(--radius);
  font-size: 13px; font-weight: 500; cursor: pointer; border: none;
  transition: all 0.15s; white-space: nowrap;
}
.btn-sm { height: 30px; padding: 0 0.75rem; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 1.5rem; font-size: 14px; }
.btn-orange { background: var(--a-orange); color: white; }
.btn-orange:hover { background: var(--a-orange-h); }
.btn-surface { background: var(--a-surface2); color: var(--a-text); border: 1px solid var(--a-border); }
.btn-surface:hover { background: var(--a-surface3); }
.btn-danger { background: rgba(239,68,68,0.12); color: #fca5a5; border: 1px solid rgba(239,68,68,0.2); }
.btn-danger:hover { background: rgba(239,68,68,0.2); }
.btn-ghost { background: transparent; color: var(--a-muted); }
.btn-ghost:hover { color: var(--a-text); background: var(--a-surface2); }

/* ── Forms ──────────────────────────────────────────────────── */
.admin-form { max-width: 800px; }
.form-section { margin-bottom: 2rem; }
.form-section-title {
  font-size: 13px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--a-muted);
  margin-bottom: 1rem; padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--a-border);
}
.form-grid { display: grid; gap: 1rem; }
.form-grid-2 { grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .form-grid-2 { grid-template-columns: 1fr; } }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 768px) { .form-grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 480px) { .form-grid-3 { grid-template-columns: 1fr; } }

.a-form-group { display: flex; flex-direction: column; gap: 6px; }
.a-form-label {
  font-size: 12px; font-weight: 500; letter-spacing: 0.04em;
  color: var(--a-muted); text-transform: uppercase;
}
.a-form-control {
  height: 40px; background: var(--a-surface2);
  border: 1px solid var(--a-border); border-radius: var(--radius);
  padding: 0 0.875rem; color: var(--a-text);
  font-family: inherit; font-size: 13.5px; outline: none;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
}
.a-form-control:focus { border-color: var(--a-orange); background: var(--a-surface3); }
textarea.a-form-control { height: auto; min-height: 120px; padding: 0.75rem 0.875rem; resize: vertical; }
select.a-form-control { cursor: pointer; }
.a-form-control::placeholder { color: var(--a-muted); opacity: 0.6; }
.a-form-hint { font-size: 11px; color: var(--a-muted); }
.a-checkbox-group { display: flex; align-items: center; gap: 0.625rem; }
.a-checkbox-group input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--a-orange); }
.a-checkbox-group label { font-size: 13.5px; cursor: pointer; }

.form-actions {
  display: flex; align-items: center; gap: 0.75rem; padding-top: 1.5rem;
  border-top: 1px solid var(--a-border);
  margin-top: 2rem;
}

/* Image preview */
.img-preview {
  width: 120px; height: 90px; border-radius: var(--radius);
  border: 1px solid var(--a-border);
  background: var(--a-surface2); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.img-preview-placeholder { color: var(--a-muted); font-size: 12px; }

/* ── Sortable ────────────────────────────────────────────────── */
.sortable-item {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.875rem 1.25rem; background: var(--a-surface);
  border: 1px solid var(--a-border); border-radius: var(--radius);
  margin-bottom: 0.5rem; cursor: grab; transition: background 0.15s;
}
.sortable-item:hover { background: var(--a-surface2); }
.sortable-item.ui-sortable-helper { box-shadow: 0 8px 24px rgba(0,0,0,0.4); cursor: grabbing; }
.sortable-handle { color: var(--a-muted); flex-shrink: 0; }
.sortable-content { flex: 1; min-width: 0; }
.sortable-title { font-size: 13.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sortable-sub { font-size: 12px; color: var(--a-muted); }
.sortable-actions { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }

/* ── Modal / Confirm ────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  z-index: 9999; display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--a-surface); border: 1px solid var(--a-border);
  border-radius: 10px; padding: 2rem; max-width: 420px; width: 90%;
  box-shadow: 0 25px 60px rgba(0,0,0,0.5);
}
.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 0.75rem; }
.modal-body { font-size: 14px; color: var(--a-muted); margin-bottom: 1.5rem; line-height: 1.6; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }

/* ── Dashboard Specific ─────────────────────────────────────── */
.dashboard-grid {
  display: grid; grid-template-columns: 1fr; gap: 1.5rem;
}
@media (min-width: 1024px) { .dashboard-grid { grid-template-columns: 7fr 5fr; } }
.quick-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-top: 1.25rem;
}
.quick-action {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.875rem 1rem; border-radius: var(--radius);
  background: var(--a-surface2); border: 1px solid var(--a-border);
  font-size: 13px; color: var(--a-muted);
  transition: all 0.15s;
}
.quick-action:hover { background: var(--a-surface3); color: var(--a-orange); border-color: rgba(222,81,35,0.3); }

/* ── Submission View ────────────────────────────────────────── */
.submission-detail { max-width: 760px; }
.submission-field { margin-bottom: 1.5rem; }
.submission-field-label {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--a-muted); margin-bottom: 6px;
}
.submission-field-value {
  font-size: 15px; color: var(--a-text); line-height: 1.6;
}
.submission-field-value.message-body {
  background: var(--a-surface2); border: 1px solid var(--a-border);
  border-radius: var(--radius); padding: 1rem; font-size: 14px;
}

/* ── Mobile Overlay ─────────────────────────────────────────── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 199;
}
.sidebar-overlay.show { display: block; }
@media (min-width: 1024px) { .sidebar-overlay { display: none !important; } }

/* ── Responsive Table ───────────────────────────────────────── */
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
}

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