/* ==========================================================================
   DrCorp admin dashboard
   Built for non-technical editors: big clear labels, one idea per block,
   Arabic first, English beside it, and a live preview wherever possible.
   ========================================================================== */

:root {
  --bg: #f7f3f6;
  --surface: #ffffff;
  --surface-2: #fbf8fa;
  --border: #ebe2e9;
  --border-strong: #d9cad5;
  --text: #2b1730;
  --text-muted: #7a6a7c;
  --text-soft: #a393a5;

  --plum-950: #1c001d;
  --plum-800: #450e47;
  --plum-700: #4b274c;
  --plum-100: #f3e8f2;
  --coral: #e77e5e;
  --coral-dark: #c55d3e;
  --coral-light: #f59071;
  --coral-50: #fdf1ec;

  --sidebar-gradient: linear-gradient(170deg, var(--plum-950) 0%, var(--plum-800) 45%, var(--plum-950) 100%);
  --accent-gradient: linear-gradient(135deg, var(--coral-dark) 0%, var(--coral-light) 100%);

  --success: #16a34a;
  --success-bg: #e8f7ee;
  --warning: #d97706;
  --warning-bg: #fef6e4;
  --danger: #dc2626;
  --danger-bg: #fdecec;
  --info: #2563eb;
  --info-bg: #eaf1fe;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(28, 0, 29, 0.05);
  --shadow: 0 4px 16px rgba(28, 0, 29, 0.06);
  --shadow-lg: 0 20px 60px rgba(28, 0, 29, 0.25);

  --sidebar-w: 272px;
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { direction: rtl; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--coral-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

svg.lucide { width: 18px; height: 18px; stroke-width: 2; flex-shrink: 0; vertical-align: middle; }
.icon-lg svg.lucide, svg.lucide.icon-lg { width: 24px; height: 24px; }

/* ---------- Shell ---------- */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-gradient);
  color: #eadfe8;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 40;
}

.sidebar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 22px 18px;
  color: #fff;
}
.sidebar .brand img { width: 40px; height: 40px; flex-shrink: 0; }
.sidebar .brand strong { display: block; font-size: 17px; line-height: 1.2; }
.sidebar .brand small { display: block; font-size: 12px; color: rgba(234, 223, 232, 0.6); }

.sidebar nav { flex: 1; padding: 6px 12px 12px; }

.sidebar .nav-group-label {
  padding: 16px 12px 6px;
  font-size: 12px;
  font-weight: 600;
  color: rgba(234, 223, 232, 0.5);
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 2px;
  color: #dccbd9;
  font-size: 14.5px;
  border-radius: 10px;
  transition: background 0.15s, color 0.15s;
}
.sidebar nav a .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar nav a svg.lucide { opacity: 0.8; }
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }
.sidebar nav a.active {
  background: rgba(231, 126, 94, 0.2);
  color: #fff;
  font-weight: 600;
  box-shadow: inset -3px 0 0 var(--coral);
}
.sidebar nav a.active svg.lucide { opacity: 1; color: var(--coral-light); }

.sidebar nav a.sub-link { padding-right: 40px; font-size: 13.5px; color: rgba(220, 203, 217, 0.8); }
.sidebar nav a.sub-link .status-dot { width: 7px; height: 7px; }

.sidebar .legend {
  margin: 6px 22px 0;
  padding: 12px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  color: rgba(234, 223, 232, 0.6);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar .legend span { display: flex; align-items: center; gap: 8px; }

.sidebar .logout { padding: 14px 12px 20px; }
.sidebar .logout a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #dccbd9;
}
.sidebar .logout a:hover { background: rgba(255, 255, 255, 0.07); color: #fff; text-decoration: none; }

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.ready { background: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18); }
.status-dot.needs-action { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.18); }

.nav-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--coral);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 32px;
  background: rgba(247, 243, 246, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}
