/* استایل پایه */
body {
    background: linear-gradient(120deg, #f5f5f7, #eaf1f8);
    margin: 0;
    padding: 0;
    color: #333;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* استایل کانتینر اصلی */
#deepseek-chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%; /* عرض به 100% محدود شده */
    max-width: 1200px; /* حداکثر عرض برای جلوگیری از پهن شدن بیش از حد */
    margin: 0 auto; /* مرکز کردن کادر در صفحه */
    padding: 0;
    border: none;
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    background-color: #f5f5f7;
    transition: all 0.3s ease;
    font-family: 'Arial', sans-serif;
    box-sizing: border-box; /* لحاظ کردن پدینگ و حاشیه در عرض */
}

/* تنظیمات برای تم‌ها */
#deepseek-chat-container.light {
    background: linear-gradient(120deg, #f5f5f7, #eaf1f8);
    color: #333;
}
#deepseek-chat-container.dark {
    background: linear-gradient(120deg, #2d2d2d, #1a1a1a);
    color: #fff;
}

/* استایل تاریخچه گفتگو */
#deepseek-chat-history {
    width: 220px;
    background: linear-gradient(180deg, #ffffff, #f9fbfd);
    border-right: 1px solid #e0e0e0;
    padding: 20px;
    overflow-y: auto;
}

#deepseek-chat-container.dark #deepseek-chat-history {
    background: linear-gradient(180deg, #2d2d2d, #1a1a1a);
    border-right: 1px solid #444;
}

#deepseek-chat-history ul {
    list-style: none !important;
    padding: 0;
    margin: 0;
}

#deepseek-chat-history li {
    padding: 8px 5px;
    cursor: pointer;
    list-style: none !important;
    border-radius: 12px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #333;
    transition: background 0.3s ease, color 0.3s ease, transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

#deepseek-chat-container.dark #deepseek-chat-history li {
    color: #ddd;
}

#deepseek-chat-history li:hover {
    background: #f0f8ff;
    transform: scale(1.02);
}

#deepseek-chat-container.dark #deepseek-chat-history li:hover {
    background: #444;
}

#deepseek-chat-history li.active {
    background: #0073aa;
    color: #fff;
}

#deepseek-chat-history li .deepseek-chat-title {
    font-weight: 600;
}

/* دکمه ایجاد گفتگوی جدید */
#deepseek-new-chat {
    width: 100%;
    padding: 14px;
    background: linear-gradient(90deg, #4caf50, #2e7d32);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    margin-bottom: 20px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

#deepseek-new-chat:hover {
    background: linear-gradient(90deg, #388e3c, #1b5e20);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

/* ناحیه اصلی گفتگو */
#deepseek-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
}

/* ناحیه پیام‌ها */
#deepseek-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto; /* فعال کردن اسکرول عمودی */
    background: #ffffff;
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
    max-height: calc(100vh - 150px); /* ارتفاع محدود برای اسکرول */
}

#deepseek-chat-container.dark #deepseek-chat-messages {
    background: #333;
}

/* استایل اسکرول */
#deepseek-chat-messages::-webkit-scrollbar {
    width: 8px;
}
#deepseek-chat-messages::-webkit-scrollbar-thumb {
    background-color: #888;
    border-radius: 4px;
}
#deepseek-chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: #555;
}

#deepseek-chat-container.dark #deepseek-chat-messages::-webkit-scrollbar-thumb {
    background-color: #555;
}

#deepseek-chat-container.dark #deepseek-chat-messages::-webkit-scrollbar-thumb:hover {
    background-color: #777;
}

/* استایل حباب پیام‌ها */
.message-bubble {
    padding: 10px 15px;
    border-radius: 16px;
    margin-bottom: 12px;
    font-size: 15px;
    line-height: 1.6;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-width: 90%;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-bubble.user {
    background: linear-gradient(90deg, #0073aa, #005177);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 8px;
}

#deepseek-chat-container.dark .message-bubble.user {
    background: linear-gradient(90deg, #1e90ff, #00bfff);
}

.message-bubble.bot {
    background: #f9fbfd;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 8px;
}

#deepseek-chat-container.dark .message-bubble.bot {
    background: #3c3c3c;
    color: #ddd;
}

/* استایل کد درون پیام */
.message-bubble pre {
    background: #2d2d2d;
    color: #ffffff;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: "Courier New", monospace;
    font-size: 14px;
    line-height: 1.5;
    max-width: 100%;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-bubble pre code {
    background: none;
    color: inherit;
    padding: 0;
    border: none;
}

/* استایل جدول */
.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    background: #ffffff;
    border: 1px solid #ddd;
    font-size: 14px;
}

#deepseek-chat-container.dark .message-bubble table {
    background: #444;
    color: #ddd;
}

