/* =====================================================================
   iDomainX Manager — app.css (black & white design system)
   Palette + fonts are variables at the top: change them here.
   ===================================================================== */
:root {
  /* Palette — black and white only (color allowed ONLY for errors) */
  --bg: #FFFFFF;
  --soft: #F5F5F5;
  --border: #E5E5E5;
  --ink: #0A0A0A;
  --muted: #737373;
  --danger: #B3261E;

  /* Fonts */
  --font-ui: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Z-index scale */
  --z-topbar: 40;
  --z-editor: 60;
  --z-modal: 100;
  --z-confirm: 110;
  --z-toast: 120;

  /* Layout */
  --topbar-h: 56px;
  --sidebar-w: 224px;
  --radius: 10px;
  --shadow-dialog: 0 8px 30px rgba(0, 0, 0, 0.10);
}

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@500;700;800&family=JetBrains+Mono:wght@400;700&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  font-weight: 500;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -0.02em; }
code, pre, .mono { font-family: var(--font-mono); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.danger-text { color: var(--danger); }
.cursor-pointer { cursor: pointer; }

/* ============================ BUTTONS ============================ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-ui); font-weight: 700; font-size: 13px;
  padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid transparent; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap; text-decoration: none !important;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { opacity: 0.85; }
.btn-secondary { background: var(--bg); color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { background: var(--soft); }
.btn-ghost { background: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--soft); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger:hover { background: var(--soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-block { width: 100%; justify-content: center; }

/* ============================ BADGES / DOTS ============================ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg); color: var(--muted);
}
.badge-black { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.badge-grey { background: var(--soft); color: var(--ink); }
.badge-error { color: var(--danger); border-color: var(--danger); }
.status-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
}
.status-dot.dirty { background: var(--ink); }

/* ============================ FORMS ============================ */
.input, select.input, textarea.input {
  font-family: var(--font-ui); font-weight: 500; font-size: 13px;
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--ink);
  outline: none; transition: border-color 0.15s;
}
.input:focus { border-color: var(--ink); }
.form-field { margin-bottom: 12px; }
.form-label {
  display: block; font-size: 12px; font-weight: 700;
  margin-bottom: 5px; letter-spacing: 0.01em;
}
.form-hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.form-hint.error { color: var(--danger); }
.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 13px; }
.code-editor {
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6;
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); color: var(--ink);
  outline: none; resize: vertical; white-space: pre; tab-size: 2;
}
.code-editor:focus { border-color: var(--ink); }
.input-error { border-color: var(--danger) !important; }

