/* chat-view.css — استایل کامل صفحه‌ی چت (پیام‌ها، ورودی، بلوک کد و...)
   استخراج شده از Views/Chat/View.cshtml */

.claude-chat-shell {
    --bg: #09090b;
    --surface: #18181b;
    --panel: #202025;
    --panel-hover: #27272a;
    --border: #27272a;
    --border-soft: rgba(255, 255, 255, 0.08);
    --text: #f4f4f5;
    --text-secondary: #d4d4d8;
    --text-muted: #a1a1aa;
    --user-bubble: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    --user-bubble-border: rgba(129, 140, 248, 0.35);
    --accent-a: #6366f1;
    --accent-b: #a855f7;
    --accent-grad: linear-gradient(135deg, #4f46e5 0%, #7c3aed 55%, #a855f7 100%);
    --accent-soft: rgba(99, 102, 241, 0.14);
    --focus-ring: rgba(99, 102, 241, 0.22);
    --send-bg: #ffffff;
    --send-bg-hover: #e4e4e7;
    --send-disabled: #27272a;
    --success: #34d399;
    --success-soft: rgba(16, 185, 129, 0.12);
    --success-border: rgba(16, 185, 129, 0.3);
    --code-bg: #0b0b0e;
    --code-header-bg: #17171b;
    --code-border: #27272a;
    --code-text: #e4e4e7;
    --radius-xl: 24px;
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 10px;
    --shadow-composer: 0 12px 32px -4px rgba(0, 0, 0, 0.45), 0 4px 12px -2px rgba(0, 0, 0, 0.3);
    --shadow-panel: 0 16px 40px rgba(0, 0, 0, 0.55);
    color: var(--text);
    background: var(--bg);
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

    .claude-chat-shell::before,
    .claude-chat-shell::after {
        content: '';
        position: fixed;
        pointer-events: none;
        z-index: 0;
        border-radius: 50%;
        filter: blur(70px);
    }

    .claude-chat-shell::before {
        top: -160px;
        right: 10%;
        width: 560px;
        height: 420px;
        background: radial-gradient(circle, rgba(99, 102, 241, 0.16) 0%, rgba(0, 0, 0, 0) 70%);
    }

    .claude-chat-shell::after {
        bottom: -120px;
        left: 6%;
        width: 460px;
        height: 380px;
        background: radial-gradient(circle, rgba(168, 85, 247, 0.12) 0%, rgba(0, 0, 0, 0) 70%);
    }

    .claude-chat-shell > * {
        position: relative;
        z-index: 1;
    }

    .claude-chat-shell * {
        box-sizing: border-box;
    }

    .claude-chat-shell .text-base-boosted {
        font-size: 1.02rem;
        line-height: 1.9;
    }

    .claude-chat-shell textarea {
        font-size: 0.95rem !important;
        font-family: inherit;
    }

.typing-cursor {
    display: inline-block;
    animation: blink-cursor 1s step-start infinite;
    opacity: .55;
    color: var(--accent-a);
}

@keyframes blink-cursor {
    50% {
        opacity: 0;
    }
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes dot-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: .35;
    }

    30% {
        transform: translateY(-4px);
        opacity: 1;
    }
}

/* ---- انیمیشن نمایش نرم متن استریم‌شده ---- */
@keyframes stream-fade-in {
    from {
        opacity: 0;
        transform: translateY(3px);
        filter: blur(3px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
    }
}

.stream-fade-in {
    animation: stream-fade-in .35s ease-out both;
}

/* ---- کانتینر پیام‌ها ---- */
.chat-shell-body {
    height: 100%;
    min-height: 0;
}

.chat-scroll-area {
    min-height: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

    .chat-scroll-area::-webkit-scrollbar {
        width: 6px;
    }

    .chat-scroll-area::-webkit-scrollbar-thumb {
        background-color: var(--border);
        border-radius: 999px;
    }

/* ---- نشانگر «در حال تایپ» ---- */
#processingMessage.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 2px 14px;
}

#processingMessage.hidden {
    display: none !important;
}

.typing-label {
    font-size: .82rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.typing-avatar {
    width: 35px;
    height: 35px;
    flex-shrink: 0;
    background-image: url('../Icons/logo-chat.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    animation: spin-logo 1s linear infinite;
}

/* ---- چرخشِ لوگو حین ارسال/استریم؛ وقتی نگارش تموم شد کلاس is-streaming برداشته می‌شه و ثابت می‌مونه ---- */
@keyframes spin-logo {
    to {
        transform: rotate(360deg);
    }
}

.typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 9px 14px;
    background: var(--panel);
    border-radius: 999px;
}

    .typing-dots i {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: var(--text-muted);
        font-style: normal;
        animation: dot-bounce 1.1s ease-in-out infinite;
    }

        .typing-dots i:nth-child(2) {
            animation-delay: .15s;
        }

        .typing-dots i:nth-child(3) {
            animation-delay: .3s;
        }

/* ---- حباب پیام‌های کاربر / پاسخ مدل ---- */
.msg-row {
    display: flex;
    width: 100%;
    animation: fade-in-up .25s ease-out;
}

    .msg-row.msg-user {
        justify-content: flex-end;
    }

    .msg-row.msg-assistant {
        justify-content: flex-start;
        align-items: flex-start;
        gap: 12px;
    }

        .msg-row.msg-assistant::before {
            content: '';
            width: 35px;
            height: 35px;
            flex-shrink: 0;
            margin-top: 2px;
            background-image: url('../Icons/logo-chat.png');
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
        }

        /* ---- تا وقتی پاسخ در حال نگارش/استریم شدنه لوگو می‌چرخه؛ به‌محض اتمام (حذف کلاس is-streaming) ثابت می‌شه ---- */
        .msg-row.msg-assistant.is-streaming::before {
            animation: spin-logo 1s linear infinite;
        }

.msg-bubble-user {
    max-width: 80%;
    word-break: break-word;
    overflow-wrap: break-word;
    background: var(--user-bubble);
    border: 1px solid var(--user-bubble-border);
    color: var(--text);
    border-radius: var(--radius-lg);
    padding: 11px 17px;
}

/* ---- برچسبِ «فایل ضمیمه شده» بالای پیام کاربر ---- */
.msg-attachment-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 10px;
    padding: 4px 10px;
    font-size: .8rem;
    color: var(--text);
    margin-bottom: 8px;
}

/* ---- جمع‌شدن/بازشدن پیام‌های طولانی کاربر ---- */
.user-msg-content {
    position: relative;
    overflow: hidden;
    max-height: 4.9em;
    transition: max-height .25s ease;
}

    .user-msg-content.is-expanded {
        max-height: 4000px;
    }

    .user-msg-content.has-overflow:not(.is-expanded)::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: 1.6em;
        background: linear-gradient(to bottom, rgba(242,242,244,0) 0%, var(--user-bubble) 80%);
        pointer-events: none;
    }

