/**
 * Frontend Chat Widget Styles for WP Info Agent
 *
 * @package WP_Content_Agent
 * @since 1.0.0
 */

.wp-content-agent-chat {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 999999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.wp-content-agent-chat-toggle {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--wpca-primary, #2271b1);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
	transition: transform 0.2s, box-shadow 0.2s;
	position: absolute;
	bottom: 0;
	right: 0;
}

.wp-content-agent-chat-toggle:hover {
	transform: scale(1.05);
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.wp-content-agent-chat-toggle .dashicons {
	font-size: 28px;
	width: 28px;
	height: 28px;
}

.wp-content-agent-chat-dialog {
	display: none;
	flex-direction: column;
	position: absolute;
	bottom: 72px;
	right: 0;
	width: 380px;
	height: 520px;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
	overflow: hidden;
}

/* When dialog has been dragged, switch to fixed top/left positioning. */
.wp-content-agent-chat-dialog.dragged {
	position: fixed;
	bottom: auto;
	right: auto;
}

.wp-content-agent-chat-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	background: var(--wpca-primary, #2271b1);
	color: #fff;
	cursor: grab;
	user-select: none;
}

.wp-content-agent-chat-header:active {
	cursor: grabbing;
}

.wp-content-agent-chat-title {
	font-size: 15px;
	font-weight: 600;
}

.wp-content-agent-chat-title-wrap {
	display: flex;
	align-items: center;
	gap: 8px;
}

.wp-content-agent-chat-ai-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.wp-content-agent-chat-ai-icon svg {
	width: 20px;
	height: 20px;
	display: block;
}

.wp-content-agent-chat-close {
	background: none;
	border: none;
	color: #fff;
	font-size: 22px;
	cursor: pointer;
	padding: 0;
	line-height: 1;
	opacity: 0.8;
	transition: opacity 0.2s;
}

.wp-content-agent-chat-close:hover {
	opacity: 1;
}

.wp-content-agent-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-height: 120px;
}

.wp-content-agent-chat-message {
	padding: 10px 14px;
	border-radius: 12px;
	font-size: 14px;
	line-height: 1.6;
	max-width: 85%;
	word-wrap: break-word;
	white-space: pre-wrap;
}

.wp-content-agent-chat-message strong {
	font-weight: 600;
}

.wp-content-agent-chat-message em {
	font-style: italic;
}

.wp-content-agent-chat-message code {
	background: rgba(0, 0, 0, 0.08);
	padding: 2px 6px;
	border-radius: 3px;
	font-size: 13px;
	font-family: 'Consolas', 'Monaco', monospace;
}

.wp-content-agent-chat-message a {
	color: var(--wpca-primary, #2271b1);
	text-decoration: underline;
	word-break: break-all;
}
.wp-content-agent-chat-message a:hover {
	color: var(--wpca-primary-hover, #135e96);
}
.wp-content-agent-chat-message-assistant a {
	color: var(--wpca-primary-light, #5b9dd9);
}
.wp-content-agent-chat-message-assistant a:hover {
	color: var(--wpca-primary-light-hover, #79b8ee);
}

/* Headings */
.wpca-h1, .wpca-h2, .wpca-h3, .wpca-h4 {
	margin: 6px 0 3px;
	font-weight: 600;
	line-height: 1.4;
}
.wpca-h1 { font-size: 14px; }
.wpca-h2 { font-size: 13px; }
.wpca-h3 { font-size: 13px; }
.wpca-h4 { font-size: 12px; }

/* Table */
.wpca-table {
	width: 100%;
	border-collapse: collapse;
	margin: 6px 0;
	font-size: 12px;
}
.wpca-table th {
	background: rgba(0, 0, 0, 0.06);
	font-weight: 600;
	text-align: left;
	padding: 4px 6px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.12);
}
.wpca-table td {
	padding: 3px 6px;
	border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

/* Blockquote */
.wpca-blockquote {
	border-left: 3px solid rgba(0, 0, 0, 0.15);
	margin: 6px 0;
	padding: 2px 8px;
	color: rgba(0, 0, 0, 0.6);
	font-style: italic;
}
.wp-content-agent-chat-message-assistant .wpca-blockquote {
	border-left-color: rgba(255, 255, 255, 0.3);
	color: rgba(255, 255, 255, 0.7);
}

/* List */
.wpca-list {
	margin: 4px 0;
	padding-left: 18px;
}
.wpca-list li {
	margin-bottom: 2px;
}

/* HR */
.wp-content-agent-chat-message hr {
	border: none;
	border-top: 1px solid rgba(0, 0, 0, 0.1);
	margin: 6px 0;
}
.wp-content-agent-chat-message-assistant hr {
	border-top-color: rgba(255, 255, 255, 0.15);
}

.wp-content-agent-chat-message-user {
	background: var(--wpca-primary, #2271b1);
	color: #fff;
	align-self: flex-end;
	border-bottom-right-radius: 4px;
}

.wp-content-agent-chat-message-assistant {
	background: #f0f0f1;
	color: #1e1e1e;
	align-self: flex-start;
	border-bottom-left-radius: 4px;
}

.wp-content-agent-chat-message-typing {
	background: #f0f0f1;
	color: #757575;
	align-self: flex-start;
	font-style: italic;
}

.wp-content-agent-chat-input-area {
	display: flex;
	align-items: center;
	padding: 12px 16px;
	border-top: 1px solid #e0e0e0;
	gap: 8px;
}

.wp-content-agent-chat-input {
	flex: 1;
	border: 1px solid #ddd;
	border-radius: 20px;
	padding: 8px 16px;
	font-size: 14px;
	outline: none;
	transition: border-color 0.2s;
}

.wp-content-agent-chat-input:focus {
	border-color: var(--wpca-primary, #2271b1);
}

.wp-content-agent-chat-send {
	width: 36px;
	height: 36px;
	border-radius: 50%;
	background: var(--wpca-primary, #2271b1);
	color: #fff;
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s;
	flex-shrink: 0;
}

.wp-content-agent-chat-send:hover {
	background: var(--wpca-primary-hover, #135e96);
}

.wp-content-agent-chat-send .dashicons {
	font-size: 18px;
	width: 18px;
	height: 18px;
}

/* Resize handle at bottom-right corner of dialog. */
.wp-content-agent-chat-resize {
	position: absolute;
	bottom: 0;
	right: 0;
	width: 18px;
	height: 18px;
	cursor: nwse-resize;
	z-index: 10;
}

.wp-content-agent-chat-resize::after {
	content: '';
	position: absolute;
	bottom: 3px;
	right: 3px;
	width: 8px;
	height: 8px;
	border-right: 2px solid rgba(0, 0, 0, 0.25);
	border-bottom: 2px solid rgba(0, 0, 0, 0.25);
}

@media (max-width: 480px) {
	.wp-content-agent-chat-dialog {
		width: calc(100vw - 32px);
		right: -8px;
		bottom: 64px;
		height: 70vh;
	}

	.wp-content-agent-chat-dialog.dragged {
		right: -8px;
		bottom: 64px;
	}
}

/* Agent status indicator. */
.wpca-agent-status {
	padding: 8px 12px;
	color: #666;
	font-style: italic;
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 13px;
	align-self: flex-start;
}

.wpca-agent-spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid #ddd;
	border-top-color: #666;
	border-radius: 50%;
	animation: wpca-spin 0.8s linear infinite;
	flex-shrink: 0;
}

@keyframes wpca-spin {
	to { transform: rotate(360deg); }
}

/* Product cards. */
.wpca-product-card {
	background: #f8f9fa;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	padding: 10px 12px;
	margin: 6px 0;
	display: flex;
	justify-content: space-between;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.wpca-product-card-info {
	display: flex;
	flex-direction: column;
	gap: 2px;
	flex: 1;
	min-width: 0;
}

.wpca-product-card-name {
	font-weight: 600;
	color: #1a1a1a;
}

.wpca-product-card-desc {
	color: #666;
	font-size: 0.9em;
}

.wpca-product-card-price {
	color: #e74c3c;
	font-weight: 700;
	white-space: nowrap;
}

.wpca-product-card-link {
	color: #0073aa;
	text-decoration: none;
	font-size: 0.9em;
	white-space: nowrap;
}

.wpca-product-card-link:hover {
	text-decoration: underline;
}
