* { box-sizing: border-box; }

/* === CSS VARIABLES (THEMING) === */
:root {
	/* --- LIGHT THEME (DEFAULT NOW) --- */
	--text-main: #000000;
	--text-dim: rgba(0, 0, 0, 0.7);
	--text-legal: rgba(0, 0, 0, 0.5);
	
	/* LIGHT GLASS STYLE */
	--glass-bg: rgba(255, 255, 255, 0.8);
	--glass-border: rgba(255, 255, 255, 0.6); 
	--glass-border-top: rgba(255, 255, 255, 0.8);
	--glass-border-bottom: rgba(255, 255, 255, 0.4);
	--glass-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
	--glass-backdrop: blur(10px) saturate(200%) brightness(120%); 

	/* ELEMENTS */
	--sidebar-hover: rgba(255, 255, 255, 0.4);
	--sidebar-active-bg: rgba(0, 122, 204, 0.2); 
	--sidebar-active-border: rgba(0, 122, 204, 0.5);
	
	--input-bg: rgba(255, 255, 255, 0.4);
	--border-color-dim: rgba(0, 0, 0, 0.1);
	
	--bot-msg-headings: #000;
	--bot-msg-code-bg: rgba(0, 0, 0, 0.1);
	--bot-msg-code-color: #d63384; 
	--bot-msg-pre-bg: rgba(255, 255, 255, 0.6);
	--bot-msg-link: #0056b3;
	
	--scrollbar-thumb: rgba(0, 0, 0, 0.5);
	--scrollbar-track: rgba(0, 0, 0, 0.2);
	
	/* ПЕРЕМЕННЫЕ ДЛЯ СТАТУСА (СВЕТЛАЯ ТЕМА) */
	--status-text: #333333;
	--status-text-shadow: 0px 1px 4px rgba(255, 255, 255, 0.9);
	--status-border: rgba(0, 0, 0, 0.2);
	--status-backdrop: blur(10px) saturate(200%) brightness(120%);
	--status-box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* --- DARK THEME OVERRIDES --- */
body.dark-theme {
	--text-main: #ffffff;
	--text-dim: rgba(255, 255, 255, 0.7);
	--text-legal: rgba(255, 255, 255, 0.4);
	
	/* DARK GLASS STYLE */
	--glass-bg: rgba(0, 0, 0, 0.3);
	--glass-border: rgba(255, 255, 255, 0.3);
	--glass-border-top: rgba(255, 255, 255, 0.5);
	--glass-border-bottom: rgba(255, 255, 255, 0.1);
	--glass-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
	--glass-backdrop: blur(10px) saturate(200%) brightness(60%);

	/* ELEMENTS */
	--sidebar-hover: rgba(255, 255, 255, 0.1);
	--sidebar-active-bg: rgba(0, 122, 204, 0.5);
	--sidebar-active-border: rgba(255, 255, 255, 0.3);
	
	--input-bg: rgba(0, 0, 0, 0.25);
	--border-color-dim: rgba(255, 255, 255, 0.1);
	
	--bot-msg-headings: #fff;
	--bot-msg-code-bg: rgba(255, 255, 255, 0.15);
	--bot-msg-code-color: #ff7a7f;
	--bot-msg-pre-bg: rgba(0, 0, 0, 0.4);
	--bot-msg-link: #ffd200;
	
	--scrollbar-thumb: rgba(255, 255, 255, 0.9);
	--scrollbar-track: rgba(255, 255, 255, 0.5);
	
	/* ПЕРЕМЕННЫЕ ДЛЯ СТАТУСА (ТЁМНАЯ ТЕМА - ОРИГИНАЛ) */
	--status-text: rgba(255, 255, 255, 1);
	--status-text-shadow: 0px 1px 1px black, 0px 0px 3px black;
	--status-border: rgba(255, 255, 255, 0.5);
	--status-backdrop: blur(10px) saturate(200%) brightness(60%);
	--status-box-shadow: 0 5px 15px rgba(0,0,0,0.5);
}

/* --- ГЛОБАЛЬНОЕ СКРЫТИЕ РОДНОГО СКРОЛЛБАРА --- */
::-webkit-scrollbar { width: 0px; height: 0px; background: transparent; display: none; }
* { scrollbar-width: none; -ms-overflow-style: none; }

body { 
	margin: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	color: var(--text-main); 
	overflow: hidden; 
	background: rgb(29, 32, 65); 
	height: 100vh; 
	height: 100dvh; 
	display: flex;
	transition: color 0.3s;
}

#bg-video {
	position: fixed; top: 0; left: 0; width: 100%; height: 100%;
	object-fit: cover; z-index: -1;
	transform: translateZ(0);
}

