/* ============================================================
   codeboy — تم الهام‌گرفته از Claude AI
   فارسی: Vazirmatn | انگلیسی: Inter | کد: JetBrains Mono
   ============================================================ */

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

:root {
  /* تم روشن گرم (پیش‌فرض) */
  --bg:          #FAF9F5;
  --surface:     #FFFFFF;
  --surface-2:   #F0EEE6;
  --user-bubble: #F0EEE6;
  --border:      #E7E3D7;
  --text:        #1F1E1D;
  --muted:       #73716B;
  --accent:      #D97757;
  --accent-hover:#C4674A;
  --accent-soft: rgba(217,119,87,.12);
  --code-bg:     #1F1E1D;
  --code-text:   #ECEAE3;
  --danger:      #C0392B;
  --shadow:      0 1px 3px rgba(0,0,0,.06), 0 8px 24px rgba(0,0,0,.05);

  --font-fa:   'Inter', 'Vazirmatn', Tahoma, system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #262624;
    --surface:     #30302E;
    --surface-2:   #34332F;
    --user-bubble: #34332F;
    --border:      #3E3D39;
    --text:        #ECEAE3;
    --muted:       #A5A29A;
    --accent:      #E08a6a;
    --accent-hover:#EC9678;
    --accent-soft: rgba(224,138,106,.15);
    --code-bg:     #1A1A18;
    --code-text:   #ECEAE3;
    --shadow:      0 1px 3px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  }
}

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-fa);
  line-height: 1.85;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ============ چیدمان کلی ============ */
.app {
  max-width: 780px;
  margin: 0 auto;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ============ هدر ============ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: transparent;
}
.brand { display: flex; align-items: center; gap: 11px; }
.logo {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 15px;
}
.brand-text h1 { font-size: 18px; font-weight: 700; letter-spacing: -.2px; }
.subtitle { font-size: 12px; color: var(--muted); }

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

.credit-chip {
  background: var(--accent-soft);
  border: 1px solid transparent;
  color: var(--accent);
  padding: 7px 13px; border-radius: 999px;
  font-family: var(--font-fa); font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .15s;
}
.credit-chip:hover { background: rgba(217,119,87,.2); }

.reset-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 7px 14px; border-radius: 999px;
  cursor: pointer; font-family: var(--font-fa); font-size: 13px;
  transition: all .15s;
}
.reset-btn:hover { background: var(--surface-2); color: var(--text); }

/* ============ ناحیه پیام‌ها ============ */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 8px;
  display: flex;
  flex-direction: column;
  gap: 26px;
}

/* خوش‌آمد */
.welcome {
  margin: auto;
  text-align: center;
  max-width: 480px;
  padding: 20px;
}
.welcome-logo {
  width: 60px; height: 60px;
  margin: 0 auto 22px;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  border-radius: 16px;
  font-family: var(--font-mono);
  font-size: 22px;
  box-shadow: 0 6px 20px var(--accent-soft);
}
.welcome h2 {
  font-size: 27px; font-weight: 700;
  margin-bottom: 10px; letter-spacing: -.4px;
}
.welcome p { font-size: 15.5px; color: var(--muted); }

/* حباب پیام */
.msg { display: flex; gap: 13px; animation: fade .3s ease; }
.msg .avatar {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 8px;
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 12px;
  margin-top: 2px;
}
.msg.bot  .avatar { background: var(--accent); color: #fff; }
.msg.user .avatar { background: var(--surface-2); color: var(--muted); font-family: var(--font-fa); }

/* پیام کاربر: حباب کرم، سمت چپ (end در RTL) */
.msg.user { flex-direction: row-reverse; }
.msg.user .bubble {
  background: var(--user-bubble);
  border-radius: 18px;
  padding: 11px 16px;
  max-width: 80%;
}
/* پیام ربات: بدون حباب، تمام‌عرض */
.msg.bot .bubble {
  background: transparent;
  padding: 3px 0;
  flex: 1;
  min-width: 0;
}

.bubble { font-size: 15.5px; word-wrap: break-word; overflow-wrap: break-word; }
.bubble p { margin: 0 0 12px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { margin: 10px 0; padding-inline-start: 22px; }
.bubble li { margin: 5px 0; }
.bubble strong { font-weight: 700; }
.bubble a { color: var(--accent); }

/* کد */
.bubble code {
  direction: ltr; unicode-bidi: embed;
  background: var(--surface-2);
  padding: 2px 6px; border-radius: 5px;
  font-family: var(--font-mono); font-size: 13.5px;
}
.bubble pre {
  direction: ltr; text-align: left;
  background: var(--code-bg);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 14px 0;
  overflow-x: auto;
}
.bubble pre code {
  background: none; padding: 0;
  color: var(--code-text);
  font-size: 13.5px; line-height: 1.75;
}

/* تایپینگ */
.typing { display: flex; gap: 5px; align-items: center; padding: 6px 0; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  animation: bounce 1.3s infinite; opacity: .5;
}
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }

@keyframes bounce { 0%,60%,100% { transform: translateY(0); opacity:.4 } 30% { transform: translateY(-6px); opacity:1 } }
@keyframes fade { from { opacity:0; transform: translateY(8px) } to { opacity:1; transform: translateY(0) } }

/* ============ نوار ورودی ============ */
.composer { padding: 12px 20px 20px; background: transparent; }
#chat-form {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 9px 10px 9px 18px;
  box-shadow: var(--shadow);
  transition: border-color .15s;
}
#chat-form:focus-within { border-color: var(--accent); }
#input {
  flex: 1;
  background: none; border: none; outline: none; resize: none;
  color: var(--text);
  font-family: var(--font-fa);
  font-size: 15.5px; line-height: 1.7;
  max-height: 170px; padding: 7px 0;
}
#input::placeholder { color: var(--muted); }
#send-btn {
  width: 38px; height: 38px; flex-shrink: 0;
  border: none; border-radius: 50%;
  background: var(--accent); color: #fff;
  cursor: pointer; display: grid; place-items: center;
  transition: background .15s, transform .1s;
}
#send-btn:hover { background: var(--accent-hover); }
#send-btn:disabled { opacity: .4; cursor: not-allowed; }
#send-btn svg { transform: scaleX(-1); }
.hint { text-align: center; color: var(--muted); font-size: 11.5px; margin-top: 11px; }