/* ============================ LAYOUT: SIDEBAR / TOPBAR ============================ */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
  position: fixed; top: 0; bottom: 0; left: 0;
  z-index: calc(var(--z-topbar) - 5);
  display: flex; flex-direction: column;
  padding: 16px 12px;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; font-size: 15px; letter-spacing: -0.02em;
  padding: 4px 8px 16px;
}
.sidebar-logo img { height: 22px; width: auto; display: block; }
.nav-group-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--muted);
  padding: 14px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius);
  font-size: 13px; font-weight: 700; color: var(--ink);
  cursor: pointer; text-decoration: none !important;
  transition: background 0.12s;
}
.nav-item:hover { background: var(--soft); text-decoration: none; }
.nav-item.active { background: var(--soft); color: var(--ink); }
.nav-item svg { flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--ink); color: var(--bg);
  font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
}
.main-area { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 24px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.topbar-breadcrumb { font-size: 13px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-menu-btn {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--ink); color: var(--bg);
  font-size: 12px; font-weight: 800; border: none; cursor: pointer;
}
.view-container { padding: 24px; max-width: 1200px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title { font-size: 20px; font-weight: 800; }
.page-subtitle { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ============================ CARDS / TABLES ============================ */
.card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 20px; }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.stat-value { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; margin-top: 6px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; background: var(--bg); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg);
}
td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--soft); }
.table-title a { font-weight: 700; }
.table-sub { font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.pin-badge { font-size: 10px; font-weight: 700; color: var(--muted); border: 1px solid var(--border); padding: 1px 6px; border-radius: 999px; margin-left: 6px; }

/* ============================ TOOLBAR / FILTERS ============================ */
.toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 0; flex-wrap: wrap; }
.list-filters { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.filter-select { width: auto; min-width: 130px; }

/* ============================ DROPDOWN ============================ */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  min-width: 160px; padding: 4px; z-index: var(--z-modal);
  box-shadow: var(--shadow-dialog); display: none;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item { padding: 7px 10px; border-radius: 6px; font-size: 13px; cursor: pointer; }
.dropdown-item:hover { background: var(--soft); }
.dropdown-item.danger { color: var(--danger); }

/* ============================ EMPTY / SKELETON / ACTIVITY ============================ */
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-state-icon { opacity: 0.4; margin-bottom: 12px; }
.empty-state-title { font-size: 15px; font-weight: 700; color: var(--ink); }
.empty-state-desc { font-size: 13px; margin: 4px 0 16px; }
.skeleton { background: var(--soft); border-radius: var(--radius); }
.skeleton-line { height: 16px; margin-bottom: 10px; animation: pulse 1.4s ease-in-out infinite; }
.skeleton-line.short { width: 60%; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
.activity-item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink); margin-top: 6px; flex-shrink: 0; }
.activity-time { font-size: 11px; color: var(--muted); }
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ============================ TOASTS (C) ============================ */
.toast-root {
  position: fixed; top: calc(var(--topbar-h) + 12px); right: 24px;
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: 8px;
  width: 340px; max-width: calc(100vw - 48px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--ink); color: var(--bg);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
  font-size: 13px; font-weight: 700;
  display: flex; align-items: flex-start; gap: 10px;
  position: relative; overflow: hidden;
  animation: toastIn 220ms cubic-bezier(.2,.8,.2,1);
}
.toast.leaving { animation: toastOut 180ms ease-in forwards; }
.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-msg { flex: 1; min-width: 0; word-break: break-word; }
.toast-close {
  background: none; border: none; color: var(--bg); opacity: 0.6;
  cursor: pointer; padding: 0; flex-shrink: 0;
}
.toast-close:hover { opacity: 1; }
.toast-progress {
  position: absolute; left: 0; bottom: 0; height: 2px;
  background: rgba(255, 255, 255, 0.55); width: 100%;
  transform-origin: left;
}
.toast:hover .toast-progress { animation-play-state: paused; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(-8px); } }
@keyframes toastBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@media (max-width: 768px) {
  .toast-root { left: 50%; right: auto; transform: translateX(-50%); top: calc(var(--topbar-h) + 8px); width: calc(100vw - 32px); }
}

/* ============================ MODALS (D) — all inside #modalRoot ============================ */
#modalRoot { position: relative; z-index: var(--z-modal); }
.modal-overlay {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-overlay.confirm-layer { z-index: var(--z-confirm); }
.modal {
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  width: 100%; max-width: 520px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-dialog);
}
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 1040px; width: 96vw; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; font-weight: 800; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--muted); display: flex; }
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 14px 20px; border-top: 1px solid var(--border);
}

