/* ============================================
   DXA Admin · stylesheet
   ============================================ */

:root {
  --paper: #fbfaf6;
  --paper-2: #f5f2ec;
  --bg: #efeae0;
  --ink: #1a1814;
  --ink-2: #4a463e;
  --ink-3: #8a857a;
  --ink-4: #b8b2a3;
  --line: #e4ddd0;
  --line-2: #d4ccba;
  --accent: #b8893b;
  --accent-soft: #ecdfc7;
  --accent-deep: #8c6829;
  --red: #b8483b;
  --red-soft: #f5dad6;
  --green: #4a7a4c;
  --green-soft: #d8e6d8;
  --blue: #3b6e9c;
  --blue-soft: #d6e2ee;
  --amber: #c79220;
  --amber-soft: #f0e2c0;
  --shadow-sm: 0 1px 2px rgba(26,24,20,.04), 0 1px 1px rgba(26,24,20,.02);
  --shadow: 0 2px 6px rgba(26,24,20,.05), 0 1px 2px rgba(26,24,20,.04);
  --radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  background: var(--paper-2);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.serif { font-family: 'Cormorant Garamond', serif; }
.mono { font-family: 'JetBrains Mono', monospace; }
.en { font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; direction: ltr; text-align: left; }

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

/* ===== Shell ===== */
.shell { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  background: var(--paper);
  border-inline-start: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  padding: 20px 22px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}
.bmark {
  width: 38px; height: 38px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 500;
}
.bname { font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.brole { font-size: 11px; color: var(--ink-3); margin-top: 2px; }

.nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.nav-group { margin-bottom: 18px; }
.nav-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding: 0 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: 6px;
  color: var(--ink-2);
  font-size: 13px;
  text-align: right;
  margin-bottom: 1px;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active {
  background: var(--ink);
  color: var(--paper);
}
.nav-item.active .ic { color: var(--accent); }
.nav-item .ic {
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-3);
}
.nav-item.active .ic, .nav-item:hover .ic { color: var(--accent); }
.badge {
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.nav-item.active .badge { background: var(--accent); color: var(--ink); }

.sb-foot { padding: 14px 14px 18px; border-top: 1px solid var(--line); }

/* ===== Main ===== */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding: 12px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
}
.page { padding: 28px; max-width: 1400px; width: 100%; }
.page-head { margin-bottom: 22px; }
.page-head h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 32px;
  font-weight: 500;
  margin: 0 0 4px;
  letter-spacing: -.01em;
}
.page-head p { font-size: 13px; color: var(--ink-3); margin: 0; max-width: 600px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  background: var(--paper);
  color: var(--ink);
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--bg); }
.btn-primary {
  background: var(--ink);
  color: var(--paper);
}
.btn-primary:hover { background: var(--ink-2); }
.btn-accent {
  background: var(--accent);
  color: var(--paper);
}
.btn-accent:hover { background: var(--accent-deep); }
.btn-soft {
  background: var(--bg);
  border-color: var(--line-2);
}
.btn-soft:hover { background: var(--paper-2); }
.btn-ghost {
  background: transparent;
  border-color: var(--line-2);
  color: var(--ink-2);
}
.btn-ghost:hover { background: var(--paper); color: var(--ink); }
.ibtn {
  width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--ink-3);
  transition: background .12s, color .12s;
}
.ibtn:hover { background: var(--bg); color: var(--ink); }
.ibtn.danger:hover { background: var(--red-soft); color: var(--red); }

/* ===== Cards ===== */
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 20px;
  margin-bottom: 16px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 20px;
  font-weight: 500;
  margin: 0;
  letter-spacing: -.005em;
}
.card-head .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ===== KPI grid ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.kpi {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.kpi-icon {
  position: absolute;
  top: 14px;
  left: 14px;
  color: var(--ink-4);
  opacity: .6;
}
.kpi-label {
  font-size: 11px;
  color: var(--ink-3);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
}
.kpi-val {
  font-family: 'Cormorant Garamond', serif;
  font-size: 36px;
  font-weight: 500;
  letter-spacing: -.02em;
  line-height: 1;
  margin-bottom: 8px;
}
.kpi-trend {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-3);
}
.kpi-trend.up { color: var(--green); }
.kpi-trend.down { color: var(--red); }

