/* استایل‌های بهبود یافته برای بخش چت Gemini */
/* استایل برای دسکتاپ - صفحه چت با سایدبار */
@media screen and (min-width: 1025px) {
    .container {
        width: calc(100% - 300px) !important;
        margin-right: 300px !important;
    }
    
    #right-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        width: 300px;
        height: 100vh;
        background: #1e1e1e;
        border-left: 1px solid #404040;
        padding: 20px;
        overflow-y: auto;
        z-index: 100;
    }
    
    /* پوشاندن سایدبار روی هدر و فوتر */
    #right-sidebar {
        top: var(--wp-admin--admin-bar--height, 0px);
        height: calc(100vh - var(--wp-admin--admin-bar--height, 0px));
    }
    
    #top-bar-wrap ~ #right-sidebar {
        top: calc(var(--wp-admin--admin-bar--height, 0px) + 40px);
        height: calc(100vh - var(--wp-admin--admin-bar--height, 0px) - 40px);
    }
}

/* استایل برای تبلت (768px تا 1024px) */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    .container {
        width: calc(100% - 250px) !important;
        margin-right: 250px !important;
    }
    
    #right-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        width: 250px;
        height: 100vh;
        background: #1e1e1e;
        border-left: 1px solid #404040;
        padding: 15px;
        overflow-y: auto;
        z-index: 100;
    }
}

/* استایل برای موبایل (زیر 768px) */
@media screen and (max-width: 767px) {
    .container {
        width: 100% !important;
        margin-right: 0 !important;
    }
    
    /* سایدبار به صورت منوی کشویی در موبایل */
    #right-sidebar {
        position: fixed;
        top: 0;
        right: -100%;
        width: 85%;
        height: 100vh;
        background: #1e1e1e;
        padding: 20px;
        overflow-y: auto;
        z-index: 1000;
        transition: right 0.3s ease;
        box-shadow: -5px 0 15px rgba(0,0,0,0.3);
    }
    
    #right-sidebar.active {
        right: 0;
    }
    
    /* دکمه باز کردن سایدبار در موبایل */
    .sidebar-toggle {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        background: #81d742;
        color: white;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 999;
        box-shadow: 0 4px 12px rgba(129, 215, 66, 0.3);
    }
    
    /* پس‌زمینه محو برای موبایل */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.7);
        z-index: 999;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
}

/* استایل محتوای سایدبار */
#right-sidebar {
    direction: rtl;
    scrollbar-width: thin;
    scrollbar-color: #81d742 #2d2d2d;
}

#right-sidebar::-webkit-scrollbar {
    width: 6px;
}

#right-sidebar::-webkit-scrollbar-track {
    background: #2d2d2d;
}

#right-sidebar::-webkit-scrollbar-thumb {
    background-color: #81d742;
    border-radius: 3px;
}

.conversation-history {
    margin-top: 20px;
}

.conversation-item {
    background: #2d2d2d;
    border: 1px solid #404040;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.conversation-item:hover {
    background: #3c3c3c;
    border-color: #81d742;
}

.conversation-item.active {
    background: rgba(129, 215, 66, 0.1);
    border-color: #81d742;
}

.conversation-title {
    font-weight: 600;
    color: #f0f0f0;
    margin-bottom: 5px;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-date {
    font-size: 11px;
    color: #888;
}

.conversation-preview {
    font-size: 12px;
    color: #aaa;
    margin-top: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.4;
}

/* هدر سایدبار */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #404040;
}

.sidebar-header h3 {
    color: #81d742;
    font-size: 16px;
    margin: 0;
}

.close-sidebar {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 20px;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.close-sidebar:hover {
    color: #f0f0f0;
    background: #404040;
}

/* دکمه‌های مدیریت تاریخچه */
.history-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.btn-history {
    flex: 1;
    padding: 8px;
    background: #404040;
    border: 1px solid #505050;
    color: #f0f0f0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.btn-history:hover {
    background: #505050;
    border-color: #81d742;
}

.btn-history.delete {
    background: rgba(244, 67, 54, 0.1);
    border-color: #f44336;
    color: #ff8a80;
}

.btn-history.delete:hover {
    background: rgba(244, 67, 54, 0.2);
}

.page-header {
    display: none;
}

.site-footer {
    display: none;
}

#site-header {
    display: none;
}