.message-bubble table th {
    background: #f5f5f5;
    font-weight: bold;
    padding: 8px;
    border: 1px solid #ddd;
    text-align: left;
}

#deepseek-chat-container.dark .message-bubble table th {
    background: #555;
}

.message-bubble table td {
    padding: 8px;
    border: 1px solid #ddd;
}

.message-bubble table {
    overflow-x: auto;
    white-space: nowrap;
    max-width: 100%;
}

/* هایلایت کد */
.message-bubble pre .hljs {
    background: #2d2d2d !important;
    color: #ffffff !important;
}

/* تصاویر در پیام‌ها */
.message-bubble.bot img {
    max-width: 100%;
    border-radius: 8px;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.1);
    margin-top: 10px;
    display: block;
}

/* ناحیه ورودی و دکمه ارسال */
#deepseek-chat-input-container {
    position: sticky; /* ثابت کردن در پایین */
    bottom: 0;
    display: flex;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    align-items: center;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    z-index: 1000; /* اطمینان از نمایش بالای محتوا */
}

#deepseek-chat-container.dark #deepseek-chat-input-container {
    background: #2d2d2d;
    border-top: 1px solid #444;
}

#deepseek-chat-input {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: #fff;
    width: 100%;
}

#deepseek-chat-container.dark #deepseek-chat-input {
    background: #444;
    border-color: #555;
    color: #fff;
}

#deepseek-chat-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 4px rgba(0, 115, 170, 0.3);
    outline: none;
}

#deepseek-chat-container.dark #deepseek-chat-input:focus {
    border-color: #1e90ff;
    box-shadow: 0 0 4px rgba(30, 144, 255, 0.3);
}

#deepseek-chat-send {
    padding: 14px 24px;
    background: linear-gradient(90deg, #ff9800, #f57c00);
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 15px;
    transition: background 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
}

#deepseek-chat-send:hover {
    background: linear-gradient(90deg, #f57c00, #e65100);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

/* دکمه ترجمه مقاله - اضافه‌شده */
#deepseek-translate-article {
    padding: 5px 10px;
    background: linear-gradient(90deg, #4caf50, #2e7d32);
    color: #fff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 15px;
    margin-left: 10px;
}

#deepseek-translate-article:hover {
    background: linear-gradient(90deg, #388e3c, #1b5e20);
}

/* دکمه حذف */
.deepseek-delete-log {
    background-color: #ff4d4d;
    float: right;
    color: white;
    border: none;
    padding: 2px 5px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.deepseek-delete-log:hover {
    background-color: #e60000;
}

/* پیام ورود */
.deepseek-login-prompt {
    text-align: center;
    font-size: 18px;
    color: #0073aa;
    padding: 20px;
    margin: 20px auto;
    max-width: 600px;
    transition: all 0.3s ease;
    width: 80%;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

#deepseek-chat-messages {
    white-space: pre-wrap;
    word-wrap: break-word;
}

#deepseek-thinking-message {
    color: #888;
    font-style: italic;
}

#deepseek-chat-container.dark #deepseek-thinking-message {
    color: #bbb;
}

/* دکمه پخش صوتی */
.ai-tts-play {
    display: inline-block;
    padding: 5px 10px;
    background-color: #267ad1;
    color: #fff;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    text-align: center;
    line-height: 1;
}

.ai-tts-play:hover {
    background-color: #005177;
}

/* بهینه‌سازی پاسخگویی */
@media (max-width: 768px) {
    #deepseek-chat-container {
        flex-direction: column-reverse;
        height: 100vh;
        width: 100vw;
        margin: 0;
        border-radius: 0;
    }

    #deepseek-chat-history {
        width: 100%;
        border-right: none;
        border-top: 1px solid #e0e0e0;
    }

    #deepseek-chat-main {
        flex: 1;
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    #deepseek-chat-messages {
        flex: 1;
        padding: 15px;
        width: 100%;
    }

    #deepseek-chat-input-container {
        padding: 10px;
        width: 100%;
    }

    #deepseek-chat-input {
        width: 100%;
    }
}