/**
 * Magna AI Copilot Chat CSS
 *
 * Styles for the floating chat interface.
 *
 * @since 0.3.0
 */

/* Chat container */
.magna-ai-chat-container {
	position: fixed;
	bottom: 20px;
	right: 20px;
	width: 380px;
	max-width: calc(100vw - 40px);
	height: 500px;
	max-height: calc(100vh - 40px);
	background: #ffffff;
	border-radius: 12px;
	box-shadow: 0 5px 25px rgba(0, 0, 0, 0.15);
	display: flex;
	flex-direction: column;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
	overflow: hidden;
	transition: transform 0.3s ease, opacity 0.3s ease;
}

/* Closed state */
.magna-ai-chat-closed {
	transform: translateY(calc(100% - 60px));
	opacity: 0.9;
}

.magna-ai-chat-closed .magna-ai-chat-body {
	display: none;
}

/* Chat header */
.magna-ai-chat-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	border-radius: 12px 12px 0 0;
	cursor: pointer;
	user-select: none;
}

.magna-ai-chat-title {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
	line-height: 1.2;
}

.magna-ai-chat-toggle {
	background: rgba(255, 255, 255, 0.2);
	border: none;
	border-radius: 50%;
	width: 32px;
	height: 32px;
	color: white;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease;
}

.magna-ai-chat-toggle:hover {
	background: rgba(255, 255, 255, 0.3);
}

.magna-ai-chat-toggle:focus {
	outline: 2px solid rgba(255, 255, 255, 0.5);
	outline-offset: 2px;
}

/* Chat body */
.magna-ai-chat-body {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* Chat messages */
.magna-ai-chat-messages {
	flex: 1;
	padding: 20px;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
	gap: 16px;
	scrollbar-width: thin;
	scrollbar-color: #c1c1c1 transparent;
}

.magna-ai-chat-messages::-webkit-scrollbar {
	width: 6px;
}

.magna-ai-chat-messages::-webkit-scrollbar-track {
	background: transparent;
}

.magna-ai-chat-messages::-webkit-scrollbar-thumb {
	background: #c1c1c1;
	border-radius: 3px;
}

.magna-ai-chat-messages::-webkit-scrollbar-thumb:hover {
	background: #a8a8a8;
}

/* Chat message */
.magna-ai-chat-message {
	max-width: 85%;
	padding: 12px 16px;
	border-radius: 18px;
	line-height: 1.5;
	word-wrap: break-word;
	animation: fadeIn 0.3s ease;
}

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

.magna-ai-chat-message-bot {
	align-self: flex-start;
	background: #f0f2f5;
	color: #1c1e21;
	border-bottom-left-radius: 4px;
}

.magna-ai-chat-message-user {
	align-self: flex-end;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: white;
	border-bottom-right-radius: 4px;
}

.magna-ai-chat-message-content {
	font-size: 14px;
}

.magna-ai-chat-message-content p {
	margin: 0 0 8px 0;
}

.magna-ai-chat-message-content p:last-child {
	margin-bottom: 0;
}

/* Loading indicator */
.magna-ai-chat-loading .magna-ai-chat-message-content {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 24px;
}

.magna-ai-chat-loading-dots {
	display: flex;
	gap: 4px;
}

.magna-ai-chat-loading-dots span {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: #a8a8a8;
	animation: bounce 1.4s infinite ease-in-out both;
}

.magna-ai-chat-loading-dots span:nth-child(1) {
	animation-delay: -0.32s;
}

.magna-ai-chat-loading-dots span:nth-child(2) {
	animation-delay: -0.16s;
}

@keyframes bounce {
	0%, 80%, 100% {
		transform: scale(0);
	}
	40% {
		transform: scale(1);
	}
}

/* Chat input area */
.magna-ai-chat-input-area {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 16px 20px;
	border-top: 1px solid #e4e6eb;
	background: #ffffff;
}

/* Language selector */
.magna-language-control {
	padding: 8px 20px 4px;
	background: #ffffff;
	border-top: 1px solid #e4e6eb;
	border-bottom: 1px solid #e4e6eb;
}

#magna-language-selector {
	width: 100%;
	padding: 6px 10px;
	border: 1px solid #e4e6eb;
	border-radius: 4px;
	font-size: 12px;
	font-family: inherit;
	background: #ffffff;
	color: #1c1e21;
	outline: none;
	transition: border-color 0.2s ease;
}