.msg-expand-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 2px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 3px 0 0;
}

    .msg-expand-toggle.show {
        display: flex;
    }

    .msg-expand-toggle svg {
        transition: transform .2s;
    }

    .msg-expand-toggle[aria-expanded="true"] svg {
        transform: rotate(180deg);
    }

.msg-bubble-assistant {
    flex: 1;
    min-width: 0;
    width: 100%;
    color: var(--text);
    padding: 2px 2px;
}

    .msg-bubble-assistant > *:first-child {
        margin-top: 0 !important;
    }

    /* ---- پیامِ «سقف مصرف پر شده»: شبیه پیام‌های استریم، فقط قرمز و بدون ذخیره در دیتابیس ---- */
    .msg-bubble-assistant.msg-bubble-limit-error {
        color: #f87171;
        white-space: pre-wrap;
    }

/* ---- بنر مستقل هشدارِ ۸۰٪ مصرف: نه بخشی از حباب پیام، نه alert مرورگر ---- */
.msg-row.msg-system-notice {
    justify-content: center;
}

.usage-notice-block {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 90%;
    background: rgba(251, 191, 36, 0.10);
    border: 1px solid rgba(251, 191, 36, 0.35);
    color: #fbbf24;
    font-size: .8rem;
    line-height: 1.6;
    padding: 8px 16px;
    border-radius: 999px;
    text-align: center;
}

    .usage-notice-block svg {
        flex-shrink: 0;
    }