/* ============ صفحه ورود ============ */
.login-view { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 390px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 38px 30px;
  text-align: center;
  box-shadow: var(--shadow);
}
.login-logo {
  width: 60px; height: 60px; margin: 0 auto 18px;
  display: grid; place-items: center;
  background: var(--accent); color: #fff;
  border-radius: 16px; font-family: var(--font-mono); font-size: 22px;
}
.login-card h1 { font-size: 25px; font-weight: 700; margin-bottom: 5px; letter-spacing: -.3px; }
.login-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 28px; }
.login-card label { display: block; text-align: right; font-size: 14px; color: var(--muted); margin-bottom: 9px; }
.login-card input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 19px; text-align: center; letter-spacing: 4px;
  margin-bottom: 16px; outline: none;
  transition: border-color .15s;
}
.login-card input:focus { border-color: var(--accent); }
.btn-primary {
  width: 100%;
  background: var(--accent); color: #fff;
  border: none; border-radius: 14px;
  padding: 14px; font-family: var(--font-fa); font-size: 15px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-text {
  background: none; border: none; color: var(--muted);
  font-family: var(--font-fa); font-size: 13px; cursor: pointer;
  margin-top: 14px; text-decoration: underline;
}
.btn-text:hover { color: var(--text); }
.login-error { color: var(--danger); font-size: 13px; margin-top: 15px; min-height: 18px; }

/* ============ پنجره خرید ============ */
.modal {
  position: fixed; inset: 0;
  background: rgba(31,30,29,.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; z-index: 50;
  backdrop-filter: blur(3px);
}
.modal-card {
  width: 100%; max-width: 410px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px; padding: 30px; text-align: center;
  box-shadow: var(--shadow);
}
.modal-card h3 { font-size: 21px; font-weight: 700; margin-bottom: 7px; }
.modal-sub { color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.packs { display: flex; flex-direction: column; gap: 11px; }
.pack {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 15px; padding: 15px 17px;
  cursor: pointer; font-family: var(--font-fa);
  transition: border-color .15s, transform .1s, background .15s;
}
.pack:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.pack-title { font-size: 16px; font-weight: 600; }
.pack-price { font-size: 15px; color: var(--accent); font-weight: 700; }
.pack-price small { color: var(--muted); font-weight: 400; font-size: 11.5px; }

/* ============ توست ============ */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 13px 22px; border-radius: 14px;
  font-size: 14px; z-index: 60; box-shadow: var(--shadow);
  max-width: 90%; text-align: center;
  animation: fade .3s ease;
}

/* ============ بلاک کد + دکمه کپی ============ */
.code-block { position: relative; margin: 14px 0; }
.code-block pre { margin: 0; padding-top: 36px; } /* جا برای دکمه کپی */
.copy-btn {
  position: absolute;
  top: 8px; left: 8px;            /* گوشه چپِ کد (چون کد LTR است) */
  background: rgba(255,255,255,.1);
  color: #ECEAE3;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 7px;
  padding: 4px 10px;
  font-family: var(--font-fa);
  font-size: 11.5px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background .15s;
}
.code-block:hover .copy-btn { opacity: 1; }
.copy-btn:hover { background: rgba(255,255,255,.2); }
@media (max-width: 600px) { .copy-btn { opacity: 1; } }

/* ============ چیپ‌های پیشنهادی ============ */
.chips {
  display: flex; flex-wrap: wrap; gap: 9px;
  justify-content: center;
  margin-top: 22px;
}
.chip {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 16px;
  font-family: var(--font-fa);
  font-size: 13.5px;
  cursor: pointer;
  transition: all .15s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }

/* ============ اسکرول‌بار ============ */
.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.messages::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ============ موبایل ============ */
@media (max-width: 600px) {
  body { font-size: 15.5px; }
  .msg.user .bubble { max-width: 85%; }
  .welcome h2 { font-size: 23px; }
  .brand-text h1 { font-size: 16px; }
  .subtitle { display: none; }
}
