/**
 * StockOracle AI — Admin Assistant Chat Widget
 *
 * Floating chat bubble + slide-up panel for the WP admin area.
 *
 * @package Codefreex_StockOracle_AI
 * @license GPL-2.0-or-later
 */

/* -----------------------------------------------------------------------
   Root container
----------------------------------------------------------------------- */
.soa-assistant-root {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 99999;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
	font-size: 13px;
	line-height: 1.5;
}

/* -----------------------------------------------------------------------
   Floating trigger button
----------------------------------------------------------------------- */
.soa-assistant-trigger {
	position: relative;
	width: 52px;
	height: 52px;
	border-radius: 50%;
	background: linear-gradient(135deg, #6c63ff 0%, #5a54e8 100%);
	border: none;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 16px rgba(108, 99, 255, .45);
	transition: transform .2s, box-shadow .2s;
	outline: none;
	color: #fff;
}

.soa-assistant-trigger:hover {
	transform: scale(1.08);
	box-shadow: 0 6px 22px rgba(108, 99, 255, .55);
}

.soa-assistant-trigger:focus-visible {
	box-shadow: 0 0 0 3px rgba(108, 99, 255, .4), 0 4px 16px rgba(108, 99, 255, .45);
}

.soa-assistant-trigger-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	transition: opacity .15s, transform .15s;
}

.soa-trigger-close {
	display: none;
}

.soa-assistant-root.is-open .soa-trigger-open {
	display: none;
}

.soa-assistant-root.is-open .soa-trigger-close {
	display: flex;
}

/* Unread badge */
.soa-assistant-badge {
	position: absolute;
	top: -2px;
	right: -2px;
	width: 18px;
	height: 18px;
	background: #ef4444;
	color: #fff;
	border-radius: 50%;
	font-size: 11px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid #f0f0f1;
}

/* -----------------------------------------------------------------------
   Chat panel
----------------------------------------------------------------------- */
.soa-assistant-panel {
	position: absolute;
	bottom: 64px;
	right: 0;
	width: 360px;
	max-height: 540px;
	background: #fff;
	border-radius: 16px;
	box-shadow:
		0 20px 60px rgba(0, 0, 0, .15),
		0 4px 16px rgba(0, 0, 0, .08);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	transform: scale(.9) translateY(8px);
	opacity: 0;
	pointer-events: none;
	transition: transform .22s cubic-bezier(.34, 1.56, .64, 1), opacity .18s ease;
}

.soa-assistant-root.is-open .soa-assistant-panel {
	transform: scale(1) translateY(0);
	opacity: 1;
	pointer-events: all;
}

/* -----------------------------------------------------------------------
   Header
----------------------------------------------------------------------- */
.soa-assistant-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 14px 16px;
	background: linear-gradient(135deg, #6c63ff 0%, #5a54e8 100%);
	color: #fff;
	flex-shrink: 0;
}

.soa-assistant-header-info {
	display: flex;
	align-items: center;
	gap: 10px;
}

.soa-assistant-avatar {
	width: 34px;
	height: 34px;
	background: rgba(255, 255, 255, .2);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.soa-assistant-name {
	font-weight: 700;
	font-size: 13px;
}

.soa-assistant-status {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 11px;
	opacity: .85;
}

.soa-status-dot {
	width: 7px;
	height: 7px;
	background: #4ade80;
	border-radius: 50%;
	animation: soa-pulse 2s infinite;
}

@keyframes soa-pulse {
	0%, 100% { opacity: 1; }
	50%       { opacity: .5; }
}

.soa-assistant-header-actions {
	display: flex;
	gap: 4px;
}

.soa-assistant-action-btn {
	background: rgba(255, 255, 255, .15);
	border: none;
	color: #fff;
	width: 28px;
	height: 28px;
	border-radius: 6px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background .15s;
	padding: 0;
}

.soa-assistant-action-btn:hover {
	background: rgba(255, 255, 255, .3);
}

/* -----------------------------------------------------------------------
   Messages area
----------------------------------------------------------------------- */
.soa-assistant-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scroll-behavior: smooth;
	min-height: 180px;
}

.soa-assistant-messages::-webkit-scrollbar {
	width: 4px;
}

.soa-assistant-messages::-webkit-scrollbar-track {
	background: transparent;
}

.soa-assistant-messages::-webkit-scrollbar-thumb {
	background: #d1d5db;
	border-radius: 2px;
}

/* Message bubbles */
.soa-msg {
	display: flex;
	flex-direction: column;
	max-width: 88%;
	animation: soa-msg-in .2s ease;
}