.topbar .crumb { flex: 1; font-size: 14px; color: var(--text-muted); }
.topbar .crumb strong { color: var(--text); }
.topbar .who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
}
.topbar .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-gradient);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}
.menu-toggle {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  color: var(--text);
}

.main { padding: 28px 32px 80px; max-width: 1180px; width: 100%; }

.sidebar-backdrop { display: none; }

@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    right: 0;
    top: 0;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(28, 0, 29, 0.45);
    z-index: 35;
  }
  .menu-toggle { display: grid; place-items: center; }
  .topbar { padding: 12px 16px; }
  .main { padding: 20px 16px 80px; }
  .topbar .who .name { display: none; }
}

/* ---------- Page header ---------- */

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-header .title-block { display: flex; gap: 14px; align-items: flex-start; }
.page-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--coral-50);
  color: var(--coral-dark);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.page-icon svg.lucide { width: 26px; height: 26px; }
.page-header h1 { margin: 0; font-size: 24px; line-height: 1.3; color: var(--plum-800); }
.page-header .subtitle { margin: 4px 0 0; color: var(--text-muted); font-size: 14.5px; max-width: 640px; }
.page-header .actions { flex-shrink: 0; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.back-link:hover { color: var(--coral-dark); text-decoration: none; }

/* ---------- Cards & sections ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin: -4px 0 18px;
}
.card-head h2 {
  margin: 0;
  font-size: 17px;
  color: var(--plum-800);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-head h2 .step {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--plum-100);
  color: var(--plum-800);
  display: inline-grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}
.card-head p { margin: 2px 0 0; color: var(--text-muted); font-size: 13.5px; }

.form-section {
  border-top: 1px dashed var(--border);
  padding-top: 20px;
  margin-top: 8px;
}
.form-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--plum-800);
  margin: 0 0 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-section-hint { color: var(--text-muted); font-size: 13.5px; margin: 0 0 14px; }

.editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 400px);
  gap: 20px;
  align-items: start;
}
.editor-layout > .sticky-col { position: sticky; top: 84px; }
@media (max-width: 1100px) {
  .editor-layout { grid-template-columns: 1fr; }
  .editor-layout > .sticky-col { position: static; }
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 720px) { .two-col { grid-template-columns: 1fr; } }

/* ---------- Tip / notice boxes ---------- */

.tip {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--info-bg);
  color: #1e3a8a;
  font-size: 14px;
  margin-bottom: 20px;
}
.tip svg.lucide { margin-top: 2px; }
.tip.warn { background: var(--warning-bg); color: #7c4a03; }
.tip.success { background: var(--success-bg); color: #14532d; }
.tip strong { display: block; margin-bottom: 2px; }
.tip p { margin: 0; }

/* ---------- Form fields ---------- */

.field, .form-row { margin-bottom: 20px; }
.field-label, .form-row > label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--text);
}
.field-hint, .hint { font-size: 13px; color: var(--text-muted); margin: 0 0 8px; }
.form-row .hint { margin: 6px 0 0; }
.req-chip {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--coral-dark);
  background: var(--coral-50);
  padding: 1px 8px;
  border-radius: 999px;
}
.opt-chip {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0 8px;
  border-radius: 999px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input::placeholder, textarea::placeholder { color: var(--text-soft); }
input:hover, textarea:hover, select:hover { border-color: var(--border-strong); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 4px rgba(231, 126, 94, 0.15);
}
input.is-invalid, textarea.is-invalid, select.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
}
textarea { resize: vertical; min-height: 96px; line-height: 1.7; }

/* Bilingual pair: Arabic + English side by side, each with a language chip */
.bi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 720px) { .bi-grid { grid-template-columns: 1fr; } }
.bi-cell { position: relative; }
.lang-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.lang-chip .flag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--plum-100);
  color: var(--plum-800);
  letter-spacing: 0.02em;
}
.bi-cell[dir="ltr"] .lang-chip { direction: ltr; }

