/* ══ پیش‌نمایش M-Bot — هوش مصنوعی اتد ══ */
:root {
  --bg: #eef6fc;
  --bg2: #ffffff;
  --surface: #f5fbff;
  --card: #ffffff;
  --border: #cce7f5;
  --a: #0284c7;
  --a2: #0ea5e9;
  --a-dk: #0369a1;
  --a-glow: rgba(14, 165, 233, 0.12);
  --blue: #2563eb;
  --red: #ef4444;
  --amber: #f59e0b;
  --mint: #0e9d75;
  --text: #0c4a6e;
  --text2: #475569;
  --text3: #94a3b8;
  --r: 22px;
  --rs: 14px;
  --sh: 0 10px 28px rgba(14, 165, 233, 0.1);
  --font: "Vazirmatn", system-ui, sans-serif;
  --cta-h: 52px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

.ico {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: block;
}

.app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ── سایدبار ── */
.sb {
  width: 264px;
  background: var(--bg2);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 150;
}
.sb-head {
  padding: 20px 16px 16px;
  background: linear-gradient(160deg, #0369a1 0%, #0ea5e9 55%, #7dd3fc 100%);
  flex-shrink: 0;
}
.sb-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sb-logo-ico {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: #fff;
}
.sb-logo-ico .ico { width: 20px; height: 20px; stroke: #fff; }
.sb-head h2 { font-size: 0.95rem; font-weight: 900; color: #fff; }
.sb-head p { font-size: 0.62rem; color: rgba(255, 255, 255, 0.65); }
.sb-school {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--rs);
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.9);
}
.sb-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 10px 12px 4px;
}
.sb-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  text-align: center;
}
.sb-stat-n { font-size: 1rem; font-weight: 900; color: var(--a-dk); }
.sb-stat-n.red { color: var(--red); }
.sb-stat-l { font-size: 0.58rem; color: var(--text3); font-weight: 700; margin-top: 2px; }
.sb-sec {
  padding: 10px 16px 4px;
  font-size: 0.58rem;
  font-weight: 900;
  color: var(--text3);
  letter-spacing: 0.06em;
}
.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  margin: 2px 8px;
  border-radius: var(--rs);
  color: var(--text2);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}
.sb-item:hover, .sb-item:active { background: var(--surface); color: var(--text); }
.sb-ico {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  flex-shrink: 0;
  color: var(--text3);
}
.sb-ico .ico { width: 14px; height: 14px; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  z-index: 140;
}
.overlay[hidden] { display: none; }

.menu-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg2);
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.menu-btn span {
  width: 16px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

/* ── چت (همان الگوی MBot) ── */
.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
  position: relative;
}

.ch-head {
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(14px);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  z-index: 20;
}
.ch-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}
.ch-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: linear-gradient(160deg, #0369a1, #0ea5e9);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.ch-avatar .ico { width: 18px; height: 18px; stroke: #fff; }
.ch-titles { min-width: 0; }
.ch-title { font-size: 0.88rem; font-weight: 900; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--a-dk);
  margin-top: 2px;
}
.ch-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--a2);
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.ch-actions { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.ch-action-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  position: relative;
  transition: all 0.15s;
}
.ch-action-btn .ico { width: 15px; height: 15px; }
.ch-action-btn:hover, .ch-action-btn:active {
  background: var(--a-glow);
  border-color: var(--a2);
  color: var(--a-dk);
}
.ch-notif-badge {
  position: absolute;
  top: -3px;
  left: -3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--red);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 800;
  border-radius: 999px;
  line-height: 16px;
  text-align: center;
}

.more-menu {
  position: absolute;
  top: 52px;
  left: 12px;
  min-width: 190px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--sh);
  padding: 6px;
  z-index: 30;
}
.more-menu[hidden] { display: none; }
.more-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text2);
  text-decoration: none;
}
.more-menu a:hover { background: var(--surface); color: var(--a-dk); }
.more-menu a .ico { width: 14px; height: 14px; }

/* ناحیه اسکرoll — فقط این بخش حرکت می‌کند */
.chat-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
  scroll-behavior: smooth;
}
.chat-scroll::-webkit-scrollbar { width: 4px; }
.chat-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

