/* =============================================================================
   SEO Agent Chat — Floating Drawer  v2.0.38
   ============================================================================= */

/* Floating action button */
.saiap-seo-agent-fab {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 99999;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	border: none;
	background: var(--saiap-primary, #3858e9);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 16px rgba(56, 88, 233, 0.35);
	transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.saiap-seo-agent-fab:hover {
	background: var(--saiap-primary-dark, #2a44c0);
	transform: scale(1.06);
	box-shadow: 0 6px 24px rgba(56, 88, 233, 0.45);
}

.saiap-seo-agent-fab:active {
	transform: scale(0.97);
}

.saiap-seo-agent-fab--open {
	background: var(--saiap-text-muted, #6b7280);
}

.saiap-seo-agent-fab--open:hover {
	background: var(--saiap-text-secondary, #4b5563);
}

/* Chat drawer */
.saiap-seo-agent-drawer {
	position: fixed;
	bottom: 88px;
	right: 24px;
	z-index: 99998;
	width: 420px;
	max-width: calc(100vw - 48px);
	height: 560px;
	max-height: calc(100vh - 140px);
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.08);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	animation: saiap-seo-agent-slide-up 0.25s ease-out;
}

@keyframes saiap-seo-agent-slide-up {
	from {
		opacity: 0;
		transform: translateY(12px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Header */
.saiap-seo-agent-drawer__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	border-bottom: 1px solid #e5e7eb;
	background: #fafafa;
	flex-shrink: 0;
}

.saiap-seo-agent-drawer__title-group {
	display: flex;
	flex-direction: column;
	gap: 2px;
}

.saiap-seo-agent-drawer__title {
	font-size: 14px;
	font-weight: 600;
	color: #1f2937;
	line-height: 1;
}

.saiap-seo-agent-drawer__badge {
	font-size: 10px;
	font-weight: 500;
	color: #6b7280;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.saiap-seo-agent-drawer__actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.saiap-seo-agent-new-chat {
	display: flex;
	align-items: center;
	justify-content: center;
	height: 28px;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	background: #fff;
	color: #6b7280;
	cursor: pointer;
	transition: all 0.15s ease;
	padding: 0 10px;
	font-size: 11px;
	font-weight: 500;
	white-space: nowrap;
}

.saiap-seo-agent-new-chat:hover {
	background: #f3f4f6;
	color: #374151;
	border-color: #9ca3af;
}

.saiap-seo-agent-new-chat:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

select.saiap-seo-agent-model-select {
	font-size: 11px !important;
	padding: 3px 20px 3px 6px !important;
	border: 1px solid #d1d5db;
	border-radius: 6px;
	background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 6px center !important;
	-webkit-appearance: none !important;
	-moz-appearance: none !important;
	appearance: none !important;
	color: #374151;
	max-width: 180px !important;
	width: auto !important;
	min-height: 0 !important;
	line-height: 1.4 !important;
	cursor: pointer;
	text-overflow: ellipsis;
	overflow: hidden;
	white-space: nowrap;
}

.saiap-seo-agent-model-select:focus {
	outline: none;
	border-color: var(--saiap-primary, #3858e9);
	box-shadow: 0 0 0 2px rgba(56, 88, 233, 0.15);
}

/* Messages area */
.saiap-seo-agent-drawer__messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* Message bubbles */
.saiap-seo-agent-message {
	display: flex;
	max-width: 88%;
}

.saiap-seo-agent-message--user {
	align-self: flex-end;
	margin-left: auto;
}

.saiap-seo-agent-message--assistant {
	align-self: flex-start;
}

.saiap-seo-agent-message__bubble {
	padding: 10px 14px;
	border-radius: 12px;
	font-size: 14px !important;
	line-height: 1.5;
	word-break: break-word;
}

.saiap-seo-agent-message__bubble p,
.saiap-seo-agent-message__bubble li,
.saiap-seo-agent-message__bubble code,
.saiap-seo-agent-message__bubble td,
.saiap-seo-agent-message__bubble th {
	font-size: inherit !important;
}

.saiap-seo-agent-message--user .saiap-seo-agent-message__bubble {
	background: var(--saiap-primary, #3858e9);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.saiap-seo-agent-message--user .saiap-seo-agent-message__bubble p {
	color: inherit;
	margin: 0;
}

.saiap-seo-agent-message--assistant .saiap-seo-agent-message__bubble {
	background: #f3f4f6;
	color: #1f2937;
	border-bottom-left-radius: 4px;
}

/* Markdown content in assistant messages */
.saiap-seo-agent-message--assistant .saiap-seo-agent-message__bubble p {
	margin: 0 0 8px;
}

.saiap-seo-agent-message--assistant .saiap-seo-agent-message__bubble p:last-child {
	margin-bottom: 0;
}

.saiap-seo-agent-message--assistant .saiap-seo-agent-message__bubble ul {
	margin: 4px 0 8px;
	padding-left: 20px;
	list-style: disc !important;
}

.saiap-seo-agent-message--assistant .saiap-seo-agent-message__bubble ol {
	margin: 4px 0 8px;
	padding-left: 20px;
	list-style: decimal !important;
}

.saiap-seo-agent-message--assistant .saiap-seo-agent-message__bubble li {
	margin-bottom: 4px;
}

.saiap-seo-agent-message--assistant .saiap-seo-agent-message__bubble code {
	background: #e5e7eb;
	padding: 1px 4px;
	border-radius: 3px;
	font-size: 12px;
}

.saiap-seo-agent-message--assistant .saiap-seo-agent-message__bubble strong {
	font-weight: 600;
}

/* Markdown tables */
.saiap-seo-agent-message--assistant .saiap-seo-agent-message__bubble table {
	width: 100%;
	border-collapse: collapse;
	margin: 8px 0;
	font-size: 12px;
}

.saiap-seo-agent-message--assistant .saiap-seo-agent-message__bubble th,
.saiap-seo-agent-message--assistant .saiap-seo-agent-message__bubble td {
	border: 1px solid #d1d5db;
	padding: 6px 8px;
	text-align: left;
}

.saiap-seo-agent-message--assistant .saiap-seo-agent-message__bubble th {
	background: #e5e7eb;
	font-weight: 600;
}

.saiap-seo-agent-message--assistant .saiap-seo-agent-message__bubble tr:nth-child(even) td {
	background: #f9fafb;
}

/* Strikethrough (GFM) */
.saiap-seo-agent-message--assistant .saiap-seo-agent-message__bubble del {
	text-decoration: line-through;
	opacity: 0.6;
}

/* Thinking / typing indicator */
.saiap-seo-agent-message__bubble--thinking {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 8px;
	color: #6b7280;
	font-size: 13px;
}

.saiap-seo-agent-typing {
	display: inline-flex;
	gap: 3px;
}

.saiap-seo-agent-typing span {
	width: 6px;
	height: 6px;
	background: #9ca3af;
	border-radius: 50%;
	animation: saiap-seo-agent-bounce 1.4s infinite ease-in-out;
}

.saiap-seo-agent-typing span:nth-child(1) {
	animation-delay: 0s;
}

.saiap-seo-agent-typing span:nth-child(2) {
	animation-delay: 0.2s;
}

.saiap-seo-agent-typing span:nth-child(3) {
	animation-delay: 0.4s;
}

@keyframes saiap-seo-agent-bounce {
	0%, 80%, 100% {
		transform: scale(0.6);
		opacity: 0.4;
	}
	40% {
		transform: scale(1);
		opacity: 1;
	}
}

/* Tool progress indicators */
.saiap-seo-agent-tool-progress {
	display: flex;
	flex-direction: column;
	gap: 4px;
	padding: 0 4px;
}

.saiap-seo-agent-tool-step {
	display: flex;
	align-items: center;
	gap: 6px;
	font-size: 12px;
	color: #6b7280;
	line-height: 1.4;
}

.saiap-seo-agent-tool-step--running {
	color: var(--saiap-primary, #3858e9);
}

.saiap-seo-agent-tool-step--done {
	color: #059669;
}

.saiap-seo-agent-tool-icon {
	flex-shrink: 0;
	width: 14px;
	height: 14px;
}

.saiap-seo-agent-tool-step--running .saiap-seo-agent-tool-icon {
	animation: saiap-seo-agent-spin 1s linear infinite;
}

@keyframes saiap-seo-agent-spin {
	from { transform: rotate(0deg); }
	to { transform: rotate(360deg); }
}

/* Input area */
.saiap-seo-agent-drawer__input {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 12px 16px;
	border-top: 1px solid #e5e7eb;
	background: #fafafa;
	flex-shrink: 0;
}

.saiap-seo-agent-input {
	flex: 1;
	resize: none;
	border: 1px solid #d1d5db;
	border-radius: 8px;
	padding: 10px 12px;
	font-size: 14px !important;
	line-height: 1.4;
	font-family: inherit;
	background: #fff;
	color: #1f2937;
	min-height: 40px;
	max-height: 100px;
	overflow-y: auto;
}

.saiap-seo-agent-input:focus {
	outline: none;
	border-color: var(--saiap-primary, #3858e9);
	box-shadow: 0 0 0 2px rgba(56, 88, 233, 0.15);
}

.saiap-seo-agent-input:disabled {
	background: #f9fafb;
	color: #9ca3af;
}

.saiap-seo-agent-input::placeholder {
	color: #9ca3af;
}

.saiap-seo-agent-send {
	width: 40px;
	height: 40px;
	border: none;
	border-radius: 8px;
	background: var(--saiap-primary, #3858e9);
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background 0.15s, opacity 0.15s;
}

.saiap-seo-agent-send:hover:not(:disabled) {
	background: var(--saiap-primary-dark, #2a44c0);
}

.saiap-seo-agent-send:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/* Scrollbar styling */
.saiap-seo-agent-drawer__messages::-webkit-scrollbar {
	width: 6px;
}

.saiap-seo-agent-drawer__messages::-webkit-scrollbar-track {
	background: transparent;
}

.saiap-seo-agent-drawer__messages::-webkit-scrollbar-thumb {
	background: #d1d5db;
	border-radius: 3px;
}

.saiap-seo-agent-drawer__messages::-webkit-scrollbar-thumb:hover {
	background: #9ca3af;
}

/* Nudge tooltip */
.saiap-seo-agent-nudge {
	position: fixed;
	bottom: 28px;
	right: 86px;
	z-index: 99999;
	background: #1f2937;
	color: #fff;
	padding: 10px 36px 10px 14px;
	border-radius: 10px;
	font-size: 13px;
	line-height: 1.4;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
	animation: saiap-seo-agent-nudge-in 0.4s ease-out;
	max-width: 260px;
}

.saiap-seo-agent-nudge::after {
	content: '';
	position: absolute;
	right: -6px;
	top: 50%;
	transform: translateY(-50%);
	border: 6px solid transparent;
	border-left-color: #1f2937;
	border-right: none;
}

.saiap-seo-agent-nudge__close {
	position: absolute;
	top: 6px;
	right: 6px;
	background: none;
	border: none;
	color: #9ca3af;
	cursor: pointer;
	padding: 4px;
	line-height: 1;
	display: flex;
}

.saiap-seo-agent-nudge__close:hover {
	color: #fff;
}

@keyframes saiap-seo-agent-nudge-in {
	from {
		opacity: 0;
		transform: translateX(8px);
	}
	to {
		opacity: 1;
		transform: translateX(0);
	}
}

/* Suggested prompt chips */
.saiap-seo-agent-suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 4px 0;
}

.saiap-seo-agent-suggestion-chip {
	display: inline-block;
	padding: 7px 14px;
	font-size: 13px;
	line-height: 1.3;
	color: var(--saiap-primary, #3858e9);
	background: #fff;
	border: 1px solid var(--saiap-primary, #3858e9);
	border-radius: 18px;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
	white-space: nowrap;
}

.saiap-seo-agent-suggestion-chip:hover {
	background: var(--saiap-primary, #3858e9);
	color: #fff;
}

/* Responsive */
@media (max-width: 480px) {
	.saiap-seo-agent-drawer {
		right: 8px;
		bottom: 76px;
		width: calc(100vw - 16px);
		height: calc(100vh - 100px);
	}

	.saiap-seo-agent-fab {
		right: 12px;
		bottom: 12px;
	}
}
