/* frontend/style.css */
body {
    font-family: 'Arial', sans-serif;
    background-color: #f4f7f6;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    direction: rtl; 
}

.chat-container {
    width: 90%;
    max-width: 600px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background-color: #007bff;
    color: white;
    padding: 15px 20px;
    text-align: center;
    border-bottom: 1px solid #0056b3;
}

.chat-header h1 {
    margin: 0;
    font-size: 1.4em;
}

.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: 400px; 
    display: flex;
    flex-direction: column;
}

.message {
    padding: 10px 15px;
    border-radius: 18px;
    margin-bottom: 10px;
    max-width: 80%;
    line-height: 1.5;
    word-wrap: break-word; /* لكسر الكلمات الطويلة */
}

.user-message {
    background-color: #007bff;
    color: white;
    align-self: flex-start; 
    border-bottom-left-radius: 5px;
}

.bot-message {
    background-color: #e9ecef;
    color: #333;
    align-self: flex-end; 
    border-bottom-right-radius: 5px;
}

.message p {
    margin: 0;
}

.chat-input-area {
    display: flex;
    padding: 15px;
    border-top: 1px solid #ddd;
    background-color: #f8f9fa;
}

#userInput {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: 1em;
    margin-left: 10px; 
}

#sendButton {
    padding: 10px 20px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.2s;
}

#sendButton:hover {
    background-color: #218838;
}

.disclaimer {
    font-size: 0.8em;
    color: #6c757d;
    text-align: center;
    padding: 10px 20px;
    border-top: 1px solid #eee;
    background-color: #f8f9fa;
}

/* أنماط مؤشر الكتابة (النقاط القافزة) */
.typing-indicator .is-typing { 
    width: auto; 
    min-width: 50px; /* قللت العرض الأدنى قليلاً */
    justify-content: center; 
    display: flex;
    padding: 5px 0; /* قللت المساحة الداخلية */
    align-items: center; 
}

.typing-indicator .is-typing > div { 
    width: 8px;  
    height: 8px; 
    border-radius: 100%;
    background-color: #007bff; 
    margin: 0 2px; /* قللت المسافة بين النقاط */
}

.typing-indicator .jump1 {
    animation: typing-jump 1.5s linear infinite;
    animation-delay: 0.1s; 
}
.typing-indicator .jump2 {
    animation: typing-jump 1.5s linear infinite;
    animation-delay: 0.2s;
}
.typing-indicator .jump3 {
    animation: typing-jump 1.5s linear infinite;
    animation-delay: 0.3s;
}
/* إذا كنت تستخدم 5 نقاط، أضف jump4 و jump5 */
/*
.typing-indicator .jump4 {
    animation: typing-jump 1.5s linear infinite;
    animation-delay: 0.4s; 
}
.typing-indicator .jump5 {
    animation: typing-jump 1.5s linear infinite;
    animation-delay: 0.5s;
}
*/

@keyframes typing-jump { 
    0% {
        transform: translateY(0px);
        background-color: #007bff; 
    }
    25% {
        transform: translateY(0px);
    }
    35% {
        transform: translateY(-8px); /* قللت ارتفاع القفزة */
    }
    45% {
        transform: translateY(0px);
    }
    75% {
        background-color: #a9d4ff; 
        transform: translateY(0px);
    }
    100% {
        transform: translateY(0px);
        background-color: #007bff; 
    }
}

/* أنماط لعرض المصادر */
.sources-container {
    font-size: 0.85em; /* حجم أصغر قليلاً */
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed #ccc; /* تغيير شكل الخط الفاصل */
    color: #444; /* لون أغمق قليلاً */
}
.sources-container strong {
    display: block;
    margin-bottom: 5px;
    color: #222; /* لون أغمق للعنوان */
}
.sources-container ul {
    list-style-type: disc; /* أو 'circle' أو 'square' */
    margin: 0;
    padding-right: 20px; 
}
.sources-container li {
    margin-bottom: 5px;
}
.sources-container a {
    color: #0056b3;
    text-decoration: none;
}
.sources-container a:hover {
    text-decoration: underline;
    color: #003d80; /* لون أغمق عند المرور */
}

.model-selector-container {
    margin-top: 10px;
    padding: 5px 0;
    font-size: 0.9em;
    color: #f0f0f0; 
    display: flex;
    align-items: center;
    justify-content: center; 
}

.model-selector-container label {
    margin-left: 8px; 
}

