/* --Page Styles-- */
@charset "utf-8";
body {
	font-family: sans-serif;
	font-size: 150%;
	line-height: 1.4;
	margin: 0;
	padding: 0;
	background-color: #f5f5f5;
}

h1 {
	text-align: center;
	margin: 20px 0;
	color: #333;
}

/* App Container Layout */
.app-container {
	display: flex;
	max-width: 1200px;
	margin: 0 auto;
	height: calc(100vh - 100px);
	background-color: white;
	border-radius: 8px;
	box-shadow: 0 2px 10px rgba(0,0,0,0.1);
	overflow: hidden;
}

/* Chat Sidebar */
.chat-sidebar {
	width: 300px;
	background-color: #f8f9fa;
	border-right: 1px solid #dee2e6;
	display: flex;
	flex-direction: column;
}

.sidebar-header {
	padding: 20px;
	border-bottom: 1px solid #dee2e6;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

#new-chat {
	width: 100%;
	padding: 12px;
	background-color: #007bff;
	color: white;
	border: none;
	border-radius: 6px;
	font-size: 1em;
	cursor: pointer;
	transition: background-color 0.3s;
}

#new-chat:hover {
	background-color: #0056b3;
}

#logout-btn {
	width: 100%;
	padding: 10px;
	background-color: #6c757d;
	color: white;
	border: none;
	border-radius: 6px;
	font-size: 0.9em;
	cursor: pointer;
	transition: background-color 0.3s;
}

#logout-btn:hover {
	background-color: #5a6268;
}

/* --Chat List-- */
.chat-list {
	flex: 1;
	overflow-y: auto;
	padding: 10px;
}

.chat-item {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px;
	margin-bottom: 8px;
	border-radius: 6px;
	cursor: pointer;
	transition: background-color 0.3s;
	border: 1px solid transparent;
}

.chat-item:hover {
	background-color: #e9ecef;
}

.chat-item.active {
	background-color: #007bff;
	color: white;
	border-color: #0056b3;
}

.chat-item-content {
	flex: 1;
	min-width: 0;
}

.chat-name {
	font-weight: bold;
	margin-bottom: 4px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.chat-preview {
	font-size: 0.8em;
	opacity: 0.8;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.delete-chat {
	background: none;
	border: none;
	color: inherit;
	font-size: 1.2em;
	cursor: pointer;
	padding: 4px 8px;
	border-radius: 4px;
	opacity: 0.7;
	transition: opacity 0.3s;
}

.delete-chat:hover {
	opacity: 1;
	background-color: rgba(255,255,255,0.2);
}

/* --Main Content-- */
.main-content {
	flex: 1;
	display: flex;
	flex-direction: column;
	padding: 20px;
}

form {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-bottom: 20px;
}

/* --Chat Interface Styles-- */
.chat-container {
	max-height: 700px;
	overflow-y: auto;
	border: 1px solid #ddd;
	border-radius: 8px;
	background-color: white;
	padding: 15px;
	margin-bottom: 20px;
	box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.welcome-message {
	text-align: center;
	color: #6c757d;
	font-style: italic;
	padding: 30px;
	background-color: #f8f9fa;
	border-radius: 8px;
	border: 2px dashed #dee2e6;
}

.message-wrapper {
	margin-bottom: 15px;
	padding: 12px;
	border-radius: 12px;
	max-width: 80%;
	position: relative;
	box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.user-message {
	background: linear-gradient(135deg, #007bff, #0056b3);
	color: white;
	margin-left: auto;
	text-align: right;
}

.assistant-message {
	background: linear-gradient(135deg, #f8f9fa, #e9ecef);
	color: #333;
	border: 1px solid #e9ecef;
	margin-right: auto;
}

.message-header {
	font-size: 0.8em;
	margin-bottom: 8px;
	opacity: 0.9;
	display: flex;
	align-items: center;
	gap: 8px;
}

.user-message .message-header {
	justify-content: flex-end;
}

.assistant-message .message-header {
	justify-content: flex-start;
}

.avatar {
	font-size: 1.2em;
}

.sender {
	font-weight: bold;
}

.timestamp {
	font-style: italic;
	font-size: 0.9em;
}

.message-content p {
	margin: 0;
	word-wrap: break-word;
	line-height: 1.5;
}

.message-footer {
	margin-top: 8px;
	font-size: 0.7em;
	opacity: 0.7;
}

.user-message .message-footer {
	text-align: right;
}

.assistant-message .message-footer {
	text-align: left;
}

.message-number {
	background-color: rgba(0,0,0,0.1);
	padding: 2px 6px;
	border-radius: 10px;
}

/* Loading Indicator */
.loading-indicator {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 15px;
	background-color: #f8f9fa;
	border-radius: 8px;
	margin-top: 10px;
}

.typing-indicator {
	display: flex;
	gap: 4px;
}

.typing-indicator span {
	width: 8px;
	height: 8px;
	background-color: #007bff;
	border-radius: 50%;
	animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

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

/* --Usage Statistics-- */
.usage-stats {
	background-color: #e9ecef;
	padding: 10px;
	border-radius: 5px;
	margin-top: 15px;
	font-size: 0.9em;
	text-align: center;
	border-top: 1px solid #ddd;
}

/* --Form Elements-- */
#user-message {
	padding: 10px;
	border: 1px solid #ddd;
	border-radius: 5px;
	font-size: 1em;
	resize: vertical;
}

.button-group {
	display: flex;
	gap: 10px;
	flex-wrap: wrap;
}

button {
	padding: 10px 20px;
	border: none;
	border-radius: 5px;
	cursor: pointer;
	font-size: 1em;
	transition: background-color 0.3s;
	flex: 1;
	min-width: 120px;
}

#send-message {
	background-color: #28a745;
	color: white;
}

#send-message:hover {
	background-color: #218838;
}

#check-usage {
	background-color: #6c757d;
	color: white;
}

#check-usage:hover {
	background-color: #5a6268;
}

#clear-conversation {
	background-color: #dc3545;
	color: white;
}

#clear-conversation:hover {
	background-color: #c82333;
}

