/* Pelican Email Builder */

/* ========== CSS Custom Properties ========== */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #e0e7ff;
  --secondary: #64748b;
  --secondary-hover: #475569;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --success: #16a34a;
  --success-light: #dcfce7;
  --warning: #d97706;
  --warning-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
  --sidebar-width: 240px;
  --toolbar-height: 52px;
  --transition: 150ms ease;
  --site-fork-bg: #eaecf3;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --primary-light: #1e1b4b;
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --border: #334155;
    --border-strong: #475569;
    --success: #4ade80;
    --success-light: #052e16;
    --warning: #fbbf24;
    --warning-light: #451a03;
    --danger: #f87171;
    --danger-light: #450a0a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
    --site-fork-bg: #253347;
  }
}

/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== App Layout ========== */
#app {
  display: grid;
  grid-template-areas:
    "toolbar toolbar"
    "sidebar main";
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--toolbar-height) 1fr;
  height: 100vh;
}

/* ========== Toolbar ========== */
#toolbar {
  grid-area: toolbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
}
.toolbar-left, .toolbar-center, .toolbar-right { display: flex; align-items: center; gap: 8px; }
.toolbar-title { font-weight: 600; font-size: 15px; }
.site-selector {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  min-width: 200px;
}
.user-menu { position: relative; }
.user-menu-trigger { display: flex; align-items: center; gap: 4px; }
.user-menu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  z-index: 200;
}
.user-menu.open .user-menu-dropdown { display: block; }
.user-menu-dropdown a {
  display: block;
  padding: 8px 14px;
  color: var(--text);
  font-size: 13px;
}
.user-menu-dropdown a:hover { background: var(--surface-hover); text-decoration: none; }

/* ========== Sidebar ========== */
#sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  transition: transform var(--transition);
}
#sidebar.collapsed { transform: translateX(calc(-1 * var(--sidebar-width))); }
#app.sidebar-collapsed { grid-template-columns: 0 1fr; }
#app.sidebar-collapsed #sidebar { overflow: hidden; }
.sidebar-nav { padding: 8px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--primary-light); color: var(--primary); }
.nav-item svg { flex-shrink: 0; }
.nav-divider { height: 1px; background: var(--border); margin: 8px 12px; }
.nav-section-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); padding: 14px 16px 4px; user-select: none;
}

.nav-group .nav-item { position: relative; }
.nav-group-chevron {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  transition: transform 0.2s ease; color: var(--text-muted);
}
.nav-group.collapsed .nav-group-chevron { transform: translateY(-50%) rotate(-90deg); }
.nav-group.collapsed .nav-subitems { display: none; }

.nav-subitems {
  display: flex;
  flex-direction: column;
  padding-left: 28px;
}
.nav-subitems:empty { display: none; }

.nav-subitem {
  display: block;
  padding: 5px 12px;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}
.nav-subitem:hover {
  background: var(--surface-hover);
  color: var(--text);
  text-decoration: none;
}
.nav-subitem.active {
  color: var(--primary);
}

/* ========== Main Content ========== */
#main-content {
  grid-area: main;
  overflow-y: auto;
  padding: 24px;
}
#page-content { max-width: none; }

/* ========== Page Header ========== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 { font-size: 22px; font-weight: 600; }
.page-header-actions { display: flex; gap: 12px; }

/* ========== Page Toolbar ========== */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding: 10px 0;
  gap: 16px;
  flex-wrap: wrap;
}
.page-toolbar .search-input-wrapper {
  margin-left: auto;
  min-width: 200px;
}

/* ========== Cards ========== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
}
.card-body { padding: 20px; }
.card-actions {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
/* List-card: unified card pattern for admin list views */
.list-card .card-body { padding: 16px 20px; }
.list-card .card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.list-card .card-title strong {
  font-size: 14px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-card .card-meta {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.list-card .card-meta:empty { display: none; }
.list-card .card-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}
.list-card .card-badges:empty { display: none; }

/* Layout cards — larger with wireframe preview */
.layout-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}
.layout-card { overflow: hidden; }
.layout-card-preview {
  background: var(--bg-secondary);
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.layout-card-title { font-size: 15px; }

/* Wireframe rendering */
.layout-wireframe {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 120px;
}
.layout-wireframe .lw-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 120px;
  color: var(--text-secondary);
  font-size: 13px;
}
.lw-slot {
  border: 1.5px dashed var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}