#magna-language-selector:focus {
	border-color: #667eea;
}

#magna-language-selector option {
	font-size: 12px;
}


.magna-ai-chat-input {
	flex: 1;
	min-height: 44px;
	max-height: 120px;
	padding: 12px 16px;
	border: 1px solid #e4e6eb;
	border-radius: 24px;
	font-size: 14px;
	line-height: 1.5;
	resize: none;
	outline: none;
	transition: border-color 0.2s ease;
	font-family: inherit;
}

.magna-ai-chat-input:focus {
	border-color: #667eea;
}

.magna-ai-chat-input::placeholder {
	color: #8a8d91;
}

.magna-ai-chat-voice {
	flex-shrink: 0;
	width: 46px;
	height: 46px;
	background: #ffffff;
	border: 2px solid #667eea;
	border-radius: 50%;
	color: #667eea;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.magna-ai-chat-voice:hover:not(:disabled) {
	background: #667eea;
	color: white;
	transform: scale(1.08);
	box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.magna-ai-chat-voice:active:not(:disabled) {
	transform: scale(0.95);
}

.magna-ai-chat-voice:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	border-color: #a8a8a8;
	color: #a8a8a8;
	box-shadow: none;
}

.magna-ai-chat-voice:disabled:hover {
	background: #ffffff;
	color: #a8a8a8;
	transform: none;
	box-shadow: none;
}

.magna-ai-chat-voice:focus {
	outline: 2px solid rgba(102, 126, 234, 0.5);
	outline-offset: 2px;
}

.magna-ai-chat-voice .magna-ai-chat-voice-icon svg {
	width: 22px;
	height: 22px;
	transition: all 0.2s ease;
}

.magna-ai-chat-voice:hover:not(:disabled) .magna-ai-chat-voice-icon svg {
	filter: brightness(0) invert(1);
}

.magna-ai-chat-voice.holding {
	background: #fbbf24;
	border-color: #fbbf24;
	color: white;
	transform: scale(0.95);
	box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
}

.magna-ai-chat-voice.holding .magna-ai-chat-voice-icon svg {
	filter: brightness(0) invert(1);
}

.magna-ai-chat-voice.recording {
	background: #f87171;
	border-color: #f87171;
	color: white;
	animation: pulse 1.5s infinite;
	box-shadow: 0 2px 8px rgba(248, 113, 113, 0.3);
}

.magna-ai-chat-voice.recording .magna-ai-chat-voice-icon svg {
	filter: brightness(0) invert(1);
}

@keyframes pulse {
	0% {
		box-shadow: 0 0 0 0 rgba(248, 113, 113, 0.7);
	}
	70% {
		box-shadow: 0 0 0 10px rgba(248, 113, 113, 0);
	}
	100% {
		box-shadow: 0 0 0 0 rgba(248, 113, 113, 0);
	}
}

.magna-ai-chat-send {
	flex-shrink: 0;
	width: 44px;
	height: 44px;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	border: none;
	border-radius: 50%;
	color: white;
	font-size: 18px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s ease, opacity 0.2s ease;
}

.magna-ai-chat-send:hover:not(:disabled) {
	transform: scale(1.05);
}

.magna-ai-chat-send:active:not(:disabled) {
	transform: scale(0.95);
}

.magna-ai-chat-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.magna-ai-chat-send:focus {
	outline: 2px solid rgba(102, 126, 234, 0.5);
	outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 480px) {
	.magna-ai-chat-container {
		right: 10px;
		bottom: 10px;
		width: calc(100vw - 20px);
		max-width: none;
		height: 70vh;
		max-height: none;
	}

	.magna-ai-chat-message {
		max-width: 90%;
	}
}