/* ===== Dashboard grid ===== */
.dash-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
}

/* ===== Table ===== */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.tbl thead th {
  text-align: right;
  padding: 9px 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line-2);
  background: var(--bg);
}
.tbl tbody td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.tbl tbody tr:hover { background: var(--bg); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .name { font-weight: 500; color: var(--ink); }

/* ===== Pills ===== */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 11px;
  border: 1px solid;
  white-space: nowrap;
}
.pill-green { color: var(--green); background: var(--green-soft); border-color: transparent; }
.pill-amber { color: var(--amber); background: var(--amber-soft); border-color: transparent; }
.pill-blue  { color: var(--blue); background: var(--blue-soft); border-color: transparent; }
.pill-red   { color: var(--red); background: var(--red-soft); border-color: transparent; }
.pill-muted { color: var(--ink-2); background: var(--bg); border-color: var(--line-2); }
.pill-accent { color: var(--accent-deep); background: var(--accent-soft); border-color: transparent; }

/* ===== Form fields ===== */
.field { margin-bottom: 14px; }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  color: var(--ink);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184,137,59,.12);
}
.textarea { resize: vertical; min-height: 70px; line-height: 1.55; }
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%238a857a' stroke-width='1.4' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-inline-start: 32px;
}

/* Bilingual field group */
.bilingual {
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}
.bi-row { display: grid; grid-template-columns: 60px 1fr; }
.bi-row + .bi-row { border-top: 1px solid var(--line); }
.bi-lang {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: .1em;
  border-inline-end: 1px solid var(--line);
}
.bi-row input, .bi-row textarea {
  border: none;
  background: transparent;
  padding: 10px 14px;
  font-size: 13px;
  outline: none;
  width: 100%;
  color: var(--ink);
}
.bi-row textarea { resize: vertical; min-height: 60px; font-family: inherit; line-height: 1.55; }
.bi-row.en input, .bi-row.en textarea { direction: ltr; text-align: left; color: var(--ink-2); font-size: 12px; }
.bi-row input:focus, .bi-row textarea:focus {
  background: rgba(184,137,59,.05);
}
.bi-head {
  background: var(--paper-2);
  padding: 6px 14px;
  font-size: 11px;
  color: var(--ink-3);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ===== Split editor ===== */
.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.editor-pane { min-width: 0; }
.preview-pane {
  position: sticky;
  top: 84px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
}
.preview-bar {
  padding: 9px 14px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.pdots { display: flex; gap: 5px; }
.pdots span { width: 9px; height: 9px; background: var(--line-2); border-radius: 50%; }
.pdots span:first-child { background: #d97757; }
.pdots span:nth-child(2) { background: #d8b842; }
.pdots span:nth-child(3) { background: #6ba16b; }
.purl {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: var(--ink-3);
  padding: 3px 9px;
  background: var(--paper);
  border-radius: 5px;
}
.preview-frame {
  height: calc(100vh - 200px);
  min-height: 600px;
  background: var(--bg);
}
.preview-frame iframe { width: 100%; height: 100%; border: none; display: block; }

/* ===== Media slot (upload preview) ===== */
.mslot { width: 100%; }
.mslot-frame {
  position: relative;
  width: 100%;
  background: var(--bg);
  border: 1.5px dashed var(--line-2);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color .15s, background .15s;
  cursor: pointer;
}
.mslot-frame.over {
  border-color: var(--accent);
  background: rgba(184,137,59,.08);
}
.mslot-frame.has {
  border-style: solid;
  border-color: var(--line);
  cursor: default;
  background: #1a1814;
}
.mslot-media {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.mslot-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px;
  text-align: center;
  color: var(--ink-3);
}
.mslot-empty .ph-mark {
  font-family: 'Cormorant Garamond', serif;
  font-size: 38px;
  color: var(--ink-4);
  line-height: 1;
}
.mslot-cta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12px;
}
.mslot-cta strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.mslot-hint {
  font-size: 11px;
  color: var(--ink-4);
  margin-top: 4px;
}
.mslot-overlay {
  position: absolute;
  inset: 8px 8px auto auto;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity .15s;
}
.mslot-frame.has:hover .mslot-overlay { opacity: 1; }
.ibtn-light {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  transition: background .12s;
}
.ibtn-light:hover { background: rgba(0,0,0,.78); }
.ibtn-light.danger:hover { background: var(--red); border-color: var(--red); }
.mslot-quality {
  position: absolute;
  bottom: 8px;
  inset-inline-start: 8px;
  font-size: 10px !important;
  font-weight: 600;
  letter-spacing: .03em;
  backdrop-filter: blur(4px);
}
.mslot-dur {
  position: absolute;
  bottom: 8px;
  inset-inline-end: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  background: rgba(0,0,0,.6);
  color: #fff;
  padding: 2px 7px;
  border-radius: 4px;
}
.mslot-busy {
  position: absolute;
  inset: 0;
  background: rgba(26,24,20,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
}
.spinner {
  width: 28px; height: 28px;
  border: 2.5px solid rgba(255,255,255,.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.mslot-meta {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.mslot-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  gap: 10px;
}
.mslot-name {
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.mslot-size, .mslot-dim, .mslot-type {
  color: var(--ink-3);
  font-size: 10px;
  white-space: nowrap;
}
.mslot-type {
  background: var(--paper);
  border: 1px solid var(--line-2);
  padding: 1px 6px;
  border-radius: 3px;
}
.mslot-formats {
  margin-top: 6px;
  font-size: 10px;
  color: var(--ink-3);
  text-align: center;
  letter-spacing: .02em;
}

/* ===== Empty state ===== */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--ink-3);
}
.empty .e-icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  background: var(--bg);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink-4);
}
.empty h4 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  margin: 0 0 6px;
}
.empty p { font-size: 13px; margin: 0 0 16px; }

/* ===== Tag input ===== */
.tag-input {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px 9px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--paper);
  min-height: 42px;
  align-items: center;
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  background: var(--accent-soft);
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 500;
  border-radius: 11px;
}
.tag .x {
  cursor: pointer;
  color: var(--accent-deep);
  opacity: .6;
  font-size: 14px;
  line-height: 1;
}
.tag .x:hover { opacity: 1; }

/* ===== Timeline ===== */
.timeline {
  position: relative;
  padding-inline-start: 24px;
}
.timeline::before {
  content: '';
  position: absolute;
  top: 8px; bottom: 8px;
  inset-inline-start: 6px;
  width: 1px;
  background: var(--line-2);
}
.tl-item {
  position: relative;
  padding: 8px 0 8px 0;
  font-size: 13px;
}
.tl-item::before {
  content: '';
  position: absolute;
  width: 9px; height: 9px;
  inset-inline-start: -23px;
  top: 12px;
  background: var(--paper);
  border: 1.5px solid var(--accent);
  border-radius: 50%;
}
.tl-when {
  font-size: 11px;
  color: var(--ink-3);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 3px;
}

/* ===== Theme preset cards ===== */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.preset {
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  background: var(--paper);
  transition: border-color .12s;
}
.preset:hover { border-color: var(--ink-4); }
.preset.active { border-color: var(--accent); }
.preset .swatches { display: flex; gap: 4px; margin-bottom: 10px; }
.preset .sw {
  flex: 1;
  height: 32px;
  border-radius: 5px;
  border: 1px solid rgba(0,0,0,.05);
}
.preset .pname {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}

/* scrollbar */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }
