/* ==========================================
// فایل: public/ai/css/style.css
========================================== */

/* --- Fonts --- */
@font-face { font-family: 'Dana'; src: url('/chat-ai/fonts/dana/Dana-Regular.ttf') format('truetype'); font-weight: 400; }
@font-face { font-family: 'Dana'; src: url('/chat-ai/fonts/dana/Dana-Medium.ttf') format('truetype'); font-weight: 500; }
@font-face { font-family: 'Dana'; src: url('/chat-ai/fonts/dana/Dana-Bold.ttf') format('truetype'); font-weight: 700; }
/* --- Fonts (Fallback) --- */
@font-face { 
    font-family: 'Dana'; 
    src: url('../fonts/dana/Dana-Regular.ttf') format('truetype'); 
    font-weight: 400; 
}
@font-face { 
    font-family: 'Dana'; 
    src: url('../fonts/dana/Dana-Medium.ttf') format('truetype'); 
    font-weight: 500; 
}
@font-face { 
    font-family: 'Dana'; 
    src: url('../fonts/dana/Dana-Bold.ttf') format('truetype'); 
    font-weight: 700; 
}

:root {
    --bg-app: #f0f4f9;
    --bg-sidebar: #f8fafc;
    --bg-surface: rgba(255, 255, 255, 0.75);
    --bg-surface-solid: #ffffff;
    --bg-input: #ffffff;
    --bg-message-user: #e3e3e3;
    --text-main: #1f1f1f;
    --text-muted: #444746;
    --accent: #0b57d0;
    --accent-hover: #0842a0;
    --accent-light: #e0e7ff;
    --border: rgba(0, 0, 0, 0.08);
    --success: #10b981;
    --danger: #ef4444;
    --glass-blur: blur(24px);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.1);
    --radius-full: 999px;
    --radius-lg: 24px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --chat-font-size: 15px; 
}

[data-theme="dark"] {
    --bg-app: #131314; --bg-sidebar: #1e1f20; --bg-surface: rgba(30, 31, 32, 0.75);
    --bg-surface-solid: #1e1f20; --bg-input: #1e1f20; --bg-message-user: #282a2c;
    --text-main: #e3e3e3; --text-muted: #c4c7c5; --accent: #a8c7fa;
    --accent-hover: #d3e3fd; --accent-light: rgba(168, 199, 250, 0.15);
    --border: rgba(255, 255, 255, 0.1); --shadow-md: 0 4px 20px rgba(0,0,0,0.3); --shadow-lg: 0 10px 40px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: rgba(0, 0, 0, 0.15); border-radius: 10px; }
[data-theme="dark"] ::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); }

body { font-family: 'Dana', Tahoma, sans-serif; background-color: var(--bg-app); color: var(--text-main); display: flex; height: 100vh; overflow: hidden; transition: background-color 0.3s; }
.glass-panel { background: var(--bg-surface); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur); }
.icon-btn { background: transparent; border: none; color: var(--text-muted); width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition); flex-shrink: 0; }
.icon-btn:hover { background-color: var(--border); color: var(--text-main); }
.hidden-btn { display: none !important; }

/* --- Sidebar Overlay --- */
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); z-index: 10001; opacity: 0; visibility: hidden; transition: var(--transition); }
.sidebar-overlay.active { opacity: 1; visibility: visible; }

/* --- Sidebar & Folders & Drag --- */
.sidebar { width: 280px; height: 100%; display: flex; flex-direction: column; border-left: 1px solid var(--border); z-index: 10002; transition: var(--transition); flex-shrink: 0; }
/* فقط در دسکتاپ مخفی کردن فرزندان هنگام بسته شدن اعمال شود */
@media (min-width: 769px) {
    .sidebar.collapsed { width: 0; border-left: none; }
    .sidebar.collapsed * { opacity: 0; pointer-events: none; }
}

