/* UserBot Control Center — enterprise admin theme */
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f6f7f9;
  --bg-soft: #eef0f4;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --line: #e6e8ee;
  --line-2: #eef0f4;
  --txt: #111726;
  --txt-2: #39435a;
  --muted: #6b7589;
  --primary: #4361ee;
  --primary-2: #3a55d9;
  --primary-soft: #ecefff;
  --green: #1aa251;
  --green-soft: #e6f6ec;
  --red: #e0413f;
  --red-soft: #fdecec;
  --amber: #c77700;
  --amber-soft: #fbf1df;
  --teal: #0d9488;
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow: 0 4px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, .18);
  --radius: 12px;
  --radius-sm: 9px;
  --sb: 256px;
}
[data-theme="dark"] {
  --bg: #0b0e14;
  --bg-soft: #11151d;
  --surface: #151a23;
  --surface-2: #1a1f2b;
  --line: #242b38;
  --line-2: #1f2530;
  --txt: #eaeef6;
  --txt-2: #c4ccda;
  --muted: #8b95a8;
  --primary: #5b78ff;
  --primary-2: #4a67f0;
  --primary-soft: #18213c;
  --green: #2bbd6b;
  --green-soft: #122418;
  --red: #ff5b58;
  --red-soft: #2a1718;
  --amber: #e2a23a;
  --amber-soft: #2a2012;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow: 0 6px 22px rgba(0, 0, 0, .4);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; color: var(--txt); background: var(--bg);
  font-family: Vazirmatn, "Inter", "Segoe UI", Tahoma, sans-serif;
  font-size: 13.5px; line-height: 1.6; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
.muted { color: var(--muted); }
.err { color: var(--red); }
h1, h2, h3 { color: var(--txt); }
svg { display: block; }
.ico-svg { width: 18px; height: 18px; flex: none; }
.btn .ico-svg { width: 16px; height: 16px; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh;
  background: radial-gradient(900px 420px at 50% -8%, var(--primary-soft), transparent 60%), var(--bg); }
.login-card { width: min(380px, 92vw); background: var(--surface); border: 1px solid var(--line);
  border-radius: 18px; padding: 36px 30px; text-align: center; box-shadow: var(--shadow-lg); }
.login-logo { width: 54px; height: 54px; margin: 0 auto 16px; border-radius: 15px; display: grid; place-items: center;
  font-size: 22px; color: #fff; background: linear-gradient(135deg, var(--primary), #6f86ff); box-shadow: 0 10px 24px rgba(67, 97, 238, .4); }
.login-card h1 { margin: 0 0 4px; font-size: 21px; font-weight: 700; }
.login-card input { width: 100%; margin-top: 18px; padding: 12px 14px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--txt); font-family: inherit; font-size: 15px; }
.login-card .err { margin: 14px 0 0; }
.block { width: 100%; margin-top: 14px; }

/* ---------- layout ---------- */
#app { display: grid; grid-template-columns: var(--sb) 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; padding: 20px 14px; display: flex; flex-direction: column;
  background: var(--surface); border-left: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 15.5px; display: flex; align-items: center; gap: 10px; padding: 0 6px; }
.brand-mark { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; color: #fff;
  background: linear-gradient(135deg, var(--primary), #6f86ff); flex: none; }
.brand-mark svg { width: 17px; height: 17px; }
.side-sub { font-size: 11.5px; margin: 5px 6px 0; color: var(--muted); }
.nav { margin-top: 22px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 14px 8px 6px; }
.nav button { position: relative; display: flex; align-items: center; gap: 11px; width: 100%; text-align: right;
  padding: 10px 12px; border-radius: var(--radius-sm); border: 0; background: transparent; color: var(--txt-2);
  cursor: pointer; font-family: inherit; font-size: 14px; font-weight: 500; transition: .12s; }
.nav button svg { width: 18px; height: 18px; opacity: .85; }
.nav button:hover { background: var(--bg-soft); color: var(--txt); }
.nav button.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav button.active::before { content: ""; position: absolute; right: 0; top: 18%; bottom: 18%; width: 3px; border-radius: 3px; background: var(--primary); }
.side-foot { display: flex; gap: 6px; align-items: center; padding-top: 14px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.side-foot .muted { flex: 1; font-size: 11px; padding-right: 4px; }
.icon-btn { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }
.main { padding: 24px 28px 60px; max-width: 1340px; }

/* ---------- headings & generic ---------- */
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 21px; font-weight: 700; }
.page-head .sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-xs); }
.card h2 { margin: 0 0 14px; font-size: 15.5px; font-weight: 700; }
.card h3 { margin: 0 0 12px; font-size: 13.5px; font-weight: 700; color: var(--txt-2); display: flex; align-items: center; gap: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(304px, 1fr)); gap: 16px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.spread { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; }

