/**
 * myCIVIS AI – Chat Widget Styles
 *
 * Styles for both inline and floating chat widget.
 *
 * @package MyCivisAI
 */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600&family=Playfair+Display:ital,wght@0,400;0,600;0,700;1,400&display=swap');

/* ─── CSS Custom Properties (Theme) ─────────────────────────────── */
:root {
	--mycivis-primary: #d4af37; /* Metallic Gold */
	--mycivis-primary-hover: #b5952f;
	--mycivis-bg: #141414; /* Deep luxury dark */
	--mycivis-bg-secondary: #1a1a1a;
	--mycivis-border: #2a2a2a;
	--mycivis-text: #f4f4f4;
	--mycivis-text-secondary: #a3a3a3;
	--mycivis-user-bg: #222222;
	--mycivis-user-text: #ffffff;
	--mycivis-assistant-bg: #1a1a1a;
	--mycivis-assistant-text: #f4f4f4;
	--mycivis-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
	--mycivis-radius: 12px;
	--mycivis-font-body: 'Outfit', sans-serif;
	--mycivis-font-heading: 'Playfair Display', serif;
}

/* ─── Container ──────────────────────────────────────────────────── */
.mycivis-chat-container {
	font-family: var(--mycivis-font-body);
	font-size: 15px;
	line-height: 1.5;
	color: var(--mycivis-text);
	box-sizing: border-box;
}

.mycivis-chat-container *,
.mycivis-chat-container *::before,
.mycivis-chat-container *::after {
	box-sizing: inherit;
}

/* ─── Inline Mode ────────────────────────────────────────────────── */
.mycivis-chat--inline {
	background: var(--mycivis-bg);
	border: 1px solid var(--mycivis-border);
	border-radius: var(--mycivis-radius);
	overflow: hidden;
	max-width: 700px;
	margin: 24px auto;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* ─── Floating Mode ──────────────────────────────────────────────── */
.mycivis-chat--floating {
	position: fixed;
	bottom: 90px;
	right: 24px;
	width: 400px;
	max-width: calc(100vw - 48px);
	max-height: 600px;
	background: var(--mycivis-bg);
	border-radius: var(--mycivis-radius);
	box-shadow: var(--mycivis-shadow);
	z-index: 99999;
	display: none;
	flex-direction: column;
	overflow: hidden;
}

.mycivis-chat--floating.is-open {
	display: flex;
}

/* ─── Header ─────────────────────────────────────────────────────── */
.mycivis-chat-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 16px;
	background: var(--mycivis-primary);
	color: #fff;
}

.mycivis-chat-title {
	margin: 0;
	font-family: var(--mycivis-font-heading);
	font-size: 18px;
	font-weight: 600;
	letter-spacing: 0.5px;
}

.mycivis-chat-header-actions {
	display: flex;
	gap: 6px;
}

.mycivis-chat-btn {
	background: transparent;
	border: none;
	color: rgba(255, 255, 255, 0.8);
	cursor: pointer;
	padding: 4px;
	border-radius: 4px;
	line-height: 1;
	transition: color 0.15s, background 0.15s;
}

.mycivis-chat-btn:hover {
	color: #fff;
	background: rgba(255, 255, 255, 0.15);
}

/* Hide close button in inline mode */
.mycivis-chat--inline .mycivis-chat-btn--close {
	display: none;
}

/* ─── Messages ───────────────────────────────────────────────────── */
.mycivis-chat-messages {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	min-height: 200px;
	max-height: 400px;
}

.mycivis-chat--floating .mycivis-chat-messages {
	max-height: 380px;
}

.mycivis-chat-welcome {
	text-align: center;
	color: var(--mycivis-text-secondary);
	padding: 20px 16px;
}

.mycivis-chat-welcome p {
	margin: 0;
}

/* Individual message bubble */
.mycivis-chat-message {
	margin-bottom: 12px;
	display: flex;
	flex-direction: column;
}

.mycivis-chat-message--user {
	align-items: flex-end;
}

.mycivis-chat-message--assistant {
	align-items: flex-start;
}

.mycivis-chat-bubble {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: 16px;
	word-wrap: break-word;
	white-space: pre-wrap;
}

.mycivis-chat-message--user .mycivis-chat-bubble {
	background: var(--mycivis-user-bg);
	color: var(--mycivis-user-text);
	border-bottom-right-radius: 4px;
}

