@import url('https://cdn.jsdelivr.net/npm/vazirmatn@33.0.3/Vazirmatn-font-face.css');

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-1: #0b1026;
  --bg-2: #131b3f;
  --card: rgba(255, 255, 255, 0.06);
  --card-strong: rgba(255, 255, 255, 0.1);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f2f5ff;
  --muted: #a8b3d9;
  --accent: #6d8bff;
  --accent-2: #b06bff;
  --mint: #4ce2c0;
}

html, body { height: 100%; }

body {
  font-family: Vazirmatn, "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(1100px 700px at 85% -10%, #2b1a5e 0%, transparent 60%),
              radial-gradient(900px 600px at -10% 110%, #123a5c 0%, transparent 55%),
              linear-gradient(160deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 16px;
  min-height: 100%;
}

.app {
  width: 100%;
  max-width: 760px;
  height: calc(100vh - 32px);
  max-height: 900px;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, rgba(19, 26, 58, 0.92), rgba(11, 16, 38, 0.94));
  border: 1px solid var(--line);
  border-radius: 26px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(10px);
}

/* ---------- هدر ---------- */

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, rgba(109, 139, 255, 0.18), rgba(176, 107, 255, 0.12));
}

.avatar {
  position: relative;
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 24px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 22px rgba(109, 139, 255, 0.45);
}

.avatar::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: -2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--mint);
  border: 2px solid #101736;
}

.avatar img {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 16px;
  object-fit: cover;
}

.who { flex: 1 1 auto; min-width: 0; }

.who h1 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.who p {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.clear {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: 0.2s;
  text-decoration: none;
  display: inline-block;
  white-space: nowrap;
}

.clear:hover { color: #fff; background: var(--card-strong); }

/* ---------- گفتگو ---------- */

.chat {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 20px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.chat::-webkit-scrollbar { width: 8px; }
.chat::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 99px; }

.msg {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  max-width: 86%;
  animation: pop 0.25s ease both;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.msg.bot { align-self: flex-start; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }

.pic {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
}

.msg.user .pic {
  background: linear-gradient(140deg, #2f3d6b, #3f4a7d);
}

.bubble {
  padding: 12px 15px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.9;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-right-radius: 6px;
}

.msg.user .bubble {
  background: linear-gradient(140deg, #4d63d8, #7a53d6);
  border-color: rgba(255, 255, 255, 0.18);
  border-bottom-right-radius: 18px;
  border-bottom-left-radius: 6px;
}

/* کارت جواب ریاضی */

.math-card {
  padding: 0;
  overflow: hidden;
  background: rgba(76, 226, 192, 0.08);
  border-color: rgba(76, 226, 192, 0.32);
}

.math-card .expr {
  padding: 8px 15px;
  font-size: 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
  direction: ltr;
  text-align: right;
}

.math-card .body { padding: 10px 15px 14px; }

.math-card .say { font-size: 13px; color: var(--muted); }

.math-card .result {
  font-size: 30px;
  font-weight: 800;
  color: var(--mint);
  line-height: 1.4;
  direction: ltr;
  text-align: right;
  text-shadow: 0 0 24px rgba(76, 226, 192, 0.35);
}

.typing { display: flex; gap: 5px; padding: 5px 2px; }

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- پیشنهادها و ورودی ---------- */

.chips {
  display: flex;
  gap: 8px;
  padding: 4px 18px 12px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  font-family: inherit;
  font-size: 12.5px;
  color: #dfe6ff;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
  transition: 0.18s;
}

.chip:hover {
  background: rgba(109, 139, 255, 0.22);
  border-color: rgba(109, 139, 255, 0.5);
  transform: translateY(-1px);
}

.composer {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line);
  background: rgba(8, 12, 30, 0.55);
}

.composer input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  outline: none;
  transition: 0.2s;
}

.composer input::placeholder { color: #8d97bd; }

.composer input:focus {
  border-color: rgba(109, 139, 255, 0.7);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 4px rgba(109, 139, 255, 0.15);
}

.send {
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  font-size: 20px;
  color: #fff;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 24px rgba(109, 139, 255, 0.4);
  transition: 0.18s;
}

.send:hover { transform: translateY(-2px); filter: brightness(1.08); }
.send:active { transform: scale(0.96); }

.foot {
  text-align: center;
  font-size: 11px;
  color: #7d87ad;
  padding: 0 0 10px;
}

/* ---------- نشان کاربر ویژه / لینک مدیریت ---------- */

.vip-badge {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 207, 92, 0.16);
  color: #ffcf5c;
  border: 1px solid rgba(255, 207, 92, 0.45);
  white-space: nowrap;
}

.vip-badge[hidden] { display: none; }

.foot-link {
  color: #a8b3d9;
  text-decoration: none;
  text-decoration-line: underline;
  text-decoration-style: dashed;
  text-decoration-color: rgba(168, 179, 217, 0.45);
  text-underline-offset: 3px;
}

.foot-link:hover { color: #fff; }

.admin-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: #ffcf5c;
  background: rgba(255, 207, 92, 0.14);
  border: 1px solid rgba(255, 207, 92, 0.4);
  border-radius: 999px;
  padding: 2px 8px;
  margin-bottom: 6px;
}

@media (max-width: 520px) {
  body { padding: 0; }
  .app { height: 100vh; max-height: none; border-radius: 0; border: none; }
  .top { flex-wrap: wrap; padding: 12px 14px; gap: 10px; }
  .who { flex: 1 1 auto; }
  .who h1 { font-size: 15px; }
  .msg { max-width: 92%; }
  .vip-badge { order: 2; padding: 8px 9px; }
  .vip-text { display: none; }
  .top .clear { order: 3; flex: 1 1 auto; text-align: center; }
}