/* === СТИЛЬ СТЕКЛА === */
.vision-glass {
	position: relative; 
	z-index: 1;
	background: var(--glass-bg);
	box-sizing: content-box;
	border: 1px solid var(--glass-border);
	border-top: 1px solid var(--glass-border-top);
	border-bottom: 1px solid var(--glass-border-bottom);
	box-shadow: 
		inset 1px 1px 20px rgba(255, 255, 255, 0.1),
		inset -1px -1px 20px rgba(255, 255, 255, 0.1),
		var(--glass-shadow);
	transition: background 0.3s, box-shadow 0.3s, border-color 0.3s;
}

.vision-glass::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1; 
	border-radius: inherit; 
	backdrop-filter: var(--glass-backdrop);
	pointer-events: none;
	transition: backdrop-filter 0.3s;
}

/* === SIDEBAR === */
.sidebar { 
	position: fixed; left: 10px; top: 10px; height: calc(100% - 20px); width: 300px; 
	z-index: 100; display: flex; flex-direction: column; border-radius: 24px;
}

.sidebar-header { 
	padding: 30px; font-size: 1.6rem; font-weight: 700; text-align: center; 
	text-shadow: 0 5px 15px rgba(0,0,0,0.1); letter-spacing: 1px;
	border-bottom: 1px solid var(--border-color-dim);
}

.category-list { flex: 1; overflow-y: auto; list-style: none; padding: 20px; margin: 0; display: flex; flex-direction: column; }

.category-item { 
	padding: 16px; margin-bottom: 10px; cursor: pointer; border-radius: 12px; 
	transition: 0.3s; color: var(--text-dim); font-weight: 500; border: 1px solid transparent;
	position: relative; z-index: 2; 
}

