/* ============================================================
   ZowebCMS Admin — Design System
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=Instrument+Serif:ital@0;1&family=JetBrains+Mono:wght@400;500&display=swap');

/* ---- CSS Custom Properties (warmth = default) ---- */
:root {
  /* Sidebar */
  --sb-bg: #25446a;
  --sb-bg-hover: rgba(255,255,255,0.07);
  --sb-bg-active: rgba(255,255,255,0.13);
  --sb-text: #d6e2f0;
  --sb-text-muted: #9bb0c8;
  --sb-text-strong: #f6f9fd;
  --sb-border: rgba(255,255,255,0.08);

  /* Content area */
  --bg: #f4f1ec;
  --bg-2: #ece8df;
  --surface: #ffffff;
  --surface-alt: #faf8f3;
  --border: #e6e0d4;
  --border-strong: #d6cebd;

  /* Text */
  --text: #1a2230;
  --text-2: #4a5566;
  --text-3: #7a8492;
  --text-inv: #f7f6f2;

  /* Accents */
  --accent: #c98558;
  --accent-2: #a86a3f;
  --accent-soft: #f0d9c4;
  --accent-cool: #7ba7c9;
  --accent-cool-2: #5b8bb0;
  --success: #5b8f6e;
  --warn: #b8893a;
  --danger: #c25555;
  --success-bg: #edf5f0;
  --warn-bg: #fdf6e8;
  --danger-bg: #fdf0f0;

  /* Shape */
  --r-sm: 4px;
  --r: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;

  /* Shadows */
  --sh-sm: 0 1px 2px rgba(20,28,42,0.05);
  --sh: 0 2px 8px rgba(20,28,42,0.06), 0 1px 2px rgba(20,28,42,0.04);
  --sh-md: 0 8px 24px rgba(20,28,42,0.10), 0 2px 6px rgba(20,28,42,0.05);
  --sh-lg: 0 24px 64px rgba(20,28,42,0.18);

  /* Fonts */
  --ff-ui: "Instrument Sans", "Inter", system-ui, -apple-system, sans-serif;
  --ff-serif: "Instrument Serif", "Cormorant Garamond", Georgia, serif;
  --ff-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  /* Layout */
  --sidebar-w: 220px;
}

/* ---- Theme variants ---- */
[data-theme="forest"] {
  --bg: #f0f2ee; --bg-2: #e4e8e0; --surface: #fff; --border: #dde3d6;
  --accent: #4a7c59; --accent-2: #386147; --accent-soft: #d4e6d9;
  --sb-bg: #2a3d2e;
}
[data-theme="morning"] {
  --bg: #f5f2ee; --bg-2: #ede9e2; --surface: #fff; --border: #e2ddd4;
  --accent: #e07b3c; --accent-2: #c06228; --accent-soft: #fde5d0;
  --sb-bg: #3b2d24;
}
[data-theme="ink"] {
  --bg: #f2f3f5; --bg-2: #e8e9ed; --surface: #fff; --border: #dde0e6;
  --accent: #3d5a8a; --accent-2: #2c4470; --accent-soft: #d0ddf0;
  --sb-bg: #1a2540;
}
[data-theme="rose"] {
  --bg: #f7f2f3; --bg-2: #ede6e8; --surface: #fff; --border: #e4d8db;
  --accent: #b85c78; --accent-2: #954460; --accent-soft: #f5d9e2;
  --sb-bg: #3d2030;
}
[data-theme="plum"] {
  --bg: #f3f1f6; --bg-2: #e9e6f0; --surface: #fff; --border: #ddd8e8;
  --accent: #7155a3; --accent-2: #5a4088; --accent-soft: #e2d8f5;
  --sb-bg: #2a1f40;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--ff-ui);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; }

/* ============================================================
   Admin Shell Layout
   ============================================================ */
.admin-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(123,167,201,0.22), transparent 60%),
    radial-gradient(80% 50% at 100% 100%, rgba(201,133,88,0.10), transparent 60%),
    linear-gradient(168deg, #1f3a5e 0%, var(--sb-bg) 45%, #325878 100%);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(0,0,0,0.18);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.sidebar-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--sb-border);
}

