/* ============================================================
   C-NBOS v2 — طراحی در سطح جهانی
   تم تیره شیشه‌ای + گرادیان‌های آرورا + جزئیات میکرو
   ============================================================ */
:root {
  --bg: #05070f;
  --bg2: #0a0f1e;
  --panel: rgba(13, 18, 36, .78);
  --solid: #0d1224;
  --border: rgba(148, 163, 255, .12);
  --border-hi: rgba(148, 163, 255, .28);
  --text: #e8eeff;
  --muted: #7c88ad;
  --cyan: #22d3ee;
  --indigo: #6366f1;
  --violet: #a855f7;
  --green: #34d399;
  --red: #fb7185;
  --amber: #fbbf24;
  --grad: linear-gradient(120deg, #22d3ee 0%, #6366f1 50%, #a855f7 100%);
  --glow-cyan: 0 0 24px rgba(34, 211, 238, .25);
  --glow-green: 0 4px 22px rgba(52, 211, 153, .35);
  --r: 14px;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: Vazirmatn, Tahoma, sans-serif;
  color: var(--text);
  direction: rtl;
  overflow: hidden;
  background:
    radial-gradient(1100px 550px at 88% -12%, rgba(168, 85, 247, .16), transparent 62%),
    radial-gradient(900px 500px at -8% 112%, rgba(34, 211, 238, .13), transparent 58%),
    radial-gradient(700px 400px at 50% 55%, rgba(99, 102, 241, .07), transparent 70%),
    var(--bg);
}
/* شبکه ریز زمینه */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(148, 163, 255, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 255, .035) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse at 50% 30%, black 20%, transparent 75%);
}

#app { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100vh; }

/* آیکون‌ها */
.icn { display: inline-flex; width: 1.05em; height: 1.05em; vertical-align: -0.18em; color: inherit; flex-shrink: 0; }
.icn svg { width: 100%; height: 100%; }
.icn.lg { width: 1.3em; height: 1.3em; }

/* ---------- نوار بالا ---------- */
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 16px;
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--grad);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-weight: 800; font-size: .88rem; color: #fff;
  box-shadow: 0 4px 20px rgba(99, 102, 241, .5), inset 0 1px 0 rgba(255,255,255,.35);
  position: relative;
}
.brand .logo::after { content: ''; position: absolute; inset: 0; border-radius: 12px; background: linear-gradient(160deg, rgba(255,255,255,.25), transparent 55%); }
.brand b {
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-family: var(--mono); letter-spacing: 1.5px; font-size: 1.12rem;
}
.brand .tag {
  font-size: .66rem; color: var(--muted); font-weight: 400;
  border: 1px solid var(--border); padding: 3px 11px; border-radius: 999px;
  background: rgba(255,255,255,.03);
}
#crumb { font-family: var(--mono); font-size: .74rem; color: var(--muted); direction: ltr; }
#crumb b { color: var(--cyan); font-weight: 500; }

#topbar .actions { margin-inline-start: auto; display: flex; align-items: center; gap: 9px; }