.sidebar-header { padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-shrink: 0; }
.sidebar-header-auth {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}
.btn-new-chat { background: var(--bg-surface-solid); border: 1px solid var(--border); color: var(--text-main); padding: 10px 16px; border-radius: var(--radius-lg); display: flex; align-items: center; gap: 8px; font-family: inherit; font-weight: 500; cursor: pointer; flex: 1; box-shadow: var(--shadow-md); transition: var(--transition); }

.sidebar-search-box { display: flex; align-items: center; background: var(--bg-input); margin: 0 16px 10px; padding: 8px 12px; border-radius: var(--radius-full); border: 1px solid var(--border); color: var(--text-muted); }
.sidebar-search-box input { border: none; background: none; outline: none; margin-right: 8px; font-family: inherit; color: var(--text-main); width: 100%; font-size: 13px; }

.sidebar-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
[data-auth-visible][hidden],
[data-guest-visible][hidden] {
    display: none !important;
}
.sidebar-guest-msg {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.chat-history {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px;
    -webkit-overflow-scrolling: touch;
}

.chat-folder, .chat-item { transition: transform 0.2s, background 0.2s; position: relative; }
.chat-folder.dragging, .chat-item.dragging { opacity: 0.5; background: var(--border); transform: scale(0.98); }
.drop-zone.drag-over { background: var(--accent-light); border-radius: var(--radius-sm); border: 1px dashed var(--accent); }

.pinned::after { content: '📌'; position: absolute; left: 8px; top: 12px; font-size: 12px; opacity: 0.8; }
.chat-folder.pinned .folder-header::after { content: '📌'; position: absolute; left: 40px; top: 10px; font-size: 12px; }

.folder-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; color: var(--text-main); font-weight: 700; font-size: 13px; position: relative; }
.folder-header:hover { background: var(--border); }
.folder-title { display: flex; align-items: center; gap: 8px; color: var(--text-muted); pointer-events: none; }
.folder-actions { display: flex; align-items: center; }
.folder-actions .btn-options { opacity: 0; width: 24px; height: 24px; margin-left: 4px; }
.folder-header:hover .btn-options { opacity: 1; }
.folder-header .chevron { transition: transform 0.3s ease; pointer-events: none; }
.chat-folder.open .chevron { transform: rotate(180deg); }

/* رفع مشکل بیرون‌زدگی پوشه‌ها */
.folder-content { 
    max-height: 0; 
    overflow: hidden; 
    opacity: 0; 
    visibility: hidden; 
    padding: 0;
    transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease; 
    list-style: none; 
    margin-right: 12px; 
    border-right: 1px solid var(--border); 
}
.chat-folder.open .folder-content { 
    max-height: 800px; 
    opacity: 1; 
    visibility: visible; 
    padding-top: 4px; 
    padding-bottom: 4px; 
}

.chat-list { list-style: none; min-height: 20px; }
.chat-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text-main); cursor: grab; margin-bottom: 2px; }
.chat-item.nested { padding: 8px 12px; margin-right: 4px; }
.chat-item:hover { background-color: var(--border); }
.chat-info { flex: 1; display: flex; flex-direction: column; overflow: hidden; pointer-events: none; }
.chat-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-date { font-size: 10px; color: var(--text-muted); margin-top: 2px; }

.chat-actions { display: flex; align-items: center; }
.chat-item .btn-options { opacity: 0; width: 28px; height: 28px; }
.chat-item:hover .btn-options { opacity: 1; }



.options-menu { 
    position: fixed; 
    width: 140px; 
    border-radius: var(--radius-md); 
    border: 1px solid var(--border); 
    box-shadow: var(--shadow-lg); 
    background: var(--bg-surface-solid); 
    display: none; 
    flex-direction: column; 
    overflow: hidden; 
  
    z-index: 10005 !important; 
    opacity: 0; 
    transform: translateY(-10px); 
    transition: 0.2s; 
}
.options-menu.show { display: flex; opacity: 1; transform: translateY(0); }
.menu-item { background: none; border: none; padding: 10px 16px; text-align: right; font-family: inherit; color: var(--text-main); font-size: 13px; cursor: pointer; }
.menu-item:hover { background-color: var(--border); }
.menu-item.delete-btn { color: var(--danger); }