.sidebar-logo {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.12);
  border-radius: var(--r-md);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: var(--sb-text-strong);
  flex-shrink: 0;
}

.sidebar-site-name {
  font-size: 13px; font-weight: 600;
  color: var(--sb-text-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-search {
  margin: 10px 10px 6px;
  position: relative;
}
.sidebar-search input {
  width: 100%;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--r-md);
  padding: 7px 10px 7px 32px;
  font-size: 12.5px;
  color: var(--sb-text);
  outline: none;
  transition: background 0.15s, border-color 0.15s;
}
.sidebar-search input::placeholder { color: var(--sb-text-muted); }
.sidebar-search input:focus {
  background: rgba(255,255,255,0.11);
  border-color: rgba(255,255,255,0.22);
}
.sidebar-search-icon {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--sb-text-muted); pointer-events: none;
}

.sidebar-nav { flex: 1; padding: 6px 0 10px; }

.sidebar-group {
  margin-bottom: 4px;
}
.sidebar-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sb-text-muted);
  padding: 10px 16px 4px;
}

.sidebar-nav a, .nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
  margin: 1px 8px;
  border-radius: var(--r-md);
  font-size: 13px;
  color: var(--sb-text);
  transition: background 0.12s, color 0.12s;
  position: relative;
}
.sidebar-nav a:hover, .nav-item:hover {
  background: var(--sb-bg-hover);
  color: var(--sb-text-strong);
}
.sidebar-nav a.active, .nav-item.active {
  background: var(--sb-bg-active);
  color: var(--sb-text-strong);
  font-weight: 600;
}
.nav-icon { flex-shrink: 0; opacity: 0.85; }
.nav-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.14);
  color: var(--sb-text-muted);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--sb-border);
  margin-top: auto;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; overflow: hidden; }
.sidebar-user-name {
  font-size: 12.5px; font-weight: 600; color: var(--sb-text-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px; color: var(--sb-text-muted);
}
.sidebar-user-btn {
  background: none; border: none; color: var(--sb-text-muted);
  padding: 4px; border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  transition: color 0.12s;
}
.sidebar-user-btn:hover { color: var(--sb-text-strong); }

/* ============================================================
   Main content area
   ============================================================ */
.admin-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.admin-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 24px;
  height: 52px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar-breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-2);
}
.topbar-breadcrumb .crumb-sep { color: var(--text-3); }
.topbar-breadcrumb .crumb-current { color: var(--text); font-weight: 500; }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.topbar-saved {
  font-size: 12px; color: var(--text-3);
  display: flex; align-items: center; gap: 5px;
}

.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px 28px 40px;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
  border: none; cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent); color: #fff;
  box-shadow: var(--sh-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-2); }

.btn-secondary {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--sh-sm);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg); }

.btn-ghost {
  background: transparent; color: var(--text-2);
  border: 1px solid transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-2); color: var(--text); }

.btn-danger {
  background: var(--danger); color: #fff;
}
.btn-danger:hover:not(:disabled) { opacity: 0.88; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

.btn-icon {
  padding: 7px; border-radius: var(--r-md);
  background: none; border: none; color: var(--text-3);
  display: inline-flex; align-items: center;
  transition: background 0.12s, color 0.12s;
}
.btn-icon:hover { background: var(--bg-2); color: var(--text); }

/* ============================================================
   Cards & Surfaces
   ============================================================ */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--sh);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-body { padding: 20px; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  box-shadow: var(--sh-sm);
}
.stat-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3); margin-bottom: 8px;
}
.stat-value {
  font-size: 28px; font-weight: 700;
  color: var(--text); line-height: 1;
  margin-bottom: 6px;
}
.stat-sub {
  font-size: 12px; color: var(--text-3);
}
.stat-sub.warn { color: var(--warn); }
.stat-sub.danger { color: var(--danger); }
.stat-sub.success { color: var(--success); }