.btn {
  border: 1px solid var(--border); border-radius: 11px; padding: 8px 15px;
  font-family: inherit; font-weight: 700; font-size: .82rem; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--text); background: rgba(255,255,255,.045);
  transition: all .15s cubic-bezier(.4, 0, .2, 1);
}
.btn:hover { background: rgba(255,255,255,.09); border-color: var(--border-hi); transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn.run {
  background: linear-gradient(135deg, #059669, #34d399);
  border-color: transparent; color: #03120c; box-shadow: var(--glow-green);
}
.btn.run:hover { box-shadow: 0 6px 28px rgba(52, 211, 153, .5); }
.btn.run:disabled { opacity: .55; cursor: wait; transform: none; }
.btn.kbd-hint { font-size: .68rem; color: var(--muted); padding: 7px 12px; }
kbd {
  font-family: var(--mono); font-size: .62rem; background: rgba(255,255,255,.07);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px;
}

#langBadge {
  font-family: var(--mono); font-size: .72rem;
  color: var(--cyan); background: rgba(34, 211, 238, .07);
  border: 1px solid rgba(34, 211, 238, .22); border-radius: 999px; padding: 5px 13px;
  display: inline-flex; align-items: center; gap: 7px;
}
#langBadge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }

/* ---------- بدنه ---------- */
#main { flex: 1; display: flex; min-height: 0; }

/* نوار ابزار کناری (Activity Bar) */
#activitybar {
  width: 52px; flex-shrink: 0;
  background: rgba(8, 11, 24, .85); backdrop-filter: blur(18px);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: center; padding: 10px 0; gap: 4px;
}
.ab-btn {
  width: 40px; height: 40px; border-radius: 11px; border: none; cursor: pointer;
  background: transparent; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; position: relative;
}
.ab-btn .icn { width: 19px; height: 19px; }
.ab-btn:hover { color: var(--text); background: rgba(255,255,255,.06); }
.ab-btn.active { color: var(--cyan); background: rgba(34, 211, 238, .1); }
.ab-btn.active::before {
  content: ''; position: absolute; inset-inline-end: -6px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 99px; background: var(--cyan); box-shadow: var(--glow-cyan);
}
.ab-sep { width: 26px; height: 1px; background: var(--border); margin: 6px 0; }
.ab-btn.run-mini { color: var(--green); }
.ab-btn.run-mini:hover { background: rgba(52, 211, 153, .12); }