label.field { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; color: var(--muted); font-weight: 500; }
input, select, textarea { background: var(--surface); color: var(--txt); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 10px 12px; outline: none; font-family: inherit; font-size: 13.5px; width: 100%; transition: .12s; }
textarea { resize: vertical; min-height: 90px; line-height: 1.7; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

button, .btn { border: 1px solid transparent; border-radius: var(--radius-sm); padding: 9px 13px; background: var(--surface-2);
  color: var(--txt-2); cursor: pointer; display: inline-flex; gap: 7px; align-items: center; justify-content: center;
  font-family: inherit; font-size: 13px; font-weight: 600; transition: .12s; white-space: nowrap; text-decoration: none; }
button:hover, .btn:hover { background: var(--bg-soft); }
button:active { transform: translateY(.5px); }
button:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: 7px 10px; font-size: 12.5px; }
.btn.icon-btn { gap: 0; }
.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.primary:hover { background: var(--primary-2); }
.ghost { background: transparent; border-color: var(--line); color: var(--txt-2); }
.ghost:hover { background: var(--bg-soft); }
.danger { background: var(--red-soft); color: var(--red); }
.green { background: var(--green-soft); color: var(--green); }
.orange { background: var(--amber-soft); color: var(--amber); }

.badge { padding: 4px 9px; border-radius: 7px; font-size: 11.5px; font-weight: 600; display: inline-flex; gap: 5px; align-items: center; }
.badge.on { background: var(--green-soft); color: var(--green); }
.badge.off { background: var(--bg-soft); color: var(--muted); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }

/* ---------- stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { display: flex; align-items: center; gap: 14px; }
.stat .ico { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); flex: none; }
.stat .ico svg { width: 20px; height: 20px; }
.stat .n { font-size: 23px; font-weight: 800; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 12.5px; }

/* ---------- account card ---------- */
.account .top-row { display: flex; align-items: center; gap: 12px; }
.avatar { width: 42px; height: 42px; border-radius: 11px; flex: none; display: inline-grid; place-items: center;
  font-weight: 700; color: #fff; font-size: 16px; background: linear-gradient(135deg, var(--primary), #7d93ff); }
.avatar.sm { width: 34px; height: 34px; border-radius: 9px; font-size: 13px; }
.account .name { font-weight: 700; font-size: 15px; }
.account .key { color: var(--muted); font-size: 12px; }
.account .meta { font-size: 12px; color: var(--muted); margin: 14px 0; display: flex; gap: 8px 16px; flex-wrap: wrap; }
.account .meta span { display: inline-flex; gap: 6px; align-items: center; }
.account .meta svg { width: 14px; height: 14px; opacity: .8; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tab { background: transparent; border: 0; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted);
  padding: 9px 13px; font-weight: 600; font-size: 13px; display: inline-flex; gap: 7px; align-items: center; }
.tab svg { width: 16px; height: 16px; }
.tab:hover { background: transparent; color: var(--txt); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.toggle-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-2); }
.toggle-line:last-child { border-bottom: 0; }