/* --- Sidebar Footer --- */
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.settings-trigger-btn { width: 100%; display: flex; align-items: center; gap: 10px; background: transparent; border: 1px solid var(--border); color: var(--text-main); cursor: pointer; padding: 10px; border-radius: var(--radius-md); font-family: inherit; font-size: 13px; font-weight: bold; transition: var(--transition); }
.settings-trigger-btn:hover { background: var(--border); }
.profile-btn { width: 100%; display: flex; align-items: center; gap: 12px; background: transparent; border: none; color: var(--text-main); cursor: pointer; padding: 8px; border-radius: var(--radius-md); transition: var(--transition); font-family: inherit; }
.sidebar-avatar { width: 32px; height: 32px; background: var(--accent); color: white; font-size: 14px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; }

/* --- Main Content --- */
.main-content { flex: 1; display: flex; flex-direction: column; position: relative; height: 100%; min-width: 0; }
.top-nav {
    position: absolute;
    top: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    min-height: 52px;
    z-index: 50;
    overflow: visible;
    box-sizing: border-box;
}
.top-nav .icon-btn {
    width: 36px;
    height: 36px;
}
.top-nav .icon-btn svg {
    width: 20px;
    height: 20px;
}
.nav-right, .nav-left { display: flex; align-items: center; gap: 8px; overflow: visible; }
.nav-left { gap: 6px; }
.app-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex-shrink: 0;
    padding: 0 2px;
}
.app-brand-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    display: block;
    border-radius: 10px;
    padding: 2px;
    background: var(--bg-surface-solid, #fff);
    border: 1px solid var(--border, rgba(0, 0, 0, 0.08));
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.app-title {
    margin: 0;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-main, #1f1f1f);
    line-height: 1.1;
    white-space: nowrap;
}
[data-theme="dark"] .app-brand-logo {
    background: #282a2c;
    border-color: rgba(255, 255, 255, 0.1);
}

.custom-dropdown { position: relative; user-select: none; }
.dropdown-header { display: flex; align-items: center; gap: 10px; background: var(--bg-surface-solid); border: 1px solid var(--border); padding: 8px 16px; border-radius: var(--radius-full); font-size: 13px; font-weight: 500; cursor: pointer; box-shadow: var(--shadow-md); color: var(--text-main); }
.dropdown-list { position: absolute; top: calc(100% + 8px); left: 0; min-width: 160px; background: var(--bg-surface-solid); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-lg); overflow: hidden; display: none; flex-direction: column; opacity: 0; transform: translateY(-10px); transition: 0.2s; z-index: 100; }
.custom-dropdown.active .dropdown-list { display: flex; opacity: 1; transform: translateY(0); }
.dropdown-list li { padding: 12px 16px; font-size: 13px; cursor: pointer; color: var(--text-main); }
.dropdown-list li:hover { background-color: var(--border); }
.dropdown-list li.active { color: var(--accent); font-weight: 700; background-color: var(--accent-light); }
.theme-toggle-btn { width: 38px; height: 38px; border-radius: 50%; background: var(--bg-surface-solid); border: 1px solid var(--border); color: var(--text-main); display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: var(--shadow-md); transition: var(--transition); }

