/* ===== Bale Bot Builder — پنل مدیریت (تم ساده) ===== */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700&display=swap');

:root {
  --bg: #f3f4f6;
  --bg-panel: #ffffff;
  --bg-panel-raised: #f8f9fb;
  --bg-input: #ffffff;

  --border: #e3e6ea;
  --border-bright: #cfd4db;

  /* رنگ اصلی (قبلاً سبزِ هکری بود، الان آبیِ معمولیِ پنل ادمین) */
  --green: #2563eb;
  --green-dim: #1d4ed8;
  --green-faint: #eaf1ff;
  --green-glow: rgba(37, 99, 235, 0.18);

  --text: #1f2430;
  --text-dim: #6b7280;
  --text-faint: #9aa1ac;

  --red: #dc2626;
  --red-dim: #ef4444;
  --amber: #b45309;

  --font-mono: 'Vazirmatn', -apple-system, 'Segoe UI', Tahoma, sans-serif;

  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.7;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--green-faint); color: var(--green-dim); }

/* scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: var(--radius); }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ===== Layout shell ===== */
.shell {
  position: relative;
  z-index: 2;
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-inline-end: 1px solid var(--border);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 20px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-brand .logo-line {
  font-size: 12px;
  color: var(--text-dim);
}

.sidebar-brand .logo-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0;
}

.nav-group-label {
  padding: 14px 20px 6px;
  font-size: 11px;
  letter-spacing: 0.3px;
  color: var(--text-faint);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  color: var(--text-dim);
  border-inline-start: 3px solid transparent;
  transition: all 0.12s ease;
  cursor: pointer;
  font-size: 13.5px;
}

.nav-item:hover {
  color: var(--green-dim);
  background: var(--bg-panel-raised);
  text-decoration: none;
}

.nav-item.active {
  color: var(--green-dim);
  font-weight: 600;
  border-inline-start-color: var(--green);
  background: var(--green-faint);
}

/* فلش کوچیک کنار آیتم‌های منو — دیگه رنگ سبز شبح‌وار نیست */
.nav-item .prompt-char { color: var(--text-faint); }

.main {
  flex: 1;
  padding: 28px 36px 60px;
  min-width: 0;
}

.topbar-prompt {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.topbar-prompt .user { color: var(--text-dim); }
.topbar-prompt .path { color: var(--text-dim); }

.page-title {
  font-size: 21px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
  display: flex;
  align-items: baseline;
  gap: 10px;
}

/* دیگه چشمک نمی‌زنه؛ اگه جایی هنوز span.cursor مونده باشه، مخفی می‌مونه */
.page-title .cursor { display: none; }

.page-subtitle {
  color: var(--text-dim);
  margin-bottom: 24px;
  font-size: 13px;
}

/* ===== Cards / panels ===== */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* دکمه‌های تزئینیِ «پنجره‌ی ترمینال» — دیگه لازم نیست دیده بشن */
.panel-header .dots { display: none; }

.panel-body { padding: 18px; }

.grid { display: grid; gap: 16px; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 900px) {
  .grid-cols-2, .grid-cols-3 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ===== Bot cards ===== */
.bot-card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.bot-card:hover {
  border-color: var(--border-bright);
  box-shadow: 0 4px 14px -6px rgba(16, 24, 40, 0.15);
}
.bot-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 10px;
}
.bot-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.bot-card-meta {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}
.bot-card-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.bot-card-actions a, .bot-card-actions button {
  font-size: 12px;
}

/* ===== Status badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-bright);
}
.badge::before { content: '●'; font-size: 8px; }
.badge-on { color: #16a34a; border-color: #bbf7d0; background: #f0fdf4; }
.badge-on::before { color: #16a34a; }
.badge-off { color: var(--text-dim); border-color: var(--border); background: var(--bg-panel-raised); }
.badge-off::before { color: var(--text-faint); }

/* ===== Forms ===== */
label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dim);
  margin-bottom: 6px;
}
label .req { color: var(--red); }

.field { margin-bottom: 16px; }

input[type=text],
input[type=url],
input[type=search],
input[type=password],
input[type=email],
select,
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-bright);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13.5px;
  padding: 9px 12px;
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-glow);
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

textarea { min-height: 90px; resize: vertical; }

.field-hint {
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 5px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.checkbox-row input { width: auto; accent-color: var(--green); }
.checkbox-row label { margin: 0; color: var(--text); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border-bright);
  background: var(--bg-panel);
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s ease;
}
.btn:hover { text-decoration: none; border-color: var(--green); color: var(--green-dim); background: var(--green-faint); }

