:root {
    --primary-color: #0056b3; /* أغمق من الأزرق الأصلي لتحسين التباين */
    --primary-hover: #004494;
    --secondary-color: #495057; /* أغمق من اللون الثانوي */
    --success-color: #28a745;
    --danger-color: #dc3545;
    --bg-color: #ffffff;
    --text-color: #212529; /* أغمق للنص عمومًا */
    --border-color: #e5e5e5;
    --input-bg: #ffffff;
    --placeholder-color: #6B6B6B;
    --message-user-bg: #f0f7ff;
    --message-assistant-bg: #ffffff;
    --header-bg: #f8f9fa;
    --chat-bg: #f9f9f9;
    
    --font-primary: 'Inter', 'Söhne', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, Cantarell, 'Noto Sans', sans-serif;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --transition-speed: 0.3s;
    
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #2b8bff; /* أفتح في الوضع المظلم */
        --primary-hover: #1a7cff;
        --bg-color: #1a1a1a;
        --text-color: #ffffff; /* أبيض أكثر سطوعًا للنص */
        --border-color: #2d2d2d;
        --input-bg: #2d2d2d;
        --placeholder-color: #adb5bd;
        --message-user-bg: #193d5c;
        --message-assistant-bg: #2d2d2d;
        --header-bg: #212529;
        --chat-bg: #121212;
        --secondary-color: #adb5bd; /* أفتح للوضع المظلم */
    }
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-primary);
    color: var(--text-color);
    background: var(--bg-color);
    line-height: 1.6;
}

/* عنصر مخفي بصريًا لدعم إمكانية الوصول */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.deepseek-container {
    display: flex;
    flex-direction: column;
    height: 90vh;
    max-height: 800px;
    background: var(--bg-color);
    max-width: 900px;
    margin: 2rem auto;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    font-family: var(--font-primary);
    overflow: hidden;
    transition: all var(--transition-speed) ease;
}

.deepseek-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--header-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.deepseek-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.deepseek-brand img {
    height: 28px;
    width: auto;
}

/* تحسين تباين النص في شريط العنوان */
.deepseek-brand span {
    font-weight: 700; /* زيادة سمك النص */
    color: #003166; /* لون أغمق للتباين */
}

.model-selector {
    position: relative;
    width: 200px;
}

#deepseek-model {
    width: 100%;
    padding: 8px 12px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-color);
    font-size: 14px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: all var(--transition-speed) ease;
}

#deepseek-model:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

#deepseek-model:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.deepseek-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: var(--chat-bg);
}

.message {
    display: flex;
    max-width: 85%;
    padding: 15px;
    border-radius: var(--border-radius-md);
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    transition: all var(--transition-speed) ease;
    position: relative;
    animation: messageAppear 0.3s ease-out;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    background-color: var(--message-user-bg);
    border: 1px solid rgba(0, 123, 255, 0.2);
    margin-left: auto;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.05);
}

.message.assistant {
    background-color: var(--message-assistant-bg);
    border: 1px solid var(--border-color);
    margin-right: auto;
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    position: absolute;
    top: -10px;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.message.user .message-avatar {
    left: -14px;
    background: var(--primary-color);
}

.message.assistant .message-avatar {
    right: -14px;
    background: var(--secondary-color);
}

.message-content {
    width: 100%;
}

.message-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message:hover .message-actions {
    opacity: 1;
}

.message-action-btn {
    background: transparent;
    border: none;
    color: var(--secondary-color);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: 3px;
}

.message-action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--primary-color);
}

.deepseek-input {
    position: relative;
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
}

.input-wrapper {
    position: relative;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    background: var(--input-bg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-speed) ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

#deepseek-prompt {
    width: 100%;
    min-height: 48px;
    max-height: 200px;
    padding: 14px 50px 14px 16px;
    border: none;
    background: transparent;
    color: var(--text-color);
    resize: none;
    font-size: 1rem;
    line-height: 1.5;
    font-family: var(--font-primary);
}

#deepseek-prompt::placeholder {
    color: var(--placeholder-color);
}

#deepseek-prompt:focus {
    outline: none;
}

#deepseek-submit {
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--primary-color);
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-speed) ease;
    box-shadow: var(--shadow-sm);
}

#deepseek-submit:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

#deepseek-submit svg {
    width: 20px;
    height: 20px;
    color: white;
}

.typing-indicator {
    display: flex;
    gap: 0.5rem;
    padding: 15px;
    background: var(--message-assistant-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    margin-right: auto;
    align-items: center;
    max-width: 85%;
    box-shadow: var(--shadow-sm);
    animation: messageAppear 0.3s ease-out;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: typing 1.5s infinite;
    opacity: 0.7;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.5s;
}

.typing-dot:nth-child(3) {
    animation-delay: 1s;
}

@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: 0.7; }
    50% { transform: translateY(-5px); opacity: 1; }
}

#deepseek-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--secondary-color);
}

.input-wrapper:has(textarea:disabled) {
    opacity: 0.7;
}

.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--placeholder-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    height: 100%;
}