.category-item:hover { 
	background: var(--sidebar-hover); color: var(--text-main); 
	transform: scale(1.05) translateX(5px); box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.category-item.active { 
	background: var(--sidebar-active-bg); color: var(--text-main); 
	border: 1px solid var(--sidebar-active-border); box-shadow: 0 8px 20px rgba(0, 122, 204, 0.2); 
}

.category-item.theme-toggle {
	margin-top: 10px; border: 1px dashed var(--border-color-dim); text-align: center;
}

/* === CHAT CONTAINER === */
.chat-container {
	margin-left: 320px; width: calc(100% - 330px); height: 100%;
	position: relative; overflow: hidden;
}

.messages { 
	position: absolute; top: 0; left: 0; width: 100%; height: 100%;
	z-index: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; 
	padding-top: 100px; padding-bottom: 140px; padding-left: 10%; padding-right: 10%;
	-webkit-overflow-scrolling: touch;
}

.chat-header-wrapper {
	position: absolute; top: 20px; left: 0; width: 100%;
	display: flex; justify-content: center; z-index: 10; pointer-events: none;
}
.chat-header { 
	pointer-events: auto; padding: 15px 60px; border-radius: 30px;
	font-size: 1.2rem; font-weight: 600; text-shadow: 0 2px 5px rgba(0,0,0,0.1);
	color: var(--text-main);
}

/* === BOTTOM SHEET === */
.bottom-sheet {
	position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
	width: 100%; max-width: 850px; z-index: 20;
	display: flex; flex-direction: column; align-items: center;
	border-radius: 24px 24px 0 0; border-bottom: none; padding: 10px;
}

.input-slot {
	width: 100%; display: flex; align-items: flex-end; gap: 15px; padding: 8px 15px;
	background: var(--input-bg); border-radius: 20px;
	border: 1px solid var(--border-color-dim); box-shadow: inset 0 2px 10px rgba(0,0,0,0.1);
}

.legal-footer {
	margin-top: 6px; font-size: 0.75rem; color: var(--text-legal);
	text-align: center; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
	padding: 0 20px;
}

/* === СТИЛИ СООБЩЕНИЙ === */
.message { 
	max-width: 80%; padding: 20px 25px; line-height: 1.6; font-size: 1.05rem; 
	position: relative; border-radius: 20px; transform: translateZ(0); color: var(--text-main);
}

/* СТИЛЬ ЮЗЕРА ПО УМОЛЧАНИЮ (СВЕТЛАЯ ТЕМА) */
.message.user { 
	align-self: flex-end; border-bottom-right-radius: 4px; 
	background: rgba(10, 132, 255, 0.3); 
	border: 1px solid rgba(0, 0, 0, 0.1);
	color: #000000; /* Черный текст в светлой теме */
}

/* СТИЛЬ ЮЗЕРА ДЛЯ ТЕМНОЙ ТЕМЫ */
body.dark-theme .message.user {
	color: #ffffff !important;
	background: rgba(10, 132, 255, 0.8);
	border: 1px solid rgba(100, 200, 255, 0.3);
}

.message.bot { align-self: flex-start; border-bottom-left-radius: 4px; }

textarea { 
	flex: 1; background: transparent; border: none; font-size: 1.1rem; color: var(--text-main); font-family: inherit;
	outline: none; resize: none; overflow-y: hidden; padding: 10px 5px; line-height: 1.5;
	height: 44px; max-height: 200px; 
}
textarea::placeholder { color: var(--text-dim); }

button { 
	background: rgba(255,255,255,0.1); border: 1px solid var(--border-color-dim); 
	width: 44px; height: 44px; border-radius: 50%; color: var(--text-main); cursor: pointer; transition: 0.3s;
	display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-bottom: 2px;
}
button:hover { background: rgba(255,255,255,0.3); }

/* MARKDOWN */
.message.bot h1, .message.bot h2, .message.bot h3 {
	color: var(--bot-msg-headings); font-weight: 700; margin-top: 15px; margin-bottom: 8px; line-height: 1.3;
}
.message.bot h1 { font-size: 1.4em; border-bottom: 1px solid var(--border-color-dim); padding-bottom: 5px; }
.message.bot h3 { 
	background-color: var(--sidebar-active-bg); border: 1px solid var(--border-color-dim);
	border-radius: 6px; text-align: center;
}
.message.bot a { color: var(--bot-msg-link); text-decoration: none; border-bottom: 1px dotted var(--bot-msg-link); }
.message.bot code {
	background: var(--bot-msg-code-bg); padding: 2px 6px; border-radius: 4px;
	font-family: 'Menlo', 'Consolas', monospace; font-size: 0.9em; color: var(--bot-msg-code-color);
}
.message.bot pre {
	background: var(--bot-msg-pre-bg); padding: 12px; border-radius: 8px; overflow-x: auto; margin: 10px 0;
	border: 1px solid var(--border-color-dim);
}
.message.bot pre code { background: transparent; color: inherit; padding: 0; white-space: pre; }
.message.bot blockquote { border-left: 3px solid #4facfe; margin: 10px 0; padding-left: 12px; color: var(--text-dim); font-style: italic; }
.message.bot th, .message.bot td { border: 1px solid var(--border-color-dim); padding: 8px; text-align: left; }
.message.bot th { background: rgba(127, 127, 127, 0.1); font-weight: bold; }


/* === СТАТУС ОБРАБОТКИ (VISION GLASS STYLE - ADAPTIVE) === */
.processing-status {
	align-self: center;
	
	/* Размеры и текст */
	padding: 10px 25px;
	margin: 15px 0;
	border-radius: 10px;
	font-size: 0.9rem;
	font-weight: 500;
	
	/* Цвета через переменные */
	color: var(--status-text);
	text-shadow: var(--status-text-shadow);
	border: 1px solid var(--status-border);
	
	text-align: center;
	letter-spacing: 0.5px;
	
	/* Центрирование и ограничение ширины */
	max-width: fit-content;
	
	/* АНИМАЦИЯ */
	animation: glassPulse 2.5s infinite ease-in-out;
	
	/* Начальное состояние фона */
	backdrop-filter: var(--status-backdrop);
	box-shadow: var(--status-box-shadow);
}

@keyframes glassPulse {
	0%, 15% {
		backdrop-filter: var(--status-backdrop);
		box-shadow: var(--status-box-shadow);
		border-color: var(--status-border);
		transform: scale(1);
		background: var(--glass-bg);
	}
	50% {
		/* В середине цикла делаем его прозрачным/чистым */
		backdrop-filter: blur(0px) saturate(100%) brightness(100%);
		box-shadow: 0 0 5px rgba(0,0,0,0);
		border-color: transparent;
		transform: scale(0.98);
		background: rgba(0,0,0,0);
	}
	85%, 100% {
		backdrop-filter: var(--status-backdrop);
		box-shadow: var(--status-box-shadow);
		border-color: var(--status-border);
		transform: scale(1);
		background: var(--glass-bg);
	}
}


/* SCROLLBAR */
.custom-scrollbar {
	position: fixed; top: 0; bottom: 0; right: 0; width: 24px; padding-right: 6px; z-index: 9999;
	background: transparent; border-left: 1px solid var(--border-color-dim); opacity: 1; pointer-events: auto;
}
.scroll-track {
	position: absolute; top: 15px; bottom: 15px; left: 50%; transform: translateX(-50%); width: 2px;
	background: var(--scrollbar-track); border-radius: 10px; cursor: pointer; z-index: 1;
}
.scroll-thumb {
	position: absolute; left: 50%; transform: translateX(-50%); width: 8px;
	background: var(--scrollbar-thumb); border-radius: 4px; cursor: grab; min-height: 30px; z-index: 10;
}
.scroll-marker {
	position: absolute; left: 50%; transform: translateX(-50%); width: 8px; height: 15px;
	border-radius: 2px; border: 1px solid rgba(255, 255, 255, 0.5); pointer-events: none;
}
.scroll-marker.user { background-color: #0a84ff; z-index: 21; }
.scroll-marker.bot { background-color: #666; z-index: 21; }



/* === RTL SUPPORT (Hebrew) - FULL MIRROR === */
/* Сайдбар справа, Чат слева */

body.rtl {
	direction: rtl;
	text-align: right;
}

/* --- САЙДБАР --- */
body.rtl .sidebar {
	left: auto;   /* Отцепляем от левого края */
	right: 10px;  /* Прицепляем к правому */
	text-align: right;
}

/* --- ЧАТ --- */
body.rtl .chat-container {
	margin-left: 0;        /* Убираем отступ слева */
	margin-right: 320px;   /* Добавляем отступ справа под меню */
}

/* --- ЭЛЕМЕНТЫ МЕНЮ --- */
body.rtl .category-item {
	display: flex;
	align-items: center;
	/* В RTL flex-direction row идет справа налево */
}

/* Отступ иконки */
body.rtl .category-item .icon {
	margin-left: 10px;
	margin-right: 0;
}

/* АНИМАЦИЯ: При наведении сдвигаем ВЛЕВО (в центр экрана), 
   так как меню теперь справа */
body.rtl .category-item:hover { 
	transform: scale(1.05) translateX(-5px); 
}

/* --- СООБЩЕНИЯ --- */
body.rtl .message {
	text-align: right;
	direction: rtl;
}

/* --- ПОЛЕ ВВОДА --- */
/* Разворачиваем стрелку отправки (чтобы указывала влево) */
body.rtl button {
	transform: rotate(180deg); 
}

/* --- СКРОЛЛБАР --- */
/* Переносим скроллбар ВЛЕВО, чтобы он был у края экрана */
body.rtl .custom-scrollbar {
	right: auto;
	left: 0;
	border-left: none; /* Убираем левую границу */
	border-right: 1px solid var(--border-color-dim); /* Добавляем правую */
}