.chat-inner {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.msg {
  max-width: 92%;
  padding: 12px 16px;
  border-radius: 20px;
  line-height: 1.75;
  font-size: 0.86rem;
  animation: msgIn 0.25s ease-out;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.msg-bot {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom-right-radius: 5px;
  box-shadow: var(--sh);
}
.msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #0284c7, #0ea5e9);
  color: #fff;
  border-bottom-left-radius: 5px;
}

.typing {
  display: flex;
  gap: 5px;
  padding: 13px 18px;
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  border-bottom-right-radius: 5px;
}
.typing span {
  width: 7px;
  height: 7px;
  background: var(--text3);
  border-radius: 50%;
  animation: bop 1.3s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bop { 0%, 60%, 100% { transform: translateY(0); opacity: 0.35; } 30% { transform: translateY(-7px); opacity: 1; } }

.req-choices { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.req-choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 30px;
  font-family: var(--font);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text2);
  transition: all 0.16s;
}
.req-choice .ico { width: 14px; height: 14px; color: var(--a-dk); }
.req-choice:hover, .req-choice:active {
  background: var(--a-dk);
  color: #fff;
  border-color: var(--a-dk);
}
.req-choice:hover .ico, .req-choice:active .ico { stroke: #fff; color: #fff; }

.info-card {
  align-self: stretch;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  width: 100%;
  overflow: hidden;
  box-shadow: var(--sh);
  animation: msgIn 0.3s ease-out;
  position: relative;
  flex-shrink: 0;
}
.info-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--a2), var(--blue), #7c3aed);
}
.ic-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.06), transparent);
}
.ic-head h3 { font-size: 0.95rem; font-weight: 900; color: var(--text); margin-bottom: 4px; }
.ic-head p { font-size: 0.72rem; color: var(--text3); line-height: 1.6; }
.ic-body { padding: 14px 16px 18px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
@media (min-width: 520px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rs);
  padding: 10px 12px;
  position: relative;
  overflow: hidden;
}
.kpi-card::after {
  content: "";
  position: absolute;
  bottom: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: var(--a2);
}
.kpi-card.red::after { background: var(--red); }
.kpi-card.amber::after { background: var(--amber); }
.kpi-card.purple::after { background: #7c3aed; }
.kpi-card.mint::after { background: var(--mint); }
.kpi-val { font-size: 1.1rem; font-weight: 900; color: var(--a-dk); line-height: 1.2; }
.kpi-card.red .kpi-val { color: var(--red); }
.kpi-card.amber .kpi-val { color: var(--amber); }
.kpi-card.purple .kpi-val { color: #7c3aed; }
.kpi-card.mint .kpi-val { color: var(--mint); }
.kpi-lbl { font-size: 0.6rem; color: var(--text3); font-weight: 700; margin-top: 3px; }
.kpi-delta { font-size: 0.58rem; font-weight: 800; margin-top: 2px; }
.kpi-delta.up { color: var(--mint); }
.kpi-delta.down { color: var(--red); }

.report-section { margin-bottom: 16px; }
.rs-title {
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rs-title .ico { width: 14px; height: 14px; color: var(--a-dk); }
.chart-wrap {
  position: relative;
  height: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rs);
  padding: 10px;
  margin-bottom: 6px;
  touch-action: pan-y;
}
.chart-wrap canvas {
  pointer-events: none !important;
  touch-action: pan-y !important;
}
.chart-wrap.tall { height: 260px; }

.report-bullets { list-style: none; padding: 0; }
.report-bullets li {
  font-size: 0.8rem;
  color: var(--text2);
  padding: 7px 10px;
  margin-bottom: 5px;
  background: var(--surface);
  border-radius: 10px;
  border-right: 3px solid var(--a2);
  line-height: 1.65;
}
.report-bullets li.warn { border-right-color: var(--amber); }
.report-bullets li.alert { border-right-color: var(--red); }
.report-bullets li.ok { border-right-color: var(--mint); }

.insight-box {
  background: linear-gradient(135deg, var(--a-glow), rgba(37, 99, 235, 0.06));
  border: 1px solid rgba(14, 165, 233, 0.2);
  border-radius: var(--rs);
  padding: 12px 14px;
  font-size: 0.82rem;
  line-height: 1.75;
  margin-bottom: 14px;
}
.insight-box strong { color: var(--a-dk); }

.chat-footer {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.98);
  border-top: 1px solid var(--border);
  z-index: 10;
}

.quick-bar {
  padding: 8px 12px;
  overflow-x: auto;
  white-space: nowrap;
  display: flex;
  gap: 7px;
  -webkit-overflow-scrolling: touch;
}
.quick-bar::-webkit-scrollbar { height: 0; }
.qbtn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 7px 13px;
  border-radius: 30px;
  font-family: var(--font);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text2);
  flex-shrink: 0;
  transition: all 0.16s;
}
.qbtn .ico { width: 13px; height: 13px; }
.qbtn:hover, .qbtn.on, .qbtn:active {
  background: var(--a-dk);
  color: #fff;
  border-color: var(--a-dk);
}
.qbtn.on .ico, .qbtn:hover .ico { stroke: #fff; }

.demo-cta-bar {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
}

.demo-cta-contact,
.demo-cta-real {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--cta-h);
  padding: 10px 12px;
  border-radius: 14px;
  font-family: var(--font);
  font-weight: 800;
  font-size: 0.78rem;
  line-height: 1.35;
  text-decoration: none;
  cursor: pointer;
  border: none;
  text-align: center;
}