.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--line); border-radius: 99px; transition: .2s; cursor: pointer; }
.slider:before { content: ""; position: absolute; height: 18px; width: 18px; right: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider:before { transform: translateX(-18px); }

/* ---------- chats (full two-column) ---------- */
.chat-layout { display: grid; grid-template-columns: 320px 1fr; height: calc(100vh - 230px); min-height: 480px;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-xs); }
.chat-aside { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--surface); }
.chat-search { padding: 12px; border-bottom: 1px solid var(--line); position: relative; }
.chat-search input { background: var(--surface-2); padding-right: 34px; }
.chat-search svg { position: absolute; right: 22px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); }
.chat-topbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line-2); }
.chat-status { flex: 1; font-size: 11px; line-height: 1.4; }
.chat-tabs { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chat-tabs button { padding: 5px 10px; font-size: 12px; border-radius: 99px; flex: 1; }
.chat-tabs button.active { background: var(--primary-soft); color: var(--primary); }
.chat-scroll { overflow-y: auto; flex: 1; min-height: 0; }
.chatitem { display: flex; gap: 11px; align-items: center; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--line-2); transition: .1s; }
.chatitem:hover { background: var(--bg-soft); }
.chatitem.active { background: var(--primary-soft); }
.chatitem .title { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatitem .sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatitem .grow { min-width: 0; flex: 1; }

.chat-main { display: flex; flex-direction: column; min-height: 0; background: var(--bg-soft); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 18px 18px 8px; display: flex; flex-direction: column; gap: 3px; min-height: 0; }
.bubble { max-width: 68%; padding: 8px 11px; border-radius: 12px; white-space: pre-wrap; word-break: break-word; line-height: 1.65;
  font-size: 13px; box-shadow: var(--shadow-xs); position: relative; }
.bubble.in { background: var(--surface); align-self: flex-start; border-top-right-radius: 3px; }
.bubble.out { background: var(--primary); color: #fff; align-self: flex-end; border-top-left-radius: 3px; }
.bubble .date { font-size: 10.5px; opacity: .65; text-align: left; direction: ltr; margin-top: 3px; }
.bubble.out .date { color: #e6ecff; }
.bubble .msg-photo { max-width: 280px; max-height: 340px; width: 100%; border-radius: 9px; display: block; margin-bottom: 5px; cursor: zoom-in; object-fit: cover; background: var(--bg-soft); }
.bubble .msg-sticker { width: 130px; height: auto; }
.bubble video.msg-video { max-width: 300px; max-height: 360px; border-radius: 9px; margin-bottom: 5px; background: #000; display: block; }
.bubble audio.msg-audio { display: block; margin-bottom: 5px; max-width: 260px; }
.media-chip { display: inline-flex; gap: 7px; align-items: center; background: rgba(127,127,127,.13); padding: 7px 11px; border-radius: 9px; margin-bottom: 5px; font-size: 12.5px; }
.bubble.out .media-chip { background: rgba(255,255,255,.18); }
.media-chip svg { width: 16px; height: 16px; }
.media-chip a { color: inherit; text-decoration: underline; }
.chat-empty { display: grid; place-items: center; height: 100%; color: var(--muted); text-align: center; padding: 30px; gap: 8px; }
.chat-empty svg { width: 38px; height: 38px; opacity: .4; }

.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: var(--surface); }
.composer input { background: var(--surface-2); }
.composer button { flex: none; }

/* ---------- archive ---------- */
.arch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(244px, 1fr)); gap: 14px; }
.arch-card { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); box-shadow: var(--shadow-xs); display: flex; flex-direction: column; }
.arch-thumb { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--bg-soft); cursor: zoom-in; display: block; }
.arch-thumb.placeholder { display: grid; place-items: center; color: var(--muted); cursor: default; }
.arch-thumb.placeholder svg { width: 40px; height: 40px; opacity: .55; }
.arch-body { padding: 12px; display: flex; flex-direction: column; gap: 7px; }
.arch-meta { font-size: 11.5px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.arch-meta span { display: inline-flex; gap: 6px; align-items: center; }
.arch-meta svg { width: 13px; height: 13px; opacity: .8; }
.arch-text { font-size: 13px; max-height: 84px; overflow: auto; white-space: pre-wrap; word-break: break-word; }
.arch-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.tag { font-size: 10.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--bg-soft); color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.tag.del { background: var(--red-soft); color: var(--red); }
.tag.once { background: var(--primary-soft); color: var(--primary); }

/* ---------- logs ---------- */
pre.log { direction: ltr; text-align: left; background: #0d1117; color: #c9d1d9; border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px; white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow: auto;
  font-size: 12.5px; margin: 0; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(15, 22, 40, .55); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 60; padding: 18px; }
.modalbox { width: min(560px, 100%); max-height: 92vh; overflow: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; padding: 22px; box-shadow: var(--shadow-lg); }
.modalbox.lg { width: min(880px, 100%); }
.modalbox.sm { width: min(420px, 100%); }
.modalbox h2 { display: flex; align-items: center; gap: 8px; }
.qrbox { display: grid; grid-template-columns: 300px 1fr; gap: 22px; }
.qrsvg { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; place-items: center; min-height: 300px; }
.qrsvg svg { width: 100%; height: auto; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: grid; place-items: center; z-index: 80; cursor: zoom-out; padding: 24px; }
.lightbox img { max-width: 94vw; max-height: 92vh; border-radius: 10px; box-shadow: var(--shadow-lg); }

/* ---------- toast ---------- */
.toast { position: fixed; left: 22px; bottom: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  padding: 12px 15px; z-index: 90; box-shadow: var(--shadow-lg); max-width: 360px; transform: translateY(140%); opacity: 0; transition: .25s;
  font-weight: 500; display: flex; gap: 9px; align-items: center; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast svg { width: 18px; height: 18px; flex: none; }
.toast.ok { border-right: 3px solid var(--green); }
.toast.ok svg { color: var(--green); }
.toast.bad { border-right: 3px solid var(--red); }
.toast.bad svg { color: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 36px 20px; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.loading { display: flex; gap: 10px; align-items: center; color: var(--muted); padding: 26px; justify-content: center; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) { :root { --sb: 220px; } .chat-layout { grid-template-columns: 260px 1fr; } }
@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  .side { position: sticky; top: 0; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 10px 14px; z-index: 30; }
  .brand { flex: 1; }
  .side-sub, .nav-label { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; margin-top: 0; width: 100%; gap: 4px; order: 3; }
  .nav button { width: auto; flex: 1; min-width: 110px; justify-content: center; }
  .nav button.active::before { display: none; }
  .side-foot { border: 0; padding: 0; width: auto; }
  .side-foot .muted { display: none; }
  .main { padding: 16px 14px 50px; }
  .qrbox { grid-template-columns: 1fr; }
  .chat-layout { grid-template-columns: 1fr; height: auto; }
  .chat-aside { max-height: 300px; border-left: 0; border-bottom: 1px solid var(--line); }
  .chat-main { min-height: 440px; }
  .bubble { max-width: 86%; }
}