/* ============================ FULL-SCREEN EDITOR (I) ============================ */
.editor-overlay {
  position: fixed; inset: 0; z-index: var(--z-editor);
  background: var(--bg); display: flex; flex-direction: column;
}
.editor-topbar {
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.editor-title-input {
  font-family: var(--font-ui); font-size: 15px; font-weight: 800; letter-spacing: -0.02em;
  border: 1px solid transparent; border-radius: var(--radius);
  padding: 6px 10px; background: transparent; color: var(--ink);
  flex: 1; min-width: 0; outline: none;
}
.editor-title-input:hover, .editor-title-input:focus { border-color: var(--border); background: var(--bg); }
.editor-save-indicator { font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
.editor-split { flex: 1; display: flex; min-height: 0; }
.editor-left {
  width: 40%; flex-shrink: 0; overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 14px;
}
.editor-right { flex: 1; min-width: 0; background: var(--soft); }
.preview-frame { width: 100%; height: 100%; border: none; background: var(--bg); }
@media (max-width: 900px) {
  .editor-split { flex-direction: column; overflow-y: auto; }
  .editor-left { width: 100%; overflow: visible; border-right: none; border-bottom: 1px solid var(--border); }
  .editor-right { min-height: 60vh; }
}

/* Accordion — one section open at a time */
.editor-accordion-section { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; background: var(--bg); }
.editor-accordion-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; cursor: pointer;
  font-size: 12px; font-weight: 700; letter-spacing: 0.02em;
  user-select: none;
}
.editor-accordion-chevron { transition: transform 0.15s; color: var(--muted); }
.editor-accordion-section:not(.collapsed) .editor-accordion-chevron { transform: rotate(180deg); }
.editor-accordion-body { padding: 2px 12px 12px; display: none; }
.editor-accordion-section:not(.collapsed) .editor-accordion-body { display: block; }
.editor-left .input, .editor-left textarea, .editor-left select { padding: 6px 10px; font-size: 12.5px; min-height: 32px; }
.editor-left .form-label { font-size: 12px; margin-bottom: 4px; }
.editor-left .form-field { margin-bottom: 8px; }
.editor-left .field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ============================ MEDIA ============================ */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-item {
  position: relative; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--bg); cursor: pointer;
  transition: border-color 0.15s;
}
.media-item:hover { border-color: var(--ink); }
.media-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; background: var(--soft); }
.media-item-info { padding: 8px 10px; }
.media-item-name { font-size: 12px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.media-item-actions {
  position: absolute; top: 6px; right: 6px; display: flex; gap: 4px;
  opacity: 0; transition: opacity 0.15s;
}
.media-item:hover .media-item-actions { opacity: 1; }
.media-item-action {
  width: 24px; height: 24px; border-radius: 6px; border: none;
  background: var(--bg); color: var(--ink); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
}
.drop-active { border-color: var(--ink) !important; background: var(--soft); }

/* Field toolbar (markdown/html insert image) */
.field-toolbar { display: flex; gap: 4px; margin-bottom: 4px; flex-wrap: wrap; }
.field-toolbar .btn { font-size: 11px; padding: 3px 8px; }

/* ============================ PUBLISH ============================ */
.diff-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.diff-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.diff-card-value { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.publish-steps { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.publish-step {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 8px 14px; font-size: 13px; font-weight: 700; color: var(--muted);
}
.publish-step.active { border-color: var(--ink); color: var(--ink); }
.publish-step.done { color: var(--ink); }
.publish-step.error { color: var(--danger); border-color: var(--danger); }
.spin { animation: rotate 1s linear infinite; display: inline-block; }
@keyframes rotate { to { transform: rotate(360deg); } }

/* ============================ SETTINGS ============================ */
.settings-layout { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: start; }
.settings-subnav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--topbar-h) + 16px); }
.settings-subnav-item {
  padding: 7px 10px; border-radius: var(--radius);
  font-size: 13px; font-weight: 700; cursor: pointer;
}
.settings-subnav-item:hover { background: var(--soft); }
.settings-subnav-item.active { background: var(--soft); color: var(--ink); }
@media (max-width: 768px) { .settings-layout { grid-template-columns: 1fr; } .settings-subnav { flex-direction: row; flex-wrap: wrap; position: static; } }

/* ============================ RESPONSIVE SHELL ============================ */
.mobile-menu-btn { display: none; }
@media (max-width: 900px) {
  .mobile-menu-btn { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform 0.2s; box-shadow: var(--shadow-dialog); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .view-container { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .diff-cards { grid-template-columns: 1fr; }
}