/* سایدبار */
#sidebar {
  width: 216px; flex-shrink: 0;
  background: var(--panel); backdrop-filter: blur(18px);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: margin .22s cubic-bezier(.4, 0, .2, 1);
}
#sidebar.hidden2 { margin-inline-start: -216px; }
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 14px 9px; font-size: .72rem; font-weight: 700; color: var(--muted);
  letter-spacing: .4px;
}
.side-head .icn { width: 15px; height: 15px; }
.side-head button {
  background: rgba(34,211,238,.1); color: var(--cyan); border: 1px solid rgba(34,211,238,.25);
  width: 25px; height: 25px; border-radius: 8px; cursor: pointer; transition: all .15s;
  display: flex; align-items: center; justify-content: center;
}
.side-head button:hover { background: rgba(34,211,238,.22); box-shadow: var(--glow-cyan); }
.side-head button .icn { width: 13px; height: 13px; }
#fileList { list-style: none; flex: 1; overflow-y: auto; padding: 2px 8px 8px; }
#fileList li {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: 10px; cursor: pointer;
  font-family: var(--mono); font-size: .76rem; direction: ltr; text-align: left;
  border: 1px solid transparent; transition: all .13s; margin-bottom: 2px;
}
#fileList li:hover { background: rgba(255,255,255,.05); }
#fileList li.active {
  background: linear-gradient(90deg, rgba(99,102,241,.16), rgba(34,211,238,.08));
  border-color: rgba(99, 102, 241, .3);
}
#fileList .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 6px currentColor; }
#fileList .del { margin-inline-start: 2px; color: var(--muted); opacity: 0; transition: opacity .13s; display: inline-flex; }
#fileList .del .icn { width: 12px; height: 12px; }
#fileList li:hover .del { opacity: .85; }
#fileList .del:hover { color: var(--red); }
/* دکمه زنجیر (افزودن به گروه اجرا) */
#fileList .grp { margin-inline-start: auto; color: var(--muted); opacity: 0; transition: all .13s; display: inline-flex; padding: 1px; border-radius: 5px; }
#fileList .grp .icn { width: 13px; height: 13px; }
#fileList li:hover .grp { opacity: .7; }
#fileList .grp:hover { color: var(--cyan); opacity: 1 !important; }
#fileList li.grouped .grp { opacity: 1; color: var(--cyan); background: rgba(34,211,238,.12); box-shadow: 0 0 8px rgba(34,211,238,.25); }
#fileList li.grouped { border-inline-start: 2px solid rgba(34,211,238,.45); }
/* پنل گروه اجرای چندفایلی */
#grpPanel { border-top: 1px solid rgba(255,255,255,.06); padding: 8px 10px 6px; max-height: 38%; overflow-y: auto; background: rgba(8,12,26,.5); }
.grp-head { display: flex; align-items: center; gap: 7px; font-size: .74rem; font-weight: 700; color: var(--text2, #b8c2e0); letter-spacing: .2px; padding-bottom: 6px; }
.grp-head .icn { width: 14px; height: 14px; color: var(--cyan); }
.grp-head .cnt { background: rgba(34,211,238,.14); color: var(--cyan); border-radius: 20px; padding: 0 8px; font-size: .7rem; font-weight: 800; min-width: 20px; text-align: center; }
.grp-actions { margin-inline-start: auto; display: flex; gap: 4px; }
.grp-actions button { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08); border-radius: 7px; color: var(--muted); cursor: pointer; padding: 4px 7px; display: inline-flex; transition: all .13s; }
.grp-actions button .icn { width: 12px; height: 12px; }
.grp-actions #grpRun:hover { color: var(--green); border-color: rgba(74,222,128,.4); background: rgba(74,222,128,.1); }
.grp-actions #grpClear:hover { color: var(--red); border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.08); }
#grpItems { display: flex; flex-wrap: wrap; gap: 5px; }
.grp-chip { display: inline-flex; align-items: center; gap: 5px; font-size: .7rem; font-family: 'JetBrains Mono', monospace; background: rgba(34,211,238,.08); border: 1px solid rgba(34,211,238,.22); color: var(--cyan); border-radius: 8px; padding: 3px 8px; cursor: pointer; transition: all .13s; }
.grp-chip:hover { background: rgba(34,211,238,.16); }
.grp-chip .x { color: var(--muted); display: inline-flex; }
.grp-chip .x:hover { color: var(--red); }
.grp-chip .x .icn { width: 10px; height: 10px; }
.grp-empty { font-size: .7rem; color: var(--muted); opacity: .75; }
.grp-hint { font-size: .64rem; color: var(--muted); opacity: .65; margin-top: 6px; line-height: 1.7; }
.grp-hint .inline-icn { display: inline-flex; vertical-align: -2px; color: var(--cyan); }
.grp-hint .inline-icn .icn { width: 11px; height: 11px; }
.side-foot {
  padding: 10px 14px; font-size: .63rem; color: var(--muted);
  border-top: 1px solid var(--border); font-family: var(--mono); direction: ltr;
  display: flex; align-items: center; gap: 7px;
}
.side-foot .pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 2.4s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* ویرایشگر */
#editorWrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#tabs { display: flex; gap: 3px; padding: 7px 12px 0; overflow-x: auto; scrollbar-width: thin; }
#tabs .tab {
  font-family: var(--mono); font-size: .73rem; direction: ltr;
  padding: 7px 14px; border-radius: 10px 10px 0 0; cursor: pointer;
  background: rgba(255,255,255,.025); color: var(--muted);
  border: 1px solid transparent; border-bottom: none;
  white-space: nowrap; display: inline-flex; align-items: center; gap: 8px;
  transition: all .13s;
}
#tabs .tab:hover { color: var(--text); }
#tabs .tab.active {
  background: var(--bg2); color: var(--text); border-color: var(--border);
  box-shadow: 0 -8px 20px rgba(99, 102, 241, .08);
}
#tabs .tab .cdot { width: 6px; height: 6px; border-radius: 50%; }
#editor { flex: 1; min-height: 0; background: var(--bg2); direction: ltr; border-top: 1px solid var(--border); }

/* اسپلیتر */
#splitter { height: 5px; cursor: row-resize; background: transparent; transition: background .15s; position: relative; }
#splitter::after { content: ''; position: absolute; inset: 2px 0; background: var(--border); }
#splitter:hover::after, #splitter.drag::after { background: var(--indigo); box-shadow: 0 0 10px rgba(99,102,241,.5); }

