/* ==============================================================
   chatali.css – تمام استایل‌ها (نسخهٔ اصلاح‌شده)
   --------------------------------------------------------------
   هدف: هم‌ترازی دقیق شماره خطوط و متن کد
   --------------------------------------------------------------
   نکتهٔ مهم:
   برای هم‌ترازی از CSS Grid استفاده می‌شود.
   تمام قابلیت‌های قبلی (تم روشن/تیره، ساید‑بارها، جستجو,
   منوهای زمینه، ویرایشگر، پیام‌ها و …) دست نخورده باقی می‌مانند.
   ============================================================== */

/* --------------------------- ریشه --------------------------- */
:root {
    --edit-color: #000;
    --editor-width: 220px;
    --bg-dark: #000000;
    --bg-panel: #000000;
    --bg-input: #333333;
    --border-color: #3e3e42;
    --text-primary: #e0e0e0;
    --text-secondary: #aaaaaa;
    --accent-color: #007acc;
    --accent-hover: #005f9e;
    --msg-user-bg: #2b5b84;
    --msg-ai-bg: #333333;
}

/* --------------------------- تنظیمات پایه --------------------------- */
html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: calc(var(--vh, 1vh) * 100);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-dark);
    overflow: hidden;
}

/* --------------------------- مدل‑سِلِکت --------------------------- */
.model-select {
    width: 190px;
    max-width: 100%;
    margin-left: 35px;
    height: 30px;
    padding: 4px 8px;
    font-size: 15px;
    line-height: 1.2;
    direction: rtl;
}

/* ==============================================================
   سایدبار چپ – ویرایشگر کد
   ============================================================== */
.left-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--editor-width);
    height: calc(var(--vh, 1vh) * 100);
    background: var(--bg-dark);
    color: var(--text-primary);
    box-shadow: 2px 0 12px rgba(0,0,0,0.6);
    transition: transform 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transform: translateX(-100%);
}
.left-sidebar.open { transform: translateX(0); }

.resize-handle-vertical {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    z-index: 1010;
}
.resize-handle-vertical:hover,
.left-sidebar.resizing .resize-handle-vertical {
    background: var(--accent-color);
}

/* هدر سایدبار چپ */
.left-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 10px 14px;
    min-height: 34px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    flex-wrap: nowrap;
    gap: 12px;
}
.header-btn-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.left-sidebar-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 120px;
    margin-right: auto;
}

/* دکمه‌های ابزار */
.icon-btn-small,
#editor-run-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.15s;
    background: #3a3a3a;
    border: 1px solid #555;
    color: #e0e0e0;
}
.icon-btn-small:hover,
#editor-run-btn:hover:not(.stopping) {
    background: #4a4a4a;
    border-color: #888;
    transform: translateY(-1px);
}

/* دکمه اجرا */
#editor-run-btn {
    background: #2e7d32;
    border: none;
    color: white;
    font-size: 1.4rem;
    font-weight: bold;
}
#editor-run-btn:hover { background: #388e3c; }
#editor-run-btn.stopping { background: #c62828; }
#editor-run-btn.stopping:hover { background: #d32f2f; }

/* کانتینر اصلی ویرایشگر */
.editor-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    position: relative;
}

/* لایهٔ کد (wrapper) */
.code-editor-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: row;
    background: var(--bg-dark);
    height: 100%;
    font-family: 'Courier New', Courier, monospace;
    direction: ltr !important;
}

/* لایهٔ هایلایت (پایین) */
#editor-highlight {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    color: transparent;
    background: transparent;
    pointer-events: none;
    overflow: hidden;
    white-space: pre;
    margin: 0;
    padding: 10px;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    direction: ltr;
    text-align: left;
}
#editor-highlight-content { direction: inherit; text-align: inherit; }
#editor-highlight::-webkit-scrollbar { display: none; }
#editor-highlight { -ms-overflow-style: none; scrollbar-width: none; }
#editor-highlight code {
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    background: transparent;
    display: block;
}