.lw-slot span {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}
.lw-full { width: 100%; }
.lw-row {
  display: flex;
  gap: 4px;
  flex: 1;
}
.lw-row .lw-wide { flex: 3; }
.lw-row .lw-narrow { flex: 1; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stat-card .stat-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }

/* ========== Tables ========== */
.table-wrapper { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--surface-hover); }
th {
  text-align: left;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
tr:hover td { background: var(--surface-hover); }
tr.selected td { background: var(--primary-bg, rgba(99, 102, 241, 0.1)); }
tr.row-clickable { cursor: pointer; }
tr.row-disabled td { opacity: 0.5; }
tr.row-disabled td:has(.form-toggle) { opacity: 1; }
.pages-table td:first-child a { font-weight: 500; color: var(--text); }
.pages-table td:first-child a:hover { color: var(--primary); text-decoration: none; }

/* ========== Status Badges ========== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge-draft { background: var(--border); color: var(--text-secondary); }
.badge-published { background: var(--success-light); color: var(--success); }
.badge-archived { background: var(--warning-light); color: var(--warning); }
.badge-trashed { background: var(--danger-light); color: var(--danger); }
.badge-active { background: var(--success-light); color: var(--success); }
.badge-role { background: var(--primary-light, #e3f2fd); color: var(--primary, #1976d2); }
.badge-paused { background: var(--warning-light); color: var(--warning); }
.badge-completed { background: var(--primary-light); color: var(--primary); }
.badge-under_construction { background: var(--warning-light); color: var(--warning); }
.badge-info { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-muted { background: var(--border); color: var(--text-muted); }
.badge-warning { background: var(--warning-light); color: var(--warning); }

/* Sites - fork rows */
.site-fork-row td { background: var(--site-fork-bg) !important; }

/* ========== Alerts ========== */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.5;
}
.alert strong { font-weight: 600; }
.alert-warning {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid var(--warning);
}
.alert-info {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary);
}
.alert-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger);
}
.alert-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid var(--success);
}
.alert-muted {
  background: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
}
.alert-compact {
  padding: 6px 12px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.alert-compact .btn-dismiss-warning {
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: 1.2em;
  font-weight: bold;
  line-height: 1;
  opacity: 0.6;
  flex-shrink: 0;
}
.alert-compact .btn-dismiss-warning:hover { opacity: 1; }

/* ========== Tabs ========== */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; padding-bottom: 1px; }
.tab {
  padding: 8px 10px;
  font-size: 12px;
  white-space: nowrap;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs::-webkit-scrollbar { height: 3px; }
.tabs::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.tabs::-webkit-scrollbar-track { background: transparent; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  line-height: 1;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: none; padding: 6px 8px; }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; }

/* ========== Forms ========== */
.form-group { margin-bottom: 20px; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.form-hint {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-top: 6px;
}

.form-input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input-sm {
  padding: 6px 10px;
  font-size: 13px;
}

input:focus, select:focus, textarea:focus, .form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

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

/* Checkbox styling */
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}

.form-check,
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.form-check input[type="checkbox"],
.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.form-check-label {
  font-weight: 500;
  color: var(--text);
}

/* Field with help text pattern */
.form-field {
  margin-bottom: 20px;
}

.form-field:last-child {
  margin-bottom: 0;
}