/* Switch (styled checkbox) */
.switch-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
  margin-bottom: 14px;
  transition: border-color 0.15s, background 0.15s;
}
.switch-row:hover { border-color: var(--border-strong); }
.switch-row:has(input:checked) { border-color: rgba(22, 163, 74, 0.35); background: #f3fbf6; }
.switch { position: relative; width: 46px; height: 26px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch .slider {
  position: absolute;
  inset: 0;
  background: #d4c8d2;
  border-radius: 999px;
  transition: background 0.2s;
}
.switch .slider::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
.switch input:checked + .slider { background: var(--success); }
.switch input:checked + .slider::after { transform: translateX(-20px); }
.switch input:focus-visible + .slider { box-shadow: 0 0 0 4px rgba(231, 126, 94, 0.25); }
.switch-text { flex: 1; }
.switch-text strong { display: block; font-size: 14.5px; font-weight: 600; }
.switch-text small { display: block; font-size: 13px; color: var(--text-muted); }
.switch-state { font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: #eee6ec; color: var(--text-muted); }
.switch-state .on { display: none; }
.switch-row:has(input:checked) .switch-state { background: var(--success-bg); color: var(--success); }
.switch-row:has(input:checked) .switch-state .on { display: inline; }
.switch-row:has(input:checked) .switch-state .off { display: none; }

/* Legacy small checkbox row */
.checkbox-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.checkbox-row input { width: 18px; height: 18px; accent-color: var(--coral-dark); }

/* Choice cards (radio groups: icon picker, mission/vision, status) */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.choice {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  font-size: 13.5px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.choice:hover { border-color: var(--border-strong); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .choice-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--plum-700);
}
.choice .choice-icon svg.lucide { width: 22px; height: 22px; }
.choice:has(input:checked) {
  border-color: var(--coral);
  background: var(--coral-50);
  box-shadow: 0 0 0 3px rgba(231, 126, 94, 0.15);
}
.choice:has(input:checked) .choice-icon { background: var(--accent-gradient); color: #fff; }
.choice:has(input:focus-visible) { box-shadow: 0 0 0 4px rgba(231, 126, 94, 0.3); }
.choice-row { display: flex; flex-wrap: wrap; gap: 10px; }
.choice-row .choice { flex-direction: row; padding: 10px 16px; min-width: 140px; justify-content: center; }
.choice-row .choice .choice-icon { width: 30px; height: 30px; border-radius: 8px; }
.choice-row .choice .choice-icon svg.lucide { width: 17px; height: 17px; }

/* Link field with the "pick a page" helper */
.link-field { display: flex; gap: 8px; }
.link-field input { flex: 1; }
.link-field select.link-picker { width: auto; min-width: 170px; max-width: 45%; background: var(--surface-2); color: var(--text-muted); }
@media (max-width: 720px) {
  .link-field { flex-direction: column; }
  .link-field select.link-picker { max-width: none; }
}

/* Advanced (collapsed) options */
details.advanced {
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 0 16px;
  margin: 8px 0 18px;
  background: var(--surface-2);
}
details.advanced > summary {
  list-style: none;
  cursor: pointer;
  padding: 13px 0;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
details.advanced > summary::-webkit-details-marker { display: none; }
details.advanced > summary .chev { margin-inline-start: auto; transition: transform 0.2s; }
details.advanced[open] > summary .chev { transform: rotate(180deg); }
details.advanced[open] { padding-bottom: 4px; }

/* ---------- Upload box ---------- */

.upload-box { display: flex; flex-direction: column; gap: 10px; }
.upload-current, .upload-new {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.upload-new { border-color: rgba(22, 163, 74, 0.35); background: #f3fbf6; }
.upload-current img, .upload-new img {
  width: 76px;
  height: 76px;
  object-fit: contain;
  border-radius: 10px;
  background: repeating-conic-gradient(#f1ecf0 0% 25%, #fff 0% 50%) 50% / 14px 14px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.upload-meta { flex: 1; min-width: 0; font-size: 13.5px; }
.upload-meta strong { display: block; font-size: 14px; }
.upload-meta .muted { color: var(--text-muted); word-break: break-all; }
.upload-current.is-removed { opacity: 0.55; border-color: rgba(220, 38, 38, 0.4); background: var(--danger-bg); }
.upload-current.is-removed img { filter: grayscale(1); }
.file-icon {
  width: 76px;
  height: 76px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #fff;
  border: 1px solid var(--border);
  color: var(--danger);
  flex-shrink: 0;
}
.file-icon svg.lucide { width: 30px; height: 30px; }

.remove-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 13px;
  color: var(--danger);
  cursor: pointer;
  font-weight: 600;
}
.remove-toggle input { width: 16px; height: 16px; accent-color: var(--danger); }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 22px 16px;
  border: 2px dashed var(--border-strong);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone.is-dragover { border-color: var(--coral); background: var(--coral-50); }
.dropzone strong { color: var(--coral-dark); font-size: 14.5px; }
.dropzone svg.lucide { width: 28px; height: 28px; color: var(--coral); margin-bottom: 2px; }
.dropzone input[type="file"] { display: none; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 10px;
  border: 1.5px solid transparent;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s, transform 0.05s, background 0.15s;
  text-decoration: none;
}
.btn:hover { filter: brightness(0.95); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-loading { opacity: 0.7; cursor: progress; }
.btn-secondary {
  background: #fff;
  color: var(--plum-800);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-2); filter: none; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: rgba(28, 0, 29, 0.05); filter: none; color: var(--text); }
.btn-danger { background: #fff; color: var(--danger); border-color: rgba(220, 38, 38, 0.3); }
.btn-danger:hover { background: var(--danger-bg); filter: none; }
.btn-danger-solid { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 12px; font-size: 13.5px; border-radius: 8px; }
.btn-sm svg.lucide { width: 16px; height: 16px; }
.btn-lg { padding: 13px 26px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-icon { padding: 7px; }

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

/* Sticky save bar at the bottom of long singleton forms */
.save-bar {
  position: sticky;
  bottom: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 18px;
  margin-top: 8px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.save-bar .save-hint { font-size: 13.5px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.save-bar .dirty-flag { display: none; color: var(--warning); font-weight: 600; }
form.is-dirty .save-bar .dirty-flag { display: inline-flex; align-items: center; gap: 6px; }
form.is-dirty .save-bar .clean-flag { display: none; }

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge.active { background: var(--success-bg); color: #15803d; }
.badge.inactive { background: #f1edf0; color: #6b5d6d; }
.badge.neutral { background: var(--plum-100); color: var(--plum-800); }
.badge.coral { background: var(--coral-50); color: var(--coral-dark); }
.badge.status-new { background: var(--warning-bg); color: #92400e; }
.badge.status-in_progress { background: var(--info-bg); color: #1e40af; }
.badge.status-resolved { background: var(--success-bg); color: #166534; }
.badge svg.lucide { width: 13px; height: 13px; }

/* ---------- Item list (list sections) ---------- */

.item-list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.item:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.item.is-inactive { background: var(--surface-2); }
.item.is-inactive .item-title { color: var(--text-muted); }
.item-order {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}
.item-media {
  width: 50px;
  height: 50px;
  border-radius: 12px;
  background: var(--coral-50);
  color: var(--coral-dark);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  font-weight: 700;
}
.item-media img { width: 100%; height: 100%; object-fit: cover; }
.item-media.big-text { font-size: 15px; background: var(--plum-100); color: var(--plum-800); }
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 600; font-size: 15.5px; margin: 0; }
.item-sub { font-size: 13.5px; color: var(--text-muted); direction: ltr; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.item .actions { flex-shrink: 0; }
@media (max-width: 720px) {
  .item { flex-wrap: wrap; }
  .item .actions { width: 100%; justify-content: flex-end; }
}

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
  font-size: 14.5px;
}
.empty-state .empty-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--text-soft);
}
.empty-state .empty-icon svg.lucide { width: 30px; height: 30px; }
.empty-state strong { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }
.empty-state .btn { margin-top: 14px; }

/* ---------- Tables (inbox) ---------- */

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: start; padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--text-muted); font-size: 13px; font-weight: 600; background: var(--surface-2); }
tbody tr { transition: background 0.1s; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
tbody tr.unread td { font-weight: 600; }
tbody tr.unread td:first-child { box-shadow: inset -3px 0 0 var(--coral); }
.kv-table th { width: 150px; background: transparent; }

.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); }

/* ---------- Tabs / segmented ---------- */

.segmented {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  border-radius: 12px;
  background: #efe8ee;
  flex-wrap: wrap;
}
.segmented a, .segmented button {
  border: none;
  background: transparent;
  padding: 7px 16px;
  border-radius: 9px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.segmented a:hover, .segmented button:hover { color: var(--text); text-decoration: none; }
.segmented .is-active { background: #fff; color: var(--plum-800); box-shadow: var(--shadow-sm); }

.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pagination a {
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  color: var(--text);
  font-weight: 600;
}
.pagination a:hover { text-decoration: none; border-color: var(--coral); }
.pagination a.is-active { background: var(--accent-gradient); color: #fff; border-color: transparent; }

/* ---------- Repeaters ---------- */

.repeater-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.repeater-row {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.repeater-row .rf label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.repeater-row .rf input, .repeater-row .rf select { padding: 9px 12px; font-size: 14.5px; }
.repeater-row .row-tools { display: flex; gap: 4px; }
@media (max-width: 720px) {
  .repeater-row { grid-template-columns: 1fr; }
  .repeater-row .row-tools { justify-content: flex-end; }
}
.repeater-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
}

.column-card {
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  background: #fff;
}
.column-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.column-card-head strong { display: flex; align-items: center; gap: 8px; color: var(--plum-800); }
.column-card .sub-label { font-size: 13.5px; font-weight: 600; color: var(--text-muted); margin: 14px 0 8px; }

/* ---------- Modal (list-item editor) ---------- */

dialog.modal {
  border: none;
  padding: 0;
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100vh - 32px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}
dialog.modal.wide { width: min(1080px, calc(100vw - 24px)); }
dialog.modal::backdrop { background: rgba(28, 0, 29, 0.55); backdrop-filter: blur(2px); }
dialog.modal[open] { display: flex; flex-direction: column; animation: pop 0.18s ease-out; }
@keyframes pop { from { transform: translateY(10px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; flex: 1; font-size: 18px; color: var(--plum-800); }
.modal-body { padding: 22px; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex;
  gap: 10px;
  justify-content: flex-start;
  padding: 14px 22px;
  background: #fff;
  border-top: 1px solid var(--border);
}
dialog.modal form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.modal-grid > .preview-panel { position: sticky; top: 0; }
@media (max-width: 900px) { .modal-grid { grid-template-columns: 1fr; } .modal-grid > .preview-panel { position: static; } }

/* ---------- Live preview ---------- */

.preview-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
}
.preview-head .ttl { display: flex; align-items: center; gap: 6px; }
.preview-head .segmented { padding: 3px; }
.preview-head .segmented button { padding: 4px 10px; font-size: 12.5px; }
.preview-foot { padding: 8px 14px; font-size: 12px; color: var(--text-soft); border-top: 1px solid var(--border); background: var(--surface-2); }
.preview-canvas { padding: 22px; }
.preview-canvas .is-empty { opacity: 0.45; font-style: italic; }

.pv-hero {
  background: var(--sidebar-gradient);
  color: #fff;
  border-radius: 12px;
  padding: 22px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.pv-hero .pv-img { width: 100%; max-height: 150px; object-fit: cover; border-radius: 10px; }
.pv-hero h4 { margin: 0; font-size: 22px; line-height: 1.3; }
.pv-hero .pv-sub { color: var(--coral-light); font-weight: 600; font-size: 14px; }
.pv-hero p { margin: 0; font-size: 13.5px; color: rgba(255, 255, 255, 0.8); }
.pv-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.pv-btn {
  display: inline-block;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.pv-btn.outline { background: transparent; border: 1.5px solid rgba(255, 255, 255, 0.6); }
.pv-cta {
  background: var(--accent-gradient);
  color: #fff;
  border-radius: 14px;
  padding: 24px;
  text-align: center;
}
.pv-cta h4 { margin: 0 0 6px; font-size: 20px; }
.pv-cta p { margin: 0 0 14px; font-size: 13.5px; opacity: 0.92; }
.pv-cta .pv-btn { background: #fff; color: var(--coral-dark); }
.pv-eyebrow {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  background: var(--coral-50);
  color: var(--coral-dark);
  font-size: 12.5px;
  font-weight: 700;
  margin-bottom: 8px;
}
.pv-title { margin: 0 0 8px; font-size: 20px; color: var(--plum-800); }
.pv-text { margin: 0; font-size: 13.5px; color: var(--text-muted); white-space: pre-line; }
.pv-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  background: #fff;
}
.pv-card .pv-icon {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--accent-gradient);
  color: #fff;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  overflow: hidden;
}
.pv-card .pv-icon img { width: 60%; height: 60%; object-fit: contain; }
.pv-card .pv-num { font-size: 13px; font-weight: 700; color: var(--coral); }
.pv-card h5 { margin: 0 0 6px; font-size: 16px; color: var(--plum-800); }
.pv-card .pv-link { margin-top: 10px; font-size: 13px; font-weight: 600; color: var(--coral-dark); }
.pv-stat { text-align: center; }
.pv-stat .pv-value { font-size: 34px; font-weight: 700; color: var(--plum-800); line-height: 1.1; }
.pv-stat.is-highlighted { background: var(--sidebar-gradient); color: #fff; }
.pv-stat.is-highlighted .pv-value, .pv-stat.is-highlighted h5 { color: #fff; }
.pv-hidden-note {
  display: none;
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--warning-bg);
  color: #92400e;
  font-size: 12.5px;
  font-weight: 600;
}
.preview-panel.is-hidden-on-site .pv-hidden-note { display: block; }

/* ---------- Dashboard ---------- */

.welcome {
  background: var(--sidebar-gradient);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 22px;
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.welcome h1 { margin: 0 0 6px; font-size: 24px; }
.welcome p { margin: 0; color: rgba(255, 255, 255, 0.75); max-width: 560px; }
.welcome .actions .btn-secondary { background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.25); color: #fff; }
.welcome .actions .btn-secondary:hover { background: rgba(255, 255, 255, 0.18); }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 800px) { .steps { grid-template-columns: 1fr; } }
.step-card {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--border);
}
.step-card .n {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--coral-50);
  color: var(--coral-dark);
  display: grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}
.step-card strong { display: block; font-size: 14.5px; }
.step-card span { font-size: 13px; color: var(--text-muted); }

.section-block { margin-bottom: 28px; }
.section-block > h2 { font-size: 17px; margin: 0 0 12px; color: var(--plum-800); display: flex; align-items: center; gap: 8px; }

.dash-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.dash-card:hover { border-color: var(--coral); text-decoration: none; box-shadow: var(--shadow); transform: translateY(-2px); }
.dash-card .dc-top { display: flex; align-items: center; gap: 12px; }
.dash-card .dc-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--coral-50);
  color: var(--coral-dark);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.dash-card h3 { margin: 0; font-size: 16px; color: var(--plum-800); }
.dash-card .desc { font-size: 13px; color: var(--text-muted); margin: 0; flex: 1; }
.dash-card .meta { font-size: 12.5px; color: var(--text-soft); }
.dash-card .status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.dash-card .status-row.ok { color: #15803d; }
.dash-card .status-row.todo { color: #b45309; }
.stat-tile { display: flex; align-items: center; gap: 14px; }
.stat-tile .num { font-size: 30px; font-weight: 700; color: var(--plum-800); line-height: 1; }

/* ---------- Login / error ---------- */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--sidebar-gradient);
}
.login-box {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
}
.login-box .login-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.login-box .login-logo img { width: 64px; height: 64px; }
.login-box h1 { font-size: 21px; margin: 0 0 4px; text-align: center; color: var(--plum-800); }
.login-box .lead { text-align: center; color: var(--text-muted); margin: 0 0 24px; font-size: 14px; }
.input-icon { position: relative; }
.input-icon svg.lucide { position: absolute; top: 50%; right: 14px; transform: translateY(-50%); color: var(--text-soft); pointer-events: none; }
.input-icon input { padding-right: 42px; }
.pw-toggle {
  position: absolute;
  top: 50%;
  left: 8px;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
}
.error-illustration {
  width: 72px;
  height: 72px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--danger-bg);
  color: var(--danger);
  display: grid;
  place-items: center;
}
.error-illustration svg.lucide { width: 34px; height: 34px; }
.tech-details { margin-top: 14px; font-size: 12.5px; color: var(--text-muted); }
.tech-details summary { cursor: pointer; }
.tech-details pre { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: 10px; border-radius: 8px; direction: ltr; text-align: left; }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 14px; }
.alert-error { background: var(--danger-bg); color: #991b1b; }
.alert-success { background: var(--success-bg); color: #166534; }

/* ---------- Contact requests ---------- */

.message-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  white-space: pre-wrap;
  font-size: 15px;
  line-height: 1.8;
  margin: 0;
}
.reply-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: #fff;
  border-inline-start: 4px solid var(--coral-light);
}
.reply-item .reply-meta { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.reply-item .reply-message { margin: 0; white-space: pre-wrap; }
.reply-fail { color: var(--danger); font-weight: 600; }
.delivery { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ---------- Blog ---------- */

.rich-editor { background: #fff; border-radius: 10px; }
.rich-editor .ql-toolbar { border-color: var(--border) !important; border-radius: 10px 10px 0 0; background: var(--surface-2); }
.rich-editor .ql-container { border-color: var(--border) !important; border-radius: 0 0 10px 10px; min-height: 320px; font-size: 15.5px; font-family: var(--font); }
.rich-editor .ql-editor { min-height: 320px; line-height: 1.9; }
.rich-editor[dir="rtl"] .ql-editor { direction: rtl; text-align: right; }
.rich-editor .ql-editor.ql-blank::before { right: 15px; left: 15px; font-style: normal; color: var(--text-soft); }

.lang-tabs { margin-bottom: 12px; }
.lang-pane[hidden] { display: none; }

.prose { font-size: 15.5px; line-height: 1.9; }
.prose p { margin: 0 0 12px; }
.prose img { max-width: 100%; border-radius: 8px; }
.blog-cover { width: 100%; max-height: 340px; object-fit: cover; border-radius: var(--radius); margin-bottom: 18px; display: block; }

/* ---------- SweetAlert2 brand tweaks ---------- */

.swal2-popup { font-family: var(--font) !important; border-radius: 18px !important; }
.swal2-title { color: var(--plum-800) !important; font-size: 21px !important; }
.swal2-html-container { color: var(--text-muted) !important; font-size: 15px !important; }
.swal2-actions .swal2-styled { border-radius: 10px !important; font-family: var(--font) !important; font-weight: 600 !important; padding: 10px 22px !important; }
.swal2-toast { font-family: var(--font) !important; box-shadow: var(--shadow-lg) !important; }
.swal2-toast .swal2-title { font-size: 15px !important; color: var(--text) !important; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