/* ============================================================
   Status Badges
   ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 500;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  flex-shrink: 0;
}
.badge-published { background: #e8f5ee; color: #2e6e47; }
.badge-published::before { background: #3ea76a; }
.badge-draft { background: #f0ede8; color: #6b5c44; }
.badge-draft::before { background: #c9a876; }
.badge-scheduled { background: #e8eef8; color: #2d4f8a; }
.badge-scheduled::before { background: #4a7fce; }
.badge-pending { background: #fff4e5; color: #7a4f0d; }
.badge-pending::before { background: #e08c2e; }
.badge-spam { background: #fdeaea; color: #7a1f1f; }
.badge-spam::before { background: #d94040; }
.badge-trash { background: var(--bg-2); color: var(--text-3); }
.badge-trash::before { background: var(--text-3); }

/* role badges */
.badge-role {
  background: var(--bg-2);
  color: var(--text-2);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--r);
}

/* ============================================================
   Tables
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--bg); }

.table-title { font-weight: 500; color: var(--text); }
.table-slug { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.table-actions {
  display: flex; gap: 4px; justify-content: flex-end;
  opacity: 0;
  transition: opacity 0.15s;
}
.data-table tbody tr:hover .table-actions { opacity: 1; }

/* ============================================================
   Filter tabs
   ============================================================ */
.filter-tabs {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.filter-tab {
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.12s;
  display: inline-flex; align-items: center; gap: 5px;
}
.filter-tab:hover { border-color: var(--accent); color: var(--accent); }
.filter-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 500;
}

/* ============================================================
   Form controls
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; margin-bottom: 5px;
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  border-color: var(--accent-cool);
  box-shadow: 0 0 0 3px rgba(123,167,201,0.18);
}
.form-control::placeholder { color: var(--text-3); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }

.form-hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }

/* ============================================================
   Page header
   ============================================================ */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 24px; gap: 16px;
}
.page-title {
  font-size: 28px; font-weight: 700;
  font-family: var(--ff-serif);
  color: var(--text); line-height: 1.15;
}
.page-subtitle {
  font-size: 13px; color: var(--text-3); margin-top: 4px;
}
.page-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ============================================================
   Search input
   ============================================================ */
.search-input {
  position: relative;
}
.search-input input {
  padding-left: 32px;
  width: 220px;
}
.search-input-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}

/* ============================================================
   Avatar
   ============================================================ */
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-md { width: 36px; height: 36px; font-size: 14px; }
.avatar-lg { width: 44px; height: 44px; font-size: 17px; }

/* ============================================================
   Toast system
   ============================================================ */
.toast-container {
  position: fixed; bottom: 20px; left: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999; pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  min-width: 260px; max-width: 380px;
  pointer-events: all;
  animation: toast-in 0.22s ease;
  font-size: 13.5px;
}
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warn); }
.toast-info { border-left: 3px solid var(--accent-cool); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   Modal / Dialog
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20,28,42,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  width: 100%; max-width: 480px;
  overflow: hidden;
  animation: slideUp 0.18s ease;
}
.modal-lg { max-width: 780px; }
.modal-header {
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-body { padding: 20px 22px; }
.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Media grid
   ============================================================ */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.media-card:hover { box-shadow: var(--sh-md); border-color: var(--accent-cool); }
.media-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.media-thumb {
  aspect-ratio: 4/3;
  background: var(--bg-2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-type-badge {
  position: absolute; top: 6px; left: 6px;
  background: rgba(20,28,42,0.7);
  color: #fff; font-size: 9px; font-weight: 700;
  letter-spacing: 0.05em;
  padding: 2px 5px; border-radius: 3px;
}
.media-info { padding: 8px 10px; }
.media-filename {
  font-size: 12px; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.media-size { font-size: 11px; color: var(--text-3); margin-top: 2px; }

/* ============================================================
   Page editor split view
   ============================================================ */
.editor-shell {
  display: flex;
  height: 100%;
  overflow: hidden;
}
.editor-left {
  width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}
.editor-left-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.editor-left-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-3); margin-bottom: 2px;
}
.editor-page-title-input {
  width: 100%;
  border: none; outline: none;
  font-size: 16px; font-weight: 600;
  color: var(--text);
  background: transparent;
  padding: 0;
}

.editor-status-row {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px; flex-wrap: wrap;
}
.status-btn {
  padding: 3px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12px; cursor: pointer;
  color: var(--text-2);
  transition: all 0.12s;
}
.status-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 500;
}

.editor-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}
.editor-tab {
  flex: 1; padding: 10px;
  background: none; border: none;
  font-size: 12.5px; color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.12s, border-color 0.12s;
}
.editor-tab.active {
  color: var(--accent); font-weight: 600;
  border-bottom-color: var(--accent);
}