.chat-container { flex: 1; overflow-y: auto; padding: 16px 20px 140px; display: flex; flex-direction: column; gap: 32px; max-width: 900px; margin: 0 auto; width: 100%; scroll-behavior: smooth; }
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    margin: auto;
    gap: 16px;
    padding: 24px 16px;
    animation: fadeIn 0.8s ease;
}
.welcome-screen h2 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--text-main, #1f1f1f);
    line-height: 1.5;
    max-width: 320px;
}
.welcome-icon { font-size: 48px; margin-bottom: 16px; background: -webkit-linear-gradient(45deg, #0b57d0, #a8c7fa); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.message { display: flex; gap: 16px; align-items: flex-start; width: 100%; animation: fadeIn 0.4s ease; }
.message-body { flex: 1; line-height: 1.8; font-size: var(--chat-font-size); color: var(--text-main); transition: font-size 0.2s; }
.user-message .message-body { background-color: var(--bg-message-user); padding: 12px 20px; border-radius: 20px; border-top-right-radius: 4px; max-width: fit-content; display: inline-block; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; }

/* --- Input Area & Uploads --- */
.input-section { position: absolute; bottom: 0; left: 0; right: 0; padding: 0 20px 20px; display: flex; flex-direction: column; align-items: center; background: linear-gradient(to top, var(--bg-app) 80%, transparent); z-index: 40; }
.input-wrapper { position: relative; width: 100%; max-width: 860px; border-radius: var(--radius-lg); background: var(--bg-input); border: 1px solid var(--border); padding: 8px; box-shadow: var(--shadow-md); transition: var(--transition); display: flex; flex-direction: column; overflow: visible; }
.input-wrapper .file-preview-area { overflow: hidden; border-radius: 12px 12px 0 0; }
.input-wrapper:focus-within { border-color: var(--accent); box-shadow: var(--shadow-lg); }

/* استایل‌های پیش‌نمایش فایل ارتقا یافته */
.file-preview-area { display: flex; gap: 10px; padding: 0 10px; flex-wrap: wrap; }
.file-thumb-container { position: relative; margin-top: 10px; display: inline-flex; align-items: center; background: var(--bg-surface-solid); border: 1px solid var(--border); border-radius: 12px; padding: 4px; animation: scaleIn 0.2s ease; }
.file-thumb { width: 60px; height: 60px; border-radius: 8px; object-fit: cover; }
.doc-preview { padding: 8px 14px; gap: 8px; color: var(--text-main); font-weight: bold; font-size: 13px; }
.remove-file-btn { position: absolute; top: -8px; right: -8px; background: var(--bg-surface-solid); color: var(--danger); border: 1px solid var(--border); border-radius: 50%; width: 22px; height: 22px; font-size: 12px; font-weight: bold; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 5px rgba(0,0,0,0.2); transition: 0.2s; }
.remove-file-btn:hover { background: var(--danger); color: white; }
@keyframes scaleIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.input-controls { display: flex; align-items: flex-end; gap: 8px; width: 100%; transition: 0.3s; margin-top: 4px; }
.attach-btn, .send-btn, .voice-btn { background: transparent; border: none; color: var(--text-muted); width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition); flex-shrink: 0; }
.attach-btn:hover, .voice-btn:hover { background: var(--border); color: var(--text-main); }
.send-btn:hover { color: var(--accent); background: var(--accent-light); }
.send-btn.is-streaming-stop { color: var(--danger); background: rgba(239, 68, 68, 0.12); }
.send-btn.is-streaming-stop:hover { color: #dc2626; background: rgba(239, 68, 68, 0.2); }
.send-btn:disabled { opacity: 0.85; cursor: default; }
#chat-input:disabled { opacity: 0.65; cursor: not-allowed; }
textarea { flex: 1; background: transparent; border: none; outline: none; color: var(--text-main); font-family: inherit; font-size: 15px; resize: none; max-height: 200px; padding: 12px 10px; line-height: 1.5; }

/* استایل ضبط صدا */
.recording-ui, .voice-preview-ui { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 4px 12px; height: 44px; animation: fadeIn 0.3s ease; }
.recording-status { display: flex; align-items: center; gap: 12px; }
.pulse-dot { width: 12px; height: 12px; background-color: var(--danger); border-radius: 50%; animation: pulse 1.5s infinite; }
#recording-timer { font-family: monospace; font-size: 1.1rem; font-weight: 700; color: var(--text-main); letter-spacing: 1px; }
.recording-actions { display: flex; align-items: center; gap: 8px; }
.cancel-record-btn { color: var(--danger); }
.cancel-record-btn:hover { background: rgba(239,68,68,0.1); }
.stop-record-btn { color: var(--accent); }
.stop-record-btn:hover { background: var(--accent-light); }
.send-voice-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: white; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.send-voice-btn:hover { transform: scale(1.1); background: var(--accent-hover); box-shadow: 0 4px 12px rgba(11,87,208,0.4); }

audio { filter: sepia(20%) saturate(70%) grayscale(1) contrast(99%) invert(12%); border-radius: var(--radius-lg); }
[data-theme="dark"] audio { filter: invert(1); }

@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }

/* ================= Settings & Modals ================= */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; z-index: 10050; transition: opacity 0.3s; }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-box { width: 92%; max-width: 440px; border-radius: var(--radius-lg); position: relative; box-shadow: var(--shadow-lg); background: var(--bg-surface-solid); transform: translateY(20px) scale(0.95); transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.modal-overlay.active .modal-box { transform: translateY(0) scale(1); }
.close-modal { position: absolute; top: 16px; left: 16px; width: 32px; height: 32px; }

.settings-modal-box { padding: 30px 24px; min-height: 450px; display: flex; flex-direction: column; }
.settings-title { color: var(--text-main); font-size: 1.5rem; margin-bottom: 24px; text-align: center; }
.settings-content { flex: 1; display: flex; flex-direction: column; gap: 20px; }
.settings-card { background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px; }
.stat-item { display: flex; justify-content: space-between; align-items: center; font-size: 0.95rem; }
.stat-label { color: var(--text-muted); }
.stat-value { font-weight: bold; color: var(--text-main); }
.badge-pro { background: linear-gradient(45deg, #0b57d0, #a8c7fa); color: white; padding: 4px 10px; border-radius: 20px; font-size: 0.85rem; }
.progress-bar-bg { width: 100%; height: 6px; background: var(--border); border-radius: 10px; overflow: hidden; margin-top: 12px; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 10px; }

.settings-group { display: flex; flex-direction: column; gap: 10px; }
.settings-label { color: var(--text-main); font-weight: bold; font-size: 1rem; }
.range-slider-container { display: flex; align-items: center; gap: 12px; background: var(--bg-input); padding: 10px 16px; border-radius: var(--radius-md); border: 1px solid var(--border); }
.range-icon { color: var(--text-muted); font-weight: bold; }
input[type="range"] { flex: 1; accent-color: var(--accent); cursor: pointer; }
.font-preview { background: var(--bg-message-user); padding: 12px; border-radius: 12px; text-align: center; color: var(--text-main); font-size: var(--chat-font-size); transition: 0.2s; }
.danger-text { color: var(--text-muted); font-size: 0.85rem; text-align: center; }
.btn-danger-full { width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid var(--danger); padding: 14px; border-radius: var(--radius-md); font-family: inherit; font-size: 1rem; font-weight: bold; cursor: pointer; transition: 0.2s; }
.btn-danger-full:hover { background: var(--danger); color: white; }

.action-modal-box { padding: 30px 24px; }
.action-modal-box h3 { color: var(--text-main); font-size: 1.4rem; margin-bottom: 12px; }
.action-modal-box p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; margin-bottom: 24px; }
.custom-input { width: 100%; padding: 14px; margin-bottom: 24px; border: 1.5px solid var(--border); border-radius: var(--radius-md); background: var(--bg-input); color: var(--text-main); font-family: inherit; font-size: 1rem; outline: none; transition: 0.2s; }
.action-modal-buttons { display: flex; gap: 12px; justify-content: flex-end; }
.action-modal-buttons button { padding: 10px 20px; border: none; border-radius: var(--radius-md); font-family: inherit; font-size: 1rem; font-weight: bold; cursor: pointer; }
.btn-cancel { background: transparent; color: var(--text-muted); border: 1px solid var(--border) !important; }
.btn-cancel:hover { background: var(--border); }
.btn-confirm { background: var(--accent); color: white; }
.btn-confirm.danger-action { background: var(--danger); }

#toast-container { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 10060; display: flex; flex-direction: column; gap: 10px; pointer-events: none; width: 90%; max-width: 350px; }
.toast { background: var(--bg-surface-solid); color: var(--text-main); padding: 16px; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 0.95rem; border-right: 4px solid; animation: toastIn 0.4s forwards; }
.toast.success { border-right-color: var(--success); }
.toast.error { border-right-color: var(--danger); }
.toast.info { border-right-color: #3b82f6; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-30px); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ================= Footer Text & Icons ================= */
.footer-disclaimer { 
    text-align: center; 
    padding-top: 12px; 
    line-height: 1.5; 
    display: flex; 
    justify-content: center; 
    width: 100%;
}

.disclaimer-text { 
    font-size: 0.75rem; 
    color: var(--text-muted); 
    display: block; 
}

/* استایل دکمه کپسولی (پیش‌فرض در دسکتاپ مخفی است) */
.disclaimer-pill-btn {
    display: none; 
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
    margin: 0 auto;
}

.disclaimer-pill-btn:hover {
    background: var(--bg-surface-solid);
    color: var(--text-main);
    box-shadow: var(--shadow-md);
    border-color: var(--text-muted);
}

/* ================= Custom Audio Player (Telegram/WhatsApp Style) ================= */
.custom-audio-player {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-app);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 30px;
    flex: 1;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}
[data-theme="dark"] .custom-audio-player { background: #282a2c; }

.play-pause-btn {
    background: var(--accent);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(11, 87, 208, 0.3);
}
.play-pause-btn:hover { background: var(--accent-hover); transform: scale(1.05); }

.audio-track {
    flex: 1;
    height: 4px;
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
    position: relative;
}
[data-theme="dark"] .audio-track { background: rgba(255,255,255,0.1); }

.audio-progress {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.1s linear;
}

/* ساخت دکمه دایره‌ای روی نوار پیشرفت (شبیه واتس‌اپ) */
.audio-progress::after {
    content: '';
    position: absolute;
    right: -5px;
    top: -3px;
    width: 10px;
    height: 10px;
    background: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 4px rgba(0,0,0,0.2);
}

.audio-duration {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: monospace;
    font-weight: 600;
}


/* ================= بهینه‌سازی موبایل ================= */
@media (max-width: 768px) {
    
    .top-nav {
        position: fixed !important; /* ثابت شدن قطعی نسبت به صفحه گوشی */
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        z-index: 9999 !important; /* قرارگیری در بالاترین لایه ممکن */
        /* حفظ حالت شیشه‌ای (Glassmorphism) بعد از ثابت شدن */
        background: var(--bg-surface) !important;
        backdrop-filter: var(--glass-blur) !important;
        -webkit-backdrop-filter: var(--glass-blur) !important;
        border-bottom: 1px solid var(--border) !important;
        box-shadow: 0 4px 10px rgba(0,0,0,0.03) !important;
    }

    /* فاصلهٔ هدر ثابت موبایل روی chat-area-stack؛ نه padding دوبل روی chat-container */
    .chat-area-stack {
        padding-top: 92px !important;
    }

    .top-nav {
        padding: 8px 12px !important;
        min-height: 48px !important;
    }

    .chat-container {
        padding-top: 16px !important;
    }
    
    /* سایدبار در موبایل به طور پیش‌فرض خارج از کادر است */
    .sidebar { position: fixed; right: -300px; box-shadow: -5px 0 25px rgba(0,0,0,0.15); width: 280px; }
    /* وقتی کلاس open دارد، وارد صفحه می‌شود */
    .sidebar.open { right: 0; }
    
    #toggle-sidebar { display: none; }
    #open-sidebar { display: flex !important; }
    .app-brand { gap: 2px; }
    .app-brand-logo { width: 26px; height: 26px; border-radius: 8px; }
    .app-title { font-size: 0.62rem; }
    
    /* اطمینان از دیده شدن دکمه‌ها در موبایل (خنثی کردن استایل‌های collapsed) */
    .sidebar *:not([hidden]) { opacity: 1 !important; pointer-events: auto !important; }

    /* --- جایگزینی متن هشدار با کپسول (Pill) در موبایل --- */
    .footer-disclaimer .disclaimer-text { 
        display: none !important; 
    }
    
    .footer-disclaimer .disclaimer-pill-btn { 
        display: inline-flex !important; 
    }

    /* ================= بهینه‌سازی تایپوگرافی و فضا برای مطالعه در موبایل ================= */
    /* ۱. کاهش فاصله کل کانتینر چت از لبه‌های گوشی (باز کردن فضا) */
    .chat-container { 
        padding: 80px 10px 130px !important; 
        gap: 24px !important; 
    }

    /* ۲. کاهش فاصله بین آواتار و خود متن */
    .message { 
        gap: 10px !important; 
    }

    /* ۳. تنظیمات حرفه‌ای تایپوگرافی (شبیه کتاب‌خوان‌ها) */
    .message-body {
        line-height: 1.85 !important; 
        font-size: 0.95rem !important; 
        text-align: justify; 
        text-justify: inter-word;
    }

    /* ۴. کوچک کردن ظریف آواتارها در موبایل برای آزادسازی عرض صفحه */
    .ai-avatar, .user-avatar { 
        width: 28px !important; 
        height: 28px !important; 
        font-size: 13px !important; 
    }
    
    /* ۵. بهینه‌سازی پیام کاربر که در پس‌زمینه رنگی است */
    .user-message .message-body {
        padding: 10px 14px !important; 
        text-align: right; 
    }

    /* ================= طراحی Native اپلیکیشن برای المان‌های چت در موبایل ================= */

    /* ۱. لبه‌به‌لبه شدن جدول‌ها و اینفوباکس‌ها (Full-Width Tables) */
    .infobox-container, .table-responsive {
        margin: 16px -10px !important; 
        width: calc(100% + 20px) !important; 
        border-radius: 0 !important; 
        border-left: none !important;
        border-right: none !important;
    }
    
    .ai-table th, .ai-table td {
        white-space: nowrap; 
        padding: 14px 16px !important; 
    }

    /* ۲. لبه‌به‌لبه شدن باکس‌های بازشو (Details / Accordions) */
    .ai-message details {
        margin: 12px -10px !important;
        width: calc(100% + 20px) !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        padding: 4px 16px !important;
        background: var(--bg-surface-solid) !important;
    }
    
    .ai-message summary {
        padding: 14px 0 !important;
        font-size: 1.05rem !important;
    }

    /* ۳. تبدیل منوی پلاس به Bottom Sheet (بازشو از پایین گوشی) */
    .floating-menu {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100vw !important;
        max-width: 100% !important;
        border-radius: 28px 28px 0 0 !important; 
        padding: 24px 16px 32px !important;
        box-shadow: 0 -10px 40px rgba(0,0,0,0.15) !important;
        animation: slideUpBottomSheet 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
        z-index: 100000 !important;
    }
    
    [data-theme="dark"] .floating-menu {
        box-shadow: 0 -10px 50px rgba(0,0,0,0.5) !important;
    }

    /* خط تزیینی بالای Bottom Sheet (نشانگر درگ کردن) */
    .floating-menu::before {
        content: '';
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 5px;
        background: var(--border);
        border-radius: 10px;
    }

    .floating-menu .menu-item {
        padding: 16px !important; 
        font-size: 1.05rem !important;
    }

    /* ۴. استایل اپلیکیشنی برای کومبوباکس‌ها (Selects) در تنظیمات */
    select.custom-select {
        width: 100% !important;
        font-size: 1.05rem !important;
        padding: 18px 20px !important;
        border-radius: 16px !important;
        appearance: none !important; 
        -webkit-appearance: none !important;
        /* اضافه کردن آیکون فلش سفارشی به سمت چپ کومبوباکس */
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="%23444746" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 9l6 6 6-6"/></svg>') !important;
        background-repeat: no-repeat !important;
        background-position: left 16px center !important;
        box-shadow: inset 0 2px 6px rgba(0,0,0,0.02) !important;
    }
}

/* انیمیشن باز شدن Bottom Sheet باید خارج از تگ‌های دیگر تعریف شود */
@keyframes slideUpBottomSheet {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}