/* استایل کانتینر اصلی چت */
#chat-container {
    background-color: #1e1e1e;
    border: 1px solid #81d742;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    min-height: 400px;
    max-height: 600px;
    overflow-y: auto;
    direction: rtl;
    scrollbar-width: thin;
    scrollbar-color: #81d742 #2d2d2d;
}

#chat-container::-webkit-scrollbar {
    width: 8px;
}

#chat-container::-webkit-scrollbar-track {
    background: #2d2d2d;
    border-radius: 4px;
}

#chat-container::-webkit-scrollbar-thumb {
    background-color: #81d742;
    border-radius: 4px;
}

/* استایل پیام‌های کاربر */
.message-user {
    background: linear-gradient(135deg, #1e73be 0%, #0d5ba3 100%);
    color: #2c0202;
    border-radius: 18px 18px 4px 18px;
    padding: 14px 18px;
    margin: 10px 0 10px auto;
    max-width: 85%;
    border: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
}

.message-user::before {
    content: 'شما';
    position: absolute;
    top: -20px;
    left: 15px;
    font-size: 11px;
    color: #888;
    font-weight: 500;
}

/* استایل پیام‌های دستیار */
.message-assistant {
    background: linear-gradient(135deg, #2d2d2d 0%, #3c3c3c 100%);
    color: #f0f0f0;
    border-radius: 18px 18px 18px 4px;
    padding: 14px 18px;
    margin-top: 24px;
    width: 100%;
    border: 1px solid #404040;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
    position: relative;
}

.message-assistant::before {
    content: 'هوش مصنوعی';
    position: absolute;
    top: -20px;
    right: 15px;
    font-size: 11px;
    color: #81d742;
    font-weight: 500;
}

/* هدر پیام‌ها */
.message-header {
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 0.9em;
    color: #81d742;
    border-bottom: 1px solid rgba(129, 215, 66, 0.3);
    padding-bottom: 4px;
}

/* محتوای پیام */
.message-content {
    line-height: 1.8;
    word-wrap: break-word;
    font-size: 14px;
}

.message-content p {
    margin-bottom: 10px;
}

.message-content ul, .message-content ol {
    margin-right: 20px;
    margin-bottom: 10px;
}

.message-content li {
    margin-bottom: 5px;
}

/* بلوک کد */
.code-block {
    background: #1a1a1a;
    color: #f8f8f2;
    border-radius: 8px;
    padding: 0;
    margin: 15px 0;
    overflow: hidden;
    border: 1px solid #404040;
    direction: ltr;
    text-align: left;
}

.code-block pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Fira Code', 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.code-block code:not([class*=language-]) {
    background: transparent;
    padding: 0;
    border: none;
    color: #f8f8f2;
}

/* بلوک تفکر */
.thinking-block {
    background: rgba(129, 215, 66, 0.1);
    border-right: 4px solid #81d742;
    padding: 12px 16px;
    margin: 15px 0;
    font-style: italic;
    color: #a0d468;
    border-radius: 8px;
    animation: pulse 2s infinite;
}

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

/* دکمه‌ها */
#ask-gemini, #clear-chat {
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    margin: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#ask-gemini {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    box-shadow: 0 4px 6px rgba(76, 175, 80, 0.2);
}

#ask-gemini:hover {
    background: linear-gradient(135deg, #45a049 0%, #3d8b40 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(76, 175, 80, 0.3);
}

#ask-gemini:active {
    transform: translateY(0);
}

#clear-chat {
    background: linear-gradient(135deg, #f44336 0%, #da190b 100%);
    color: white;
    box-shadow: 0 4px 6px rgba(244, 67, 54, 0.2);
}

#clear-chat:hover {
    background: linear-gradient(135deg, #da190b 0%, #c62828 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(244, 67, 54, 0.3);
}

#clear-chat:active {
    transform: translateY(0);
}

/* تکست‌اریا */
#text_content {
    width: 100%;
    resize: vertical;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    background-color: #2d2d2d;
    color: #f0f0f0!important;
    border: 1px solid #404040;
    border-radius: 8px;
    padding: 12px;
    transition: border-color 0.3s ease;
    min-height: 100px;
    max-height: 200px;
}