.editor-blocks-list {
  flex: 1; overflow-y: auto;
  padding: 8px;
}
.block-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.12s;
  border: 1px solid transparent;
}
.block-item:hover { background: var(--bg); }
.block-item.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.block-drag-handle {
  cursor: grab;
  color: var(--text-3);
  padding: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.12s;
}
.block-item:hover .block-drag-handle { opacity: 1; }
.block-item-ghost { opacity: 0.4; background: var(--accent-soft); border-color: var(--accent); }
.block-item-dragging { box-shadow: var(--sh-md); cursor: grabbing; background: var(--surface); }

.block-item-icon {
  width: 30px; height: 30px;
  background: var(--bg-2);
  border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-2);
}
.block-item-info { flex: 1; overflow: hidden; min-width: 0; }
.block-item-type {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3);
}
.block-item-preview {
  font-size: 12.5px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.block-item-actions {
  display: flex; gap: 2px;
  opacity: 0;
  transition: opacity 0.12s;
}
.block-item:hover .block-item-actions { opacity: 1; }

.add-block-btn {
  margin: 8px;
  width: calc(100% - 16px);
  padding: 10px;
  border: 1.5px dashed var(--border);
  border-radius: var(--r-md);
  background: none;
  color: var(--text-3);
  font-size: 13px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.add-block-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.editor-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.editor-preview-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
}
.preview-url {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 5px 12px;
  font-size: 12.5px;
  color: var(--text-3);
  font-family: var(--ff-mono);
}
.preview-device-btns {
  display: flex; gap: 4px;
}
.preview-device-btn {
  padding: 5px; border-radius: var(--r);
  background: none; border: none;
  color: var(--text-3); cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.preview-device-btn:hover, .preview-device-btn.active {
  background: var(--bg); color: var(--text);
}

.editor-canvas {
  flex: 1; overflow: auto;
  background: var(--bg-2);
  display: flex; justify-content: center; padding: 16px;
}
.canvas-frame {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-md);
  width: 100%;
  max-width: 1100px;
  min-height: 400px;
  overflow: visible;
  transition: max-width 0.2s;
  align-self: flex-start;
}
.canvas-frame.tablet { max-width: 768px; }
.canvas-frame.mobile { max-width: 390px; }

/* ============================================================
   Block settings panel
   ============================================================ */
.block-settings-panel {
  width: 280px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-direction: column;
  overflow-y: auto;
  transition: width 0.2s ease;
}
.block-settings-panel--wide {
  width: 420px;
}

/* Trix inside the settings panel — moderate height (tabs, etc.) */
.block-settings-panel trix-editor {
  min-height: 160px;
  max-height: 360px;
  overflow-y: auto;
  font-size: 13.5px;
}
/* RichText block opens the wide panel → give its editor full height */
.block-settings-panel--wide trix-editor {
  min-height: calc(100vh - 320px);
  max-height: none;
}
.block-settings-panel trix-toolbar .trix-button-group {
  margin-bottom: 4px;
}
.block-settings-panel trix-toolbar .trix-button {
  width: 28px;
  height: 28px;
  font-size: 12px;
  padding: 0;
}
.block-settings-panel trix-toolbar .trix-button--icon::before {
  width: 14px;
  height: 14px;
}
.settings-panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.06em;
}
.settings-panel-body { padding: 14px; }
.settings-group { margin-bottom: 14px; }
.settings-label {
  display: block; margin-bottom: 5px;
  font-size: 11.5px; font-weight: 500; color: var(--text-2);
}