@keyframes soa-msg-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

.soa-msg-user {
	align-self: flex-end;
	align-items: flex-end;
}

.soa-msg-bot {
	align-self: flex-start;
	align-items: flex-start;
}

.soa-msg-sender {
	font-size: 10px;
	font-weight: 600;
	color: #9ca3af;
	margin-bottom: 3px;
	text-transform: uppercase;
	letter-spacing: .4px;
}

.soa-msg-bubble {
	padding: 10px 14px;
	border-radius: 14px;
	font-size: 13px;
	line-height: 1.55;
	word-break: break-word;
}

.soa-msg-user .soa-msg-bubble {
	background: linear-gradient(135deg, #6c63ff 0%, #5a54e8 100%);
	color: #fff;
	border-bottom-right-radius: 4px;
}

.soa-msg-bot .soa-msg-bubble {
	background: #f3f4f6;
	color: #1f2937;
	border-bottom-left-radius: 4px;
}

.soa-msg-bot .soa-msg-bubble a {
	color: #6c63ff;
	text-decoration: underline;
}

.soa-msg-bot .soa-msg-bubble ul,
.soa-msg-bot .soa-msg-bubble ol {
	margin: .5em 0 .5em 1.2em;
	padding: 0;
}

.soa-msg-bot .soa-msg-bubble li {
	margin-bottom: 3px;
}

.soa-msg-bot .soa-msg-bubble code {
	background: #e5e7eb;
	padding: 1px 5px;
	border-radius: 3px;
	font-size: 12px;
	font-family: monospace;
}

/* Typing indicator */
.soa-msg-typing .soa-msg-bubble {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 12px 16px;
}

.soa-typing-dot {
	width: 7px;
	height: 7px;
	background: #9ca3af;
	border-radius: 50%;
	animation: soa-typing-bounce .9s infinite;
}

.soa-typing-dot:nth-child(2) { animation-delay: .15s; }
.soa-typing-dot:nth-child(3) { animation-delay: .30s; }

@keyframes soa-typing-bounce {
	0%, 80%, 100% { transform: translateY(0); }
	40%           { transform: translateY(-6px); }
}

/* -----------------------------------------------------------------------
   Quick questions
----------------------------------------------------------------------- */
.soa-assistant-quick {
	padding: 0 12px 10px;
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	flex-shrink: 0;
}

.soa-quick-btn {
	background: #f0eeff;
	color: #6c63ff;
	border: 1px solid #d5d0ff;
	border-radius: 20px;
	padding: 4px 12px;
	font-size: 11px;
	font-weight: 500;
	cursor: pointer;
	transition: background .15s, transform .1s;
	white-space: nowrap;
	max-width: 100%;
	overflow: hidden;
	text-overflow: ellipsis;
}

.soa-quick-btn:hover {
	background: #e0d9ff;
	transform: translateY(-1px);
}

/* -----------------------------------------------------------------------
   Input area
----------------------------------------------------------------------- */
.soa-assistant-input-wrap {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px;
	border-top: 1px solid #f3f4f6;
	background: #fff;
	flex-shrink: 0;
}

.soa-assistant-input {
	flex: 1;
	border: 1px solid #e5e7eb;
	border-radius: 10px;
	padding: 8px 12px;
	font-size: 13px;
	font-family: inherit;
	resize: none;
	outline: none;
	background: #f9fafb;
	transition: border-color .15s, background .15s;
	max-height: 80px;
	overflow-y: auto;
	color: #1f2937;
}

.soa-assistant-input:focus {
	border-color: #6c63ff;
	background: #fff;
}

.soa-assistant-input::placeholder {
	color: #9ca3af;
}

.soa-assistant-send {
	width: 34px;
	height: 34px;
	border-radius: 10px;
	background: linear-gradient(135deg, #6c63ff 0%, #5a54e8 100%);
	border: none;
	color: #fff;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: opacity .15s, transform .1s;
}

.soa-assistant-send:hover:not(:disabled) {
	opacity: .9;
	transform: scale(1.05);
}

.soa-assistant-send:disabled {
	opacity: .5;
	cursor: not-allowed;
}

/* -----------------------------------------------------------------------
   Responsive — on very small viewports reduce width
----------------------------------------------------------------------- */
@media (max-width: 480px) {
	.soa-assistant-root {
		bottom: 16px;
		right: 16px;
	}

	.soa-assistant-panel {
		width: calc(100vw - 32px);
		right: 0;
	}
}
