/* ============================================================
   D7SIN AI — Dashboard styles
   Modern AI Control Center · RTL · dark-first · responsive
   ============================================================ */

:root {
  --bg: #0a0e17;
  --bg-soft: #0d1320;
  --surface: #111827;
  --surface-2: #16202f;
  --surface-3: #1b2740;
  --border: rgba(148, 163, 184, 0.13);
  --border-strong: rgba(148, 163, 184, 0.25);
  --text: #e7ecf5;
  --muted: #93a1b8;
  --faint: #5f6c83;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --accent-soft: rgba(124, 92, 255, 0.14);
  --gradient: linear-gradient(135deg, #7c5cff 0%, #22d3ee 100%);
  --ok: #10b981;
  --ok-soft: rgba(16, 185, 129, 0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --err: #ef4444;
  --err-soft: rgba(239, 68, 68, 0.14);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --font: "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
  --mono: "Cascadia Code", "Consolas", "Courier New", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--font);
  background:
    radial-gradient(1000px 500px at 85% -10%, rgba(124, 92, 255, 0.10), transparent 60%),
    radial-gradient(900px 480px at 10% 110%, rgba(34, 211, 238, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0; /* right in RTL */
  width: var(--sidebar-w);
  background: rgba(13, 19, 32, 0.92);
  backdrop-filter: blur(14px);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 60;
  transition: transform 0.28s ease;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
}
.brand .logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--gradient);
  display: grid; place-items: center;
  font-weight: 800; color: #fff; font-size: 17px;
  box-shadow: 0 6px 18px rgba(124, 92, 255, 0.35);
  flex-shrink: 0;
}
.brand .name { font-weight: 700; font-size: 16px; letter-spacing: 0.3px; }
.brand .tag { font-size: 11px; color: var(--muted); margin-top: 2px; }

.nav { flex: 1; overflow-y: auto; padding: 14px 12px 20px; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.nav-group { margin-top: 16px; }
.nav-group:first-child { margin-top: 0; }
.nav-group-label {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--faint);
  padding: 0 10px 8px;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 2px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
  text-align: start;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: rgba(148, 163, 184, 0.07); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.35), 0 4px 16px rgba(124, 92, 255, 0.15);
}
.nav-item.active svg { opacity: 1; color: var(--accent-2); }
.nav-item .badge {
  margin-inline-start: auto;
  font-size: 10.5px;
  background: var(--err-soft);
  color: #fca5a5;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 700;
}

.sidebar-foot {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--faint);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-foot .ver { font-family: var(--mono); }