.form-field-help {
  margin: 6px 0 0 28px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Range input styling */
input[type="range"] {
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  border: 2px solid var(--surface);
  box-shadow: var(--shadow);
}

input[type="range"]:focus {
  outline: none;
  box-shadow: none;
}

.form-row { display: flex; gap: 16px; }
.form-row > * { flex: 1; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.char-count { font-size: 11px; color: var(--text-muted); text-align: right; margin-top: 2px; }
.char-count.over { color: var(--danger); }

/* Toggle switch style (optional, for special cases) */
.form-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.form-toggle input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
}

.form-toggle input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.form-toggle input[type="checkbox"]:checked {
  background: var(--primary);
}

.form-toggle input[type="checkbox"]:checked::after {
  transform: translateX(16px);
}

/* ========== Search ========== */
.search-input-wrapper {
  position: relative;
  max-width: 300px;
}
.search-input-wrapper input {
  padding-left: 32px;
}
.search-input-wrapper svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

/* ========== Modals ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}
.modal-overlay.hidden { display: none; }
.modal-container {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 560px;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-container.modal-sm { max-width: 400px; }
.modal-container.modal-lg { max-width: 780px; }
.modal-container.modal-xl { max-width: 1000px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.modal-body { padding: 20px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

/* Scrollable modal variant - fixed header/footer, scrollable body */
.modal-container.modal-scrollable {
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
}
.modal-scrollable .modal-header {
  flex-shrink: 0;
}
.modal-scrollable .modal-body {
  flex: 1;
  overflow-y: auto;
}
.modal-scrollable .modal-footer {
  flex-shrink: 0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover {
  background: var(--hover);
  color: var(--text);
}
.modal-confirm-message {
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
}
.modal-confirm-details {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-height: 200px;
  overflow-y: auto;
  margin-top: 12px;
}
/* ========== Starter Preset Cards ========== */
.starter-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.starter-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.starter-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.starter-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: #c0392b;
  border-color: #c0392b;
}
.btn-warning {
  background: var(--warning);
  color: #fff;
  border-color: var(--warning);
}
.btn-warning:hover {
  background: #d68910;
  border-color: #d68910;
}

/* ========== Toast Notifications ========== */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}
.toast {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 200ms ease;
  min-width: 260px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast-warning { background: var(--warning); color: #fff; }
.toast.removing { animation: toastOut 200ms ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(10px); } }

/* ========== Media Grid ========== */
.media-layout { display: flex; gap: 16px; min-height: calc(100vh - 200px); }
.media-sidebar { width: 200px; flex-shrink: 0; min-width: 0; overflow: hidden; }
.media-main { flex: 1; position: relative; }
.media-main.drag-over { outline: 2px dashed var(--primary); outline-offset: -4px; border-radius: var(--radius-lg); background: var(--primary-light); }
.media-empty-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; min-height: 300px; color: var(--text-muted); text-align: center; }
.media-empty-drop p { margin-top: 8px; font-size: 13px; }
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.media-item {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--surface);
}
.media-item:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.media-item.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.media-thumb {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb .file-icon { font-size: 28px; color: var(--text-muted); }
.media-info { padding: 8px 10px; }
.media-info .media-name { font-size: 12px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-info .media-size { font-size: 11px; color: var(--text-muted); }
.media-list-view .media-grid {
  grid-template-columns: 1fr;
}
.media-list-view .media-item {
  display: flex;
  align-items: center;
}
.media-list-view .media-thumb { width: 48px; height: 48px; aspect-ratio: auto; flex-shrink: 0; }
.media-list-view .media-info { flex: 1; }

/* Drag feedback */
.category-drop-target { background: var(--primary-light) !important; color: var(--primary) !important; }
.media-item.dragging { opacity: 0.4; }

/* Media delete button overlay */
.media-delete-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--danger);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  padding: 0;
}
.media-item:hover .media-delete-btn { opacity: 1; }
.media-delete-btn:hover { filter: brightness(1.1); }
.media-list-view .media-delete-btn {
  position: static;
  opacity: 0;
  flex-shrink: 0;
  margin-right: 8px;
}
.media-list-view .media-item:hover .media-delete-btn { opacity: 1; }

/* Media select checkbox overlay */
.media-select-cb {
  position: absolute;
  top: 6px;
  left: 6px;
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 2px solid rgba(255,255,255,0.8);
  background: rgba(0,0,0,0.25);
  cursor: pointer;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: bold;
  color: #fff;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
  user-select: none;
}
.media-item:hover .media-select-cb,
.media-item.bulk-selected .media-select-cb { opacity: 1; }
.media-item.bulk-selected .media-select-cb {
  background: var(--primary);
  border-color: var(--primary);
}
.media-list-view .media-select-cb {
  position: static;
  flex-shrink: 0;
  margin-left: 8px;
  opacity: 0;
}
.media-list-view .media-item:hover .media-select-cb,
.media-list-view .media-item.bulk-selected .media-select-cb { opacity: 1; }

/* Media bulk action bar */
.media-bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin-bottom: 12px;
  background: var(--primary-light);
  border: 1px solid var(--primary);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  position: sticky;
  top: 0;
  z-index: 5;
}
.media-bulk-bar .bulk-count {
  color: var(--primary);
  white-space: nowrap;
}
.media-bulk-bar select {
  width: auto;
  min-width: 140px;
  padding: 4px 8px;
  font-size: 12px;
}

