:root {
  --bg-a: #e8ecff;
  --bg-b: #f7f7ff;
  --indigo: #4f46e5;
  --violet: #7c3aed;
  --grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --ink: #171832;
  --muted: #7c7fa0;
  --line: #e7e9f7;
  --card: #ffffff;
  --radius: 26px;
  --shadow: 0 18px 44px rgba(79, 70, 229, 0.12);
  --green: #0ea371;
  --red: #f43f5e;
  --amber: #f59e0b;
}

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

html, body { height: 100%; }

body {
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(640px 420px at 92% -8%, rgba(124, 58, 237, 0.16), transparent 62%),
    radial-gradient(560px 400px at -4% 12%, rgba(79, 70, 229, 0.14), transparent 60%),
    radial-gradient(700px 500px at 50% 115%, rgba(59, 130, 246, 0.10), transparent 65%),
    linear-gradient(160deg, var(--bg-a), var(--bg-b) 55%, #eef1ff);
  background-attachment: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 18px;
}

button, input, select, textarea {
  font-family: 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
}

/* ---------- برند و دکمه‌های قرصی ---------- */
.brand { display: flex; align-items: center; gap: 12px; }

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: #fff;
  object-fit: contain;
  padding: 5px;
  border: 1px solid rgba(79, 70, 229, 0.14);
  box-shadow: 0 10px 22px rgba(79, 70, 229, 0.28);
  flex: none;
}

.pill-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.08);
  transition: transform .15s ease, box-shadow .15s ease;
}

.pill-link:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(79, 70, 229, 0.16); }

.pill-link.solid { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 8px 18px rgba(79, 70, 229, 0.28); }

