/**
 * Document Chat Component Styles
 * Version: 1.0
 * Description: Reusable chat interface for document Q&A with AI assistant
 * Dependencies: None
 *
 * Features:
 * - Left slide-out panel (800px wide)
 * - Streaming and non-streaming message support
 * - Markdown rendering styles
 * - Animated loading states
 * - Responsive message bubbles
 * - Status update indicators
 */

/* ===================================
   1. CHAT CONTAINER & LAYOUT
   =================================== */

/* Chat Interface Styles - Left Slide-Out Panel */
.document-chat-container {
	position: fixed;
	left: -800px;
	top: 0;
	width: 800px;
	height: 100vh;
	background-color: #f9f9f9;
	border-right: 2px solid #0070c9;
	box-shadow: 2px 0 15px rgba(34, 85, 170, 0.2);
	z-index: 9999;
	transition: left 0.3s ease-in-out;
	display: flex;
	flex-direction: column;
	padding: 0;
}

.document-chat-container.active {
	left: 0;
}

/* ===================================
   2. HEADER SECTION
   =================================== */

.chat-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 18px 20px;
	border-bottom: 3px solid #004d82;
	background: linear-gradient(135deg, #0070c9 0%, #005fa3 100%);
	flex-shrink: 0;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chat-header h3 {
	margin: 0;
	color: #ffffff;
	font-size: 18px;
	font-weight: 600;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
	letter-spacing: 0.3px;
}

.chat-toggle-section {
	display: flex;
	align-items: center;
	gap: 10px;
}

.toggle-label {
	font-size: 11px;
	color: #ffffff;
	display: flex;
	align-items: center;
	gap: 5px;
	font-weight: 500;
}

/* Clear Chat Button */
.chat-header button {
	padding: 6px 12px;
	font-size: 11px;
	background: rgba(255, 255, 255, 0.2);
	border: 1px solid rgba(255, 255, 255, 0.5);
	border-radius: 4px;
	color: #fff;
	cursor: pointer;
	font-weight: 500;
	transition: all 0.2s;
}

.chat-header button:hover {
	background: rgba(255, 255, 255, 0.3);
	border-color: rgba(255, 255, 255, 0.7);
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* ===================================
   3. CHAT BOX & MESSAGES
   =================================== */

.chat-box {
	flex: 1;
	overflow-y: auto;
	padding: 20px;
	background-color: #ffffff;
	margin: 0;
	box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-message {
	margin-bottom: 15px;
	padding: 12px 16px;
	border-radius: 8px;
	max-width: 85%;
	word-wrap: break-word;
	animation: fadeIn 0.3s ease-in;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
	font-family: 'Segoe UI', 'Open Sans', Arial, sans-serif;
}

.chat-message.user {
	background: linear-gradient(135deg, #e3f2fd 0%, #d1e7fd 100%);
	margin-left: auto;
	text-align: right;
	border: 1px solid #0070c9;
	border-left: 4px solid #0070c9;
}

.chat-message.bot {
	background-color: #f8f9fa;
	margin-right: auto;
	border: 1px solid #ddd;
	border-left: 4px solid #0070c9;
	position: relative;
	padding-bottom: 32px;
}

.chat-copy-btn {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	position: absolute;
	bottom: 8px;
	right: 8px;
	padding: 4px 9px;
	background: #ffffff;
	border: 1px solid #cbd5e1;
	border-radius: 6px;
	cursor: pointer;
	font-size: 11px;
	font-weight: 500;
	color: #64748b;
	box-shadow: 0 1px 3px rgba(0,0,0,0.06);
	transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.chat-copy-btn:hover {
	background: #f1f5f9;
	color: #1a2332;
	border-color: #94a3b8;
	box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.chat-copy-btn.copied {
	background: #f0fdf4;
	color: #16a34a;
	border-color: #86efac;
	box-shadow: 0 1px 3px rgba(22,163,74,0.15);
	opacity: 1;
	pointer-events: none;
}

.chat-copy-btn svg {
	flex-shrink: 0;
	transition: transform 0.15s;
}

.chat-copy-btn:hover svg {
	transform: scale(1.1);
}

.chat-message strong {
	display: block;
	margin-bottom: 6px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.3px;
}

.chat-message.bot strong {
	color: #005fa3;
}

.chat-message.user strong {
	color: #0070c9;
}

/* ===================================
   4. INPUT SECTION
   =================================== */

.chat-input-section {
	display: flex;
	gap: 10px;
	align-items: center;
	padding: 18px 20px;
	background-color: #f9f9f9;
	border-top: 2px solid #e8e8e8;
	flex-shrink: 0;
	box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05);
}

.chat-input-section input[type="text"] {
	flex: 1;
	padding: 12px 15px;
	border: 2px solid #ddd;
	border-radius: 6px;
	font-size: 14px;
	font-family: 'Segoe UI', 'Open Sans', Arial, sans-serif;
	transition: border-color 0.2s;
	background-color: #ffffff;
}

.chat-input-section input[type="text"]:focus {
	outline: none;
	border-color: #0070c9;
	box-shadow: 0 0 0 3px rgba(0, 112, 201, 0.1);
}

.chat-input-section button {
	padding: 12px 20px;
	background: linear-gradient(135deg, #0070c9 0%, #005fa3 100%);
	color: white;
	border: none;
	border-radius: 6px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	transition: all 0.2s;
	box-shadow: 0 2px 4px rgba(0, 112, 201, 0.2);
}

.chat-input-section button:hover {
	background: linear-gradient(135deg, #005fa3 0%, #004d82 100%);
	box-shadow: 0 4px 8px rgba(0, 112, 201, 0.3);
	transform: translateY(-1px);
}

.chat-input-section button:active {
	transform: translateY(0);
}

.chat-input-section button:disabled {
	background: #ccc;
	cursor: not-allowed;
	box-shadow: none;
	transform: none;
}

.chat-input-section .stop-btn {
	padding: 12px 20px;
	background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
	color: white;
	border: none;
	border-radius: 6px;
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	transition: all 0.2s;
	display: none;
	box-shadow: 0 2px 4px rgba(220, 53, 69, 0.2);
}

.chat-input-section .stop-btn:hover {
	background: linear-gradient(135deg, #c82333 0%, #bd2130 100%);
	box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
	transform: translateY(-1px);
}

.chat-input-section .stop-btn:active {
	transform: translateY(0);
}

.chat-input-section .stop-btn.show {
	display: block;
}

/* ===================================
   5. STATUS UPDATES & LOADING
   =================================== */

/* Real-time Status Update Styles - Enhanced with Animated Loading Icon */
.chat-status-container {
	margin: 10px 0;
	padding: 0;
	background-color: transparent;
	border: none;
	max-width: 85%;
	min-height: 50px;
}

.chat-status-message {
	display: flex;
	align-items: center;
	gap: 12px;
	padding: 12px 18px;
	margin: 0;
	background: linear-gradient(135deg, #f8f9fa 0%, #e8f0f7 100%);
	border-radius: 8px;
	font-size: 14px;
	color: #333;
	border: 1px solid #d1e7fd;
	box-shadow: 0 2px 8px rgba(0, 112, 201, 0.1);
	animation: fadeInScale 0.4s ease-out;
	transition: all 0.3s ease;
}

.chat-status-message.completed {
	background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
	border-color: #81c784;
	box-shadow: 0 2px 8px rgba(76, 175, 80, 0.15);
}

/* Animated Loading Icon - Star Spinner */
.chat-status-icon {
	width: 24px;
	height: 24px;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	position: relative;
}

.chat-status-icon .loading-spinner {
	width: 24px;
	height: 24px;
	position: relative;
	animation: spinRotate 2s linear infinite;
}

.chat-status-icon .loading-spinner svg {
	width: 100%;
	height: 100%;
}

.chat-status-icon .loading-spinner .star-path {
	fill: url(#blueGradient);
	opacity: 0.9;
	animation: starPulse 1.5s ease-in-out infinite;
}

/* Completed icon */
.chat-status-message.completed .chat-status-icon {
	animation: none;
}

.chat-status-message.completed .chat-status-icon .loading-spinner {
	animation: none;
}

.chat-status-icon .check-icon {
	font-size: 20px;
	color: #2e7d32;
	animation: checkBounce 0.5s ease-out;
}

.chat-status-text {
	flex: 1;
	font-weight: 500;
	color: #333;
	line-height: 1.4;
	letter-spacing: 0.2px;
}

.chat-status-message.completed .chat-status-text {
	color: #1b5e20;
	font-weight: 600;
}

/* Remove old progress bar styles - no longer used */
.chat-status-progress {
	display: none;
}

.chat-status-progress-bar {
	display: none;
}

.chat-loading {
	padding: 10px 15px;
	background-color: #fff3cd;
	border: 1px solid #ffc107;
	border-left: 4px solid #ffc107;
	border-radius: 6px;
	color: #856404;
	font-style: italic;
	margin: 8px 0;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
	font-size: 13px;
}

/* ===================================
   6. TOGGLE BUTTON (Fixed Position)
   =================================== */

.chat-toggle-btn {
	position: fixed;
	left: 0;
	top: 50%;
	transform: translateY(-50%);
	padding: 15px 10px;
	background: linear-gradient(135deg, #0070c9 0%, #005fa3 100%);
	color: white;
	border: none;
	border-radius: 0 8px 8px 0;
	cursor: pointer;
	font-size: 14px;
	font-weight: 600;
	z-index: 9998;
	box-shadow: 2px 2px 12px rgba(34, 85, 170, 0.3);
	transition: all 0.3s ease;
	writing-mode: vertical-rl;
	text-orientation: mixed;
	letter-spacing: 0.3px;
}

.chat-toggle-btn:hover {
	background: linear-gradient(135deg, #005fa3 0%, #004d82 100%);
	padding-right: 14px;
	box-shadow: 3px 3px 16px rgba(34, 85, 170, 0.4);
}

.chat-toggle-btn.chat-open {
	left: 800px;
}

/* ===================================
   7. CHAT FEATURE BUTTON (Optional)
   =================================== */

/* Prominent Document Chat Feature Button */
.chat-feature-btn {
	display: inline-block;
	padding: 12px 24px;
	background: #0070c9;
	color: white;
	border: none;
	border-radius: 8px;
	cursor: pointer;
	font-size: 15px;
	font-weight: bold;
	box-shadow: 0 4px 12px rgba(34, 85, 170, 0.3);
	transition: all 0.3s ease;
	margin: 15px 0;
	text-align: center;
}

.chat-feature-btn:hover {
	background: linear-gradient(135deg, #1a4280 0%, #0070c9 100%);
	box-shadow: 0 6px 16px rgba(34, 85, 170, 0.4);
	transform: translateY(-2px);
}

.chat-feature-btn:active {
	transform: translateY(0);
	box-shadow: 0 2px 8px rgba(34, 85, 170, 0.3);
}

.chat-feature-btn .icon {
	font-size: 18px;
	margin-right: 8px;
	animation: pulse 2s infinite;
}

.chat-feature-container {
	text-align: center;
	margin: 20px 0;
	padding: 15px;
	background: linear-gradient(to bottom, rgba(34, 85, 170, 0.05) 0%, rgba(34, 85, 170, 0.02) 100%);
	border-radius: 8px;
}

.chat-feature-container p {
	color: #666;
	font-size: 13px;
	margin: 5px 0 15px 0;
}

/* ===================================
   8. DOCUMENT SUMMARY STYLES (Optional)
   =================================== */

/* Document Summary Styles */
.document-summary-container {
	margin: 20px auto;
	padding: 20px;
	border: 2px solid #0070c9;
	border-radius: 8px;
	background-color: #f9f9f9;
	max-width: 100%;
	box-shadow: 0 2px 8px rgba(34, 85, 170, 0.1);
	overflow: hidden;
}

.document-summary-container h3 {
	color: #0070c9;
	font-size: 20px;
	margin: 0 0 15px 0;
	font-weight: bold;
	border-bottom: 2px solid #0070c9;
	padding-bottom: 10px;
}

.document-summary-container pre {
	white-space: pre-wrap;
	word-wrap: break-word;
	font-family: Arial, sans-serif;
	margin: 0;
	background-color: #ffffff;
	padding: 12px;
	border: 1px solid #ddd;
	border-radius: 5px;
	font-size: 13px;
}

.document-summary-container .summary-content {
	white-space: normal;
	word-wrap: break-word;
	font-family: 'Segoe UI', 'Open Sans', Arial, sans-serif;
	margin: 0;
	background-color: #ffffff;
	padding: 25px;
	border: 1px solid #ddd;
	border-radius: 8px;
	line-height: 1.7;
	font-size: 14px;
	overflow-x: auto;
	box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Main H2 Title Styling */
.document-summary-container .summary-content h2 {
	color: #ffffff;
	background: linear-gradient(135deg, #0070c9 0%, #005fa3 100%);
	font-size: 18px;
	font-weight: 600;
	margin: -25px -25px 25px -25px;
	padding: 18px 25px;
	border-radius: 8px 8px 0 0;
	border-bottom: 3px solid #004d82;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
	letter-spacing: 0.3px;
}

/* Paragraph Styling */
.document-summary-container .summary-content p {
	margin: 14px 0;
	line-height: 1.75;
	color: #333;
	font-size: 14px;
}

/* First paragraph after h2 or hr - special styling */
.document-summary-container .summary-content h2 + p,
.document-summary-container .summary-content hr + p {
	background-color: #f8f9fa;
	padding: 12px 15px;
	border-left: 4px solid #0070c9;
	border-radius: 4px;
	margin: 20px 0;
	font-size: 13px;
}

/* Inline strong/bold within paragraphs */
.document-summary-container .summary-content p strong,
.document-summary-container .summary-content p b {
	color: #0070c9;
	font-weight: 600;
	display: inline;
	font-size: inherit;
}

/* Standalone strong/bold (section headers) */
.document-summary-container .summary-content > strong,
.document-summary-container .summary-content > b {
	color: #0070c9;
	font-weight: 700;
	display: block;
	margin: 24px 0 12px 0;
	font-size: 16px;
	padding-bottom: 6px;
	border-bottom: 2px solid #e3f2fd;
}

/* List Styling */
.document-summary-container .summary-content ul {
	margin: 16px 0;
	padding-left: 28px;
	list-style-type: none;
}

.document-summary-container .summary-content ul li {
	position: relative;
	margin: 10px 0;
	padding-left: 20px;
	line-height: 1.7;
	color: #333;
}

.document-summary-container .summary-content ul li:before {
	content: "•";
	color: #0070c9;
	font-weight: bold;
	font-size: 18px;
	position: absolute;
	left: 0;
	top: -2px;
}

/* Horizontal Rule as Section Divider */
.document-summary-container .summary-content hr {
	border: none;
	height: 2px;
	background: linear-gradient(to right, #0070c9, #e3f2fd, #0070c9);
	margin: 30px 0;
	position: relative;
	overflow: visible;
}

.document-summary-container .summary-content hr:after {
	content: "◆";
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	background: #ffffff;
	color: #0070c9;
	padding: 0 10px;
	font-size: 12px;
}

/* Table Container */
.document-summary-container .summary-content table {
	border-collapse: separate;
	border-spacing: 0;
	width: 100%;
	margin: 20px 0;
	background-color: #ffffff;
	font-size: 13px;
	border: 1px solid #ddd;
	border-radius: 8px;
	overflow: hidden;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Table Headers */
.document-summary-container .summary-content table th {
	background: linear-gradient(180deg, #0070c9 0%, #005fa3 100%);
	color: #ffffff;
	font-weight: 600;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	padding: 12px 12px;
	text-align: left;
	border-bottom: 2px solid #004d82;
	white-space: normal;
}

/* Table Cells */
.document-summary-container .summary-content table td {
	border-bottom: 1px solid #e8e8e8;
	border-right: 1px solid #f0f0f0;
	padding: 10px 12px;
	text-align: left;
	word-wrap: break-word;
	overflow-wrap: break-word;
	vertical-align: top;
	line-height: 1.6;
}

.document-summary-container .summary-content table td:first-child {
	font-weight: 600;
	color: #005fa3;
	background-color: #f8f9fa;
	width: 25%;
	min-width: 180px;
	border-right: 2px solid #e3f2fd;
}

.document-summary-container .summary-content table td:last-child {
	border-right: none;
}

/* Table Row Styling */
.document-summary-container .summary-content table tbody tr:nth-child(even) {
	background-color: #fafbfc;
}

.document-summary-container .summary-content table tbody tr:hover {
	background-color: #e3f2fd;
	transition: background-color 0.2s ease;
}

.document-summary-container .summary-content table tbody tr:last-child td {
	border-bottom: none;
}

/* Code/monospace text */
.document-summary-container .summary-content code {
	background-color: #f4f4f4;
	border: 1px solid #e0e0e0;
	border-radius: 3px;
	padding: 2px 6px;
	font-family: 'Courier New', monospace;
	font-size: 13px;
	color: #d14;
}

/* Nested content spacing */
.document-summary-container .summary-content > div {
	margin-bottom: 15px;
}

/* ===================================
   9. MARKDOWN RENDERING IN CHAT MESSAGES
   =================================== */

.chat-message.bot table {
	border-collapse: collapse;
	width: 100%;
	margin: 10px 0;
	background-color: #ffffff;
	font-size: 12px;
	table-layout: auto;
}

.chat-message.bot table th,
.chat-message.bot table td {
	border: 1px solid #0070c9;
	padding: 6px 8px;
	text-align: left;
	font-size: 12px;
	word-wrap: break-word;
	overflow-wrap: break-word;
	max-width: 120px;
}

.chat-message.bot table th {
	background-color: #0070c9;
	color: #ffffff;
	font-weight: bold;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.3px;
	white-space: normal;
}

.chat-message.bot table tr:nth-child(even) {
	background-color: #f9f9f9;
}

.chat-message.bot table tr:hover {
	background-color: #e3f2fd;
}

.chat-message.bot b,
.chat-message.bot strong {
	color: #0070c9;
	font-weight: bold;
	display: inline-block;
	margin: 8px 0 5px 0;
	font-size: 14px;
}

/* Markdown rendering styles for chat messages */
.chat-message.bot h1 {
	font-size: 20px;
	color: #0070c9;
	margin: 12px 0 8px 0;
	font-weight: bold;
	border-bottom: 2px solid #0070c9;
	padding-bottom: 5px;
}

.chat-message.bot h2 {
	font-size: 18px;
	color: #0070c9;
	margin: 10px 0 6px 0;
	font-weight: bold;
	border-bottom: 1px solid #0070c9;
	padding-bottom: 4px;
}

.chat-message.bot h3 {
	font-size: 16px;
	color: #0070c9;
	margin: 8px 0 5px 0;
	font-weight: bold;
}

.chat-message.bot h4, .chat-message.bot h5, .chat-message.bot h6 {
	font-size: 14px;
	color: #0070c9;
	margin: 6px 0 4px 0;
	font-weight: bold;
}

.chat-message.bot p {
	margin: 8px 0;
	line-height: 1.6;
	font-size: 13px;
}

.chat-message.bot ul, .chat-message.bot ol {
	margin: 8px 0;
	padding-left: 20px;
	font-size: 13px;
}

.chat-message.bot li {
	margin: 4px 0;
	line-height: 1.5;
}

.chat-message.bot code {
	background-color: #f4f4f4;
	border: 1px solid #ddd;
	border-radius: 3px;
	padding: 2px 5px;
	font-family: 'Courier New', monospace;
	font-size: 12px;
	color: #c7254e;
}

.chat-message.bot pre {
	background-color: #f4f4f4;
	border: 1px solid #ddd;
	border-radius: 5px;
	padding: 10px;
	overflow-x: auto;
	margin: 10px 0;
	font-size: 12px;
}

.chat-message.bot pre code {
	background-color: transparent;
	border: none;
	padding: 0;
	color: #333;
}

.chat-message.bot .code-language {
	background-color: #0070c9;
	color: white;
	padding: 2px 8px;
	border-radius: 3px 3px 0 0;
	font-size: 11px;
	font-weight: bold;
	margin: -10px -10px 5px -10px;
}

.chat-message.bot blockquote {
	border-left: 4px solid #0070c9;
	padding-left: 10px;
	margin: 10px 0;
	color: #666;
	font-style: italic;
	background-color: #f9f9f9;
	padding: 8px 10px;
	font-size: 13px;
}

.chat-message.bot hr {
	border: none;
	border-top: 2px solid #0070c9;
	margin: 15px 0;
}

.chat-message.bot a {
	color: #0070c9;
	text-decoration: none;
	font-weight: bold;
}

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

.chat-message.bot em {
	font-style: italic;
	color: #555;
}

/* ===================================
   10. ANIMATIONS
   =================================== */

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

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

@keyframes spinRotate {
	0% {
		transform: rotate(0deg);
	}
	100% {
		transform: rotate(360deg);
	}
}

@keyframes starPulse {
	0%, 100% {
		opacity: 0.9;
		transform: scale(1);
	}
	50% {
		opacity: 0.6;
		transform: scale(0.95);
	}
}

@keyframes checkBounce {
	0% {
		transform: scale(0);
		opacity: 0;
	}
	50% {
		transform: scale(1.2);
	}
	100% {
		transform: scale(1);
		opacity: 1;
	}
}

@keyframes pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.6; }
}