/* پنل پایین */
#bottom { height: 216px; background: var(--panel); backdrop-filter: blur(18px); display: flex; flex-direction: column; }
.btabs { display: flex; gap: 5px; padding: 8px 12px 0; align-items: center; }
.btabs button {
  border: none; background: transparent; color: var(--muted); font-family: inherit;
  font-size: .76rem; font-weight: 700; padding: 7px 13px; border-radius: 9px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; transition: all .13s;
}
.btabs button .icn { width: 14px; height: 14px; }
.btabs button:hover { color: var(--text); background: rgba(255,255,255,.05); }
.btabs button.active { background: rgba(99, 102, 241, .14); color: var(--text); }
#panelStatus {
  margin-inline-start: auto; font-size: .68rem; color: var(--muted);
  font-family: var(--mono); direction: ltr; display: inline-flex; align-items: center; gap: 8px;
}
#panel { flex: 1; min-height: 0; padding: 9px 15px 12px; }
#output {
  height: 100%; overflow: auto; font-family: var(--mono); font-size: .79rem;
  direction: ltr; text-align: left; white-space: pre-wrap; line-height: 1.7; color: #d5e0ff;
}
#output .err { color: var(--red); }
#output .meta { color: var(--muted); }
#output .okline { color: var(--green); }
#output .badline { color: var(--red); }
#stdinBox {
  width: 100%; height: 100%; resize: none; background: rgba(10, 15, 30, .8); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 11px;
  font-family: var(--mono); font-size: .79rem; direction: ltr; outline: none; transition: border-color .15s;
}
#stdinBox:focus { border-color: var(--indigo); }
#preview { width: 100%; height: 100%; border: none; border-radius: 10px; background: #fff; }
/* ==== پنل کتابخانه‌های پایتون ==== */
#packages { height: 100%; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
#packages.hidden { display: none; }
.pkg-row { display: flex; gap: 8px; align-items: center; }
#pkgInput {
  flex: 1; min-width: 180px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 14px; color: var(--text); font-family: var(--mono);
  font-size: .82rem; outline: none; transition: border-color .15s, box-shadow .15s;
}
#pkgInput:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(34,211,238,.12); }
#pkgInstall {
  display: inline-flex; align-items: center; gap: 6px; background: var(--grad); border: none;
  color: #fff; font-family: inherit; font-weight: 700; font-size: .8rem; border-radius: 10px;
  padding: 9px 18px; cursor: pointer; transition: filter .15s, transform .1s;
}
#pkgInstall:hover { filter: brightness(1.15); }
#pkgInstall:active { transform: scale(.97); }
#pkgInstall .icn { width: 14px; height: 14px; }
.pkg-note { font-size: .68rem; color: var(--muted); line-height: 1.8; opacity: .85; }
#pkgList { display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; }
.pkg-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: .72rem; font-family: var(--mono);
  background: rgba(168,85,247,.1); border: 1px solid rgba(168,85,247,.3); color: var(--violet);
  border-radius: 9px; padding: 4px 10px;
}
.pkg-chip .icn { width: 12px; height: 12px; }
.pkg-chip .x { color: var(--muted); display: inline-flex; cursor: pointer; }
.pkg-chip .x:hover { color: var(--red); }
.pkg-chip .x .icn { width: 10px; height: 10px; }
/* ==== سوییچ موتور پایتون ==== */
.engine-toggle {
  display: inline-flex; align-items: center; gap: 2px; font-size: .68rem; color: var(--muted);
  background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 9px; padding: 2px 6px 2px 2px;
}
[dir="rtl"] .engine-toggle { padding: 2px 2px 2px 6px; }
.engine-toggle button {
  border: none; background: transparent; color: var(--muted); font-family: inherit;
  font-size: .68rem; font-weight: 700; padding: 3px 10px; border-radius: 7px; cursor: pointer; transition: all .15s;
}
.engine-toggle button.active { background: rgba(34,211,238,.16); color: var(--cyan); }
.hidden { display: none !important; }