/* ورودی متن (textarea) – اصلاح Selection */
#code-editor {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    padding: 10px;
    margin: 0;
    border: none;
    white-space: pre;
    overflow: auto;
    box-sizing: border-box;
    resize: none;
    outline: none;
    background: transparent;
    color: rgba(0,0,0,0.01);
    caret-color: #fff;
    tab-size: 4;
    direction: ltr;
    text-align: left;
    ::selection {
        background: rgba(0,122,204,0.4);
        color: rgba(0,0,0,0.01);
    }
    ::-moz-selection {
        background: rgba(0,122,204,0.4);
        color: rgba(0,0,0,0.01);
    }
}

/* --------------------------- کنسول --------------------------- */
.console-container {
    height: 160px;
    background: #111;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
}
.resize-handle-horizontal {
    position: absolute;
    top: -6px;
    left: 0;
    right: 0;
    height: 6px;
    cursor: row-resize;
    background: transparent;
    z-index: 1010;
}
.resize-handle-horizontal:hover,
.console-container.resizing .resize-handle-horizontal {
    background: var(--accent-color);
}
.console-header {
    padding: 5px 10px;
    background: var(--bg-panel);
    font-size: 0.8rem;
    color: #888;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    flex-shrink: 0;
}
.console-output {
    flex: 1;
    padding: 10px;
    font-family: 'Consolas','Monaco','Courier New',monospace;
    font-size: 14px;
    overflow-y: auto;
    color: #ccc;
    direction: rtl;
    text-align: left;
}
.console-log   { color: #ccc; }
.console-error { color: #ff5252; }
.console-info  { color: #2196f3; }

/* --------------------------- دکمه همبرگری چپ --------------------------- */
.left-hamburger-btn {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1001;
    background: #333;
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.left-hamburger-btn:hover { background: #444; }

/* --------------------------- تب‌های ویرایشگر --------------------------- */
.editor-tabs {
    display: flex;
    background: #2d2d2d;
    overflow-x: auto;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}
.editor-tab {
    padding: 8px 15px;
    background: #2d2d2d;
    color: #888;
    cursor: pointer;
    border-right: 1px solid var(--border-color);
    font-size: 0.9rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 5px;
}
.editor-tab.active {
    background: var(--bg-dark);
    color: #fff;
    border-top: 2px solid var(--accent-color);
}
.tab-close {
    font-size: 12px;
    border-radius: 50%;
    padding: 2px;
}
.tab-close:hover { background: #444; color: #fff; }

/* منوی ابزار */
.editor-tools-menu-wrapper { position: relative; }
.editor-tools-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    width: 180px;
    display: none;
    flex-direction: column;
    z-index: 1100;
    padding: 5px 0;
}
.editor-tools-dropdown.show { display: flex; }
.tool-item {
    background: transparent;
    border: none;
    color: #ddd;
    width: 100%;
    padding: 10px 15px;
    text-align: right;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    transition: background 0.2s;
}
.tool-item:hover { background: #444; color: #fff; }

/* --------------------------- ساختار اصلی اپلیکیشن --------------------------- */
.app-container {
    width: 100%;
    height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: row;
    position: relative;
}

/* رپر اصلی (main‑wrapper) */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: row;
    height: calc(var(--vh, 1vh) * 100);
    overflow: hidden;
    transition: margin-left 0.3s ease;
}
.left-sidebar.open ~ .main-wrapper { margin-left: var(--editor-width); }

/* سایدبار راست (تاریخچه) */
.sidebar {
    width: 260px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 900;
    flex-shrink: 0;
    height: calc(var(--vh, 1vh) * 100);
}
.sidebar.collapsed { margin-right: -260px; }

@media (max-width: 600px) {
    .sidebar {
        position: fixed;
        right: 0;
        top: 0;
        bottom: 0;
        transform: translateX(100%);
        width: 80%;
        box-shadow: -2px 0 10px rgba(0,0,0,0.5);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar.collapsed {
        margin-right: 0;
        transform: translateX(100%);
    }
}

/* محتوای اصلی (main‑content) */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-dark);
    position: relative;
    min-width: 0;
    height: 100%;
}

/* دکمه همبرگری راست */
.hamburger-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 901;
    background: #333;
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}
.hamburger-btn:hover { background: #444; }

/* overlay برای موبایل */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 899;
}
.overlay.active { display: block; }

/* wrapper داخلی */
#wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* --------------------------- هدر (بالای صفحه) --------------------------- */
.header-container {
    padding: 10px 20px;
    background: #2d2d2d;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    height: auto !important;
    min-height: 50px !important;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 5px;
    padding: 10px;
}
.header-container h2 {
    color: #ffffff;
    margin: 0;
    font-size: 1.2rem;
}
.header-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    justify-content: center;
}
.header-controls label { color: #ffffff; }
.header-controls select {
    background: #3c3c3c;
    color: #fff;
    border: 1px solid #555;
    padding: 5px;
    border-radius: 4px;
    max-width: 90%;
}

@media (max-width: 768px) {
    .header-container {
        height: auto !important;
        min-height: 50px !important;
        flex-direction: column;
        justify-content: center;
        text-align: center;
        gap: 5px;
        padding: 10px;
    }
}

/* --------------------------- ناحیهٔ چت --------------------------- */
#chat {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* پیام‌ها */
.msg {
    max-width: 85%;
    padding: 10px 15px;
    border-radius: 10px;
    position: relative;
    line-height: 1.6;
    word-wrap: break-word;
    font-size: 16px;
    color: #fff;
}
.msg.user {
    align-self: flex-start;
    background: var(--msg-user-bg);
    border-bottom-right-radius: 2px;
}
.msg.ai {
    align-self: flex-start;
    background: var(--msg-ai-bg);
    border-bottom-left-radius: 2px;
    border-bottom-right-radius: 2px;
    text-align: right;
    direction: rtl;
}

/* محتوی پیام */
.msg-content {
    margin-bottom: 5px;
    overflow-wrap: break-word;
    word-break: break-word;
    white-space: pre-wrap;
}
.msg-content pre {
    white-space: pre-wrap;
    word-break: break-all;
    overflow-wrap: break-word;
}

/* فوتر پیام (دکمه کپی) */
.msg-footer-actions {
    margin-top: 5px;
    display: flex;
    justify-content: flex-end;
}
.copy-full-msg-btn {
    background: none;
    border: none;
    color: #666;
    font-size: 0.8rem;
    cursor: pointer;
}
.copy-full-msg-btn:hover { color: #aaa; }

/* اکشن‌های کنار پیام */
.msg-actions {
    position: absolute;
    top: 5px;
    left: 5px;
    display: flex;
    gap: 8px;
    opacity: 0;
    transition: opacity .2s;
    z-index: 10;
    align-items: center;
    background: rgba(0,0,0,0.3);
    padding: 4px 8px;
    border-radius: 4px;
}
.msg:hover .msg-actions { opacity: 1; }
.copy-msg-btn,
.edit-msg-btn,
.cancel-msg-btn {
    background: none;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 1rem;
    padding: 2px;
    transition: color .2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.copy-msg-btn:hover,
.edit-msg-btn:hover { color: #fff; }
.edit-msg-btn:hover { color: var(--edit-color); }
.cancel-msg-btn { color: #e53935; }
.cancel-msg-btn:hover { color: #ff5252; }
#send.editing { background: var(--edit-color); }

/* دکمه لغو ویرایش */
#cancel-edit-btn {
    display: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: #e53935;
    flex-shrink: 0;
    font-size: 1.2rem;
    transition: transform 0.2s;
}
#cancel-edit-btn:hover { transform: scale(1.05); }
.input-controls.editing-mode #cancel-edit-btn { display: flex !important; }

/* --------------------------- ناحیهٔ ورودی (input‑area) --------------------------- */
.input-area {
    padding: 15px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}
.input-controls {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-input);
    padding: 10px;
    border-radius: 10px;
    border: 1px solid #444;
}
.input-wrapper { flex: 1; position: relative; }
#input {
    width: 100%;
    background: transparent;
    border: none;
    color: #fff;
    resize: none;
    max-height: 200px;
    min-height: 24px;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    padding: 0;
    line-height: 1.5;
}
.btn-action {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #0069d9;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.btn-action:hover { background: #0056b3; }

/* دکمهٔ فایل */
.file-btn-wrapper { position: relative; display: flex; align-items: center; }
.file-btn { cursor: pointer; font-size: 1.2rem; color: #aaa; transition: color 0.2s; }
.file-btn:hover { color: #fff; }
#file-input { display: none; }
.file-indicator {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e53935;
    color: #fff;
    font-size: 0.7rem;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* --------------------------- منوی زمینه (Context Menu) --------------------------- */
.custom-context-menu {
    display: none;
    position: absolute;
    background: #333;
    border: 1px solid #555;
    border-radius: 5px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 2000;
    min-width: 150px;
}
.custom-context-menu ul {
    list-style: none;
    padding: 5px 0;
    margin: 0;
}
.custom-context-menu li {
    padding: 8px 15px;
    cursor: pointer;
    color: #ddd;
    display: flex;
    align-items: center;
    gap: 10px;
}
.custom-context-menu li:hover { background: #444; color: #fff; }
.custom-context-menu li.disabled { color: #666; cursor: default; }
.custom-context-menu li.disabled:hover { background: transparent; }

/* --------------------------- کد داخل پیام --------------------------- */
.code-wrapper {
    background: var(--bg-dark);
    border-radius: 6px;
    margin: 10px 0;
    overflow: hidden;
    border: 1px solid var(--border-color);
}
.code-btn-group {
    display: flex;
    gap: 5px;
    padding: 5px 10px;
    background: #2d2d2d;
    border-bottom: 1px solid var(--border-color);
}
.code-action-btn {
    background: transparent;
    border: none;
    color: #aaa;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 4px;
}
.code-action-btn:hover { color: #fff; }

/* --------------------------------------------------------------
   هم‌ترازی دقیق شماره خطوط در بلوک کد (به‌روزرسانی)
   -------------------------------------------------------------- */
.code-content-wrapper {
    display: grid;
    grid-template-columns: auto 1fr;   /* ستون شماره‌ها + متن کد */
    align-items: start;                /* هر سطر در بالای خودش */
}



/* هر شماره در یک بلوک جدا */
.line-numbers-code span {
    display: block;                     /* هر شماره در خط خودش */
}

/* متن کد */
.code-block {
    margin: 0;
    padding: 1000px;
    overflow-x: auto;                  /* اسکرول افقی برای خطوط طولانی */
    direction: ltr;
    text-align: left;
    line-height: 1.5;                  /* دقیقاً همان مقدار line‑height بالا */
    white-space: pre;                  /* نگهداری فضا و شکست خطوط همانند پیش‌فرمت */
}

/* کد داخل <pre><code> */
.code-block code {
    display: block;
    line-height: inherit;              /* از line‑height والد استفاده می‌کند */
    white-space: pre;                  /* همانند بالا */
}

/* جلوگیری از شکست اعداد داخل خود <code> (اگر از span استفاده می‌کنید) */
.code-block code span {
    white-space: nowrap;
}

/* --------------------------------------------------------------
   تاریخچه (Sidebar‑right)
   -------------------------------------------------------------- */
.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}
.new-chat-btn,
.login-btn {
    width: 80%;
    padding: 10px;
    margin-bottom: 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center !important; /* ✅ اصلاح شد: center برای تراز عمودی */
    gap: 8px;
    font-weight: bold;
    /*text-align: left !important;  ← این خط را حذف کنید چون در flex کاربردی ندارد */
    justify-content: left ;  ✅ این خط محتوا را به چپ می‌برد */
    padding-left: 10px;
    padding-right: 30px;
    background: #444;
    color: #fff;
	margin-right: auto;
    direction: ltr !important;
}
.new-chat-btn { background: var(--accent-color); color: #fff;
justify-content: center ; width: 100%;}
.new-chat-btn:hover { background: var(--accent-hover); }
.login-btn:hover { background: #555; }

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}
.history-item {
    padding: 10px;
    background: #333;
    border-radius: 5px;
    margin-bottom: 8px;
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
}
.history-item:hover { background: #444; }
.history-item.active {
    background: var(--msg-user-bg);
    border-right: 3px solid var(--accent-color);
}
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.history-title {
    font-weight: bold;
    color: #eee;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
    font-size: 0.8rem;
}
.delete-chat-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 0.9rem;
}
.delete-chat-btn:hover { color: #ff5252; }
.history-model-badge {
    font-size: .7rem;
    color: #aaa;
    margin-top: 4px;
    display: block;
}

/* --------------------------- لودینگ --------------------------- */
.loading-dots span {
    animation: blink 1.4s infinite both;
    font-size: 20px;
    margin: 0 2px;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink {
    0%   { opacity: 0.2; }
    20%  { opacity: 1;   }
    100% { opacity: 0.2; }
}

/* --------------------------- جهت متن --------------------------- */
.is-ltr { direction: ltr; text-align: left; }

/* --------------------------- جستجو در ویرایشگر --------------------------- */
.search-bar-container {
    display: none;
    background-color: #2d2d2d;
    padding: 5px 10px;
    border-bottom: 1px solid #444;
    align-items: center;
    gap: 10px;
    flex-direction: row;
}
.search-bar-container.active { display: flex; }
.search-input-wrapper {
    position: relative;
    flex-grow: 1;
    display: flex;
    align-items: center;
}
.search-input {
    width: 100%;
    background: #1e1e1e;
    border: 1px solid #555;
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: inherit;
    outline: none;
}
.search-input:focus { border-color: #007acc; }
.search-options {
    display: flex;
    gap: 5px;
    align-items: center;
}
.search-btn {
    background: #3c3c3c;
    border: 1px solid #555;
    color: #ccc;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 12px;
}
.search-btn:hover {
    background: #505050;
    color: #fff;
}
.search-info {
    color: #aaa;
    font-size: 12px;
    min-width: 60px;
    text-align: left;
}

/* --------------------------- شماره خطوط در ویرایشگر --------------------------- */
.line-numbers {
    width: 40px;
    background-color: #1e1e1e;
    color: #858585;
    text-align: right;
    padding: 10px 5px;
    font-family: 'Consolas','Monaco','Courier New',monospace;
    font-size: 14px;
    line-height: 1.5;
    user-select: none;
    overflow: hidden;
    border-left: 1px solid #333;
    direction: ltr;
    white-space: pre;
}

/* --------------------------- نوار وضعیت (Status Bar) --------------------------- */
.editor-status-bar {
    height: 25px;
    background-color: #007acc;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    font-size: 12px;
    user-select: none;
    border-top: 1px solid #005a9e;
}
.status-item { display: flex; align-items: center; gap: 5px; }
.theme-toggle-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    padding: 2px 5px;
    border-radius: 3px;
    display: flex;
    align-items: center;
}
.theme-toggle-btn:hover { background-color: rgba(255,255,255,0.2); }

/* --------------------------- تم روشن (Light Theme) --------------------------- */
body.light-theme {
    background-color: #f3f3f3;
    color: #333;
}
body.light-theme .app-container { background-color: #fff; }

/* سایدبار چپ (ویرایشگر) */
body.light-theme .left-sidebar {
    background-color: #f0f0f0;
    border-left: 1px solid #ccc;
}
body.light-theme .left-sidebar-header {
    background-color: #e0e0e0;
    color: #333;
    border-bottom: 1px solid #ccc;
}

/* تب‌ها */
body.light-theme .editor-tabs {
    background-color: #e0e0e0;
    border-bottom: 1px solid #ccc;
}
body.light-theme .editor-tab {
    background-color: #dcdcdc;
    color: #333;
    border: 1px solid #ccc;
    border-bottom: none;
}
body.light-theme .editor-tab.active {
    background-color: #fff;
    color: #000;
    border-bottom: 1px solid #fff;
}

/* شماره خطوط */
body.light-theme .line-numbers {
    background-color: #f0f0f0;
    color: #666;
    border-left: 1px solid #ccc;
}

/* ویرایشگر */
body.light-theme #code-editor {
    background-color: #fff;
    color: #333;
}

/* کنسول */
body.light-theme .console-container { background-color: #fff; border-top: 1px solid #ccc; }
body.light-theme .console-header { background-color: #f0f0f0; color: #333; border-bottom: 1px solid #ccc; }

/* نوار وضعیت */
body.light-theme .editor-status-bar {
    background-color: #e0e0e0;
    color: #333;
    border-top: 1px solid #ccc;
}

/* جستجو */
body.light-theme .search-bar-container {
    background-color: #e0e0e0;
    border-bottom: 1px solid #ccc;
}
body.light-theme .search-input {
    background: #fff;
    border: 1px solid #ccc;
    color: #333;
}

/* سایدبار راست (تاریخچه) */
body.light-theme .sidebar {
    background-color: #f8f9fa;
    border-left: 1px solid #ddd;
}
body.light-theme .sidebar-header {
    background-color: #e9ecef;
    border-bottom: 1px solid #ddd;
}
body.light-theme .history-item {
    border-bottom: 1px solid #eee;
    color: #333;
}
body.light-theme .history-item:hover { background-color: #e2e6ea; }

/* محتوای اصلی */
body.light-theme .main-content { background-color: #fff; }
body.light-theme .input-area {
    background-color: #f8f9fa;
    border-top: 1px solid #ddd;
}
body.light-theme #input {
    background-color: #fff;
    color: #000 !important;
    border: 1px solid #ccc;
}

/* پیام‌های چت – تم روشن */
body.light-theme .msg.user {
    background-color: #e3f2fd;
    border-right: 3px solid #2196f3;
}
body.light-theme .msg.user .msg-content,
body.light-theme .msg.user .msg-content p,
body.light-theme .msg.user .msg-content li,
body.light-theme .msg.user .msg-content span {
    color: #000000 !important;
}
body.light-theme .msg.ai {
    background-color: #f1f8e9;
    border-right: 3px solid #4caf50;
}
body.light-theme .msg.ai .msg-content,
body.light-theme .msg.ai .msg-content p,
body.light-theme .msg.ai .msg-content li,
body.light-theme .msg.ai .msg-content span,
body.light-theme .msg.ai .msg-content div,
body.light-theme .msg.ai .msg-content h1,
body.light-theme .msg.ai .msg-content h2,
body.light-theme .msg.ai .msg-content h3 {
    color: #000000 !important;
}
body.light-theme .msg.ai .msg-content code {
    color: #d63384 !important;
    background-color: #f0f0f0;
    padding: 2px 5px;
    border-radius: 4px;
}
body.light-theme .msg.ai .msg-content pre {
    background-color: #f5f5f5 !important;
    color: #333333 !important;
    border: 1px solid #ddd;
    border-radius: 4px;
}
body.light-theme .msg.ai .msg-content a {
    color: #0056b3 !important;
}
body.light-theme .msg.user .msg-content code {
    color: #c7254e !important;
    background-color: #f9f2f4;
}

/* دکمه خروج (logout) */
.logout-circle {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: #dc3545;
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-right: 10px;
}
.katex, 
.katex-display {
    direction: ltr !important;
	text-align: left !important;
    unicode-bidi: embed;
    
}

/* کانتینر فرمول‌های نمایشی */
.katex-display {
    display: block;
    text-align: center !important;
    margin: 1em 0;
    overflow-x: auto;
    overflow-y: hidden;
}

/* فرمول‌های inline */
.katex {
    direction: ltr !important;
    display: inline-block;
}

/* استایل‌های اضافی برای دکمه نمایش متن خام */
.code-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
}
.raw-code-block {
  display: none; /* پیش‌فرض مخفی */
  background-color: #282c34;
  color: #abb2bf;
  padding: 10px;
  border-radius: 6px;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 0.9em;
  overflow-x: auto;
}
/* کلاس کمکی برای مخفی کردن عناصر توسط جاوااسکریپت */
.hidden-by-js {
  display: none !important;
}
/* استایل‌های جدید برای شماره ردیف کد */
.code-content-wrapper {
  display: flex;
  
  grid-template-columns: auto 1fr;   /* ستون شماره‌ها + متن کد */
  align-items: start;                /* هر سطر در بالای خودش */
  position: relative;
  background-color: #282c34; /* رنگ پس‌زمینه پیش‌فرض کد */
  border-radius: 6px;
  overflow: hidden;
}

/* ستون شماره‌ها */
.line-numbers-code {
    background-color: #21252b;
    color: #636d83;
    padding: 38px 5px;                 /* کمی کمتر پدینگ برای هم‌ترازی بهتر */
    text-align: right;
    user-select: none;
    font-family: monospace;
    font-size: .9em;
    line-height: 1.58;                  /* هم‌ارز با line‑height متن کد */
    width: 5ch;                        /* عرض ثابت برای ۴ رقم */
    min-width: 5ch;                    /* در صورت استفاده از min‑width هم ثابت می‌ماند */
    box-sizing: border-box;            /* پدینگ/حاشیه در محاسبهٔ عرض */
    border-left: 1px solid #181a1f;
    direction: ltr;
    white-space: nowrap;               /* از شکست اعداد جلوگیری می‌کند */
    overflow: hidden;                  /* اگر عدد بزرگتر شد، مخفی می‌شود (به‌جای شکست) */
}

/* متن کد */
.code-block {
    margin: 0;
    padding: 10px;
    overflow-x: auto;                  /* اسکرول افقی برای خطوط طولانی */
    direction: ltr;
    text-align: left;
    line-height: 1.5;                  /* دقیقاً همان مقدار line‑height بالا */
    white-space: pre;                  /* نگهداری فضا و شکست خطوط همانند پیش‌فرمت */
}
/* کد داخل <pre><code> */
.code-block code {
    display: block;
    line-height: inherit;              /* از line‑height والد استفاده می‌کند */
    white-space: pre;                  /* همانند بالا */
}
/* جلوگیری از شکست اعداد داخل خود <code> (اگر از span استفاده می‌کنید) */
.code-block code span {
    white-space: nowrap;
}


/* استایل‌های مودال لاگین */
.login-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.login-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.login-modal-content {
  background: var(--sidebar-bg, #252526);
  padding: 25px;
  border-radius: 10px;
  width: 90%;
  max-width: 350px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  border: 1px solid var(--border-color, #3e3e42);
  color: var(--text-color, #d4d4d4);
}
.login-modal-title {
  text-align: center;
  margin-bottom: 20px;
  font-size: 1.2rem;
  font-weight: bold;
}
.login-form-group {
  margin-bottom: 15px;
}
.login-form-group label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.9rem;
}
.login-form-group input {
  width: 100%;
  padding: 10px;
  border-radius: 5px;
  border: 1px solid var(--border-color, #3e3e42);
  background: var(--input-bg, #3c3c3c);
  color: var(--text-color, #d4d4d4);
  box-sizing: border-box;
}
.login-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}
.login-btn-action {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
}
.login-btn-primary {
  background-color: var(--accent-color, #007acc);
  color: white;
}
.login-btn-secondary {
  background-color: #555;
  color: white;
}
.login-btn-logged-in {
  background-color: #2e7d32; /* سبز برای وضعیت لاگین */
  cursor: default;
}

/* استایل‌های طرح‌ها */
.plan-boxes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 15px;
}
.plan-box {
  padding: 10px;
  border: 1px solid #555;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.2s;
}
.plan-box:hover {
  background: #333;
}
.plan-box.selected {
  background: #007acc;
  border-color: #005fa3;
}
.plan-name {
  font-weight: bold;
}
.plan-tokens {
  font-size: 0.9rem;
  color: #aaa;
}

    /* استایل برای نوار هشدار قرمز */
    #auth-warning-bar {
        background-color: #ffebee; /* پس‌زمینه قرمز خیلی روشن */
        color: #c62828; /* متن قرمز تیره */
        text-align: center;
        padding: 10px;
        font-weight: bold;
        font-family: Tahoma, sans-serif;
        display: none; /* در ابتدا مخفی است */
        border-bottom: 1px solid #ef9a9a;
        z-index: 1000;
        position: relative;
    }
/* استایل‌های نوار پیش‌نمایش فایل */
.file-preview-bar {
  display: none; /* پیش‌فرض مخفی */
  flex-wrap: wrap; /* اجازه می‌دهد فایل‌ها به خط بعد بروند */
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  background-color: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid var(--border-color, #3e3e42);
  min-height: 50px; /* ✅ ارتفاع حداقل برای اینکه دیده شود */
  max-height: 120px; /* ✅ ارتفاع حداکثر */
  overflow-y: auto; /* ✅ اسکرول اگر فایل‌ها زیاد شدند */
}

.file-preview-bar.active {
  display: flex;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: rgba(0, 122, 204, 0.15);
  border: 1px solid rgba(0, 122, 204, 0.4);
  color: #ffffff !important; /* رنگ والد */
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  white-space: nowrap;
  user-select: none;
  transition: all 0.2s ease;
  height: 36px;
}

.file-chip span {
  color: #ffffff !important; /* ✅ رنگ فرزندان (span) را هم اجبارا سفید کن */
}

.file-chip:hover {
  background-color: rgba(0, 122, 204, 0.3);
  border-color: rgba(0, 122, 204, 0.6);
  color: #ffffff !important; /* ✅ رنگ متن سفید در حالت هاور */
}

/* دکمه حذف روی چیپ */
.file-chip-remove {
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2); /* ✅ پس‌زمینه کمی روشن‌تر */
  color: #ffffff !important; /* ✅ رنگ ضربدر سفید */
  font-size: 14px;
  line-height: 1;
  margin-right: 4px;
  flex-shrink: 0;
}

.file-chip-remove:hover {
  background-color: #ff4d4d;
  color: #ffffff !important;
}

/* مخفی کردن نشانگر قدیمی */
.file-indicator {
  display: none !important;
}




#auth-warning-bar {
  cursor: pointer;   /* نشانگر ماوس به شکل اشاره‌گر تغییر می‌کند */
}
/* 1️⃣ اجازه انتخاب متن در پیام‌ها */
.msg-content{
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
}

/* 2️⃣ (اختیاری) جلوگیری از تغییر اسکرول هنگام اضافه کردن محتوا */
.chat-scroll-anchor{
  position: relative;
  top: 0;
}
/* جدول داخل پیام‌های ربات */
.msg.assistant .msg-content table {
    width: 100%;               /* یا هر عرض دلخواه */
    border-collapse: collapse; /* برای یکپارچگی حاشیه‌ها */
    margin: 0.8rem 0;
}

/* حاشیه سلول‌ها */
.msg.assistant .msg-content table th,
.msg.assistant .msg-content table td {
    border: 2px solid var(--border-color, #555);
    padding: 0.4rem 0.6rem;
}

/* رنگ پس‌زمینه سرستون (اختیاری) */
.msg.assistant .msg-content table th {
    background: var(--sidebar-bg, #252526);
    color: var(--text-color, #d4d4d4);
}
/* متن عمومی */
.msg.assistant .msg-content {
    color: #e0e0e0;               /* رنگ متن */
    line-height: 1.6;
}

/* لینک‌ها */
.msg.assistant .msg-content a {
    color: #4da6ff;               /* رنگ لینک */
    text-decoration: underline;
}








/* کدهای inline */
.msg.assistant .msg-content code {
    background: #2d2d2d;
    color: #ffcb6b;
    padding: 0 0.7rem;
    border-radius: 3px;
}

/* بلوک‌های کد (pre) */
.msg.assistant .msg-content pre {
    background: #1e1e1e;
    color: #c5c8c6;
    padding: 0.8rem;
    border-radius: 5px;
    overflow-x: auto;
}



.msg .msg-content pre,
.msg .msg-content pre code {
    line-height: 1.5;           /* کدها هم فشرده‌تر می‌شوند */
    padding: 0.9rem;            /* فضای داخلی را کمی کم می‌کنیم */
}
.msg .msg-content table td,
.msg .msg-content table th {
    line-height: 1.4;
    padding: 0.3rem 0.5rem;     /* فضای داخل سلول‌ها */
}


.thinking-box {
    background-color: #2d2d2d;
    border-right: 4px solid #ff9800;
    border-radius: 8px;
    padding: 10px;
    margin: 10px 0;
    font-size: 0.9em;
    color: #ccc;
}
.thinking-box summary {
    cursor: pointer;
    font-weight: bold;
    color: #ff9800;
}
.thinking-content {
    margin-top: 8px;
    padding: 5px;
    background-color: #1e1e1e;
    border-radius: 5px;
    white-space: pre-wrap;
}
.main-response-content {
    margin-top: 10px;
}


.assistant-msg.deleted-count {
    color: #888;
    font-style: italic;
    margin-top: 8px;
}