.demo-cta-contact {
  background: var(--surface);
  color: var(--a-dk);
  border: 1.5px solid var(--a2);
}
.demo-cta-contact .ico { width: 15px; height: 15px; stroke: var(--a-dk); flex-shrink: 0; }
.demo-cta-contact:active { background: var(--a-glow); }

.demo-cta-real {
  background: linear-gradient(135deg, #0284c7, #0ea5e9);
  color: #fff;
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.25);
}
.demo-cta-real .ico { width: 14px; height: 14px; stroke: #fff; flex-shrink: 0; }
.demo-cta-real span { min-width: 0; }

/* ── مودال تماس ── */
.ldc-modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(12, 74, 110, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}
.ldc-modal[hidden] { display: none; }
.ldc-modal-card {
  width: 100%;
  max-width: 420px;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--bg2);
  border-radius: 20px 20px 16px 16px;
  padding: 20px 18px 18px;
  position: relative;
  box-shadow: var(--sh);
}
.ldc-modal-close {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--surface);
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text2);
}
.ldc-modal-card h2 { font-size: 1rem; font-weight: 900; margin-bottom: 6px; color: var(--text); }
.ldc-modal-sub { font-size: 0.78rem; color: var(--text3); margin-bottom: 14px; line-height: 1.6; }
.ldc-modal-card label {
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text2);
  margin: 10px 0 5px;
}
.ldc-modal-card input,
.ldc-modal-card textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-family: var(--font);
  font-size: 0.85rem;
  background: var(--surface);
  color: var(--text);
}
.ldc-modal-card input:focus,
.ldc-modal-card textarea:focus {
  outline: none;
  border-color: var(--a2);
  box-shadow: 0 0 0 3px var(--a-glow);
}
.ldc-form-msg { font-size: 0.78rem; margin: 10px 0 0; min-height: 1.2em; }
.ldc-form-msg.err { color: var(--red); }
.ldc-form-msg.ok { color: var(--mint); }
.ldc-modal-submit {
  width: 100%;
  margin-top: 14px;
  font-size: 0.88rem;
}

@media (max-width: 768px) {
  .menu-btn { display: flex; }
  .sb {
    position: fixed;
    top: 0;
    right: -100%;
    height: 100%;
    transition: right 0.3s ease;
    box-shadow: var(--sh);
  }
  .sb.open { right: 0; }
  .ch-head { padding-right: 8px; }
  .chart-wrap { height: 200px; }
}

@media (max-width: 380px) {
  .demo-cta-bar {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 769px) {
  .menu-btn, .overlay { display: none !important; }
}