.msg-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 10px;
    opacity: .55;
    transition: opacity .15s;
}

.msg-row.msg-assistant:hover .msg-actions {
    opacity: 1;
}

.msg-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: inherit;
    font-size: .8rem;
    padding: 5px 9px;
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s, color .15s;
}

    .msg-action-btn:hover {
        background: var(--panel);
        color: var(--text);
    }

    .msg-action-btn.copied {
        color: var(--success);
    }

/* ---- بلوک کد به سبک ChatGPT / Gemini ---- */
.code-block {
    margin: 14px 0;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--code-border);
    background: var(--code-bg);
}

.code-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    background: #17171B;
    border-bottom: 1px solid var(--code-border);
    font-size: .8rem;
    color: #B6B6C2;
    direction: ltr;
    text-align: left;
}

.code-lang {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    text-transform: lowercase;
    letter-spacing: .02em;
}

.code-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: transparent;
    border: none;
    color: #B6B6C2;
    font-size: .8rem;
    font-family: inherit;
    cursor: pointer;
    padding: 3px 7px;
    border-radius: 6px;
    transition: background .15s, color .15s;
}

    .code-copy-btn:hover {
        background: rgba(255,255,255,.08);
        color: #fff;
    }

    .code-copy-btn.copied {
        color: #6EE7B7;
    }

/* همیشه چپ‌چین/LTR (صرف‌نظر از جهتِ کلیِ صفحه که راست‌چین است) */
.code-block pre {
    margin: 0;
    padding: 14px;
    overflow: auto;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    direction: ltr;
    text-align: left;
}

    .code-block pre code {
        font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
        font-size: .82rem;
        line-height: 1.7;
        color: var(--code-text);
        background: transparent !important;
        direction: ltr;
        text-align: left;
        unicode-bidi: plaintext;
    }

        /* رنگ‌آمیزی سینتکس با highlight.js: پس‌زمینه‌ی تم رو بی‌اثر می‌کنیم تا با پس‌زمینه‌ی خودمون هماهنگ بمونه،
           و فقط رنگ توکن‌ها (کلیدواژه، رشته، عدد و...) از تمِ ایمپورت‌شده اعمال بشه */
        .code-block pre code.hljs {
            background: transparent !important;
            padding: 0 !important;
        }

.claude-chat-shell code {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    background: var(--panel);
    color: var(--text);
    border-radius: 6px;
    padding: 1px 6px;
    font-size: .85em;
}

/* ---- فرمت‌دهی جدول / نقل‌قول ---- */
.claude-chat-shell table {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.claude-chat-shell th {
    background: var(--panel) !important;
    color: var(--text) !important;
    font-weight: 600 !important;
    border-color: var(--border) !important;
}

.claude-chat-shell td {
    border-color: var(--border-soft) !important;
}

.claude-chat-shell blockquote {
    border-inline-start: 3px solid var(--accent-a) !important;
    background: var(--panel);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 10px 14px !important;
    color: var(--text-secondary);
}

/* ---- حالت‌های فعال دکمه‌های جستجو و تفکر عمیق ---- */
.toggle-active-search {
    background-color: rgba(16, 185, 129, 0.12) !important;
    border-color: rgba(16, 185, 129, 0.4) !important;
    color: #34d399 !important;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.25);
}

.toggle-active-think {
    background-color: rgba(168, 85, 247, 0.12) !important;
    border-color: rgba(168, 85, 247, 0.4) !important;
    color: #c084fc !important;
    box-shadow: 0 0 16px rgba(168, 85, 247, 0.25);
}

/* ---- حالت فعالِ آیکون «ساخت اسلاید» — نئون طلایی ---- */
.toggle-active-slide {
    background-color: rgba(251, 191, 36, 0.12) !important;
    border-color: rgba(251, 191, 36, 0.45) !important;
    color: #fbbf24 !important;
    box-shadow: 0 0 16px rgba(251, 191, 36, 0.3);
}

/* ---- کارت‌های وضعیتِ ساختِ فایل ارائه (پردازش/آماده/خطا) ----
   قبلاً تو presentation-view.css بودن، حالا چون این جریان وارد چت عادی شده،
   به chat-view.css منتقل شدن ---- */
.presentation-processing-card,
.presentation-result-card,
.presentation-error-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: .85rem;
    line-height: 1.7;
    max-width: 100%;
    flex-wrap: wrap;
}