/* Media usage section in detail panel */
.media-usage-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.media-usage-section h4 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.media-usage-list {
  list-style: none;
  font-size: 13px;
}
.media-usage-list li {
  padding: 4px 0;
}
.media-usage-list .usage-type {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-right: 4px;
}
.media-usage-empty {
  font-size: 12px;
  font-style: italic;
  color: var(--text-muted);
}

/* Media Detail Panel */
.media-detail {
  position: fixed;
  right: 0;
  top: var(--toolbar-height);
  bottom: 0;
  width: 340px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  overflow-y: auto;
  z-index: 50;
  transform: translateX(100%);
  transition: transform 200ms ease;
}
.media-detail.open { transform: none; }

/* ========== Pagination ========== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 20px;
}
.pagination button {
  min-width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.pagination button:hover { background: var(--surface-hover); }
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: default; }

/* ========== Split Test Chart ========== */
.bar-chart { display: flex; align-items: flex-end; gap: 12px; height: 200px; padding: 16px 0; }
.bar-chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar-chart-bar { width: 100%; max-width: 60px; background: var(--primary); border-radius: 4px 4px 0 0; transition: height 300ms ease; }
.bar-chart-label { font-size: 11px; color: var(--text-secondary); text-align: center; }
.bar-chart-value { font-size: 12px; font-weight: 600; }

/* ========== Category Tree ========== */
.category-tree { list-style: none; }
.category-tree li {
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
  border-radius: var(--radius);
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 4px;
}
.category-tree .category-name { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.category-tree .category-delete {
  display: none; background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 16px; line-height: 1; padding: 0 2px; flex-shrink: 0;
}
.category-tree .category-delete:hover { color: var(--danger, #e53e3e); }
.category-tree li:hover .category-delete { display: block; }
.category-tree li:hover { background: var(--surface-hover); }
.category-tree li.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }

/* ========== Loading Spinner ========== */
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 13px; margin-bottom: 16px; }

/* ========== Responsive ========== */
@media (max-width: 1024px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-palette { display: none; }
}
@media (max-width: 768px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "toolbar"
      "main";
  }
  #sidebar {
    position: fixed;
    top: var(--toolbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 90;
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }
  #sidebar.mobile-open { transform: none; }
  .media-layout { flex-direction: column; }
  .media-sidebar { width: 100%; }
  .form-row { flex-direction: column; }
}

/* ========== Utility ========== */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.inline-flex { display: inline-flex; align-items: center; gap: 6px; }

/* ========== Split Test Inline Results ========== */
.split-results-row > td { background: color-mix(in srgb, var(--surface), var(--surface-hover)); }
.split-results-panel {
  padding: 16px 20px;
  border-top: 2px solid var(--color-primary, #3b82f6);
  color: var(--text);
}
.split-results-header {
  margin-bottom: 12px;
  font-size: 0.9rem;
}
.split-results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.split-results-table th,
.split-results-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.split-results-table th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.split-results-table th.num,
.split-results-table td.num { text-align: right; }
.split-bar {
  background: var(--border);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}
.split-bar-fill {
  background: var(--color-primary, #3b82f6);
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}
.split-results-promote {
  display: flex;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ========== Email Editor ========== */
.email-editor {
  display: grid;
  grid-template-columns: 200px 1fr 280px;
  height: calc(100vh - var(--toolbar-height) - 120px);
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.email-editor-palette {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  background: var(--bg);
}
.palette-header {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}
.palette-category { padding: 8px 0; }
.palette-category-label {
  padding: 4px 16px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}
.palette-block {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  transition: background var(--transition);
}
.palette-block:hover { background: var(--surface-hover); }
.palette-block-icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.palette-block-label { font-size: 13px; }
.palette-empty { padding: 16px; color: var(--text-muted); font-size: 13px; }

/* Canvas */
.email-editor-canvas {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
}
.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.canvas-toolbar-spacer { flex: 1; }
.canvas-blocks { padding: 12px; flex: 1; }
.canvas-empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Block items */
.canvas-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 4px;
  background: var(--surface);
  transition: border-color var(--transition);
}
.canvas-block.selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.canvas-block.container-block { background: var(--bg); }
.canvas-block.depth-0 { margin-bottom: 8px; }

.block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  cursor: pointer;
  user-select: none;
}
.block-header:hover { background: var(--surface-hover); }
.block-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 3px;
  font-size: 9px;
  font-weight: 700;
  flex-shrink: 0;
}
.block-label { font-size: 13px; flex: 1; }
.block-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
}
.block-header:hover .block-actions { opacity: 1; }
.btn-icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 12px;
  border-radius: 3px;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }

/* Block previews */
.block-preview-text,
.block-preview-heading,
.block-preview-button,
.block-preview-image,
.block-preview-divider,
.block-preview-spacer {
  padding: 4px 10px 8px 42px;
  font-size: 12px;
  color: var(--text-secondary);
}
.block-preview-heading { font-weight: 600; }
.block-preview-button { padding-bottom: 10px; }

/* Container children */
.block-children { padding: 4px 4px 4px 16px; }
.block-add-child {
  margin: 4px 16px 8px;
  font-size: 12px;
  color: var(--text-muted);
}

/* Properties panel */
.email-editor-properties {
  border-left: 1px solid var(--border);
  overflow-y: auto;
  background: var(--surface);
}
.properties-header {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}
.properties-body { padding: 12px; }
.properties-empty { padding: 24px 16px; color: var(--text-muted); font-size: 13px; text-align: center; }
.properties-block-title { font-weight: 600; font-size: 14px; margin-bottom: 12px; }
.properties-section { margin-bottom: 16px; }
.properties-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

/* Color input group */
.color-input-group {
  display: flex;
  gap: 6px;
  align-items: center;
}
.color-input-group input[type="color"] {
  width: 32px;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--surface);
}
.color-input-group input[type="text"] { flex: 1; }

/* Editor page layout */
.editor-page { display: flex; flex-direction: column; height: calc(100vh - var(--toolbar-height)); }
.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.editor-header-left { display: flex; align-items: center; gap: 12px; }
.editor-header-right { display: flex; align-items: center; gap: 8px; }
.editor-title-input {
  border: none;
  background: none;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  padding: 4px 8px;
  border-radius: var(--radius);
  min-width: 200px;
}
.editor-title-input:focus { outline: none; background: var(--surface-hover); }
.save-status { font-size: 12px; color: var(--text-muted); }
.btn-back { font-size: 13px; }

.editor-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}
.editor-meta .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 150px;
}
.editor-meta label { font-size: 11px; margin-bottom: 2px; }
.editor-meta .form-control { font-size: 13px; padding: 4px 8px; }

/* Inline form groups */
.form-group-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-group-inline label {
  white-space: nowrap;
  min-width: auto;
  margin-bottom: 0;
}

/* Loading spinner */
.loading-center {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Error page */
.error-page { padding: 40px; text-align: center; }
.error-page h2 { margin-bottom: 12px; }

/* Additional table styles for list views */
.actions-cell { white-space: nowrap; }
.text-sm { font-size: 12px; }
.text-muted { color: var(--text-muted); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-light); }

/* Page toolbar with tabs + search */
.page-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 16px;
}
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.tab:hover { background: var(--surface-hover); }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.search-input-wrapper { min-width: 200px; }
.search-input-wrapper input { width: 100%; }

/* ========== Media Grid ========== */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  padding: 16px;
}
.media-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow 0.2s;
}
.media-card:hover { box-shadow: var(--shadow); }
.media-card-thumb {
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.media-card-info { padding: 8px 10px; }
.media-card-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-card-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.media-card-actions {
  display: flex;
  gap: 4px;
  padding: 4px 8px 8px;
}
pelican-media.drag-over { outline: 2px dashed var(--primary); outline-offset: -4px; }

.input-with-btn { display: flex; gap: 8px; align-items: center; }
.input-with-btn .form-control { flex: 1; }

.view-toggle { display: flex; gap: 2px; }
.view-toggle .btn.active { background: var(--primary-light); color: var(--primary); }

/* ========== Pagination ========== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px;
}
.pagination-info { font-size: 13px; color: var(--text-secondary); }

/* ========== Media Picker Modal ========== */
.media-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.media-picker-item {
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
  background: var(--bg);
}
.media-picker-item:hover { border-color: var(--primary); }
.media-picker-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.media-picker-name {
  font-size: 11px;
  padding: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

/* ========== Site Access Rows ========== */
.site-access-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.site-access-row:last-child { border-bottom: none; }
.site-access-name { flex: 1; font-weight: 500; }

/* ========== Badges ========== */
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
