/* UNIFIED SIDEBAR - Chat & AI Assistant Styles
-----------------------------------------------------------------*/

:root {
	/* Shared colors */
	--sidebar-bg-dark: #1a1c21;
	--sidebar-bg-darker: #1b1e24;
	--sidebar-bg-light: #21252d;
	--sidebar-text: #e2e8f0;
	--sidebar-text-muted: #94a3b8;
	--sidebar-border: rgba(255, 255, 255, 0.1);
	
	/* AI specific */
	--ai-primary: #6366f1;
	--ai-secondary: #8b5cf6;
	--ai-bubble: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
	
	/* User chat specific */
	--chat-primary: #3b82f6;
	--chat-secondary: #2563eb;
	--chat-bubble: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
	
	/* Received messages (same for both) */
	--bubble-received: #2d3748;
	
	/* Right sidebar sizing (default keeps legacy behavior) */
	--rightSidebarWidth: 260px;
}

#ai-sidebar-app {
	height: 100%;
}

/* UNIFIED SIDEBAR WRAPPER */
.sidebar-unified {
	background: linear-gradient(180deg, var(--sidebar-bg-dark) 0%, var(--sidebar-bg-darker) 100%) !important;
	height: 100%;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.chat-window-wrapper {
	width: var(--rightSidebarWidth) !important;
}

/* Ensure sidebar is above page-container (z-index: 10) when visible */
.chat-window-wrapper.visible {
	z-index: 1001 !important;
}

.sidr {
	width: var(--rightSidebarWidth) !important;
}

.sidr.right {
	right: calc(-1 * var(--rightSidebarWidth)) !important;
}

.sidr.left {
	left: calc(-1 * var(--rightSidebarWidth)) !important;
}

/* Poignée de redimensionnement (bord gauche du panneau) — glisser pour
   élargir/réduire jusqu'à la moitié de l'écran. Petite pastille au survol. */
.sidebar-resize-handle {
	display: block;
	position: absolute;
	top: 0;
	left: -7px;
	width: 14px;
	height: 100%;
	cursor: ew-resize;
	z-index: 22;
	background: transparent;
	transition: background 0.15s ease;
}

.sidebar-resize-handle:hover,
body.sidebar-resizing .sidebar-resize-handle {
	background: linear-gradient(90deg, rgba(99, 102, 241, 0), rgba(99, 102, 241, 0.28));
}

/* Pastille avec icône de préhension (visible au survol / pendant le drag) */
.sidebar-resize-handle::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 1px;
	transform: translateY(-50%) scale(0.6);
	width: 18px;
	height: 34px;
	border-radius: 9px;
	/* Exactement 3 points de préhension empilés au centre (pas de motif répété) */
	background:
		radial-gradient(circle 1.5px at 50% calc(50% - 7px), #fff 99%, transparent 100%) no-repeat,
		radial-gradient(circle 1.5px at 50% 50%,             #fff 99%, transparent 100%) no-repeat,
		radial-gradient(circle 1.5px at 50% calc(50% + 7px), #fff 99%, transparent 100%) no-repeat,
		linear-gradient(135deg, #6366f1, #8b5cf6);
	box-shadow: 0 3px 10px rgba(99, 102, 241, 0.5);
	opacity: 0;
	transition: opacity 0.15s ease, transform 0.15s ease;
	pointer-events: none;
}

.sidebar-resize-handle:hover::before,
body.sidebar-resizing .sidebar-resize-handle::before {
	opacity: 1;
	transform: translateY(-50%) scale(1);
}

body.sidebar-resizing,
body.sidebar-resizing .chat-window-wrapper,
body.sidebar-resizing .chat-window-wrapper * {
	user-select: none !important;
}

/* Pas d'animation de largeur pendant le drag (fluidité) */
body.sidebar-resizing .chat-window-wrapper {
	transition: none !important;
}

/* ============================================================
   MODE OVERLAY (toutes largeurs) — le panneau glisse PAR-DESSUS la
   page, sans jamais la décaler. Le menu de gauche se réduit en mode
   « mini » (géré côté JS) pour rester accessible pendant l'ouverture.
   ============================================================ */
.chat-window-wrapper {
	right: calc(-1 * var(--rightSidebarWidth)) !important;
	top: 0 !important;
	height: 100% !important;
	z-index: 1001 !important;
	transition: right 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

body.open-menu-right .chat-window-wrapper {
	right: 0 !important;
	box-shadow: -10px 0 40px -10px rgba(0, 0, 0, 0.5);
}

body.rtl .chat-window-wrapper {
	right: auto !important;
	left: calc(-1 * var(--rightSidebarWidth)) !important;
}
body.rtl.open-menu-right .chat-window-wrapper {
	left: 0 !important;
	right: auto !important;
}

/* Aucun décalage de la page : on neutralise TOUTES les anciennes règles
   translateX / left qui poussaient le contenu, l'en-tête et le menu. */
body.open-menu-right .page-content,
body.open-menu-right .header,
body.open-menu-right .page-sidebar,
body.open-menu-right .footer-widget,
body.open-menu-right .page-container,
body.open-menu-right .page-content .admin-bar {
	transform: none !important;
	left: auto !important;
}

.sidebar-unified .inner-content {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
}

/* MINI NAVIGATION TABS
-----------------------------------------------------------------*/
.sidebar-mini-nav {
	display: flex;
	align-items: center;
	background: var(--sidebar-bg-darker);
	border-bottom: 1px solid var(--sidebar-border);
	padding: 8px 10px;
	gap: 6px;
	flex-shrink: 0;
}

.sidebar-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	color: var(--sidebar-text-muted);
	transition: color 0.2s;
	text-decoration: none;
}

.sidebar-close:hover {
	color: var(--sidebar-text);
	text-decoration: none;
}

.sidebar-close i {
	font-size: 20px;
}

.sidebar-tab {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 8px;
	border-radius: 8px;
	cursor: pointer;
	color: var(--sidebar-text-muted);
	background: transparent;
	border: 1px solid transparent;
	transition: all 0.2s ease;
	font-size: 12px;
	white-space: nowrap;
}

.sidebar-tab i {
	font-size: 16px;
}

/* Hide text by default, show only on active */
.sidebar-tab span {
	font-weight: 500;
	display: none;
}

.sidebar-tab:hover {
	background: var(--sidebar-bg-light);
	color: var(--sidebar-text);
}

.sidebar-tab.active {
	background: var(--sidebar-bg-light);
	color: var(--sidebar-text);
	border-color: var(--sidebar-border);
	padding: 8px 14px;
}

/* Show text only on active tab */
.sidebar-tab.active span {
	display: inline;
}

.sidebar-tab[data-tab="ai"].active {
	background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(139, 92, 246, 0.2));
	border-color: rgba(99, 102, 241, 0.3);
}

.sidebar-tab[data-tab="ai"] i {
	color: var(--ai-primary);
}

.sidebar-tab-ai-icon {
	width: 16px;
	height: 16px;
	object-fit: contain;
}

.sidebar-logout {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	color: var(--sidebar-text-muted);
	transition: color 0.2s;
	text-decoration: none;
	margin-left: 4px;
}

.sidebar-logout:hover {
	color: #ef4444;
	text-decoration: none;
}

/* TAB CONTENTS
-----------------------------------------------------------------*/
.sidebar-content {
	flex: 1;
	min-height: 0;
	overflow: hidden;
	display: flex;
	flex-direction: column;
}

.sidebar-content > * {
	flex: 1;
	display: flex;
	flex-direction: column;
	min-height: 0;
}

.sidebar-tab-content {
	display: none;
	flex-direction: column;
	flex: 1;
	min-height: 0;
	overflow: hidden;
	animation: fadeIn 0.2s ease;
}

.sidebar-tab-content.active {
	display: flex;
}

/* SECTION TITLES */
.sidebar-section-title {
	color: var(--sidebar-text-muted);
	font-size: 10px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	padding: 12px 15px 6px;
}

/* SECTIONS TAB
-----------------------------------------------------------------*/
#tab-sections {
	overflow-y: auto;
	padding-bottom: 20px;
}

.sidebar-sections-grid {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	gap: 8px;
	padding: 8px 15px;
}

.sidebar-sections-grid .btn-nav {
	background: var(--sidebar-bg-light) !important;
	border: 1px solid var(--sidebar-border) !important;
	color: var(--sidebar-text) !important;
	border-radius: 8px !important;
	padding: 10px 14px !important;
	margin: 0 !important;
	text-align: center !important;
	transition: all 0.2s !important;
	min-width: 44px;
}

/* Hide text in section buttons, show only icon */
.sidebar-sections-grid .btn-nav .depart,
.sidebar-sections-grid .btn-nav .bold {
	display: none !important;
}

.sidebar-sections-grid .btn-nav .pull-left {
	float: none !important;
}

.sidebar-sections-grid .btn-nav:hover {
	background: var(--sidebar-bg-dark) !important;
	border-color: var(--chat-primary) !important;
}

.sidebar-sections-grid .btn-nav.active {
	background: linear-gradient(135deg, rgba(59, 130, 246, 0.2), rgba(37, 99, 235, 0.2)) !important;
	border-color: var(--chat-primary) !important;
}

.sidebar-sections-grid .btn-nav i {
	margin-right: 0;
	font-size: 16px;
}

.sidebar-session-info {
	padding: 10px 15px;
}

.session-user {
	color: var(--sidebar-text);
	font-size: 12px;
}

.session-user i {
	margin-right: 6px;
	color: var(--sidebar-text-muted);
}

/* CHAT TAB - LIST VIEW
-----------------------------------------------------------------*/
#tab-chat {
	overflow-y: auto;
}

.sidebar-chat-status {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 15px;
	background: var(--sidebar-bg-light);
	margin: 10px 15px;
	border-radius: 8px;
}

.sidebar-chat-status span {
	color: var(--sidebar-text);
	font-size: 12px;
}

.status-indicator {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #6b7280;
}

.status-indicator.online {
	background: #10b981;
	box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
}

.status-indicator.busy {
	background: #ef4444;
}

.status-indicator.away {
	background: #f59e0b;
}

.sidebar-chat-list {
	padding: 0 10px;
}

/* Chat user items */
.sidebar-chat-list .user-details-wrapper {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	margin: 4px 0;
	border-radius: 8px;
	cursor: pointer;
	background: transparent;
	transition: background 0.2s;
}

.sidebar-chat-list .user-details-wrapper:hover {
	background: var(--sidebar-bg-light);
}

.sidebar-chat-list .user-details-wrapper.active {
	background: var(--sidebar-bg-light);
}

.sidebar-chat-list .user-profile {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: var(--sidebar-bg-light);
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.sidebar-chat-list .user-profile img {
	width: 100%;
	height: 100%;
	border-radius: 50%;
	object-fit: cover;
}

.sidebar-chat-list .user-details {
	flex: 1;
	min-width: 0;
}

.sidebar-chat-list .user-name {
	color: var(--sidebar-text);
	font-size: 13px;
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.sidebar-chat-list .user-more {
	color: var(--sidebar-text-muted);
	font-size: 11px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* CONVERSATION VIEW (shared structure for user chat & AI)
-----------------------------------------------------------------*/
.sidebar-conv-header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 15px;
	background: var(--sidebar-bg-darker);
	border-bottom: 1px solid var(--sidebar-border);
	flex-shrink: 0;
}

.sidebar-conv-header.ai-header {
	justify-content: space-between;
}

.sidebar-back-btn {
	background: transparent;
	border: none;
	color: var(--sidebar-text-muted);
	cursor: pointer;
	padding: 6px 10px;
	border-radius: 6px;
	transition: all 0.2s;
}

.sidebar-back-btn:hover {
	background: var(--sidebar-bg-light);
	color: var(--sidebar-text);
}

.conv-user-info {
	display: flex;
	align-items: center;
	gap: 10px;
}

.conv-user-name {
	color: var(--sidebar-text);
	font-size: 14px;
	font-weight: 500;
}

/* MESSAGES CONTAINER (unified)
-----------------------------------------------------------------*/
.sidebar-messages-container {
	flex: 1;
	overflow-y: auto;
	padding: 15px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	background: linear-gradient(180deg, var(--sidebar-bg-dark) 0%, var(--sidebar-bg-darker) 100%);
}

.sidebar-messages-container::-webkit-scrollbar {
	width: 5px;
}

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

.sidebar-messages-container::-webkit-scrollbar-thumb {
	background: var(--sidebar-bg-light);
	border-radius: 3px;
}

/* MESSAGE BUBBLES (unified)
-----------------------------------------------------------------*/
.chat-message {
	display: flex;
	gap: 8px;
	max-width: 90%;
	animation: fadeInUp 0.25s ease;
}

.chat-message-sent {
	align-self: flex-end;
	flex-direction: row-reverse;
}

.chat-message-received {
	align-self: flex-start;
}

.chat-bubble {
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 13px;
	line-height: 1.5;
	word-wrap: break-word;
}

.chat-bubble-sent {
	background: var(--chat-bubble);
	color: white;
	border-bottom-right-radius: 4px;
}

.chat-bubble-received {
	background: var(--bubble-received);
	color: var(--sidebar-text);
	border-bottom-left-radius: 4px;
}

.chat-message-time {
	font-size: 10px;
	color: var(--sidebar-text-muted);
	margin-top: 4px;
	text-align: right;
	display: none; /* Hidden by default, shown on click */
}

.chat-message-received .chat-message-time {
	text-align: left;
}

.chat-content-wrapper {
	display: flex;
	flex-direction: column;
}

.chat-message-author {
	font-size: 11px;
	color: var(--sidebar-text-muted);
	margin-bottom: 3px;
	font-weight: 500;
}

/* OLD CHAT FORMAT SUPPORT (for messages from engine_chat.php)
-----------------------------------------------------------------*/
.sidebar-messages-container .user-details-wrapper {
	display: flex;
	flex-direction: column;
	margin-bottom: 8px;
	max-width: 85%;
}

.sidebar-messages-container .user-details-wrapper.pull-right {
	align-self: flex-end;
	align-items: flex-end;
}

.sidebar-messages-container .user-details-wrapper:not(.pull-right) {
	align-self: flex-start;
	align-items: flex-start;
}

.sidebar-messages-container .user-details-wrapper .sent_time {
	font-size: 11px;
	color: var(--sidebar-text-muted);
	margin-bottom: 4px;
	display: block;
	width: auto;
}

.sidebar-messages-container .user-details-wrapper .sent_time.off {
	display: none;
	margin-top: 4px;
	margin-bottom: 0;
}

.sidebar-messages-container .user-details-wrapper .user-details {
	display: block;
}

.sidebar-messages-container .user-details-wrapper .bubble {
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 13px;
	line-height: 1.5;
	word-wrap: break-word;
	max-width: 100%;
}

.sidebar-messages-container .user-details-wrapper:not(.pull-right) .bubble {
	background: var(--bubble-received);
	color: var(--sidebar-text);
	border-bottom-left-radius: 4px;
}

.sidebar-messages-container .user-details-wrapper.pull-right .bubble,
.sidebar-messages-container .user-details-wrapper .bubble.sender {
	background: var(--chat-bubble);
	color: white;
	border-bottom-right-radius: 4px;
	border-bottom-left-radius: 14px;
}

.sidebar-messages-container .user-details-wrapper .clearfix {
	display: none;
}

.sidebar-messages-container .inner-scroll-content {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

/* AI specific bubble colors */
.ai-message {
	display: flex;
	gap: 8px;
	max-width: 90%;
	min-width: 0; /* autorise le rétrécissement sous la largeur du contenu (pas de scroll-x) */
	animation: fadeInUp 0.25s ease;
}

.ai-message-user {
	align-self: flex-end;
	flex-direction: row-reverse;
}

.ai-message-assistant {
	align-self: flex-start;
}

.ai-message-error {
	align-self: center;
}

.ai-bubble {
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 13px;
	line-height: 1.5;
	word-wrap: break-word;
}

.ai-bubble-user {
	background: var(--ai-bubble);
	color: white;
	border-bottom-right-radius: 4px;
}

.ai-msg-image-icon {
	font-size: 11px;
	opacity: 0.7;
	margin-right: 5px;
	vertical-align: middle;
}

.ai-bubble-assistant {
	background: var(--bubble-received);
	color: var(--sidebar-text);
	border-bottom-left-radius: 4px;
}

.ai-bubble-assistant strong {
	/* --ai-primary (#6366f1) est trop sombre sur la bulle (#2d3748) : ~2,9:1.
	   Indigo clair #a5b4fc → ~6,7:1, lisible tout en restant dans la charte. */
	color: #a5b4fc;
}

.ai-bubble-assistant code {
	background: rgba(99, 102, 241, 0.2);
	padding: 2px 5px;
	border-radius: 3px;
	font-size: 12px;
}

.ai-bubble-wrap {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0; /* clé : sans ça, une source/table nowrap fige la largeur → scroll-x */
}

.ai-rag-badge {
	font-size: 10px;
	opacity: 0.8;
}

.ai-rag-badge.ai-rag-supabase {
	color: #34d399;
}

.ai-rag-badge.ai-rag-full_doc {
	color: #f59e0b;
}

.ai-rag-badge.ai-rag-disabled {
	color: var(--sidebar-text-muted);
}

.ai-bubble-assistant ul,
.ai-bubble-assistant ol {
	margin: 6px 0;
	padding-left: 18px;
}

.ai-bubble-assistant li {
	margin: 3px 0;
}

/* Titres markdown (## / ###) : bornés à la taille de la bulle pour éviter le
   saut de police face au corps (13px) — sinon tailles navigateur (~19/15px). */
.ai-bubble-assistant h2,
.ai-bubble-assistant h3,
.ai-bubble-assistant h4 {
	color: #fff;
	font-weight: 700;
	line-height: 1.35;
	margin: 10px 0 4px;
}
.ai-bubble-assistant h2 { font-size: 15px; }
.ai-bubble-assistant h3 { font-size: 14px; }
.ai-bubble-assistant h4 { font-size: 13px; }
.ai-bubble-assistant h2:first-child,
.ai-bubble-assistant h3:first-child,
.ai-bubble-assistant h4:first-child { margin-top: 0; }

.ai-bubble-error {
	background: rgba(239, 68, 68, 0.2);
	color: #fca5a5;
	border-radius: 8px;
	font-size: 12px;
}

.ai-bubble-error i {
	margin-right: 5px;
}

/* AVATAR */
.ai-avatar,
.chat-avatar {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.ai-avatar {
	background: linear-gradient(135deg, var(--ai-primary), var(--ai-secondary));
}

.chat-avatar {
	background: var(--sidebar-bg-light);
}

.ai-avatar i,
.chat-avatar i {
	color: white;
	font-size: 12px;
}

.ai-avatar-small {
	width: 28px;
	height: 28px;
	border-radius: 50%;
	background: transparent;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ai-avatar-small i {
	color: white;
	font-size: 12px;
}

.ai-avatar-small img {
	width: 22px;
	height: 22px;
	object-fit: contain;
	transition: transform 3s ease;
}

.ai-avatar-small:hover img {
	transform: rotate(360deg);
}

/* TYPING INDICATOR */
.chat-typing,
.ai-typing {
	display: flex;
	gap: 4px;
	padding: 10px 14px;
}

.chat-typing span,
.ai-typing span {
	width: 6px;
	height: 6px;
	border-radius: 50%;
	animation: typingBounce 1.4s infinite ease-in-out both;
}

.chat-typing span {
	background: var(--chat-primary);
}

.ai-typing span {
	background: var(--ai-primary);
}

.chat-typing span:nth-child(1),
.ai-typing span:nth-child(1) { animation-delay: -0.32s; }
.chat-typing span:nth-child(2),
.ai-typing span:nth-child(2) { animation-delay: -0.16s; }
.chat-typing span:nth-child(3),
.ai-typing span:nth-child(3) { animation-delay: 0s; }

@keyframes typingBounce {
	0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
	40% { transform: scale(1); opacity: 1; }
}

/* INPUT WRAPPER (unified)
-----------------------------------------------------------------*/
.sidebar-input-wrapper {
	display: flex;
	gap: 8px;
	padding: 12px 15px;
	background: var(--sidebar-bg-darker);
	border-top: 1px solid var(--sidebar-border);
	flex-shrink: 0;
}

.sidebar-input-wrapper textarea {
	flex: 1;
	background: var(--sidebar-bg-light);
	border: 1px solid var(--sidebar-border);
	border-radius: 10px;
	padding: 10px 14px;
	color: var(--sidebar-text);
	font-size: 14px;
	resize: none;
	min-height: 40px !important;
	height: auto !important;
	max-height: 100px;
	overflow-y: auto;
	transition: border-color 0.2s;
	font-family: inherit;
}

.sidebar-input-wrapper textarea:focus {
	outline: none;
	border-color: var(--chat-primary);
}

.sidebar-input-wrapper textarea::placeholder {
	color: var(--sidebar-text-muted);
}

#tab-ai .sidebar-input-wrapper textarea:focus {
	border-color: var(--ai-primary);
}

.sidebar-input-wrapper button {
	border: none;
	border-radius: 10px;
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	transition: transform 0.2s, box-shadow 0.2s;
	flex-shrink: 0;
}

#chat-send-btn {
	background: linear-gradient(135deg, var(--chat-primary), var(--chat-secondary));
}

#chat-send-btn:hover {
	transform: scale(1.05);
	box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

#ai-send-btn,
#ai-send-btn-learn {
	background: linear-gradient(135deg, var(--ai-primary), var(--ai-secondary));
}

#ai-send-btn:hover,
#ai-send-btn-learn:hover {
	transform: scale(1.05);
	box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.sidebar-input-wrapper button i {
	color: white;
	font-size: 14px;
}

/* AI HEADER ACTIONS */
.ai-header-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.ai-header-actions button {
	background: transparent;
	border: none;
	color: var(--sidebar-text-muted);
	cursor: pointer;
	padding: 6px 10px;
	border-radius: 6px;
	transition: all 0.2s;
}

.ai-header-actions button:hover {
	background: var(--sidebar-bg-light);
	color: var(--sidebar-text);
}

/* MODE TOGGLE */
.ai-mode-toggle {
	display: flex;
	align-items: center;
	cursor: pointer;
	padding: 4px 8px;
	border-radius: 4px;
	transition: background 0.2s;
}

.ai-mode-toggle:hover {
	background: var(--sidebar-bg-light);
}

.ai-mode-toggle input {
	display: none;
}

.ai-mode-label {
	font-size: 14px;
	opacity: 0.5;
	transition: opacity 0.2s;
}

.ai-mode-toggle input:checked + .ai-mode-label {
	opacity: 1;
}

/* CONTEXT BADGE */
.ai-context-badge {
	padding: 8px 15px;
	background: var(--sidebar-bg-light);
	color: var(--sidebar-text-muted);
	font-size: 11px;
	border-bottom: 1px solid var(--sidebar-border);
}

.ai-context-badge i {
	margin-right: 6px;
	color: var(--ai-primary);
}

/* AI CHAT PANEL */
#ai-chat-panel {
	display: flex;
	flex-direction: column;
	flex: 1;
	overflow: hidden;
}

#ai-messages-container {
	flex: 1;
	min-height: 0;
	overflow-y: auto;
}

/* SUGGESTIONS */
#ai-suggestions,
.ai-suggestions {
	padding: 10px 15px;
	background: var(--sidebar-bg-darker);
	border-top: 1px solid var(--sidebar-border);
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	flex-shrink: 0;
}

.ai-suggestion {
	background: var(--sidebar-bg-light);
	border: 1px solid var(--sidebar-border);
	color: var(--sidebar-text-muted);
	padding: 5px 10px;
	border-radius: 16px;
	font-size: 11px;
	cursor: pointer;
	transition: all 0.2s;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 100%;
}

.ai-suggestion:hover {
	background: var(--ai-primary);
	border-color: var(--ai-primary);
	color: white;
}

/* ANIMATIONS
-----------------------------------------------------------------*/
@keyframes fadeInUp {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes fadeIn {
	from { opacity: 0; }
	to { opacity: 1; }
}

.animated.fadeInUp {
	animation: fadeInUp 0.25s ease;
}

.animated.fadeIn {
	animation: fadeIn 0.25s ease;
}

/* AI TOGGLE BUTTON IN TOP NAVBAR (keep for compatibility) */
.ai-assistant-toggle {
	position: relative;
	cursor: pointer;
}

.ai-assistant-toggle .ai-toggle-btn i {
	transition: color 0.2s, transform 0.2s;
}

.ai-assistant-toggle:hover .ai-toggle-btn i {
	color: #4f46e5 !important;
	transform: scale(1.1);
}

.ai-assistant-toggle.active .ai-toggle-btn i {
	color: #4f46e5 !important;
}

/* RESPONSIVE
-----------------------------------------------------------------*/
@media (max-width: 480px) {
	.sidebar-tab span {
		display: none;
	}
	
	.sidebar-tab {
		padding: 8px;
	}
}

/* Tool / Vision badges */
.ai-tool-badge, .ai-vision-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	font-size: 10px;
	margin-right: 4px;
	vertical-align: middle;
}
.ai-tool-badge { background: rgba(59,130,246,.15); color: #3b82f6; }
.ai-vision-badge { background: rgba(168,85,247,.15); color: #a855f7; }

/* PRINT */
@media print {
	.sidebar-unified,
	.chat-window-wrapper {
		display: none !important;
	}
}

/* Shared assistant identity: the existing ribbon mark, at rest or thinking. */
.assistant-brand {
	position: relative;
	display: inline-grid;
	place-items: center;
	width: var(--assistant-icon-size, 22px);
	height: var(--assistant-icon-size, 22px);
	flex-shrink: 0;
	vertical-align: middle;
}
.assistant-brand > img { display: block; width: 100%; height: 100%; object-fit: contain; }
.assistant-brand.is-thinking > img {
	transform-origin: center;
	animation: assistant-think-turn 6s linear infinite;
}
.ai-response-identity { display: flex; align-items: center; gap: 13px; min-height: 38px; padding: 4px 2px; }
.ai-response-identity .assistant-brand.is-thinking { --assistant-icon-size: 28px; }
.ai-thinking-label { color: var(--sidebar-text-muted); font-size: 12px; line-height: 1.5; }
@keyframes assistant-think-turn { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
	.assistant-brand, .assistant-brand > img { animation: none !important; transition: none !important; }
	.ai-avatar-small:hover .assistant-brand > img { transform: none; }
}
