/* =====================================================
   پلتفرم ربات‌ساز — تم اصلی پنل مدیریت
   RTL / Dark / Vazirmatn
   ===================================================== */

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

/* ── توکن‌های تم تیره (پیش‌فرض) ── */
:root {
  --bg-root:      #0D0F14;
  --bg-surface:   #141720;
  --bg-elevated:  #1A1E2E;
  --border:       #1E2230;
  --border-light: #262C42;

  --accent:       #5B6EF5;
  --accent-soft:  rgba(91,110,245,.12);
  --accent-glow:  rgba(91,110,245,.35);
  --purple:       #8B5CF6;
  --purple-soft:  rgba(139,92,246,.12);

  --text-primary: #E2E8F0;
  --text-muted:   #64748B;
  --text-faint:   #3A4155;

  --success:      #22C55E;
  --warning:      #F59E0B;
  --danger:       #EF4444;
  --info:         #38BDF8;

  --sidebar-w:    260px;
  --header-h:     60px;
  --radius:       10px;
  --radius-sm:    6px;

  --font: 'Vazirmatn', system-ui, sans-serif;
  --transition: 180ms cubic-bezier(.4,0,.2,1);
}

/* ── توکن‌های تم روشن ── */
[data-theme="light"] {
  --bg-root:      #F1F4F9;
  --bg-surface:   #FFFFFF;
  --bg-elevated:  #F8FAFC;
  --border:       #E2E8F0;
  --border-light: #CBD5E1;

  --accent:       #4F63E7;
  --accent-soft:  rgba(79,99,231,.09);
  --accent-glow:  rgba(79,99,231,.2);
  --purple:       #7C3AED;
  --purple-soft:  rgba(124,58,237,.09);

  --text-primary: #0F172A;
  --text-muted:   #64748B;
  --text-faint:   #94A3B8;

  --success:      #16A34A;
  --warning:      #D97706;
  --danger:       #DC2626;
  --info:         #0284C7;
}

/* ── دکمه سوئیچ تم ── */
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  flex-shrink: 0;
}
.theme-toggle:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--accent);
}
/* آیکون ماه در تم تیره، آفتاب در تم روشن */
.theme-toggle .icon-moon { display: block; }
.theme-toggle .icon-sun  { display: none;  }
[data-theme="light"] .theme-toggle .icon-moon { display: none;  }
[data-theme="light"] .theme-toggle .icon-sun  { display: block; }

/* در تم روشن: سایه ملایم برای sidebar و header */
[data-theme="light"] .sidebar,
[data-theme="light"] .header {
  box-shadow: 0 1px 0 var(--border);
}
[data-theme="light"] .sidebar {
  box-shadow: -1px 0 0 var(--border);
}
[data-theme="light"] .card {
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
[data-theme="light"] .bot-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.1);
}
[data-theme="light"] .modal {
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
/* اسکرول‌بار در تم روشن */
[data-theme="light"] .sidebar-nav::-webkit-scrollbar { display: none; }
/* گلو روی تم روشن خیلی پررنگ نباشد */
[data-theme="light"] .nav-item.active::before {
  box-shadow: 0 0 8px var(--accent-glow);
}
[data-theme="light"] .sidebar::before {
  opacity: .6;
}

/* ── ریست ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--bg-root);
  color: var(--text-primary);
  direction: rtl;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }

/* ── Layout ── */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--header-h) 1fr;
  grid-template-areas:
    "sidebar header"
    "sidebar main";
  min-height: 100vh;
}

/* ── Sidebar ── */
.sidebar {
  grid-area: sidebar;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; right: 0;
  width: var(--sidebar-w);
  height: 100vh;
  z-index: 100;
  overflow: hidden;
}

/* امضای طراحی: خط نئون متحرک در بالای sidebar */
.sidebar::before {
  content: '';
  position: absolute;
  top: 0; right: 0; left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--purple), transparent);
  animation: shimmer 3s ease-in-out infinite;
}
@keyframes shimmer {
  0%, 100% { opacity: .4; transform: scaleX(.6); }
  50%       { opacity: 1;  transform: scaleX(1); }
}