.presentation-processing-card {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.presentation-spinner {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 2px solid var(--border-soft);
    border-top-color: var(--accent-a);
    animation: spin-presentation .8s linear infinite;
}

@keyframes spin-presentation {
    to {
        transform: rotate(360deg);
    }
}

.presentation-result-card {
    background: var(--success-soft);
    border: 1px solid var(--success-border);
    color: var(--success);
}

.presentation-result-text {
    flex: 1;
    min-width: 120px;
}

.presentation-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(16, 185, 129, 0.18);
    border: 1px solid var(--success-border);
    color: var(--success);
    border-radius: 999px;
    padding: 6px 14px;
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s;
    white-space: nowrap;
}

    .presentation-download-btn:hover {
        background: rgba(16, 185, 129, 0.3);
    }

.presentation-error-card {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: #f87171;
}

/* ---- Glassmorphism Card ---- */
.glass-card {
    background: rgba(24, 24, 27, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.input-wrapper-transition {
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    width: 100%;
    max-width: 48rem;
}

/* ---- حالت خالی (چت جدید) ---- */
.empty-state-wrap {
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 1;
    padding: 0 20px;
}

.empty-state-card {
    pointer-events: none;
    max-width: 280px;
    width: 100%;
    background: rgba(24, 24, 27, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-composer);
    padding: 26px 22px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.empty-state-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--accent-grad);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 0 3px rgba(255,255,255,.35), 0 4px 14px rgba(76,110,245,.28);
}

.empty-state-text {
    font-size: .86rem;
    line-height: 1.9;
    color: var(--text-secondary);
    margin: 0;
}

/* ---- ریسپانسیو ---- */
@media (max-width: 480px) {
    .msg-bubble-user {
        max-width: 90%;
    }

    .claude-chat-shell .text-base-boosted {
        font-size: .97rem;
    }

    .msg-row.msg-assistant::before {
        width: 35px;
        height: 35px;
    }
}

.textbox-gr {
    position: absolute;
    align-items: center;
    justify-content: center;
    z-index: 1;
}

/* اصلاح Border اصلی و پس‌زمینه کادر ورودی */
#input-box-card {
    background-color: rgba(24, 24, 27, 0.75) !important; /* پس‌زمینه تیره شفاف */
    border: 1px solid rgba(63, 63, 70, 0.5) !important; /* border ملایم */
    backdrop-filter: blur(12px);
}

    /* اصلاح حالت فوکوس روی کادر */
    #input-box-card:focus-within {
        border-color: rgba(99, 102, 241, 0.6) !important;
        box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2) !important;
    }

    /* اصلاح خط پررنگ وسط کادر (جداکننده دکمه‌ها و textarea) */
    #input-box-card .border-t {
        border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    }

/* اصلاح استایل نشانگر فایل/متن پیست شده */
#file-preview-bar > div {
    background-color: rgba(39, 39, 42, 0.8) !important;
    border: 1px solid rgba(63, 63, 70, 0.8) !important;
}

#pasted-text-preview-bar > div {
    background-color: rgba(30, 27, 75, 0.6) !important;
    border: 1px solid rgba(99, 102, 241, 0.4) !important;
}

/* به انتهای chat-view.css اضافه کن */
.chat-error-box {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    direction: rtl;
    text-align: right;
    max-width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(245, 166, 35, .12);
    border: 1px solid rgba(245, 166, 35, .45);
    color: inherit;
    font-size: .95rem;
    line-height: 1.9;
}

    .chat-error-box svg {
        flex: none;
        margin-top: 5px;
        color: #e09b1a;
    }