#modelSelector {
    padding: 5px 8px;
    border-radius: 4px;
    border: 1px solid #ccc;
    background-color: #fff;
    color: #333;
    font-size: 0.9em;
    cursor: pointer;
}

#modelSelector:disabled {
    background-color: #e9ecef;
    cursor: not-allowed;
}

.app-container {
    display: flex;
    width: 100vw; /* عرض كامل */
    height: 100vh; /* ارتفاع كامل */
    overflow: hidden; /* منع التمرير على مستوى التطبيق */
    position: relative;
}

.sidebar {
    width: 280px; /* عرض القائمة الجانبية */
    background-color: #f8f9fa;
    border-left: 1px solid #dee2e6; /* لليمين في RTL */
    padding: 15px;
    display: flex;
    flex-direction: column;
    transition: margin-right 0.3s ease; /* للتحريك في RTL */
}

.sidebar.closed { /* لإخفاء القائمة */
    margin-right: -280px; /* لليمين في RTL */
}


.sidebar-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-header h2 {
    margin: 0;
    font-size: 1.2em;
    color: #333;
}

#newChatButton {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
}
#newChatButton:hover {
    background-color: #0056b3;
}


#chatHistoryList {
    list-style: none;
    padding: 0;
    margin: 0;
    overflow-y: auto; /* تمرير إذا كانت القائمة طويلة */
    flex-grow: 1;
}

#chatHistoryList li {
    padding: 10px 8px;
    margin-bottom: 5px;
    border-radius: 4px;
    cursor: pointer;
    background-color: #fff;
    border: 1px solid #eee;
    font-size: 0.95em;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* عرض نقاط إذا كان النص طويلاً */
}

#chatHistoryList li:hover {
    background-color: #e9ecef;
}
#chatHistoryList li.active-session { /* لتمييز الجلسة النشطة */
    background-color: #007bff;
    color: white;
    font-weight: bold;
}


.chat-main-area {
    flex-grow: 1; /* تأخذ المساحة المتبقية */
    display: flex;
    justify-content: center; /* لتوسيط chat-container إذا كان أصغر */
    align-items: center; /* لتوسيط chat-container */
    /* chat-container سيأخذ عرضه الأقصى المحدد سابقًا */
}

/* زر فتح/إغلاق القائمة */
#toggleSidebarButton {
    background: none;
    border: none;
    font-size: 1.5em;
    color: white; /* ليتناسب مع الهيدر */
    cursor: pointer;
    padding: 0 10px;
    margin-left: 10px; /* لليمين في RTL */
}

/* Styles for "Found X results" header */
.found-results-header {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 8px;
    background-color: #f0f0f0;
    border-radius: 16px;
    font-size: 0.9em;
    color: #333;
    cursor: pointer;
    border: 1px solid #e0e0e0;
    align-self: flex-start;
    max-width: fit-content;
}

.found-results-header .ds-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 6px;
}

.found-results-header ._0f883e7 {
    margin-left: 6px;
    margin-right: 0;
    transition: transform 0.2s ease-in-out;
}

/* Styles for Search Results Panel */
.search-results-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 320px;
    max-width: 80%;
    height: 100vh;
    background-color: #fff;
    box-shadow: -2px 0 8px rgba(0,0,0,0.15);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease-in-out;
    transform: translateX(100%);
}

.search-results-panel:not(.hidden) {
    transform: translateX(0%);
}

.search-results-panel.hidden {
    transform: translateX(100%);
}

/* Panel Inner Structure */
.search-results-panel ._26c5bc2 {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.search-results-panel ._2c74d7a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    font-weight: bold;
    color: #333;
    font-size: 1.1em;
    flex-shrink: 0;
}

.search-results-panel ._2c74d7a [role="heading"] {
    flex-grow: 1;
}

.search-results-panel .ds-icon-button._5d271a3 {
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
}

.search-results-panel .ds-icon-button._5d271a3:hover {
    background-color: #f0f0f0;
}

.search-results-panel .fcd12e6e {
    flex-grow: 1;
    overflow-y: auto;
    padding: 8px 16px;
}