/* ---------- Main ---------- */
.main {
  flex: 1;
  margin-inline-start: var(--sidebar-w); /* pushes content beside sidebar */
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  background: rgba(10, 14, 23, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .burger {
  display: none;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  place-items: center;
}
.topbar .burger svg { width: 19px; height: 19px; }
.topbar h1 { font-size: 17px; font-weight: 700; }
.topbar .crumb { font-size: 12px; color: var(--faint); margin-top: 2px; }

.top-spacer { flex: 1; }

.status-pills { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 30px;
  white-space: nowrap;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.pill.ok .dot { background: var(--ok); box-shadow: 0 0 8px rgba(16,185,129,0.7); }
.pill.warn .dot { background: var(--warn); box-shadow: 0 0 8px rgba(245,158,11,0.6); }
.pill.err .dot { background: var(--err); box-shadow: 0 0 8px rgba(239,68,68,0.6); }
.pill.ok { color: #a7f3d0; }
.pill.warn { color: #fcd34d; }
.pill.err { color: #fca5a5; }

.content { padding: 26px; max-width: 1240px; width: 100%; margin-inline: auto; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-2-1 { grid-template-columns: 2fr 1fr; }

.card {
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
}
.card + .card { margin-top: 0; }

.card-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 10px;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 9px; }
.card-title svg { width: 17px; height: 17px; color: var(--accent-2); }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* status cards */
.stat-card { display: flex; flex-direction: column; gap: 12px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-ico {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--surface-3); border: 1px solid var(--border);
}
.stat-ico svg { width: 21px; height: 21px; color: var(--accent-2); }
.stat-dot { width: 11px; height: 11px; border-radius: 50%; }
.stat-dot.ok { background: var(--ok); box-shadow: 0 0 12px rgba(16,185,129,0.7); }
.stat-dot.warn { background: var(--warn); box-shadow: 0 0 12px rgba(245,158,11,0.6); }
.stat-dot.err { background: var(--err); box-shadow: 0 0 12px rgba(239,68,68,0.6); }
.stat-name { font-size: 13px; font-weight: 700; }
.stat-state { font-size: 12px; color: var(--muted); margin-top: 3px; }
.stat-state b { color: var(--text); font-weight: 600; }
.stat-foot { font-size: 11px; color: var(--faint); border-top: 1px dashed var(--border); padding-top: 10px; }

/* ---------- list rows ---------- */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row .ico {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--accent-2);
}
.row .ico svg { width: 16px; height: 16px; }
.row .grow { flex: 1; min-width: 0; }
.row .t { font-size: 13.5px; font-weight: 600; }
.row .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.row .meta { font-size: 11px; color: var(--faint); white-space: nowrap; }

/* ---------- badges / tags ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 20px;
  background: var(--surface-3); color: var(--muted);
  border: 1px solid var(--border);
}
.tag.ok { background: var(--ok-soft); color: #6ee7b7; border-color: rgba(16,185,129,0.3); }
.tag.warn { background: var(--warn-soft); color: #fcd34d; border-color: rgba(245,158,11,0.3); }
.tag.err { background: var(--err-soft); color: #fca5a5; border-color: rgba(239,68,68,0.3); }
.tag.accent { background: var(--accent-soft); color: #c4b5fd; border-color: rgba(124,92,255,0.35); }

/* ---------- caps tags (Kick capabilities) ---------- */
.caps-tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- live chat box ---------- */
.chat-box {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 300px; overflow-y: auto;
  padding: 10px 4px;
}
.chat-msg {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 9px 12px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
}
.chat-msg.streamer { border-color: rgba(124,92,255,0.45); background: var(--accent-soft); }
.chat-user { font-size: 12px; font-weight: 800; color: var(--accent-2); white-space: nowrap; }
.chat-text { font-size: 13px; color: var(--text); word-break: break-word; }
.chat-time { font-size: 10px; color: var(--faint); margin-left: auto; white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 13.5px; font-weight: 700;
  padding: 9px 18px; border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s ease;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--gradient); border: none; color: #fff; box-shadow: 0 6px 18px rgba(124,92,255,0.3); }
.btn-danger { background: var(--err); border: none; color: #fff; box-shadow: 0 6px 18px rgba(239,68,68,0.3); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }

/* ---------- empty state ---------- */
.empty {
  text-align: center; padding: 34px 16px; color: var(--muted);
}
.empty .e-ico {
  width: 56px; height: 56px; margin: 0 auto 14px;
  border-radius: 16px; display: grid; place-items: center;
  background: var(--surface-3); border: 1px dashed var(--border-strong);
  color: var(--faint);
}
.empty .e-ico svg { width: 26px; height: 26px; }
.empty .t { font-size: 14px; font-weight: 700; color: var(--text); }
.empty .s { font-size: 12.5px; margin-top: 6px; }
.empty .phase { margin-top: 12px; }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 7px; }
.field .hint { font-size: 11px; color: var(--faint); margin-top: 6px; }
.input, .select, .textarea {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-family: inherit; font-size: 13.5px;
  padding: 10px 13px; border-radius: 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,92,255,0.18);
}
.textarea { resize: vertical; min-height: 90px; }

.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { display: none; }
.toggle .track {
  width: 44px; height: 24px; border-radius: 30px;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  position: relative; transition: background 0.18s ease;
}
.toggle .track::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--muted); transition: transform 0.18s ease, background 0.18s ease;
}
.toggle input:checked + .track { background: var(--accent); border-color: var(--accent); }
.toggle input:checked + .track::after {
  background: #fff;
  transform: translateX(-20px); /* RTL: moves to the end */
}
.toggle .tl { font-size: 13px; font-weight: 600; }

.range-row { display: flex; align-items: center; gap: 14px; }
.range-row input[type="range"] {
  flex: 1; accent-color: var(--accent); height: 5px; cursor: pointer;
}
.range-val {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  color: var(--accent-2); min-width: 42px; text-align: center;
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 4px 8px; border-radius: 8px;
}

/* ---------- sliders for AI personality preview ---------- */
.persona-pill {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border-radius: 12px;
  background: var(--bg-soft); border: 1px solid var(--border);
  margin-bottom: 9px;
}
.persona-pill .pp-t { font-size: 13px; font-weight: 700; }
.persona-pill .pp-s { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- kick update cards ---------- */
.upd-card {
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; margin-bottom: 12px;
}
.upd-card .upd-hd { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.upd-card .upd-t { font-size: 14px; font-weight: 700; flex: 1; }
.upd-card .upd-meta { font-size: 11px; color: var(--faint); margin-bottom: 8px; }
.upd-card .upd-body { font-size: 12.5px; color: var(--muted); line-height: 1.7; }
.upd-card .upd-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- emergency ---------- */
.emerg-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.emerg-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 16px; border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--bg-soft); color: var(--text);
  cursor: pointer; font-family: inherit; text-align: start;
  transition: transform 0.08s ease, border-color 0.15s ease;
}
.emerg-btn:hover { transform: translateY(-1px); }
.emerg-btn.danger { border-color: rgba(239,68,68,0.45); }
.emerg-btn.danger .eb-ico { background: var(--err-soft); color: var(--err); }
.emerg-btn.danger:hover { border-color: var(--err); }
.emerg-btn.warny { border-color: rgba(245,158,11,0.4); }
.emerg-btn.warny .eb-ico { background: var(--warn-soft); color: var(--warn); }
.emerg-btn .eb-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-3); flex-shrink: 0; }
.emerg-btn .eb-ico svg { width: 21px; height: 21px; }
.emerg-btn .eb-t { font-size: 14px; font-weight: 800; }
.emerg-btn .eb-s { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* ---------- logs ---------- */
.log-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.log-table th {
  text-align: start; color: var(--faint); font-size: 11px; letter-spacing: 0.5px;
  padding: 8px 10px; border-bottom: 1px solid var(--border-strong);
}
.log-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); color: var(--muted); }
.log-table td.time { font-family: var(--mono); color: var(--faint); white-space: nowrap; }
.log-table tr:hover td { background: rgba(148,163,184,0.04); }

