/* AI Chat Widget — Al-Shahen
   Forced light theme to defeat Safari/Chrome system dark-mode auto-styling.
*/

.aic-root,
.aic-root *,
.aic-root *::before,
.aic-root *::after {
	box-sizing: border-box;
}

.aic-root {
	--aic-primary:        #3564AF;
	--aic-primary-dark:   #244B8A;
	--aic-primary-light:  #4D7DC9;
	--aic-bg:             #ffffff;
	--aic-bg-soft:        #f3f5fa;
	--aic-border:         #e6eaf2;
	--aic-text:           #0f172a;
	--aic-text-soft:      #64748b;
	--aic-text-light:     #94a3b8;
	--aic-shadow:         0 24px 60px rgba(15, 23, 42, 0.18);
	--aic-radius:         18px;

	color-scheme: light;
	color: var(--aic-text);
	font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ===== Floating button (closed state) ===== */
.aic-fab {
	position: fixed;
	bottom: 22px;
	right: 22px;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: #ffffff !important;
	color: var(--aic-primary) !important;
	border: 0;
	cursor: pointer;
	box-shadow: 0 14px 32px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(53, 100, 175, 0.06);
	z-index: 1080;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 24px;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	-webkit-tap-highlight-color: transparent;
	animation: aic-pulse-ring 2.4s ease-out infinite;
}
.aic-fab i {
	color: var(--aic-primary) !important;
	font-size: 24px;
	pointer-events: none;
}
.aic-fab:hover  { transform: translateY(-3px) scale(1.04); box-shadow: 0 22px 48px rgba(15, 23, 42, 0.22); }
.aic-fab:active { transform: translateY(0) scale(0.98); }
[dir="rtl"] .aic-fab { right: auto; left: 22px; }

@keyframes aic-pulse-ring {
	0%   { box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18), 0 0 0 0   rgba(53, 100, 175, 0.45); }
	70%  { box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18), 0 0 0 18px rgba(53, 100, 175, 0); }
	100% { box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18), 0 0 0 0   rgba(53, 100, 175, 0); }
}

/* Alert badge on FAB */
.aic-fab-badge {
	position: absolute;
	top: 4px;
	right: 4px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 11px;
	background: #ef4444 !important;
	color: #ffffff !important;
	font-size: 11px;
	font-weight: 700;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 2px solid #ffffff;
	box-shadow: 0 2px 6px rgba(239, 68, 68, 0.45);
	animation: aic-badge-bounce 1.6s ease-in-out infinite;
}
[dir="rtl"] .aic-fab-badge { right: auto; left: 4px; }
@keyframes aic-badge-bounce {
	0%, 100% { transform: scale(1); }
	50%      { transform: scale(1.12); }
}