.btn-primary {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}
.btn-primary:hover {
  background: var(--green-dim);
  border-color: var(--green-dim);
  color: #ffffff;
}

.btn-danger { border-color: #fecaca; color: var(--red); background: #fff; }
.btn-danger:hover { background: var(--red); color: #fff; border-color: var(--red); }

.btn-sm { padding: 5px 10px; font-size: 11.5px; }
.btn-block { width: 100%; justify-content: center; }

/* ===== Table ===== */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: right;
  padding: 10px 14px;
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
tr:hover td { background: var(--bg-panel-raised); }

/* ===== Tree (menus) ===== */
.menu-tree { list-style: none; padding: 0; margin: 0; }
.menu-tree ul { list-style: none; padding-inline-start: 22px; margin: 6px 0 0; }
.menu-node {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
}
.menu-node:hover { border-color: var(--border); background: var(--bg-panel-raised); }
.menu-node .branch-char { color: var(--text-faint); }
.menu-node .type-tag {
  font-size: 10.5px;
  color: var(--green-dim);
  border: 1px solid var(--border);
  background: var(--green-faint);
  padding: 1px 8px;
  border-radius: 10px;
}

/* ===== Flow builder (simple step list) ===== */
.flow-step {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  position: relative;
}
.flow-step-index {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1px solid var(--green);
  color: var(--green-dim);
  background: var(--green-faint);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.flow-step-connector {
  position: absolute;
  inset-inline-start: 27px;
  top: -10px;
  height: 10px;
  border-inline-start: 1px dashed var(--border-bright);
}
.flow-step-body { flex: 1; }
.flow-step-condition {
  font-size: 11.5px;
  color: var(--amber);
  margin-bottom: 4px;
}
.flow-step-condition::before { content: 'اگر '; color: var(--text-faint); }
.flow-step-action { font-size: 13px; color: var(--text); }
.flow-step-action .arrow { color: var(--green-dim); margin: 0 4px; }

/* ===== Alerts ===== */
.alert {
  padding: 11px 16px;
  border-radius: var(--radius);
  border: 1px solid;
  font-size: 13px;
  margin-bottom: 18px;
}
.alert-success { border-color: #bbf7d0; background: #f0fdf4; color: #15803d; }
.alert-error { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty-state .glyph {
  font-size: 24px;
  color: var(--border-bright);
  margin-bottom: 10px;
}

/* ===== Utility ===== */
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.text-dim { color: var(--text-dim); }
.text-faint { color: var(--text-faint); }
.text-green { color: var(--green-dim); }
.code-inline {
  background: var(--bg-panel-raised);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--green-dim);
}

/* ===== Visual Flow Builder (Drag & Drop canvas) ===== */
.flow-canvas-wrap {
  position: relative;
  overflow: auto;
  background:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 24px 24px;
  background-color: #fafbfc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 70vh;
}

#flow-canvas {
  position: relative;
  width: 100%;
  min-height: 100%;
}

#flow-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.flow-node {
  position: absolute;
  width: 260px;
  background: var(--bg-panel);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  cursor: grab;
  user-select: none;
  box-shadow: 0 4px 14px -6px rgba(16, 24, 40, 0.18);
}
.flow-node:hover { border-color: var(--green); }
.flow-node.dragging {
  cursor: grabbing;
  box-shadow: 0 8px 24px -4px rgba(16, 24, 40, 0.25);
  z-index: 50;
}

.flow-node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}
.flow-node-head .step-no {
  color: var(--green-dim);
  font-weight: 700;
}
.flow-node-body { padding: 10px 12px; }
.flow-node-condition {
  font-size: 11.5px;
  color: var(--amber);
  margin-bottom: 6px;
}
.flow-node-condition::before { content: 'اگر '; color: var(--text-faint); }
.flow-node-action { font-size: 12.5px; color: var(--text); line-height: 1.5; }
.flow-node-actions {
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}
.flow-node-actions button, .flow-node-actions a {
  background: none;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11.5px;
  cursor: pointer;
  padding: 0;
}
.flow-node-actions button:hover, .flow-node-actions a:hover { color: var(--green-dim); }
.flow-node-actions .del:hover { color: var(--red); }

.flow-canvas-fab {
  position: fixed;
  bottom: 34px;
  inset-inline-end: 40px;
  z-index: 5;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--green);
  color: #ffffff;
  border: none;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 4px 14px -2px rgba(37, 99, 235, 0.45);
}
.flow-canvas-fab:hover { background: var(--green-dim); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(17, 24, 39, 0.5);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.open { display: flex; }
.modal-box {
  width: 100%; max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 40px -8px rgba(16, 24, 40, 0.25);
}