/* نوار وضعیت */
#statusbar {
  display: flex; align-items: center; gap: 4px;
  padding: 4px 12px; font-size: .68rem; color: #cdd8ff;
  background: linear-gradient(90deg, rgba(99,102,241,.22), rgba(34,211,238,.12));
  border-top: 1px solid var(--border); font-family: var(--mono);
}
#statusbar .seg { padding: 2px 10px; border-radius: 7px; display: inline-flex; align-items: center; gap: 6px; direction: ltr; }
#statusbar .seg:hover { background: rgba(255,255,255,.06); }
#statusbar .grow { flex: 1; }
#statusMsg { font-family: Vazirmatn, Tahoma, sans-serif; direction: rtl; }

/* Command Palette */
#paletteOverlay {
  position: fixed; inset: 0; z-index: 200; display: none;
  background: rgba(3, 5, 12, .6); backdrop-filter: blur(6px);
}
#paletteOverlay.open { display: flex; justify-content: center; align-items: flex-start; padding-top: 12vh; }
#palette {
  width: min(560px, 92vw); background: rgba(13, 18, 36, .97);
  border: 1px solid var(--border-hi); border-radius: 18px; overflow: hidden;
  box-shadow: 0 30px 90px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.04) inset;
  animation: palIn .18s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes palIn { from { opacity: 0; transform: translateY(-14px) scale(.98); } }
#paletteInput {
  width: 100%; border: none; outline: none; background: transparent;
  padding: 16px 20px; font-family: inherit; font-size: .95rem; color: var(--text);
  border-bottom: 1px solid var(--border);
}
#paletteList { max-height: 320px; overflow-y: auto; padding: 8px; }
.pal-item {
  display: flex; align-items: center; gap: 11px; padding: 10px 13px;
  border-radius: 11px; cursor: pointer; font-size: .85rem;
}
.pal-item .icn { width: 16px; height: 16px; color: var(--muted); }
.pal-item .kind { margin-inline-start: auto; font-size: .66rem; color: var(--muted); font-family: var(--mono); }
.pal-item.sel { background: linear-gradient(90deg, rgba(99,102,241,.2), rgba(34,211,238,.1)); }
.pal-item.sel .icn { color: var(--cyan); }
.pal-item .fname { font-family: var(--mono); font-size: .8rem; direction: ltr; }

/* toast */
#toast {
  position: fixed; bottom: 250px; right: 50%; transform: translateX(50%) translateY(20px);
  background: var(--solid); border: 1px solid var(--border-hi); color: var(--text);
  padding: 11px 22px; border-radius: 999px; font-size: .82rem; opacity: 0; pointer-events: none;
  transition: all .28s cubic-bezier(.2, .9, .3, 1.2); z-index: 300;
  box-shadow: 0 14px 44px rgba(0,0,0,.5);
  display: inline-flex; align-items: center; gap: 8px;
}
#toast.show { opacity: 1; transform: translateX(50%) translateY(0); }
#toast .icn { color: var(--cyan); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(99,102,241,.28); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(99,102,241,.5); }
::-webkit-scrollbar-track { background: transparent; }

#menuBtn { display: none; }
@media (max-width: 820px) {
  #sidebar { position: fixed; inset-inline-start: 52px; top: 57px; bottom: 26px; z-index: 60; transform: translateX(110%); transition: transform .25s; border-radius: 0 0 0 16px; }
  #sidebar.open { transform: translateX(0); box-shadow: -14px 0 50px rgba(0,0,0,.6); }
  #sidebar.hidden2 { margin-inline-start: 0; }
  #menuBtn { display: inline-flex; }
  .brand .tag, #crumb, .btn.kbd-hint { display: none; }
}