.sidebar-logo {
  height: var(--header-h);
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
  box-shadow: 0 0 16px var(--accent-glow);
}
.sidebar-logo .logo-text {
  font-size: .9rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text-primary);
}
.sidebar-logo .logo-sub {
  font-size: .7rem;
  color: var(--text-muted);
  font-weight: 400;
  display: block;
  line-height: 1;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
  scrollbar-width: none;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.nav-section {
  padding: 16px 20px 6px;
}
.nav-section-label {
  font-size: .68rem;
  font-weight: 600;
  color: var(--text-faint);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  border-radius: 0;
  color: var(--text-muted);
  font-size: .88rem;
  font-weight: 500;
  transition: color var(--transition), background var(--transition);
  position: relative;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: right;
}
.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,.03);
}
.nav-item.active {
  color: var(--text-primary);
  background: var(--accent-soft);
}
/* خط درخشنده کنار آیتم فعال — امضای طراحی */
.nav-item.active::before {
  content: '';
  position: absolute;
  right: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--purple));
  border-radius: 0 3px 3px 0;
  box-shadow: 0 0 12px var(--accent-glow);
}
.nav-item .nav-icon {
  width: 18px; height: 18px;
  opacity: .6;
  flex-shrink: 0;
  transition: opacity var(--transition);
}
.nav-item.active .nav-icon,
.nav-item:hover .nav-icon { opacity: 1; }