.empty-state-icon {
    font-size: 3rem;
    color: var(--primary-color);
    opacity: 0.3;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.empty-state-text {
    max-width: 400px;
    margin: 0 auto;
    line-height: 1.6;
}

.deepseek-messages::-webkit-scrollbar {
    width: 6px;
}

.deepseek-messages::-webkit-scrollbar-track {
    background: transparent;
}

.deepseek-messages::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.deepseek-messages::-webkit-scrollbar-thumb:hover {
    background-color: rgba(0, 0, 0, 0.3);
}

@media (max-width: 768px) {
    .deepseek-container {
        height: 100vh;
        max-height: none;
        margin: 0;
        border-radius: 0;
        border: none;
    }

    .message {
        max-width: 90%;
    }
    
    .deepseek-header {
        padding: 0.75rem;
    }
}

.deepseek-reset {
    background: transparent;
    border: none;
    color: #495057; /* لون أغمق للزر */
    padding: 5px 10px;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all var(--transition-speed) ease;
    font-weight: 500; /* نص أكثر سمكًا */
}

.deepseek-reset:hover {
    color: #c82333; /* أغمق للرؤية الأفضل عند التحويم */
    background: rgba(220, 53, 69, 0.2); /* خلفية أغمق قليلاً عند التحويم */
}

.deepseek-reset svg {
    width: 14px;
    height: 14px;
}

.quick-prompts {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.quick-prompts::-webkit-scrollbar {
    display: none;
}

.quick-prompt {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.quick-prompt:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* دعم RTL للغة العربية */
[dir="rtl"] .message.user {
    margin-right: auto;
    margin-left: 0;
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: var(--border-radius-md);
}

[dir="rtl"] .message.assistant {
    margin-left: auto;
    margin-right: 0;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: var(--border-radius-md);
}

[dir="rtl"] .message.user .message-avatar {
    right: -14px;
    left: auto;
}

[dir="rtl"] .message.assistant .message-avatar {
    left: -14px;
    right: auto;
}

[dir="rtl"] #deepseek-submit {
    left: 8px;
    right: auto;
}

[dir="rtl"] #deepseek-prompt {
    padding: 14px 16px 14px 50px;
}

/* Adiciones para soporte de formato Markdown */

/* Formato de código */
.message-content pre {
    margin: 12px 0;
    padding: 0;
    overflow: auto;
    background: #f6f8fa;
    border-radius: 6px;
    border: 1px solid #e1e4e8;
}

.message-content code {
    font-family: SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
    font-size: 85%;
    padding: 0.2em 0.4em;
    margin: 0;
    background-color: rgba(27, 31, 35, 0.05);
    border-radius: 3px;
}

.message-content pre > code {
    font-size: 85%;
    padding: 16px;
    background-color: transparent;
    border: 0;
    display: block;
    line-height: 1.45;
    overflow-x: auto;
}

/* Formato de tablas */
.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 15px 0;
    overflow-x: auto;
    display: block;
}

.message-content th, 
.message-content td {
    border: 1px solid #dfe2e5;
    padding: 8px 12px;
    text-align: left;
}

.message-content th {
    background-color: #f6f8fa;
    font-weight: 600;
}

.message-content tr:nth-child(even) {
    background-color: #f8f9fa;
}

/* Formato de encabezados */
.message-content h1, 
.message-content h2, 
.message-content h3, 
.message-content h4, 
.message-content h5, 
.message-content h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
}

.message-content h1 {
    font-size: 2em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.message-content h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
}

.message-content h3 {
    font-size: 1.25em;
}

.message-content h4 {
    font-size: 1em;
}

/* Formato de listas */
.message-content ul,
.message-content ol {
    padding-left: 2em;
    margin: 1em 0;
}

.message-content ul ul,
.message-content ul ol,
.message-content ol ul,
.message-content ol ol {
    margin: 0;
}

.message-content li {
    margin: 0.25em 0;
}

.message-content li > p {
    margin-top: 1em;
}

.message-content blockquote {
    padding: 0 1em;
    color: #6a737d;
    border-left: 0.25em solid var(--primary-color);
    margin: 0 0 16px 0;
}

.message-content blockquote > :first-child {
    margin-top: 0;
}

.message-content blockquote > :last-child {
    margin-bottom: 0;
}

/* Formato de enlaces */
.message-content a {
    color: var(--primary-color);
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

/* Botón copiar HTML */
.copy-html-btn {
    margin-left: 5px;
}

/* Formato para modo oscuro */
.deepseek-container[data-theme="dark"] .message-content pre,
.deepseek-container[data-theme="dark"] .message-content code {
    background-color: #1e1e1e;
    border-color: #333;
}

.deepseek-container[data-theme="dark"] .message-content pre > code {
    background-color: transparent;
}

.deepseek-container[data-theme="dark"] .message-content th, 
.deepseek-container[data-theme="dark"] .message-content td {
    border-color: #444;
}

.deepseek-container[data-theme="dark"] .message-content th {
    background-color: #2d2d2d;
}

.deepseek-container[data-theme="dark"] .message-content tr:nth-child(even) {
    background-color: #1a1a1a;
}

.deepseek-container[data-theme="dark"] .message-content blockquote {
    color: #9e9e9e;
    border-left-color: var(--primary-color);
}

.deepseek-container[data-theme="dark"] .deepseek-brand span {
    color: #62a9ff; /* لون أفتح للعلامة التجارية في الوضع المظلم */
}

.deepseek-container[data-theme="dark"] .deepseek-reset {
    color: #e9ecef; /* نص أفتح في الوضع المظلم */
}

/* Añadir espaciado correcto para párrafos */
.message-content p {
    margin: 0 0 16px 0;
    line-height: 1.6;
}

.message-content p:last-child {
    margin-bottom: 0;
}

/* Formato de imágenes */
.message-content img {
    max-width: 100%;
    height: auto;
    margin: 10px 0;
    border-radius: 4px;
}