/* ---------- toast ---------- */
#toasts {
  position: fixed; bottom: 22px; inset-inline-start: 22px;
  display: flex; flex-direction: column; gap: 10px; z-index: 200;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  color: var(--text); font-size: 13px; font-weight: 600;
  padding: 12px 16px; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  animation: slideIn 0.25s ease;
  max-width: 360px;
}
.toast.ok { border-inline-start: 4px solid var(--ok); }
.toast.warn { border-inline-start: 4px solid var(--warn); }
.toast.err { border-inline-start: 4px solid var(--err); }
@keyframes slideIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- modal ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(5,8,15,0.72); backdrop-filter: blur(6px);
  display: grid; place-items: center;
  opacity: 0; pointer-events: none; transition: opacity 0.18s ease;
}
.modal-mask.show { opacity: 1; pointer-events: auto; }
.modal {
  width: min(420px, 92vw);
  background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 18px; padding: 22px;
  transform: translateY(10px) scale(0.98); transition: transform 0.18s ease;
}
.modal-mask.show .modal { transform: none; }
.modal .m-t { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.modal .m-t svg { width: 20px; height: 20px; color: var(--warn); }
.modal .m-s { font-size: 13px; color: var(--muted); margin: 12px 0 18px; line-height: 1.7; }
.modal .m-btns { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- misc ---------- */
.page-head { margin-bottom: 20px; }
.page-head h2 { font-size: 21px; font-weight: 800; }
.page-head p { font-size: 13px; color: var(--muted); margin-top: 5px; line-height: 1.7; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.flex { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; }
.code {
  font-family: var(--mono); font-size: 12px; color: #c4b5fd;
  background: var(--bg-soft); border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 6px;
}
.kv { display: grid; grid-template-columns: 1fr; gap: 0; }
.kv .kv-row {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13px;
}
.kv .kv-row:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; text-align: end; word-break: break-all; }

/* page transitions */
.page-fade { animation: fadeUp 0.28s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2, .grid.cols-2-1 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,0.6); }
  .main { margin-inline-start: 0; }
  .topbar .burger { display: grid; }
  .status-pills .pill { display: none; }
  .status-pills .pill:first-child { display: inline-flex; }
}
@media (max-width: 560px) {
  .content { padding: 16px; }
  .grid.cols-4, .grid.cols-3 { grid-template-columns: 1fr; }
  .emerg-grid { grid-template-columns: 1fr; }
}