/* ===== Panel ===== */
.aic-panel {
	position: fixed;
	bottom: 22px;
	right: 22px;
	width: 410px;
	max-width: calc(100vw - 32px);
	height: min(640px, calc(100vh - 44px));
	background: var(--aic-bg) !important;
	border-radius: var(--aic-radius);
	box-shadow: var(--aic-shadow);
	z-index: 1090;
	display: none;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
	transform: translateY(20px) scale(0.96);
	opacity: 0;
	transition: opacity 0.18s ease, transform 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
.aic-panel.aic-open {
	display: flex;
	opacity: 1;
	transform: translateY(0) scale(1);
}
[dir="rtl"] .aic-panel { right: auto; left: 22px; transform-origin: bottom left; }

/* ===== Header ===== */
.aic-header {
	flex-shrink: 0;
	background: linear-gradient(135deg, var(--aic-primary) 0%, var(--aic-primary-dark) 100%);
	color: #ffffff !important;
	padding: 18px 20px;
	display: flex;
	align-items: center;
	gap: 14px;
}
.aic-avatar {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: #ffffff !important;
	color: var(--aic-primary) !important;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 22px;
	flex-shrink: 0;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
.aic-avatar i { color: var(--aic-primary) !important; font-size: 22px; }
.aic-header-text { flex: 1; min-width: 0; }
.aic-header h4 {
	margin: 0;
	font-size: 16px;
	font-weight: 700;
	color: #ffffff !important;
	line-height: 1.2;
}
.aic-header .aic-sub {
	font-size: 12px;
	opacity: 0.92;
	margin-top: 4px;
	color: #ffffff !important;
	display: flex;
	align-items: center;
	gap: 6px;
}
.aic-status-dot {
	width: 8px; height: 8px; border-radius: 50%;
	background: #4ade80;
	box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
	animation: aic-status 2s ease-in-out infinite;
}
@keyframes aic-status {
	0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7); }
	50%      { box-shadow: 0 0 0 6px rgba(74, 222, 128, 0); }
}
.aic-close {
	background: rgba(255, 255, 255, 0.16) !important;
	border: 0;
	color: #ffffff !important;
	cursor: pointer;
	width: 36px;
	height: 36px;
	border-radius: 10px;
	font-size: 16px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s ease;
}
.aic-close:hover { background: rgba(255, 255, 255, 0.28) !important; }
.aic-close i { color: #ffffff !important; font-size: 16px; }

/* ===== Messages ===== */
.aic-messages {
	flex: 1;
	overflow-y: auto;
	overflow-x: hidden;
	padding: 18px 16px;
	background: var(--aic-bg-soft) !important;
	display: flex;
	flex-direction: column;
	gap: 12px;
	scroll-behavior: smooth;
}
.aic-messages::-webkit-scrollbar { width: 6px; }
.aic-messages::-webkit-scrollbar-track { background: transparent; }
.aic-messages::-webkit-scrollbar-thumb { background: rgba(15, 23, 42, 0.18); border-radius: 3px; }

.aic-msg-row {
	display: flex;
	gap: 10px;
	max-width: 100%;
	align-items: flex-end;
}
.aic-msg-row-user { justify-content: flex-end; }
.aic-msg-row-bot  { justify-content: flex-start; }

.aic-msg-bubble-avatar {
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: #ffffff !important;
	color: var(--aic-primary) !important;
	border: 1px solid var(--aic-border);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 15px;
	flex-shrink: 0;
	margin-bottom: 2px;
	box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
}
.aic-msg-bubble-avatar i { color: var(--aic-primary) !important; font-size: 15px; }

.aic-msg {
	max-width: 78%;
	padding: 11px 15px;
	border-radius: 16px;
	font-size: 14px;
	line-height: 1.5;
	word-wrap: break-word;
	white-space: pre-wrap;
	color: var(--aic-text) !important;
	background: var(--aic-bg) !important;
}
.aic-msg-user {
	background: linear-gradient(135deg, var(--aic-primary) 0%, var(--aic-primary-dark) 100%) !important;
	color: #ffffff !important;
	border-bottom-right-radius: 4px;
}
.aic-msg-bot {
	background: var(--aic-bg) !important;
	color: var(--aic-text) !important;
	border: 1px solid var(--aic-border);
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
[dir="rtl"] .aic-msg-user { border-bottom-right-radius: 16px; border-bottom-left-radius: 4px; }
[dir="rtl"] .aic-msg-bot  { border-bottom-left-radius: 16px; border-bottom-right-radius: 4px; }

.aic-msg-system {
	align-self: center;
	background: transparent !important;
	color: var(--aic-text-soft) !important;
	font-size: 12px;
	font-style: italic;
	padding: 4px 10px;
	max-width: 100%;
	text-align: center;
}
.aic-msg-system.aic-msg-success { color: #15803d !important; font-weight: 600; }
.aic-msg-system.aic-msg-error   { color: #b91c1c !important; }

/* Typing indicator */
.aic-typing-row { display: flex; gap: 10px; align-items: flex-end; }
.aic-typing {
	background: var(--aic-bg) !important;
	border: 1px solid var(--aic-border);
	border-radius: 16px;
	border-bottom-left-radius: 4px;
	padding: 13px 16px;
	display: inline-flex;
	gap: 5px;
	box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.aic-typing span {
	display: inline-block;
	width: 8px; height: 8px;
	border-radius: 50%;
	background: var(--aic-primary);
	opacity: 0.55;
	animation: aic-bounce 1.4s infinite ease-in-out both;
}
.aic-typing span:nth-child(1) { animation-delay: -0.32s; }
.aic-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes aic-bounce {
	0%, 80%, 100% { transform: scale(0.6); opacity: 0.45; }
	40%           { transform: scale(1); opacity: 1; }
}

/* ===== Success state: ticket created card ===== */
.aic-success {
	align-self: center;
	max-width: 320px;
	width: 100%;
	background: #ffffff !important;
	border: 1px solid #d1fae5;
	border-radius: 16px;
	padding: 22px 20px 18px;
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.10);
	text-align: center;
	margin: 4px auto;
	animation: aic-pop-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
@keyframes aic-pop-in {
	from { transform: scale(0.9); opacity: 0; }
	to   { transform: scale(1);   opacity: 1; }
}
.aic-success-icon {
	width: 56px; height: 56px;
	border-radius: 50%;
	background: linear-gradient(135deg, #10b981 0%, #059669 100%);
	color: #fff;
	display: flex; align-items: center; justify-content: center;
	margin: 0 auto 12px;
	font-size: 24px;
	box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}
.aic-success-icon i { color: #fff !important; font-size: 24px; }
.aic-success-title {
	font-size: 15px;
	font-weight: 700;
	color: var(--aic-text) !important;
	margin-bottom: 4px;
}
.aic-success-ticket {
	display: inline-block;
	background: #f0fdf4;
	color: #15803d !important;
	font-size: 11px;
	font-weight: 700;
	padding: 3px 10px;
	border-radius: 12px;
	margin-bottom: 10px;
	letter-spacing: 0.04em;
}
.aic-success-body {
	font-size: 13px;
	color: var(--aic-text-soft) !important;
	line-height: 1.5;
	margin-bottom: 14px;
}
.aic-success-channels {
	display: flex; gap: 8px; justify-content: center;
	margin-bottom: 14px;
	font-size: 11px; color: var(--aic-text-soft) !important;
}
.aic-success-channels span {
	display: inline-flex; align-items: center; gap: 4px;
	padding: 3px 8px; border-radius: 8px; background: #f3f5fa;
}
.aic-success-channels i { color: var(--aic-primary) !important; font-size: 10px; }
.aic-success-btn {
	display: inline-flex; align-items: center; gap: 8px;
	padding: 10px 18px; border-radius: 22px;
	background: linear-gradient(135deg, var(--aic-primary) 0%, var(--aic-primary-dark) 100%) !important;
	color: #fff !important;
	border: 0; cursor: pointer;
	font-size: 13px; font-weight: 600;
	font-family: inherit;
	transition: transform 0.15s, box-shadow 0.15s;
	box-shadow: 0 4px 12px rgba(53, 100, 175, 0.32);
}
.aic-success-btn:hover  { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(53, 100, 175, 0.42); }
.aic-success-btn i      { color: #fff !important; }

/* ===== Guest gate (full-screen-style, blocks chat until filled) ===== */
.aic-guest-gate {
	display: none;
	position: absolute;
	inset: 0;
	top: 76px;          /* below header */
	background: var(--aic-bg) !important;
	padding: 24px 22px 22px;
	overflow-y: auto;
	z-index: 5;
}
.aic-guest-gate.aic-show { display: block; }

.aic-gate-icon {
	width: 56px;
	height: 56px;
	border-radius: 50%;
	background: rgba(53, 100, 175, 0.10) !important;
	color: var(--aic-primary) !important;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 22px;
	margin: 0 auto 12px;
}
.aic-gate-icon i { color: var(--aic-primary) !important; font-size: 22px; }

.aic-gate-title {
	font-size: 16px;
	font-weight: 700;
	color: var(--aic-text) !important;
	text-align: center;
	margin-bottom: 4px;
}
.aic-gate-sub {
	font-size: 13px;
	color: var(--aic-text-soft) !important;
	text-align: center;
	line-height: 1.4;
	margin-bottom: 16px;
}

.aic-guest-gate label {
	display: block;
	font-size: 11px;
	color: var(--aic-text-soft) !important;
	margin: 10px 0 4px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}
.aic-guest-gate input {
	-webkit-appearance: none;
	appearance: none;
	width: 100%;
	padding: 11px 14px;
	border: 1px solid var(--aic-border) !important;
	border-radius: 10px;
	font-size: 14px;
	background: var(--aic-bg) !important;
	color: var(--aic-text) !important;
	-webkit-text-fill-color: var(--aic-text) !important;
	font-family: inherit;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.aic-guest-gate input:focus {
	outline: 0;
	border-color: var(--aic-primary) !important;
	box-shadow: 0 0 0 3px rgba(53, 100, 175, 0.12);
}
.aic-guest-gate input.aic-invalid {
	border-color: #ef4444 !important;
	box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.aic-gate-submit {
	width: 100%;
	margin-top: 16px;
	padding: 12px 16px;
	border: 0;
	border-radius: 10px;
	background: linear-gradient(135deg, var(--aic-primary) 0%, var(--aic-primary-dark) 100%) !important;
	color: #ffffff !important;
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
	box-shadow: 0 6px 16px rgba(53, 100, 175, 0.32);
	font-family: inherit;
}
.aic-gate-submit:hover  { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(53, 100, 175, 0.42); }
.aic-gate-submit:active { transform: translateY(0); }

/* Locked input row (when guest gate is showing) */
.aic-input-row.aic-locked {
	pointer-events: none;
	opacity: 0.5;
	filter: grayscale(0.4);
}

/* ===== Input row ===== */
.aic-input-row {
	flex-shrink: 0;
	display: flex;
	gap: 10px;
	padding: 14px 16px;
	background: var(--aic-bg) !important;
	border-top: 1px solid var(--aic-border);
	align-items: flex-end;
}
.aic-input {
	-webkit-appearance: none;
	appearance: none;
	flex: 1;
	padding: 12px 18px;
	border: 1px solid var(--aic-border) !important;
	border-radius: 24px;
	font-size: 14px;
	resize: none;
	max-height: 120px;
	min-height: 46px;
	outline: 0;
	font-family: inherit;
	background: var(--aic-bg-soft) !important;
	color: var(--aic-text) !important;
	-webkit-text-fill-color: var(--aic-text) !important;
	transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
	line-height: 1.4;
}
.aic-input::placeholder { color: var(--aic-text-light) !important; opacity: 1; }
.aic-input:focus {
	border-color: var(--aic-primary) !important;
	background: var(--aic-bg) !important;
	box-shadow: 0 0 0 3px rgba(53, 100, 175, 0.12);
}

.aic-send {
	background: linear-gradient(135deg, var(--aic-primary) 0%, var(--aic-primary-dark) 100%) !important;
	color: #ffffff !important;
	border: 0;
	border-radius: 50%;
	width: 46px;
	height: 46px;
	cursor: pointer;
	flex-shrink: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 16px;
	transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
	box-shadow: 0 6px 16px rgba(53, 100, 175, 0.36);
}
.aic-send:hover:not(:disabled)  { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(53, 100, 175, 0.46); }
.aic-send:active:not(:disabled) { transform: translateY(0); }
.aic-send:disabled              { opacity: 0.5; cursor: not-allowed; box-shadow: none; }
.aic-send i { color: #ffffff !important; font-size: 16px; }
[dir="rtl"] .aic-send i { transform: scaleX(-1); }

/* ===== Footer (powered-by) ===== */
.aic-footer {
	flex-shrink: 0;
	padding: 8px 16px 10px;
	font-size: 10px;
	text-align: center;
	color: var(--aic-text-light) !important;
	background: var(--aic-bg) !important;
	border-top: 1px solid var(--aic-border);
	letter-spacing: 0.02em;
}

/* ===== Mobile ===== */
@media (max-width: 480px) {
	.aic-panel {
		width: calc(100vw - 16px);
		right: 8px;
		bottom: 8px;
		height: calc(100vh - 16px);
		border-radius: 14px;
	}
	[dir="rtl"] .aic-panel { left: 8px; right: auto; }
	.aic-fab {
		bottom: 16px; right: 16px;
		width: 56px; height: 56px;
		font-size: 22px;
	}
	.aic-fab i { font-size: 22px; }
	[dir="rtl"] .aic-fab { left: 16px; right: auto; }
}

/* ===== Hard override against site dark-mode media queries (Safari) ===== */
@media (prefers-color-scheme: dark) {
	.aic-root,
	.aic-root .aic-input,
	.aic-root .aic-guest-form input,
	.aic-root .aic-msg-bot,
	.aic-root .aic-typing,
	.aic-root .aic-msg-bubble-avatar {
		color-scheme: light;
	}
	.aic-root .aic-input,
	.aic-root .aic-guest-form input {
		background: var(--aic-bg-soft) !important;
		color: var(--aic-text) !important;
		-webkit-text-fill-color: var(--aic-text) !important;
	}
}