/* Usage meter */
.magna-ai-chat-header-left {
	display: flex;
	flex-direction: column;
	gap: 4px;
	flex: 1;
}

.magna-ai-usage-meter {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 11px;
	opacity: 0.9;
	transition: opacity 0.2s ease;
}

.magna-ai-usage-meter:hover {
	opacity: 1;
}

.magna-ai-usage-meter-bar {
	flex: 1;
	height: 4px;
	background: rgba(255, 255, 255, 0.2);
	border-radius: 2px;
	overflow: hidden;
}

.magna-ai-usage-meter-fill {
	height: 100%;
	border-radius: 2px;
	transition: width 0.3s ease, background-color 0.3s ease;
}

/* Status colors */
.magna-ai-usage-meter-normal .magna-ai-usage-meter-fill {
	background: #4ade80; /* Green */
}

.magna-ai-usage-meter-warning .magna-ai-usage-meter-fill {
	background: #fbbf24; /* Yellow */
}

.magna-ai-usage-meter-exceeded .magna-ai-usage-meter-fill {
	background: #f87171; /* Red */
}

.magna-ai-usage-meter-unlimited .magna-ai-usage-meter-fill {
	background: #60a5fa; /* Blue */
}

.magna-ai-usage-meter-text {
	font-weight: 500;
	white-space: nowrap;
	min-width: 60px;
	text-align: right;
}

/* Voice play button */
.magna-voice-play {
	position: absolute;
	right: 8px;
	bottom: 8px;
	background: rgba(255, 255, 255, 0.9);
	border: none;
	border-radius: 50%;
	width: 28px;
	height: 28px;
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	z-index: 1;
}

.magna-voice-play .magna-voice-dot {
	display: none; /* Hide the dot */
}

.magna-voice-play::before {
	content: '▶'; /* Play icon */
	font-family: "Segoe UI Symbol", "Apple Color Emoji", "Segoe UI Emoji", "Symbola", sans-serif;
	font-size: 14px;
	color: #667eea;
	transition: all 0.2s ease;
	line-height: 1;
}

.magna-voice-play.magna-voice-playing::before {
	content: '⏸'; /* Pause icon */
	color: #f87171;
	font-size: 12px;
	letter-spacing: 0;
	font-family: "Segoe UI Symbol", "Apple Color Emoji", "Segoe UI Emoji", "Symbola", sans-serif;
}

.magna-ai-chat-message-bot {
	position: relative;
	padding-bottom: 40px; /* Make room for the voice button */
}

.magna-voice-play:hover {
	background: white;
	transform: scale(1.1);
	box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.magna-voice-play:hover::before {
	transform: scale(1.2);
}

.magna-voice-play:active {
	transform: scale(0.95);
}

.magna-voice-play:focus {
	outline: 2px solid rgba(102, 126, 234, 0.5);
	outline-offset: 2px;
}

/* Print styles */
@media print {
	.magna-ai-chat-container {
		display: none !important;
	}
}

/* Notifications */
.magna-notification {
	position: fixed;
	top: 20px;
	right: 20px;
	padding: 12px 16px;
	border-radius: 8px;
	color: white;
	font-size: 14px;
	font-weight: 500;
	z-index: 1000000;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s;
	max-width: 300px;
	word-wrap: break-word;
}

.magna-notification-info {
	background: #3b82f6; /* Blue */
}

.magna-notification-success {
	background: #10b981; /* Green */
}

.magna-notification-warning {
	background: #f59e0b; /* Yellow */
}

.magna-notification-error {
	background: #ef4444; /* Red */
}

@keyframes slideIn {
	from {
		transform: translateX(100%);
		opacity: 0;
	}
	to {
		transform: translateX(0);
		opacity: 1;
	}
}

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