/* بخش هوش مصنوعی (روی بخش عمومی سایت؛ همان پالت و شکل‌های site.css) */
.site .nav-ai { display: inline-flex; align-items: center; gap: .35rem; }
.site .nav-ai-ic { color: var(--hi); width: 1.05em; height: 1.05em; }
.site .nav-ai[aria-current="page"] .nav-ai-ic { color: var(--brand); }

/* صفحه‌ی معرفی (کاربر مهمان) */
.ai-hero { position: relative; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(260px, .8fr); gap: 2rem; align-items: center; padding: clamp(1.5rem, 5vw, 3.2rem); border-radius: 28px; color: #fff; overflow: hidden;
  background: radial-gradient(640px 320px at 0% 0%, rgba(161, 140, 255, .45), transparent 62%), radial-gradient(520px 300px at 100% 100%, rgba(79, 195, 255, .34), transparent 60%), linear-gradient(135deg, #0A1836, #17306A 55%, #2A3FA0); }
.ai-hero h1 { font-size: clamp(1.8rem, 4.6vw, 3rem); line-height: 1.55; font-weight: 800; }
.ai-hero h1 span { background: linear-gradient(100deg, #FFE08A, #FFB86B); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ai-hero-copy > p:not(.ab-eyebrow) { margin-top: 1rem; max-width: 58ch; color: rgba(255, 255, 255, .86); line-height: 2.05; }
.ai-hero-points { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }
.ai-hero-points li { display: grid; grid-template-columns: auto 1fr; gap: 0 .8rem; align-items: center; padding: .8rem 1rem; border-radius: 16px; background: rgba(255, 255, 255, .11); border: 1px solid rgba(255, 255, 255, .22); backdrop-filter: blur(6px); }
.ai-hero-points span { grid-row: span 2; font-size: 1.6rem; }
.ai-hero-points small { color: rgba(255, 255, 255, .75); }

/* اپ گفتگو */
.ai-app { display: grid; grid-template-columns: 290px minmax(0, 1fr); height: clamp(560px, calc(100vh - 190px), 900px); background: var(--card); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow-md); overflow: hidden; position: relative; }
.ai-side { display: flex; flex-direction: column; gap: .8rem; min-height: 0; padding: 1rem; background: var(--card-2); border-inline-end: 1px solid var(--line); }
.ai-new { justify-content: center; }
.ai-convs { flex: 1; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: .25rem; }
.ai-conv { display: grid; gap: .1rem; padding: .6rem .8rem; border-radius: 12px; border: 1px solid transparent; transition: background .15s, border-color .15s; }
.ai-conv span { font-weight: 700; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-conv small { color: var(--ink-soft); font-size: .74rem; }
.ai-conv:hover { background: var(--card); }
.ai-conv.is-active { background: var(--card); border-color: color-mix(in srgb, var(--brand) 40%, var(--line)); box-shadow: var(--shadow-sm); }
.ai-empty-side { padding: .5rem; font-size: .85rem; }
.ai-note { color: var(--ink-soft); font-size: .74rem; line-height: 1.9; padding: .6rem; border-radius: 12px; background: color-mix(in srgb, var(--hi) 14%, var(--card)); }
.ai-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.ai-top { display: flex; align-items: center; gap: .8rem; padding: .7rem 1rem; border-bottom: 1px solid var(--line); background: var(--card); }
.ai-title { flex: 1; min-width: 0; display: grid; }
.ai-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-side-toggle { display: none; }
.ai-model select { max-width: 280px; min-height: 40px; padding: .4rem .8rem; border-radius: 12px; border: 1px solid var(--edge); background: var(--card); color: var(--ink); font: inherit; font-size: .86rem; }
.ai-log { flex: 1; min-height: 0; overflow-y: auto; padding: 1.2rem clamp(.8rem, 3vw, 2rem); display: flex; flex-direction: column; gap: 1.1rem; scroll-behavior: smooth; }
.ai-welcome { margin: auto; text-align: center; max-width: 560px; display: grid; gap: .8rem; justify-items: center; }
.ai-welcome[hidden] { display: none; }
.ai-welcome-ic { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 20px; color: #fff; background: linear-gradient(135deg, #7C5CFF, #4FC3FF); box-shadow: 0 10px 28px rgba(95, 100, 255, .35); }
.ai-welcome-ic .ic { width: 32px; height: 32px; fill: currentColor; stroke: none; }
.ai-welcome h2 { font-size: clamp(1.2rem, 3vw, 1.6rem); line-height: 1.7; }
.ai-warn { padding: .7rem 1rem; border-radius: 12px; background: var(--warn-bg, #FFF0C7); color: var(--warn, #8A5A00); line-height: 1.9; }
.ai-suggest { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; width: 100%; }
.ai-suggest button { padding: .8rem 1rem; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-size: .88rem; text-align: start; cursor: pointer; transition: border-color .15s, transform .15s, background .15s; }
.ai-suggest button:hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 7%, var(--card)); transform: translateY(-2px); }

.ai-msg { display: flex; gap: .75rem; max-width: 880px; width: 100%; margin-inline: auto; }
.ai-user { justify-content: flex-start; }
.ai-bubble { max-width: min(85%, 640px); padding: .7rem 1rem; border-radius: 18px 18px 18px 6px; background: var(--brand); color: var(--on-brand, #fff); line-height: 2; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: var(--shadow-sm); }
.ai-avatar { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; color: #fff; font-size: 1.05rem; background: linear-gradient(135deg, #7C5CFF, #4FC3FF); }
.ai-body { flex: 1; min-width: 0; display: grid; gap: .5rem; align-content: start; }
.ai-text { line-height: 2.05; overflow-wrap: anywhere; }
.ai-text p { margin: 0 0 .7rem; } .ai-text p:last-child { margin-bottom: 0; }
.ai-text h3, .ai-text h4, .ai-text h5, .ai-text h6 { margin: 1rem 0 .4rem; line-height: 1.7; }
.ai-text ul, .ai-text ol { margin: .3rem 0 .8rem; padding-inline-start: 1.5rem; } .ai-text li { margin-bottom: .2rem; }
.ai-text blockquote { margin: .5rem 0; padding: .3rem .9rem; border-inline-start: 3px solid var(--hi); background: var(--card-2); border-radius: 8px; }
.ai-text code { padding: .1rem .35rem; border-radius: 6px; background: var(--card-2); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .86em; direction: ltr; unicode-bidi: embed; }
.ai-text a { color: var(--brand); text-decoration: underline; }
.ai-text.is-streaming::after { content: "▍"; color: var(--brand); animation: ai-blink 1s steps(1) infinite; margin-inline-start: 2px; }
@keyframes ai-blink { 50% { opacity: 0; } }
.ai-code { margin: .6rem 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #0E1730; direction: ltr; }
.ai-code-bar { display: flex; justify-content: space-between; align-items: center; padding: .35rem .8rem; background: #17234A; color: #AFC0EA; font-size: .76rem; font-family: ui-monospace, Menlo, Consolas, monospace; }
.ai-code-bar button { background: transparent; border: 1px solid rgba(255, 255, 255, .25); color: #DDE6FF; border-radius: 8px; padding: .15rem .6rem; font: inherit; cursor: pointer; }
.ai-code-bar button:hover { background: rgba(255, 255, 255, .12); }
.ai-code pre { margin: 0; padding: .9rem 1rem; overflow-x: auto; color: #E6EDFF; font-size: .85rem; line-height: 1.75; }
.ai-code code { background: transparent; padding: 0; font-size: inherit; color: inherit; }

.ai-think-box { border: 1px dashed color-mix(in srgb, var(--brand) 45%, var(--line)); border-radius: 14px; background: color-mix(in srgb, var(--brand) 5%, var(--card)); overflow: hidden; }
.ai-think-head { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem .8rem; background: transparent; border: 0; color: var(--ink-soft); font: inherit; font-size: .86rem; cursor: pointer; text-align: start; }
.ai-think-head i { margin-inline-start: auto; font-style: normal; color: var(--brand); font-size: .78rem; }
.ai-think-text { max-height: 220px; overflow-y: auto; padding: .4rem .9rem .8rem; color: var(--ink-soft); font-size: .86rem; line-height: 2; white-space: pre-wrap; border-top: 1px dashed var(--line); }
.ai-spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); animation: ai-rot .8s linear infinite; }
.ai-spin[hidden] { display: none; }
@keyframes ai-rot { to { transform: rotate(360deg); } }
.ai-status { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; padding: .55rem .9rem; border-radius: 14px; background: var(--card-2); color: var(--ink-soft); font-size: .88rem; }
.ai-status.is-queued { background: color-mix(in srgb, var(--hi) 16%, var(--card)); color: var(--ink); }
.ai-status.is-failed { background: var(--bad-bg, #FFE3E6); color: var(--bad, #C62F3C); }
.ai-link { background: transparent; border: 0; color: var(--brand); font: inherit; font-size: .84rem; font-weight: 700; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.ai-status .ai-link { margin-inline-start: auto; }
.ai-dots { display: inline-flex; gap: 4px; } .ai-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: ai-bounce 1.1s infinite ease-in-out; }
.ai-dots i:nth-child(2) { animation-delay: .15s; } .ai-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes ai-bounce { 0%, 80%, 100% { transform: scale(.55); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }
.ai-foot { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; font-size: .78rem; color: var(--ink-soft); }
.ai-model-tag, .ai-note-tag { padding: .1rem .6rem; border-radius: 999px; background: var(--card-2); }
.ai-note-tag { background: color-mix(in srgb, var(--hi) 22%, var(--card)); color: var(--ink); }
.ai-error { margin: 0 1rem .5rem; padding: .6rem .9rem; border-radius: 12px; background: var(--bad-bg, #FFE3E6); color: var(--bad, #C62F3C); font-size: .9rem; }
.ai-error[hidden] { display: none; }

.ai-composer { padding: .6rem clamp(.6rem, 3vw, 1.5rem) 1rem; }
.ai-box { max-width: 880px; margin-inline: auto; border: 1px solid var(--edge); border-radius: 20px; background: var(--card); box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s; }
.ai-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.ai-box textarea { display: block; width: 100%; min-height: 54px; max-height: 200px; resize: none; padding: .9rem 1.1rem .4rem; border: 0; outline: 0; background: transparent; color: var(--ink); font: inherit; line-height: 1.9; }
.ai-tools { display: flex; align-items: center; gap: .7rem; padding: .3rem .6rem .6rem; }
.ai-tools .ai-count { margin-inline-start: auto; font-size: .76rem; }
.ai-think { display: inline-flex; align-items: center; gap: .5rem; padding: .3rem .7rem; border-radius: 999px; border: 1px solid var(--line); cursor: pointer; font-size: .84rem; user-select: none; }
.ai-think[hidden] { display: none; }
.ai-think input { position: absolute; opacity: 0; pointer-events: none; }
.ai-switch { position: relative; width: 30px; height: 18px; border-radius: 18px; background: var(--edge); transition: background .15s; }
.ai-switch::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: inset-inline-start .15s; }
.ai-think input:checked + .ai-switch { background: var(--brand); }
.ai-think input:checked + .ai-switch::after { inset-inline-start: 14px; }
.ai-think:has(input:checked) { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 8%, var(--card)); }
.ai-think input:focus-visible + .ai-switch { outline: 2px solid var(--brand); outline-offset: 2px; }
.ai-attach { display: inline-flex; align-items: center; gap: .3rem; padding: .3rem .7rem; border-radius: 999px; border: 1px dashed var(--edge); background: transparent; color: var(--ink-soft); font: inherit; font-size: .84rem; cursor: not-allowed; opacity: .75; }
.ai-attach small { font-size: .68rem; background: var(--card-2); border-radius: 999px; padding: 0 .4rem; }
.ai-send { min-width: 104px; }

@media (max-width: 860px) {
  .ai-hero { grid-template-columns: 1fr; }
  .ai-app { grid-template-columns: 1fr; height: calc(100vh - 150px); height: calc(100dvh - 150px); min-height: 520px; border-radius: 18px; }
  .ai-side { position: absolute; inset-block: 0; inset-inline-start: 0; z-index: 6; width: min(320px, 86%); transform: translateX(100%); transition: transform .22s ease; box-shadow: var(--shadow-md); }
  [dir="rtl"] .ai-side, html[dir="rtl"] .ai-side { transform: translateX(100%); }
  .ai-app.side-open .ai-side { transform: translateX(0); }
  .ai-side-toggle { display: inline-grid; }
  .ai-model select { max-width: 150px; }
  .ai-suggest { grid-template-columns: 1fr; }
  .ai-bubble { max-width: 92%; }
  .ai-send span { display: none; } .ai-send { min-width: 48px; }
  .ai-attach small { display: none; }
}
@media (prefers-reduced-motion: reduce) { .ai-dots i, .ai-spin, .ai-text.is-streaming::after { animation: none; } .ai-log { scroll-behavior: auto; } }
@media (max-width: 860px) {
  .ai-top { flex-wrap: wrap; }
  .ai-model { order: 5; flex: 1 1 100%; }
  .ai-model select { width: 100%; max-width: none; }
}
