/* پنل مدیریت چت‌بات — استایل فارسی راست‌به‌چپ */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e5e7eb;
  --danger: #dc2626;
  --ok: #16a34a;
}
body { font-family: 'Segoe UI', Tahoma, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.8; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- صفحه ورود ---------- */
.login-view { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #eef2ff, #fdf2f8); padding: 16px; }
.login-card { background: var(--card); padding: 36px 32px; border-radius: 18px; box-shadow: 0 20px 50px rgba(79,70,229,.15); width: 380px; text-align: center; }
.login-logo { font-size: 52px; }
.login-card h1 { font-size: 20px; margin: 10px 0 4px; }
.login-card p { margin-bottom: 18px; }
.login-card input { text-align: center; }

/* ---------- چیدمان ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 240px; background: #171b2e; color: #e2e5ef; display: flex; flex-direction: column; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: bold; font-size: 16px; margin-bottom: 24px; padding: 0 8px; }
.sidebar nav { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.nav-btn { text-align: right; background: transparent; border: 0; color: #c5cbe0; padding: 11px 14px; border-radius: 10px; cursor: pointer; font-size: 14px; font-family: inherit; transition: background .15s; }
.nav-btn:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-btn.active { background: var(--primary); color: #fff; }
.sidebar-footer { display: flex; align-items: center; gap: 8px; font-size: 12px; padding: 0 8px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.status-dot.ok { background: var(--ok); }
.status-dot.bad { background: var(--danger); }
.content { flex: 1; padding: 28px 32px; max-width: 980px; margin: 0 auto; width: 100%; }
.tab { display: none; }
.tab.active { display: block; }
.tab-header { margin-bottom: 16px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; margin-bottom: 12px; color: var(--primary-dark); }

/* ---------- کارت و فرم ---------- */
.card { background: var(--card); border-radius: 14px; padding: 20px; box-shadow: 0 2px 10px rgba(20,24,40,.06); margin-bottom: 16px; }
label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 12px; }
input, textarea, select { width: 100%; margin-top: 5px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; font-family: inherit; font-size: 13.5px; background: #fff; color: var(--text); }
input:focus, textarea:focus, select:focus { outline: 2px solid #c7d2fe; border-color: var(--primary); }
textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: normal; }
.check input { width: auto; }

/* ---------- دکمه‌ها ---------- */
.btn { padding: 9px 18px; border: 1px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer; font-family: inherit; font-size: 13.5px; transition: all .15s; }
.btn:hover { border-color: #9ca3af; }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn.danger:hover { background: #fef2f2; }
.btn.full { width: 100%; margin-top: 14px; }
.btn.small { padding: 4px 12px; font-size: 12px; }

.model-field { display: flex; gap: 8px; align-items: stretch; margin-top: 5px; }
.model-field input { margin-top: 0; flex: 1; min-width: 0; }
.model-field .btn { margin-top: 0; white-space: nowrap; flex-shrink: 0; }
.free-models-panel {
  margin: -4px 0 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafbff;
}
.free-models-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 8px; flex-wrap: wrap; }
.free-models-panel input[type="search"] { margin-top: 0; margin-bottom: 8px; }
.free-models-list { max-height: 260px; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.free-model-item {
  text-align: right;
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12.5px;
  transition: border-color .15s, background .15s;
}
.free-model-item:hover { border-color: var(--primary); background: #eef2ff; }
.free-model-item .id { direction: ltr; font-weight: 600; display: block; }
.free-model-item .name { color: var(--muted); font-size: 11.5px; display: block; margin-top: 2px; }

/* ---------- لیست FAQ ---------- */
.faq-item { background: var(--card); border-radius: 14px; padding: 14px 18px; box-shadow: 0 2px 8px rgba(20,24,40,.05); margin-bottom: 10px; border-right: 4px solid var(--primary); }
.faq-item .q { font-weight: bold; margin-bottom: 4px; display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.faq-item .a { font-size: 13px; color: #374151; white-space: pre-wrap; }
.faq-item .k { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #eef2ff; color: #4338ca; border-radius: 999px; padding: 1px 10px; font-size: 11.5px; }
.faq-item .actions { margin-top: 10px; display: flex; gap: 8px; }
.doc-item .a {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.9;
}
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* ---------- افزودن هوشمند دانش و محصولات ---------- */
.extract-preview { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 12px; }
.product-item { background: var(--card); border-radius: 14px; padding: 14px 18px; box-shadow: 0 2px 8px rgba(20,24,40,.05); margin-bottom: 10px; border-right: 4px solid #16a34a; }
.product-item .q { font-weight: bold; margin-bottom: 4px; display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.product-item .a { display: flex; flex-wrap: wrap; gap: 6px; }
.product-item .actions { margin-top: 0; display: flex; gap: 8px; }
code { background: #f3f4f6; border-radius: 6px; padding: 1px 6px; font-size: 12px; direction: ltr; display: inline-block; }
.embed-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.embed-card { background: #f8f9fc; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; }
.embed-card .k { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; }
.embed-card .v { font-size: 14px; font-weight: 700; color: var(--text); word-break: break-word; }
.embed-list { max-height: 220px; overflow: auto; line-height: 1.9; }
.embed-list .ok { color: var(--ok); }
.embed-list .bad { color: var(--danger); }
.embed-probe-result { background: #f8f9fc; border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; line-height: 1.9; }
.embed-probe-result table { min-width: 0; width: 100%; font-size: 12.5px; }
.embed-probe-result th, .embed-probe-result td { padding: 6px 8px; }
@media (max-width: 760px) {
  .embed-cards { grid-template-columns: 1fr 1fr; }
}

/* ---------- لاگ ---------- */
.table-card { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; min-width: 640px; }
th, td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: #f8f9fc; font-size: 12px; color: var(--muted); }
td.q, td.a { max-width: 300px; word-break: break-word; white-space: pre-wrap; }

/* ---------- سایر ---------- */
.error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; border-radius: 10px; padding: 9px 12px; font-size: 13px; margin-top: 12px; text-align: center; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #171b2e; color: #fff; padding: 11px 22px; border-radius: 12px; font-size: 13.5px; z-index: 999; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.toast.err { background: var(--danger); }
@media (max-width: 760px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .content { padding: 18px; }
  .grid2 { grid-template-columns: 1fr; }
}