.pill-link.danger { background: #feeef1; color: var(--red); border-color: transparent; }
.pill-link.danger:hover { background: #fddde4; }

/* ---------- قاب اپلیکیشن چت ---------- */
.app-container {
  width: 100%;
  max-width: 920px;
  height: min(94vh, 940px);
  min-height: 560px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  background: #fff;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.header .topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.header h1 { font-size: 1.15rem; font-weight: 800; }
.header p { font-size: 0.76rem; color: var(--muted); margin-top: 2px; }

.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- هشدار مدت فعال‌سازی حساب (≤ ۲۰ روز مانده یا منقضی‌شده) ---------- */
.expiry-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 20px 0;
  background: #fff5e6;
  border: 1px solid #fde3bd;
  color: #92400e;
  border-radius: 14px;
  padding: 10px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.8;
}
.expiry-notice.urgent { background: #fdecef; border-color: #ffd9e0; color: #9f1239; }
.expiry-notice .expiry-notice-close {
  margin-inline-start: auto;
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  border-radius: 10px;
  padding: 3px 10px;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- ناحیه پیام‌ها ---------- */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  background:
    radial-gradient(420px 240px at 92% -6%, rgba(124, 58, 237, 0.06), transparent 60%),
    linear-gradient(#f6f7ff, #fafbff);
  scroll-behavior: smooth;
}

.message {
  margin-bottom: 14px;
  display: flex;
}

.bot-message { justify-content: flex-start; }
.user-message { justify-content: flex-end; }

.message-content {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  line-height: 1.7;
  font-size: 0.9rem;
  word-break: break-word;
  white-space: pre-wrap;
}

.bot-message .message-content {
  background: #fff;
  border: 1px solid var(--line);
  border-top-right-radius: 4px;
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.07);
}

.user-message .message-content {
  background: var(--grad);
  color: #fff;
  border-top-left-radius: 4px;
  box-shadow: 0 10px 22px rgba(79, 70, 229, 0.28);
}

.message-content p { margin-bottom: 4px; }
.message-content p:last-child { margin: 0; }

.message-content ul { margin: 6px 0; padding-right: 18px; }
.message-content li { margin-bottom: 3px; }

.message-content code {
  background: #eef0ff;
  color: var(--indigo);
  padding: 1px 8px;
  border-radius: 8px;
  font-size: 0.82em;
  font-weight: 600;
}

.user-message code {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

/* ---------- راهنمای فشرده ابتدای چت ---------- */
.hint-list {
  display: grid;
  gap: 4px;
  margin: 6px 0 4px;
}

.hint-row {
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.5;
  font-size: 0.82rem;
}

.hint-row .hint-tag {
  flex: none;
  font-weight: 700;
  min-width: 96px;
}

.hint-row code {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  /* متن نمونهٔ دستورها فارسی است؛ فونت مونواسپیس پیش‌فرض آن را به‌هم می‌ریزد */
  font-family: 'Vazirmatn', 'Vazir', 'Segoe UI', Tahoma, sans-serif;
}

.hint-note {
  color: var(--muted);
  font-size: 0.78rem !important;
  margin-top: 2px !important;
}

/* ---------- ناحیه ورودی ---------- */
.input-area {
  padding: 10px 14px 12px;
  background: #fff;
  border-top: 1px solid var(--line);
  flex: none;
}

.text-input-container {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-bottom: 8px;
}

textarea {
  flex: 1;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 16px;
  resize: none;
  font-size: 0.95rem;
  background: #f6f7ff;
  color: var(--ink);
  direction: rtl;
  outline: none;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}

textarea:focus {
  border-color: var(--indigo);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.10);
}

.btn {
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.btn-primary {
  background: var(--grad);
  color: #fff;
  padding: 13px 22px;
  border-radius: 16px;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(79, 70, 229, 0.26);
  white-space: nowrap;
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(79, 70, 229, 0.36); }

.action-buttons {
  display: flex;
  gap: 8px;
}

.btn-voice, .btn-image {
  background: #eef0ff;
  color: var(--indigo);
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 14px;
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  text-align: center;
}

.btn-voice:hover, .btn-image:hover { background: #e1e5ff; }

.btn-voice.recording {
  background: #ffe3e7;
  color: #d92d4e;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.72; }
}

.recording-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-top: 10px;
  background: #fff1f2;
  border: 1px solid #ffd9de;
  border-radius: 14px;
  font-size: 0.85rem;
  color: #d92d4e;
  font-weight: 600;
}

.recording-indicator.hidden { display: none; }

.recording-dot {
  width: 11px;
  height: 11px;
  background: var(--red);
  border-radius: 50%;
  animation: pulse 1s infinite;
  flex: none;
}

.btn-stop {
  background: var(--red);
  color: #fff;
  padding: 7px 16px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  margin-inline-start: auto;
}

.btn-stop:hover { background: #d92d4e; }

/* ---------- نوار وضعیت ---------- */
.status-bar {
  flex: none;
  padding: 6px 18px;
  background: #fbfbff;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 0.74rem;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.status-bar::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex: none;
}

/* ---------- نوار ناوبری پایین (فقط موبایل نمایش داده می‌شود) ---------- */
.bottom-nav { display: none; }

/* ---------- ریسپانسیو: فقط موبایل (≤600px) — بالای آن دسکتاپ ثابت ---------- */
@media (max-width: 600px) {
  body { padding: 0; }
  .app-container {
    width: 100%;
    max-width: none;
    height: 100vh;
    height: 100dvh;
    min-height: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
  .header { padding: 10px 12px; }
  .header .topbar { flex-wrap: nowrap; gap: 8px; }
  .header h1 { font-size: 1rem; }
  .header p { font-size: 0.68rem; }
  .brand { flex-direction: row; gap: 8px; min-width: 0; }
  .brand-logo { width: 38px; height: 38px; border-radius: 12px; padding: 4px; }
  .brand div:nth-child(2) { min-width: 0; }
  /* اکشن‌های هدر در موبایل به نوار ناوبری پایین منتقل شده‌اند */
  .top-actions { display: none; }
  .chat-messages { padding: 12px 10px; }
  .message { margin-bottom: 10px; }
  .message-content { max-width: 90%; font-size: 0.86rem; padding: 9px 12px; }
  .hint-row { font-size: 0.76rem; }
  .hint-row .hint-tag { min-width: 84px; }
  .input-area { padding: 10px; }
  .text-input-container { gap: 6px; }
  textarea { padding: 10px 12px; font-size: 0.9rem; border-radius: 14px; }
  .btn-primary { padding: 11px 16px; border-radius: 14px; font-size: 0.88rem; }
  .action-buttons { gap: 6px; }
  .action-buttons .btn { flex: 1; font-size: 0.82rem; padding: 10px 8px; }
  .status-bar { font-size: 0.68rem; padding: 5px 10px; }

  .login-container { padding: 12px; align-items: flex-start; padding-top: max(12px, env(safe-area-inset-top)); }
  .login-box { padding: 26px 20px 22px; border-radius: 20px; }
  .login-box h1 { font-size: 1.3rem; }
  .login-btn { padding: 13px; font-size: 0.95rem; }

  /* نوار ناوبری پایین: چت / داشبورد / خروج */
  .bottom-nav {
    display: flex;
    flex: none;
    background: #fff;
    border-top: 1px solid var(--line, #e7e9f7);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a,
  .bottom-nav button {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--muted, #7c7fa0);
    text-decoration: none;
    padding: 6px 4px;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
  }
  .bottom-nav .nav-icon { font-size: 1.2rem; line-height: 1; }
  .bottom-nav a.active { color: var(--indigo, #4f46e5); background: #f0efff; }
  .bottom-nav .nav-logout { color: #d92d4e; }
  .bottom-nav a:active,
  .bottom-nav button:active { background: #f4f4fb; }
}

/* جلوگیری از زوم ناخواسته iOS هنگام فوکوس ورودی‌ها */
@media (max-width: 600px) {
  input, textarea, select { font-size: 16px; }
}