.mycivis-chat-message--assistant .mycivis-chat-bubble {
	background: var(--mycivis-assistant-bg);
	color: var(--mycivis-assistant-text);
	border-bottom-left-radius: 4px;
}

/* Typing indicator */
.mycivis-chat-typing {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 10px 14px;
	background: var(--mycivis-assistant-bg);
	border-radius: 16px;
	border-bottom-left-radius: 4px;
	max-width: 80px;
}

.mycivis-chat-typing-dot {
	width: 6px;
	height: 6px;
	background: var(--mycivis-text-secondary);
	border-radius: 50%;
	animation: mycivis-bounce 1.4s infinite ease-in-out both;
}

.mycivis-chat-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.mycivis-chat-typing-dot:nth-child(2) { animation-delay: -0.16s; }
.mycivis-chat-typing-dot:nth-child(3) { animation-delay: 0s; }

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

/* ─── Page Content (search results) ──────────────────────────────── */
.mycivis-chat-page-content {
	border-top: 1px solid var(--mycivis-border);
	padding: 0;
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.3s ease, padding 0.3s ease;
}

.mycivis-chat-page-content.has-content {
	padding: 12px 16px;
	max-height: 300px;
	overflow-y: auto;
}

.mycivis-chat-post-list {
	list-style: none;
	margin: 0;
	padding: 0;
}

.mycivis-chat-post-item {
	padding: 8px 0;
	border-bottom: 1px solid var(--mycivis-border);
}

.mycivis-chat-post-item:last-child {
	border-bottom: none;
}

.mycivis-chat-post-link {
	color: var(--mycivis-primary);
	text-decoration: none;
	font-weight: 500;
	font-size: 14px;
}

.mycivis-chat-post-link:hover {
	text-decoration: underline;
	color: var(--mycivis-primary-hover);
}

.mycivis-chat-post-excerpt {
	color: var(--mycivis-text-secondary);
	font-size: 13px;
	margin: 4px 0 0;
}

/* ─── Input Form ─────────────────────────────────────────────────── */
.mycivis-chat-form {
	border-top: 1px solid var(--mycivis-border);
	padding: 12px 16px;
	background: var(--mycivis-bg);
}