#text_content:focus {
    outline: none;
    border-color: #81d742;
    box-shadow: 0 0 0 2px rgba(129, 215, 66, 0.2);
}

#text_content::placeholder {
    color: #888;
    opacity: 1;
}

/* لودینگ */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(129, 215, 66, 0.3);
    border-top: 3px solid #81d742;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#iv_gemini_answers-ajax-progress {
    transition: all 0.3s ease;
    background: linear-gradient(90deg, #81d742, #4CAF50, #81d742);
    background-size: 200% 100%;
    animation: progressAnimation 2s infinite linear;
    border-radius: 4px;
}

@keyframes progressAnimation {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* استایل برای موبایل */
@media screen and (max-width: 768px) {
    #chat-container {
        padding: 15px;
        min-height: 300px;
        max-height: 500px;
        margin-bottom: 15px;
    }
    
    .message-user, .message-assistant {
        max-width: 92% !important;
        padding: 12px 15px;
        margin: 8px 0;
    }
    
    .message-user::before,
    .message-assistant::before {
        font-size: 10px;
        top: -18px;
    }
    
    #ask-gemini, #clear-chat {
        width: 100%;
        margin: 5px 0;
    }
    
    #text_content {
        font-size: 13px;
        padding: 10px;
    }
}

/* استایل برای تبلت */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    #chat-container {
        min-height: 350px;
        max-height: 550px;
    }
    
    .message-user, .message-assistant {
        max-width: 100%;
    }
}

/* استایل برای دسکتاپ بزرگ */
@media screen and (min-width: 1025px) {
    #chat-container {
        min-height: 450px;
        max-height: 700px;
    }
    
    .message-content {
        font-size: 15px;
    }
}

/* استایل برای حالت تاریک (تم سایت شما تاریک است) */
body.dark-mode #chat-container,
body #chat-container {
    background-color: #1e1e1e;
    color: #f0f0f0;
}

body.dark-mode .message-assistant,
body .message-assistant {
    background: linear-gradient(135deg, #2d2d2d 0%, #3c3c3c 100%);
}

/* استایل برای لینک‌ها در پیام‌ها */
.message-content a {
    color: #81d742;
    text-decoration: none;
    border-bottom: 1px dotted #81d742;
    transition: all 0.3s ease;
}

.message-content a:hover {
    color: #4CAF50;
    border-bottom: 1px solid #4CAF50;
}

/* استایل برای نقل‌قول‌ها */
.message-content blockquote {
    border-right: 4px solid #81d742;
    margin: 10px 0;
    padding: 8px 16px;
    background-color: rgba(129, 215, 66, 0.1);
    border-radius: 0 8px 8px 0;
    font-style: italic;
    color: #d0d0d0;
}

/* استایل برای جداول در پیام‌ها */
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    background-color: #2d2d2d;
    border-radius: 8px;
    overflow: hidden;
}

.message-content th {
    background-color: #3c3c3c;
    color: #81d742;
    padding: 10px;
    text-align: right;
    font-weight: 600;
    border-bottom: 2px solid #404040;
}

.message-content td {
    padding: 8px 10px;
    border-bottom: 1px solid #404040;
    color: #f0f0f0;
}

.message-content tr:hover {
    background-color: rgba(129, 215, 66, 0.05);
}

/* انیمیشن برای پیام‌های جدید */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-user, .message-assistant {
    animation: slideIn 0.3s ease-out;
}

/* استایل برای حالت خطا */
.message-error {
    background: linear-gradient(135deg, #ff5252 0%, #d32f2f 100%);
    color: white;
    border-radius: 12px;
    padding: 14px 18px;
    margin: 10px 0;
    border: none;
    box-shadow: 0 4px 6px rgba(255, 82, 82, 0.2);
}

/* استایل برای اطلاعات سیستم */
.system-message {
    background: linear-gradient(135deg, #607d8b 0%, #455a64 100%);
    color: white;
    border-radius: 12px;
    padding: 12px 16px;
    margin: 10px auto;
    max-width: 90%;
    font-size: 12px;
    text-align: center;
    opacity: 0.8;
}