/* --Error Messages-- */
.error {
	color: #dc3545;
	background-color: #f8d7da;
	padding: 10px;
	border-radius: 5px;
	border: 1px solid #f5c6cb;
}

/* --Success Messages-- */
.success-message {
	color: #155724;
	background-color: #d4edda;
	padding: 15px;
	border-radius: 5px;
	border: 1px solid #c3e6cb;
	text-align: center;
	margin: 20px 0;
}

.success-message p {
	margin: 0;
	font-weight: bold;
}

/* --Usage Info-- */
.usage-info {
	background-color: #d1ecf1;
	padding: 15px;
	border-radius: 5px;
	border: 1px solid #bee5eb;
}

.usage-info h3 {
	margin-top: 0;
	color: #0c5460;
}

/* --Responsive Design-- */
@media (max-width: 768px) {
	body {
		font-size: 120%;
	}
	
	.app-container {
		flex-direction: column;
		height: calc(100vh - 80px);
	}
	
	.chat-sidebar {
		width: 100%;
		height: 200px;
		border-right: none;
		border-bottom: 1px solid #dee2e6;
	}
	
	.main-content {
		flex: 1;
		padding: 15px;
	}
	
	.message-wrapper {
		max-width: 90%;
	}
	
	.button-group {
		flex-direction: column;
	}
	
	.chat-list {
		max-height: 150px;
	}
	
	.modal-content {
		width: 95%;
		margin: 20px auto;
	}
}

/* --API Key Modal Styles-- */
.modal {
	display: none;
	position: fixed;
	z-index: 1000;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0,0,0,0.5);
	backdrop-filter: blur(5px);
}

.modal.show {
	display: flex;
	align-items: center;
	justify-content: center;
}

.modal-content {
	background-color: white;
	margin: auto;
	padding: 0;
	border-radius: 12px;
	width: 500px;
	max-width: 90%;
	box-shadow: 0 10px 30px rgba(0,0,0,0.3);
	animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
	from {
		opacity: 0;
		transform: translateY(-50px) scale(0.9);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

.modal-header {
	padding: 30px 30px 20px 30px;
	text-align: center;
	border-bottom: 1px solid #e9ecef;
}

.modal-header h2 {
	margin: 0 0 10px 0;
	color: #333;
	font-size: 1.5em;
}

.modal-header p {
	margin: 0;
	color: #6c757d;
	font-size: 1em;
}

.modal-body {
	padding: 30px;
}

#api-key-form {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

#api-key-form label {
	font-weight: bold;
	color: #333;
	font-size: 1em;
}

#api-key-input {
	padding: 15px;
	border: 2px solid #e9ecef;
	border-radius: 8px;
	font-size: 1em;
	transition: border-color 0.3s;
}

#api-key-input:focus {
	outline: none;
	border-color: #007bff;
	box-shadow: 0 0 0 3px rgba(0,123,255,0.1);
}

.modal-buttons {
	display: flex;
	gap: 10px;
}

#submit-api-key {
	padding: 15px 30px;
	background-color: #007bff;
	color: white;
	border: none;
	border-radius: 8px;
	font-size: 1em;
	font-weight: bold;
	cursor: pointer;
	transition: background-color 0.3s;
	flex: 1;
}

#submit-api-key:hover {
	background-color: #0056b3;
}

.api-key-help {
	margin-top: 20px;
	padding: 15px;
	background-color: #f8f9fa;
	border-radius: 8px;
	border-left: 4px solid #007bff;
}

.api-key-help p {
	margin: 5px 0;
	font-size: 0.9em;
	color: #6c757d;
}

.api-key-help strong {
	color: #333;
}