/* ============================================================
   Block type picker
   ============================================================ */
.block-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 12px;
}
.block-type-btn {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  font-size: 11px; color: var(--text-2);
  text-align: center;
  transition: all 0.12s;
}
.block-type-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-2);
}
.block-type-icon { font-size: 18px; }
.block-group-title {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-3);
  padding: 10px 12px 4px;
}

/* ============================================================
   Utility
   ============================================================ */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.text-muted { color: var(--text-3); }
.text-sm { font-size: 12px; }
.font-mono { font-family: var(--ff-mono); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* activity feed */
.activity-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-text { flex: 1; line-height: 1.5; }
.activity-text strong { font-weight: 600; }
.activity-time { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* quick nav cards */
.quick-nav-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.quick-nav-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
  text-decoration: none; color: inherit;
}
.quick-nav-card:hover { background: var(--bg-2); border-color: var(--border-strong); }
.quick-nav-card-info { flex: 1; overflow: hidden; }
.quick-nav-card-title { font-size: 13px; font-weight: 500; color: var(--text); }
.quick-nav-card-slug { font-size: 11.5px; color: var(--text-3); }
.quick-nav-card-status { margin-left: auto; }

/* site status */
.status-row {
  display: flex; align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.status-row:last-child { border-bottom: none; }
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  margin-right: 10px; flex-shrink: 0;
}
.status-dot.ok { background: var(--success); }
.status-dot.warn { background: var(--warn); }
.status-dot.danger { background: var(--danger); }
.status-row-label { flex: 1; color: var(--text-2); }
.status-row-value { font-size: 12.5px; color: var(--text-3); }
.status-row-value.warn { color: var(--warn); }
.status-row-value.danger { color: var(--danger); }

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

/* ============================================================
   Trix editor overrides
   ============================================================ */
.trix-container { border: 1px solid var(--border); border-radius: var(--r-md); overflow: hidden; }
trix-editor {
  min-height: 320px;
  padding: 14px 16px;
  font-family: var(--ff-ui);
  font-size: 14.5px;
  line-height: 1.7;
  color: var(--text);
  border: none !important;
  outline: none;
}
trix-toolbar .trix-button-group { border-color: var(--border) !important; }
trix-toolbar .trix-button {
  border-color: transparent !important;
  color: var(--text-2) !important;
}
trix-toolbar .trix-button:hover { background: var(--bg) !important; }
trix-toolbar .trix-button.trix-active { background: var(--accent-soft) !important; color: var(--accent-2) !important; }
trix-toolbar { border-bottom: 1px solid var(--border) !important; padding: 6px 8px !important; }

/* Toolbar: wrap buttons onto multiple rows instead of a horizontal scrollbar */
trix-toolbar .trix-button-row {
  flex-wrap: wrap !important;
  overflow-x: visible !important;
  justify-content: flex-start !important;
  gap: 4px;
}
trix-toolbar .trix-button-group:not(:first-child) { margin-left: 0 !important; }

/* The shipped trix.css (2.1.1) has no rule to hide inactive dialogs, so the
   link popup ("Enter a URL…") shows permanently. Hide it unless Trix marks it active. */
trix-toolbar .trix-dialog { display: none; }
trix-toolbar .trix-dialog[data-trix-active],
trix-toolbar .trix-dialog.trix-active { display: block; }

/* Images / attachments inside Trix + rendered rich text stay responsive */
trix-editor img,
trix-editor .attachment img,
.richtext img,
.richtext .attachment img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}
trix-editor .attachment,
.richtext .attachment {
  display: inline-block;
  max-width: 100%;
}