.nav-badge {
  margin-right: auto;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(91,110,245,.2);
  font-size: .68rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 20px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar-info { flex: 1; min-width: 0; }
.avatar-name {
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.avatar-plan {
  font-size: .7rem;
  color: var(--text-muted);
}

/* ── Header ── */
.header {
  grid-area: header;
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 90;
}
.header-title {
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
}
.header-breadcrumb {
  font-size: .8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.header-breadcrumb span { color: var(--text-faint); }

/* ── Main ── */
.main {
  grid-area: main;
  padding: 28px;
  min-height: calc(100vh - var(--header-h));
}

/* ── Page Title ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}
.page-title { font-size: 1.4rem; font-weight: 700; letter-spacing: -.02em; }
.page-subtitle { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }

/* ── Stat Cards ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0; right: 0; left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--border-light), transparent);
}
.stat-label {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 10px;
}
.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.03em;
}
.stat-value.accent  { color: var(--accent); }
.stat-value.purple  { color: var(--purple); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-trend {
  font-size: .75rem;
  color: var(--text-muted);
  margin-top: 8px;
}
.stat-trend .up   { color: var(--success); }
.stat-trend .down { color: var(--danger); }
.stat-icon {
  position: absolute;
  bottom: 14px; left: 16px;
  font-size: 2rem;
  opacity: .07;
}

/* ── Cards ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: .92rem;
  font-weight: 600;
}
.card-body { padding: 22px; }
.card-body.no-pad { padding: 0; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .85rem;
}
thead th {
  padding: 12px 18px;
  text-align: right;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .05em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.015);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.02); }
tbody td {
  padding: 14px 18px;
  color: var(--text-primary);
  vertical-align: middle;
}
.td-muted { color: var(--text-muted); font-size: .82rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 600;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-primary:hover {
  background: #6B7EF7;
  box-shadow: 0 0 20px var(--accent-glow);
}
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-light);
}
.btn-ghost:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border-light);
}
.btn-danger-ghost {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239,68,68,.25);
}
.btn-danger-ghost:hover {
  background: rgba(239,68,68,.08);
}
.btn-sm { padding: 5px 12px; font-size: .78rem; }
.btn-icon {
  width: 32px; height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  transition: all var(--transition);
}
.btn-icon:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

/* ── Badges / Status ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .73rem;
  font-weight: 600;
}
.badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.badge-active  { background: rgba(34,197,94,.1);  color: var(--success); }
.badge-active::before  { background: var(--success); box-shadow: 0 0 6px var(--success); animation: pulse 2s infinite; }
.badge-paused  { background: rgba(245,158,11,.1);  color: var(--warning); }
.badge-paused::before  { background: var(--warning); }
.badge-error   { background: rgba(239,68,68,.1);   color: var(--danger);  }
.badge-error::before   { background: var(--danger);  }
.badge-telegram { background: rgba(41,182,246,.1); color: #29B6F6; }
.badge-bale     { background: rgba(139,92,246,.1); color: var(--purple); }
.badge-eitaa    { background: rgba(34,197,94,.1);  color: var(--success); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,.4); }
  50%       { box-shadow: 0 0 0 4px rgba(34,197,94,0); }
}

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 7px;
}
.form-control {
  width: 100%;
  background: var(--bg-root);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 14px;
  font-size: .88rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-control::placeholder { color: var(--text-faint); }
.form-hint { font-size: .75rem; color: var(--text-muted); margin-top: 5px; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
  padding-left: 36px;
}

/* ── Toggle Switch ── */
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle input { display: none; }
.toggle-track {
  width: 38px; height: 22px;
  background: var(--border-light);
  border-radius: 11px;
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.toggle-track::after {
  content: '';
  position: absolute;
  right: 3px; top: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::after { transform: translateX(-16px); }
.toggle-label { font-size: .85rem; }

/* ── Messenger Icon Pill ── */
.messenger-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: .75rem;
  font-weight: 600;
}
.messenger-pill.telegram { background: rgba(41,182,246,.1); color: #29B6F6; }
.messenger-pill.bale     { background: var(--purple-soft);  color: var(--purple); }
.messenger-pill.eitaa    { background: rgba(34,197,94,.1);  color: var(--success); }

/* ── Bot Card (Grid view) ── */
.bots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.bot-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition), box-shadow var(--transition);
  cursor: pointer;
}
.bot-card:hover {
  border-color: var(--border-light);
  box-shadow: 0 4px 24px rgba(0,0,0,.4);
}
.bot-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}
.bot-avatar {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.bot-name {
  font-size: .95rem;
  font-weight: 700;
  margin-bottom: 3px;
}
.bot-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.bot-stat-item { }
.bot-stat-val { font-size: 1.1rem; font-weight: 700; }
.bot-stat-lbl { font-size: .72rem; color: var(--text-muted); margin-top: 1px; }

/* ── Flow Item Builder ── */
.flow-builder { display: flex; flex-direction: column; gap: 8px; }
.flow-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  transition: border-color var(--transition);
}
.flow-item:hover { border-color: var(--accent); }
.flow-item-drag {
  color: var(--text-faint);
  cursor: grab;
  flex-shrink: 0;
}
.flow-item-type {
  padding: 3px 9px;
  border-radius: 4px;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.type-send_message    { background: rgba(91,110,245,.15); color: var(--accent); }
.type-api_call        { background: rgba(56,189,248,.12); color: var(--info);   }
.type-set_variable    { background: rgba(139,92,246,.12); color: var(--purple); }
.type-condition       { background: rgba(245,158,11,.12); color: var(--warning);}
.type-loop            { background: rgba(34,197,94,.1);   color: var(--success);}
.type-go_to_command   { background: rgba(239,68,68,.1);   color: var(--danger); }
.type-inline_button_group { background: rgba(91,110,245,.1); color: #A5B4FC; }
.type-book_appointment    { background: rgba(236,72,153,.12); color: #EC4899; }
.type-ai_chat             { background: rgba(16,185,129,.12); color: #10B981; }
.type-payment             { background: rgba(245,158,11,.12); color: #F59E0B; }
.type-vote                { background: rgba(14,165,233,.12); color: #0EA5E9; }

.flow-item-desc { flex: 1; font-size: .83rem; color: var(--text-muted); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.flow-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.flow-add-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

/* ── Tabs ── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 24px; gap: 0; }
.tab-item {
  padding: 11px 18px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
  background: none;
  border-top: none;
  border-right: none;
  border-left: none;
}
.tab-item:hover { color: var(--text-primary); }
.tab-item.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Empty State ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; opacity: .4; }
.empty-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.empty-desc { font-size: .85rem; max-width: 320px; margin: 0 auto 20px; line-height: 1.6; }

/* ── Toast / Alert ── */
.toast-container {
  position: fixed;
  top: 20px; left: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: .85rem;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  animation: toastIn .2s ease;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-12px); } }
.toast.success { border-right: 3px solid var(--success); }
.toast.error   { border-right: 3px solid var(--danger);  }
.toast.info    { border-right: 3px solid var(--accent);  }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  width: min(500px, 95vw);
  overflow: hidden;
  animation: modalIn .2s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
}
@keyframes modalIn { from { opacity: 0; transform: scale(.95) translateY(8px); } }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 700; }
.modal-body  { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-start;
}

/* ── Search ── */
.search-box {
  position: relative;
  max-width: 260px;
}
.search-box input {
  background: var(--bg-root);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 7px 12px 7px 36px;
  font-size: .83rem;
  outline: none;
  width: 100%;
  font-family: var(--font);
  transition: border-color var(--transition);
}
.search-box input:focus { border-color: var(--accent); }
.search-box input::placeholder { color: var(--text-faint); }
.search-box .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
}

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── Utility ── */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2  { gap: 8px; }
.gap-3  { gap: 12px; }
.gap-4  { gap: 16px; }
.mt-4   { margin-top: 16px; }
.mt-6   { margin-top: 24px; }
.mb-4   { margin-bottom: 16px; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: .82rem; }
.font-bold   { font-weight: 700; }
.w-full      { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ══════════════════════════════════════════
   Wizard افزودن ربات
   ══════════════════════════════════════════ */

/* نوار مراحل بالای wizard */
.wizard-steps {
  display: flex;
  align-items: center;
  gap: 0;
}
.wstep {
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: .4;
  transition: opacity var(--transition);
}
.wstep.active  { opacity: 1; }
.wstep.done    { opacity: .7; }
.wstep-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--border-light);
  display: flex; align-items: center; justify-content: center;
  font-size: .7rem;
  font-weight: 700;
  transition: background var(--transition), box-shadow var(--transition);
  flex-shrink: 0;
}
.wstep.active .wstep-num {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}
.wstep.done .wstep-num {
  background: var(--success);
}
.wstep-label {
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.wstep-line {
  flex: 1;
  height: 1px;
  background: var(--border-light);
  margin: 0 8px;
  min-width: 20px;
}

/* انتخاب پیام‌رسان */
.messenger-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}
.mpick-item { display: block; cursor: pointer; }
.mpick-item input { display: none; }
.mpick-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
  text-align: center;
}
.mpick-item input:checked + .mpick-card {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.mpick-card:hover { border-color: var(--accent); }
.mpick-icon  { font-size: 1.6rem; line-height: 1; }
.mpick-name  { font-size: .82rem; font-weight: 700; }
.mpick-desc  { font-size: .7rem; color: var(--text-muted); }

/* راهنمای توکن */
.token-guide {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.token-guide-title {
  font-size: .82rem;
  font-weight: 700;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.token-steps { display: flex; flex-direction: column; gap: 8px; }
.token-step {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: .8rem;
  color: var(--text-muted);
  line-height: 1.5;
}
.token-step-num {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .68rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}
.token-step a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.token-step code {
  background: var(--bg-root);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: .75rem;
  direction: ltr;
  display: inline-block;
}

/* جعبه تأیید مرحله ۳ */
.confirm-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
}
.confirm-header {
  background: var(--accent-soft);
  border-bottom: 1px solid var(--border-light);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: .85rem;
  font-weight: 700;
  color: var(--accent);
}
.confirm-rows { padding: 4px 0; }
.confirm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: .83rem;
}
.confirm-row:last-child { border-bottom: none; }
.confirm-row-label { color: var(--text-muted); }
.confirm-row-val   { font-weight: 600; font-family: monospace; font-size: .8rem; direction: ltr; }
.confirm-webhook {
  margin-top: 14px;
  background: rgba(34,197,94,.06);
  border: 1px solid rgba(34,197,94,.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .78rem;
  color: var(--success);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* footer wizard */
.wizard-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* وضعیت loading دکمه */
.btn.loading { opacity: .7; pointer-events: none; }
.btn.loading::after {
  content: '';
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
  margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════
   Responsive — موبایل
   ══════════════════════════════════════════ */

@media (max-width: 768px) {

  /* کل layout از grid خارج میشه */
  .layout {
    display: block;
  }

  /* sidebar تبدیل به drawer */
  .sidebar {
    position: fixed;
    top: 0;
    right: -280px;
    width: 280px;
    height: 100vh;
    z-index: 200;
    transition: right 0.25s ease;
    box-shadow: -4px 0 24px rgba(0,0,0,.4);
  }

  .sidebar.open {
    right: 0;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 199;
  }

  .sidebar-overlay.visible {
    display: block;
  }

  /* header ثابت */
  .header {
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 190;
    padding: 0 14px;
  }

  /* main اصلی */
  .main {
    width: 100%;
    max-width: 100%;
    padding: 80px 14px 100px;
    margin: 0;
  }

  /* grid ها تک ستون */
  .grid-2,
  .grid-3,
  .stats-grid,
  .bots-grid {
    grid-template-columns: 1fr !important;
  }

  /* table اسکرول */
  table {
    min-width: 600px;
  }

  /* modal پایین صفحه */
  .modal {
    width: 95vw;
    border-radius: 14px 14px 0 0;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* wizard ساده‌تر */
  .wstep-label {
    display: none;
  }

  /* دکمه همبرگر */
  .hamburger {
    display: flex;
  }
}

/* دکمه همبرگر فقط موبایل */
.hamburger { display: none; }
@media (max-width: 768px) {
  .hamburger { display: flex; }
}
