/* ═══════════════════════════════════════════════════════════════
   AI Chat Widget — AtlasDigital
   ═══════════════════════════════════════════════════════════════ */

.ai-chat-root {
	--ai-bg: #0d0f0e;
	--ai-surface: #1a1e1b;
	--ai-border: rgba(255, 255, 255, 0.08);
	--ai-text: #f0f2f0;
	--ai-text-sec: #a8b0a8;
	--ai-accent: #00c562;
	--ai-accent-hover: #00e672;
	--ai-user-bg: #00c562;
	--ai-user-text: #0d0f0e;
	--ai-radius: 12px;
	--ai-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

/* ── FAB button ──────────────────────────────────────────── */

.ai-chat-fab {
	position: fixed;
	bottom: 24px;
	right: 24px;
	z-index: 99999;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	border: none;
	background: linear-gradient(135deg, #00c562 0%, #007a3d 100%);
	color: #fff;
	font-size: 24px;
	cursor: pointer;
	box-shadow: 0 4px 16px rgba(0, 197, 98, 0.35);
	transition: all 0.2s ease;
	display: flex;
	align-items: center;
	justify-content: center;
}

.ai-chat-fab:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(0, 197, 98, 0.5);
}

.ai-chat-fab.ai-hidden {
	transform: scale(0);
	opacity: 0;
	pointer-events: none;
}

/* ── Modal ───────────────────────────────────────────────── */

.ai-chat-modal {
	position: fixed;
	bottom: 90px;
	right: 24px;
	z-index: 99998;
	width: 380px;
	max-width: calc(100vw - 48px);
	height: 520px;
	max-height: calc(100vh - 120px);
	background: var(--ai-surface);
	border: 1px solid var(--ai-border);
	border-radius: var(--ai-radius);
	box-shadow: var(--ai-shadow);
	display: flex;
	flex-direction: column;
	transform: translateY(20px);
	opacity: 0;
	pointer-events: none;
	transition: all 0.25s ease;
}

.ai-chat-modal.ai-open {
	transform: translateY(0);
	opacity: 1;
	pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────── */

.ai-chat-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-bottom: 1px solid var(--ai-border);
}

.ai-chat-title {
	font-size: 15px;
	font-weight: 600;
	color: var(--ai-text);
}

.ai-chat-close {
	background: none;
	border: none;
	color: var(--ai-text-sec);
	font-size: 18px;
	cursor: pointer;
	padding: 4px;
	border-radius: 4px;
	transition: color 0.15s;
}

.ai-chat-close:hover {
	color: var(--ai-text);
}

/* ── Messages ────────────────────────────────────────────── */

.ai-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px 20px;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

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

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

.ai-chat-messages::-webkit-scrollbar-thumb {
	background: var(--ai-border);
	border-radius: 2px;
}

/* ── Message bubbles ─────────────────────────────────────── */

.ai-msg {
	max-width: 85%;
	animation: aiFadeIn 0.2s ease;
}

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

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

.ai-msg-asistente,
.ai-msg-assistant {
	align-self: flex-start;
}

.ai-msg-error .ai-msg-text {
	border-color: #ff4d4d;
	background: rgba(255, 77, 77, 0.08);
}

.ai-msg-text {
	padding: 10px 14px;
	border-radius: 12px;
	font-size: 13.5px;
	line-height: 1.5;
	word-wrap: break-word;
}

.ai-msg-user .ai-msg-text {
	background: var(--ai-user-bg);
	color: var(--ai-user-text);
	border-bottom-right-radius: 4px;
}

.ai-msg-asistente .ai-msg-text,
.ai-msg-assistant .ai-msg-text {
	background: rgba(255, 255, 255, 0.06);
	color: var(--ai-text);
	border-bottom-left-radius: 4px;
}

/* ── Pending action ──────────────────────────────────────── */

.ai-chat-pending {
	padding: 0 20px 12px;
}

.ai-pending-box {
	background: rgba(0, 197, 98, 0.08);
	border: 1px solid rgba(0, 197, 98, 0.2);
	border-radius: 10px;
	padding: 14px;
}

.ai-pending-summary {
	font-size: 13px;
	color: var(--ai-text);
	margin-bottom: 10px;
	line-height: 1.4;
}

.ai-pending-actions {
	display: flex;
	gap: 8px;
}

.ai-pending-actions button {
	flex: 1;
	padding: 8px 12px;
	border-radius: 8px;
	font-size: 12px;
	font-weight: 600;
	border: none;
	cursor: pointer;
	transition: all 0.15s;
}

.ai-pending-confirm {
	background: var(--ai-accent);
	color: var(--ai-user-text);
}

.ai-pending-confirm:hover {
	background: var(--ai-accent-hover);
}

.ai-pending-cancel {
	background: rgba(255, 255, 255, 0.06);
	color: var(--ai-text-sec);
	border: 1px solid var(--ai-border);
}

.ai-pending-cancel:hover {
	background: rgba(255, 255, 255, 0.1);
}

/* ── Input bar ───────────────────────────────────────────── */

.ai-chat-input-bar {
	display: flex;
	gap: 8px;
	padding: 12px 20px;
	border-top: 1px solid var(--ai-border);
}

.ai-chat-input {
	flex: 1;
	padding: 10px 14px;
	border-radius: 24px;
	border: 1px solid var(--ai-border);
	background: rgba(255, 255, 255, 0.04);
	color: var(--ai-text);
	font-size: 13px;
	outline: none;
	transition: border-color 0.15s;
}

.ai-chat-input:focus {
	border-color: var(--ai-accent);
}

.ai-chat-input::placeholder {
	color: var(--ai-text-sec);
}

.ai-chat-send {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	border: none;
	background: var(--ai-accent);
	color: var(--ai-user-text);
	font-size: 16px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.15s;
	flex-shrink: 0;
}

.ai-chat-send:hover {
	background: var(--ai-accent-hover);
}

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

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 480px) {
	.ai-chat-modal {
		bottom: 0;
		right: 0;
		width: 100%;
		height: 100%;
		max-width: 100%;
		max-height: 100%;
		border-radius: 0;
	}

	.ai-chat-fab {
		bottom: 16px;
		right: 16px;
	}
}