.mycivis-chat-input-wrapper {
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

.mycivis-chat-input {
	flex: 1;
	border: 1px solid var(--mycivis-border);
	border-radius: 20px;
	padding: 8px 16px;
	font-size: 14px;
	font-family: inherit;
	resize: none;
	line-height: 1.4;
	max-height: 120px;
	overflow-y: auto;
	outline: none;
	transition: border-color 0.15s;
}

.mycivis-chat-input:focus {
	border-color: var(--mycivis-primary);
	box-shadow: 0 0 0 1px var(--mycivis-primary);
}

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

.mycivis-chat-send:hover {
	background: var(--mycivis-primary-hover);
}

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

/* ─── Floating Toggle Button ─────────────────────────────────────── */
.mycivis-chat-toggle {
	position: fixed;
	bottom: 24px;
	right: 24px;
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: var(--mycivis-primary);
	color: #fff;
	border: none;
	box-shadow: var(--mycivis-shadow);
	cursor: pointer;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s, transform 0.2s;
}

.mycivis-chat-toggle:hover {
	background: var(--mycivis-primary-hover);
	transform: scale(1.05);
}

.mycivis-chat-toggle-icon--close {
	display: none;
}

.mycivis-chat-toggle.is-active .mycivis-chat-toggle-icon--open {
	display: none;
}

.mycivis-chat-toggle.is-active .mycivis-chat-toggle-icon--close {
	display: block;
}

/* ═══════════════════════════════════════════════════════════════════
   BAR MODE — Full-width hero search bar (stile CIVIS)
   ═══════════════════════════════════════════════════════════════════ */
.mycivis-chat--bar {
	background: transparent;
	border: none;
	border-radius: 0;
	max-width: 100%;
	margin: 0;
	box-shadow: none;
}

/* Hero section */
.mycivis-chat--bar .mycivis-bar-hero {
	background: linear-gradient(135deg, #0f1419 0%, #1a2332 50%, #0d2137 100%);
	padding: 72px 24px;
	text-align: center;
	position: relative;
	overflow: hidden;
}

.mycivis-chat--bar .mycivis-bar-hero::before {
	content: '';
	position: absolute;
	inset: 0;
	background:
		radial-gradient(circle at 30% 50%, rgba(34, 113, 177, 0.15) 0%, transparent 50%),
		radial-gradient(circle at 70% 80%, rgba(34, 113, 177, 0.08) 0%, transparent 50%);
	pointer-events: none;
}

.mycivis-bar-title {
	color: #ffffff;
	font-family: var(--mycivis-font-heading);
	font-size: 2.8rem;
	font-weight: 700;
	letter-spacing: 1px;
	margin: 0 0 12px;
	position: relative;
	z-index: 1;
}

.mycivis-bar-subtitle {
	color: rgba(255, 255, 255, 0.55);
	font-size: 1rem;
	margin: 0 0 32px;
	position: relative;
	z-index: 1;
}

/* Search bar (horizontal) */
.mycivis-chat--bar .mycivis-bar-search {
	display: flex;
	width: 100%;
	max-width: 640px;
	margin: 0 auto;
	position: relative;
	z-index: 1;
	align-items: stretch;
}

.mycivis-chat--bar .mycivis-bar-input {
	flex: 1;
	width: 100%;
	min-height: 54px;
	padding: 15px 20px;
	border: 2px solid rgba(255, 255, 255, 0.1);
	border-right: none;
	border-radius: 12px 0 0 12px;
	background: rgba(255, 255, 255, 0.08);
	backdrop-filter: blur(12px);
	-webkit-backdrop-filter: blur(12px);
	color: #ffffff;
	font-size: 1rem;
	font-family: inherit;
	outline: none;
	transition: border-color 0.3s, background 0.3s;
	box-sizing: border-box;
	margin: 0;
	line-height: 1.4;
	resize: none;
	overflow: hidden;
}

.mycivis-chat--bar .mycivis-bar-input::placeholder {
	color: rgba(255, 255, 255, 0.4);
}

.mycivis-chat--bar .mycivis-bar-input:focus {
	border-color: var(--mycivis-primary);
	background: rgba(255, 255, 255, 0.12);
}

.mycivis-chat--bar .mycivis-bar-send {
	height: 54px;
	padding: 0 28px;
	background: var(--mycivis-primary);
	color: #ffffff;
	border: 2px solid var(--mycivis-primary);
	border-radius: 0 12px 12px 0;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	font-size: 0.95rem;
	font-weight: 600;
	font-family: inherit;
	transition: background 0.2s;
	box-sizing: border-box;
	margin: 0;
	line-height: 1;
}

.mycivis-chat--bar .mycivis-bar-send:hover {
	background: var(--mycivis-primary-hover);
}

.mycivis-chat--bar .mycivis-bar-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

/* Compact mode: smaller hero after first response */
.mycivis-chat--bar.is-compact .mycivis-bar-hero {
	padding: 24px;
}

.mycivis-chat--bar.is-compact .mycivis-bar-title,
.mycivis-chat--bar.is-compact .mycivis-bar-subtitle {
	display: none;
}

/* AI response banner (replaces chat bubbles in bar mode) */
.mycivis-bar-response {
	background: rgba(255, 255, 255, 0.08);
	backdrop-filter: blur(10px);
	padding: 0;
	max-width: 800px;
	margin: 20px auto 0;
	border-radius: 16px;
	color: rgba(255, 255, 255, 0.92);
	font-size: 0.95rem;
	line-height: 1.75;
	position: relative;
	z-index: 1;
	display: none;
	border: 1px solid rgba(255, 255, 255, 0.1);
}

.mycivis-bar-response.is-visible {
	display: block;
	animation: mycivis-fade-in 0.4s ease;
}

/* Answer wrapper inside response */
.mycivis-bar-answer {
	padding: 24px 32px;
	text-align: left;
}

.mycivis-bar-answer p {
	margin: 0 0 12px;
}

.mycivis-bar-answer p:last-child {
	margin-bottom: 0;
}

/* Headers in response */
.mycivis-bar-answer h3 {
	font-size: 1.15rem;
	font-weight: 700;
	margin: 20px 0 8px;
	color: #fff;
}

.mycivis-bar-answer h4 {
	font-size: 1rem;
	font-weight: 600;
	margin: 16px 0 6px;
	color: rgba(255, 255, 255, 0.95);
}

/* Links in response */
.mycivis-bar-answer a,
.mycivis-response-link {
	color: #64b5f6;
	text-decoration: none;
	font-weight: 500;
	border-bottom: 1px solid rgba(100, 181, 246, 0.3);
	transition: color 0.2s, border-color 0.2s;
}

.mycivis-bar-answer a:hover,
.mycivis-response-link:hover {
	color: #90caf9;
	border-bottom-color: #90caf9;
}

/* Bold & emphasis */
.mycivis-bar-answer strong {
	font-weight: 700;
	color: #fff;
}

.mycivis-bar-answer em {
	font-style: italic;
	color: rgba(255, 255, 255, 0.85);
}

/* Lists */
.mycivis-bar-answer ul {
	margin: 12px 0;
	padding-left: 24px;
	list-style: none;
}

.mycivis-bar-answer ul li {
	margin: 8px 0;
	padding-left: 16px;
	position: relative;
}

.mycivis-bar-answer ul li::before {
	content: '→';
	position: absolute;
	left: 0;
	color: #64b5f6;
	font-weight: 600;
}

/* Inline code */
.mycivis-bar-answer code {
	background: rgba(255, 255, 255, 0.1);
	padding: 2px 6px;
	border-radius: 4px;
	font-family: 'SF Mono', 'Fira Code', monospace;
	font-size: 0.85em;
}

/* Loading state */
.mycivis-bar-loading {
	padding: 24px 32px;
	text-align: center;
	font-size: 0.95rem;
	color: rgba(255, 255, 255, 0.7);
}

/* Error state */
.mycivis-bar-error {
	padding: 24px 32px;
	text-align: center;
	color: #ef9a9a;
}

/* Section title above cards */
.mycivis-liquid-section-title {
	font-size: 0.8rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 1.5px;
	color: var(--mycivis-text-secondary);
	margin-bottom: 16px;
	padding-bottom: 8px;
	border-bottom: 2px solid var(--mycivis-border);
}

/* Card type badge */
.mycivis-liquid-card__type {
	display: inline-block;
	font-size: 0.7rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 1px;
	color: var(--mycivis-primary);
	background: rgba(34, 113, 177, 0.08);
	padding: 3px 8px;
	border-radius: 4px;
	margin-bottom: 8px;
}

/* Reset button */
.mycivis-bar-reset {
	display: none;
	margin: 20px auto;
	padding: 10px 24px;
	background: transparent;
	color: var(--mycivis-primary);
	border: 2px solid var(--mycivis-primary);
	border-radius: 999px;
	font-size: 0.875rem;
	font-weight: 600;
	font-family: inherit;
	cursor: pointer;
	transition: all 0.2s;
}

.mycivis-bar-reset:hover {
	background: var(--mycivis-primary);
	color: #ffffff;
}

.mycivis-chat--bar.is-compact .mycivis-bar-reset {
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

/* Liquid zone: dynamic page content below */
.mycivis-bar-liquid {
	max-width: 1100px;
	margin: 0 auto;
	padding: 32px 24px;
	min-height: 0;
}

/* Spinner in bar mode */
.mycivis-bar-spinner {
	display: inline-block;
	width: 16px;
	height: 16px;
	border: 2px solid rgba(255, 255, 255, 0.2);
	border-top-color: rgba(255, 255, 255, 0.7);
	border-radius: 50%;
	animation: mycivis-spin 0.6s linear infinite;
	vertical-align: middle;
	margin-right: 6px;
}

/* ─── Liquid Layout Components (shared by bar & inline) ──────────── */

/* Post Detail */
.mycivis-liquid-detail {
	background: var(--mycivis-bg);
	border-radius: var(--mycivis-radius);
	box-shadow: var(--mycivis-shadow);
	overflow: hidden;
	animation: mycivis-slide-up 0.4s ease;
}

.mycivis-liquid-detail__header {
	background: linear-gradient(135deg, #0f1419 0%, #1a2332 100%);
	padding: 48px 40px;
	color: #fff;
}

.mycivis-liquid-detail__category {
	font-size: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.1em;
	color: var(--mycivis-primary);
	font-weight: 700;
	margin-bottom: 12px;
}

.mycivis-liquid-detail__title {
	font-family: var(--mycivis-font-heading);
	font-size: 2.4rem;
	font-weight: 700;
	margin: 0 0 16px;
	line-height: 1.3;
}

.mycivis-liquid-detail__excerpt {
	font-size: 1.1rem;
	color: rgba(255, 255, 255, 0.7);
	margin: 0;
	line-height: 1.6;
}

.mycivis-liquid-detail__body {
	padding: 40px;
	font-size: 1rem;
	line-height: 1.8;
	color: var(--mycivis-text);
}

.mycivis-liquid-detail__body h2,
.mycivis-liquid-detail__body h3 {
	margin-top: 24px;
	margin-bottom: 12px;
	font-weight: 700;
}

.mycivis-liquid-detail__cta {
	padding: 24px 40px 40px;
}

.mycivis-liquid-detail__cta a {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 14px 28px;
	background: var(--mycivis-primary);
	color: #fff;
	border-radius: 12px;
	font-weight: 700;
	text-decoration: none;
	transition: background 0.2s, transform 0.2s;
}

.mycivis-liquid-detail__cta a:hover {
	background: var(--mycivis-primary-hover);
	transform: translateY(-2px);
}

/* Post Card Grid */
.mycivis-liquid-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
	gap: 24px;
	animation: mycivis-slide-up 0.4s ease;
}

.mycivis-liquid-card {
	background: var(--mycivis-bg);
	border-radius: var(--mycivis-radius);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
	border: 1px solid var(--mycivis-border);
	transition: transform 0.2s, box-shadow 0.2s;
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

/* Card with image: vertical layout (image on top) */
.mycivis-liquid-card.has-image {
	flex-direction: column;
}

.mycivis-liquid-card__image {
	width: 100%;
	height: 200px;
	overflow: hidden;
}

.mycivis-liquid-card__image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.3s ease;
}

.mycivis-liquid-card:hover .mycivis-liquid-card__image img {
	transform: scale(1.05);
}

/* Card body (text side) */
.mycivis-liquid-card__body {
	padding: 20px 24px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	flex: 1;
}

/* Card without image: body gets padding directly */
.mycivis-liquid-card:not(.has-image) {
	padding: 28px;
}

.mycivis-liquid-card:not(.has-image) .mycivis-liquid-card__body {
	padding: 0;
}

.mycivis-liquid-card:hover {
	transform: translateY(-4px);
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
}

.mycivis-liquid-card__title {
	font-size: 1.05rem;
	font-weight: 700;
	color: var(--mycivis-text);
	margin: 0;
}

.mycivis-liquid-card__excerpt {
	font-size: 0.85rem;
	color: var(--mycivis-text-secondary);
	line-height: 1.6;
	margin: 0;
	flex: 1;
}

.mycivis-liquid-card__link {
	color: var(--mycivis-primary);
	font-size: 0.85rem;
	font-weight: 600;
	text-decoration: none;
}

.mycivis-liquid-card__link:hover {
	color: var(--mycivis-primary-hover);
	text-decoration: underline;
}

.mycivis-badge {
	display: inline-block;
	font-size: 10px;
	text-transform: uppercase;
	font-weight: 700;
	padding: 2px 6px;
	border-radius: 4px;
	letter-spacing: 0.5px;
}

.mycivis-badge-product {
	background: #eef2ff;
	color: #4f46e5;
}

.mycivis-badge-article {
	background: #f3f4f6;
	color: #4b5563;
}

/* ─── Animations ─────────────────────────────────────────────────── */
@keyframes mycivis-fade-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

@keyframes mycivis-slide-up {
	from { opacity: 0; transform: translateY(20px); }
	to   { opacity: 1; transform: translateY(0); }
}

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

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
	.mycivis-bar-title { font-size: 1.4rem; }
	.mycivis-chat--bar .mycivis-bar-hero { padding: 48px 16px; }
	.mycivis-chat--bar .mycivis-bar-input { padding: 14px 16px; font-size: 0.9rem; }
	.mycivis-chat--bar .mycivis-bar-send span { display: none; }
	.mycivis-liquid-detail__header { padding: 32px 24px; }
	.mycivis-liquid-detail__body { padding: 24px; }
	.mycivis-liquid-grid { grid-template-columns: 1fr; }
	.mycivis-liquid-card.has-image { flex-direction: column; }
	.mycivis-liquid-card__image { width: 100%; min-height: 160px; max-height: 200px; }
	.mycivis-bar-answer { padding: 16px 20px; }
}

@media (max-width: 480px) {
	.mycivis-chat--floating {
		bottom: 0;
		right: 0;
		left: 0;
		width: 100%;
		max-width: 100%;
		max-height: 100vh;
		border-radius: 16px 16px 0 0;
	}

	.mycivis-chat--floating .mycivis-chat-messages {
		max-height: calc(100vh - 200px);
	}

	.mycivis-chat-toggle {
		bottom: 16px;
		right: 16px;
	}
}