/* ============================================================
   Post editor layout
   ============================================================ */
.post-editor-shell {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 52px);
}
.post-editor-main {
  flex: 1;
  overflow-y: auto;
  padding: 28px 32px 60px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.post-editor-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.sidebar-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  margin-bottom: 10px;
}
.post-title-input {
  width: 100%;
  border: none;
  outline: none;
  font-family: var(--ff-serif);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  background: transparent;
  line-height: 1.25;
  resize: none;
}
.post-slug-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  font-size: 12.5px;
  color: var(--text-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.post-slug-input {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--ff-mono);
  font-size: 12px;
  color: var(--accent-cool-2);
  background: transparent;
}
.post-slug-input:focus { color: var(--text); }

/* Tag input */
.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: text;
  min-height: 36px;
  align-items: center;
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent-soft);
  color: var(--accent-2);
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}
.tag-chip button {
  background: none;
  border: none;
  color: var(--accent-2);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  font-size: 14px;
}
.tag-input {
  border: none;
  outline: none;
  font-size: 12.5px;
  background: transparent;
  min-width: 80px;
  flex: 1;
}

/* Featured image picker */
.featured-img-placeholder {
  aspect-ratio: 16/9;
  background: var(--bg-2);
  border: 2px dashed var(--border);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-3);
  font-size: 13px;
  transition: border-color 0.15s, background 0.15s;
}
.featured-img-placeholder:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.featured-img-preview {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
}
.featured-img-preview img { width: 100%; display: block; aspect-ratio: 16/9; object-fit: cover; }
.featured-img-remove {
  position: absolute; top: 6px; right: 6px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: none;
  border-radius: var(--r);
  padding: 4px 6px;
  font-size: 11px;
  cursor: pointer;
}

/* character counter */
.char-count { font-size: 11px; color: var(--text-3); text-align: right; margin-top: 3px; }
.char-count.warn { color: var(--warn); }
.char-count.over { color: var(--danger); }

/* ============================================================
   Gallery editor
   ============================================================ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}
.gallery-item {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-2);
  border: 2px solid transparent;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: grab;
}
.gallery-item:hover { border-color: var(--accent); box-shadow: var(--sh-md); }
.gallery-item.editing { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.gallery-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.gallery-item-overlay {
  position: absolute; inset: 0;
  background: rgba(20,28,42,0);
  transition: background 0.15s;
  display: flex; flex-direction: column;
  justify-content: space-between; padding: 6px;
}
.gallery-item:hover .gallery-item-overlay { background: rgba(20,28,42,0.35); }
.gallery-drag-handle {
  width: 24px; height: 24px;
  background: rgba(0,0,0,0.5); border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
  color: #fff; opacity: 0; transition: opacity 0.15s;
  cursor: grab;
}
.gallery-item:hover .gallery-drag-handle { opacity: 1; }
.gallery-item-actions {
  display: flex; gap: 4px; justify-content: flex-end;
  opacity: 0; transition: opacity 0.15s;
}
.gallery-item:hover .gallery-item-actions { opacity: 1; }
.gallery-action-btn {
  width: 26px; height: 26px;
  background: rgba(0,0,0,0.55); border: none; border-radius: var(--r);
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s;
}
.gallery-action-btn:hover { background: rgba(0,0,0,0.8); }
.gallery-action-btn.danger:hover { background: var(--danger); }

/* SortableJS states */
.sortable-ghost { opacity: 0.4; }
.sortable-drag { opacity: 0.9; box-shadow: var(--sh-lg); cursor: grabbing; }