/* Search Result Items */
.search-result-item {
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item .a93786a8 {
    display: flex;
    align-items: center;
    font-size: 0.8em;
    color: #555;
    margin-bottom: 4px;
}

.search-result-item .c16074e9 {
    margin-right: 6px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-result-item .siteIcon_img {
    width: 16px;
    height: 16px;
    border-radius: 2px;
}

.search-result-item .siteIcon_fallback .ds-icon {
    color: #888;
}

.search-result-item .d2eca804 {
    flex-shrink: 0;
}

.search-result-item .caa1ee14 {
    flex-grow: 1;
}

.search-result-item .ba26051b {
    background-color: #e9ecef;
    color: #495057;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.75em;
    margin-left: 6px;
}

.search-result-item .f664d0b2.search-view-card__title {
    font-size: 1em;
    font-weight: 600;
    color: #0056b3;
    text-decoration: none;
    display: block;
    margin-bottom: 4px;
}

.search-result-item .f664d0b2.search-view-card__title:hover {
    text-decoration: underline;
}

.search-result-item .c56273f9.search-view-card__snippet {
    font-size: 0.85em;
    color: #333;
    line-height: 1.4;
}

/* أنماط Markdown */
.ds-markdown {
    font-size: 1em;
    line-height: 1.6;
    word-wrap: break-word;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.ds-markdown h1,
.ds-markdown h2,
.ds-markdown h3,
.ds-markdown h4,
.ds-markdown h5,
.ds-markdown h6 {
    margin-top: 1.2em;
    margin-bottom: 0.6em;
    font-weight: 600;
    line-height: 1.25;
    color: #333;
}

.ds-markdown h1 { font-size: 1.8em; }
.ds-markdown h2 { font-size: 1.6em; }
.ds-markdown h3 { font-size: 1.4em; }
.ds-markdown h4 { font-size: 1.2em; }
.ds-markdown h5 { font-size: 1.1em; }
.ds-markdown h6 { font-size: 1em; }

.ds-markdown p,
.ds-markdown .ds-markdown-paragraph {
    margin-bottom: 0.8em;
}

.ds-markdown ul,
.ds-markdown ol {
    margin-bottom: 0.8em;
    padding-right: 25px;
}

.ds-markdown li {
    margin-bottom: 0.4em;
}

.ds-markdown ul ul,
.ds-markdown ol ol,
.ds-markdown ul ol,
.ds-markdown ol ul {
    margin-top: 0.4em;
    margin-bottom: 0.4em;
}

.ds-markdown strong {
    font-weight: bold;
}

.ds-markdown em {
    font-style: italic;
}

.ds-markdown a {
    color: #0066cc;
    text-decoration: none;
}

.ds-markdown a:hover {
    text-decoration: underline;
}

.ds-markdown blockquote {
    padding: 10px 15px;
    margin: 0 0 1em;
    border-right: 4px solid #e0e0e0;
    background-color: #f9f9f9;
    color: #555;
}

.ds-markdown code {
    padding: 0.2em 0.4em;
    margin: 0;
    font-size: 85%;
    background-color: rgba(27,31,35,0.05);
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
}

.ds-markdown pre {
    padding: 16px;
    overflow: auto;
    font-size: 85%;
    line-height: 1.45;
    background-color: #f6f8fa;
    border-radius: 3px;
    margin-bottom: 1em;
}

.ds-markdown pre code {
    padding: 0;
    margin: 0;
    font-size: 100%;
    background-color: transparent;
    border-radius: 0;
}

/* الجداول */
.ds-markdown table {
    width: auto;
    max-width: 100%;
    border-collapse: collapse;
    margin-bottom: 1em;
    display: block;
    overflow-x: auto;
}

.ds-markdown .markdown-table-wrapper {
    overflow-x: auto;
    margin-bottom: 1em;
}

.ds-markdown th,
.ds-markdown td {
    padding: 8px 12px;
    border: 1px solid #dfe2e5;
    text-align: right;
}

.ds-markdown th {
    font-weight: 600;
    background-color: #f6f8fa;
}

.ds-markdown tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* الاستشهادات */
.ds-markdown .ds-markdown-cite {
    display: inline-block;
    align-items: center;
    justify-content: center;
    font-size: 0.7em;
    font-weight: bold;
    color: #007bff;
    background-color: #e7f3ff;
    border: 1px solid #b3d7ff;
    border-radius: 3px;
    padding: 0px 4px;
    margin: 0 2px;
    vertical-align: super;
    line-height: 1;
    cursor: pointer;
}

.ds-markdown .ds-markdown-cite:hover {
    background-color: #cfe8ff;
}

/* خاصية التكبير */
.ds-markdown--block {
    --ds-md-zoom: 1;
    font-size: calc(1em * var(--ds-md-zoom));
}