/* Layout preview badges */
.layout-picker { display: flex; gap: 8px; }
.layout-option {
  flex: 1; padding: 10px 6px;
  border: 2px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); cursor: pointer;
  text-align: center; font-size: 11.5px; color: var(--text-2);
  transition: all 0.12s;
}
.layout-option:hover { border-color: var(--accent-cool); }
.layout-option.active {
  border-color: var(--accent); background: var(--accent-soft);
  color: var(--accent-2); font-weight: 600;
}
.layout-option-icon { font-size: 20px; display: block; margin-bottom: 4px; }

/* Gallery preview in editor */
.gallery-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.gallery-preview-masonry {
  columns: 3; column-gap: 6px;
}
.gallery-preview-masonry img { width: 100%; margin-bottom: 6px; border-radius: var(--r); display: block; }
.gallery-preview-slideshow {
  position: relative; overflow: hidden; border-radius: var(--r-md);
}
.gallery-preview-slideshow img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }

/* ============================================================
   Menu manager
   ============================================================ */
.menu-item-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface);
}
.menu-item-drag { cursor: grab; color: var(--text-3); display: flex; padding: 2px; flex-shrink: 0; }
.menu-item-target {
  font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-3); background: var(--bg-2); padding: 2px 8px; border-radius: 20px; flex-shrink: 0;
}
.menu-item-ghost { opacity: .4; background: var(--accent-soft); border-color: var(--accent); }

/* ============================================================
   Tabs & Accordion (shared: admin preview + public site)
   ============================================================ */
.site-tabs-bar { display:flex; gap:4px; border-bottom:2px solid var(--border); margin-bottom:18px; flex-wrap:wrap; }
.site-tab { padding:10px 18px; font-size:15px; font-weight:600; color:var(--text-3); background:none; border:none; border-bottom:2px solid transparent; margin-bottom:-2px; cursor:pointer; }
.site-tab.active { color:var(--accent); border-bottom-color:var(--accent); }
.site-tabpanel { display:none; }
.site-tabpanel.active { display:block; }

.site-accordion-item { border:1px solid var(--border); border-radius:var(--r-md); margin-bottom:8px; overflow:hidden; }
.site-accordion-header { width:100%; padding:14px 16px; background:var(--bg); display:flex; align-items:center; justify-content:space-between; font-weight:600; font-size:15px; color:var(--text); border:none; cursor:pointer; text-align:left; font-family:inherit; }
.site-accordion-chevron { transition:transform .2s ease; flex-shrink:0; }
.site-accordion-item.open .site-accordion-chevron { transform:rotate(180deg); }
.site-accordion-panel { display:none; font-size:15px; color:var(--text-2); line-height:1.6; }
.site-accordion-item.open .site-accordion-panel { display:block; }

/* ============================================================
   Rich text canvas preview styling
   ============================================================ */
.richtext h1, .richtext h2, .richtext h3,
.richtext h4, .richtext h5, .richtext h6 {
  font-family: var(--ff-serif);
  font-weight: 700;
  color: var(--text);
  margin: 0.75em 0 0.4em;
  line-height: 1.25;
}
.richtext h1 { font-size: 2em; }
.richtext h2 { font-size: 1.5em; }
.richtext h3 { font-size: 1.25em; }
.richtext p  { margin: 0 0 0.75em; }
.richtext ul, .richtext ol { padding-left: 1.5em; margin: 0 0 0.75em; }
.richtext li { margin-bottom: 0.3em; }
.richtext a  { color: var(--accent-cool-2); text-decoration: underline; }
.richtext strong { font-weight: 700; }
.richtext em { font-style: italic; }
.richtext blockquote {
  border-left: 3px solid var(--accent);
  margin: 0.75em 0;
  padding: 6px 16px;
  color: var(--text-2);
  font-style: italic;
}
.richtext pre, .richtext code {
  font-family: var(--ff-mono);
  background: var(--bg-2);
  border-radius: var(--r);
  padding: 2px 6px;
  font-size: 0.9em;
}
