/**
 * Starter Adult Shop — Live Chat Widget
 * Uses --lc-accent, --lc-x, --lc-y CSS vars injected inline by PHP.
 */

/* ===== Widget container ===== */
.sas-lc-widget {
	position: fixed;
	z-index: 99999;
	font-family: 'Inter', sans-serif;
	font-size: 14px;
	line-height: 1.5;
}

/* Position variants */
.sas-lc-widget.sas-lc-pos--right  { right: var(--lc-x, 24px); bottom: var(--lc-y, 80px); }
.sas-lc-widget.sas-lc-pos--left   { left:  var(--lc-x, 24px); bottom: var(--lc-y, 80px); }
.sas-lc-widget.sas-lc-pos--bottom-center {
	left: 50%; transform: translateX(-50%);
	bottom: var(--lc-y, 24px);
}

/* ===== Toggle button ===== */
.sas-lc-toggle {
	width: 56px; height: 56px;
	border-radius: 50%;
	background: var(--lc-accent, #e8628a);
	border: none; cursor: pointer;
	display: flex; align-items: center; justify-content: center;
	box-shadow: 0 4px 20px rgba(0,0,0,.25);
	transition: transform .2s, box-shadow .2s;
	position: relative;
}
.sas-lc-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(0,0,0,.3); }
.sas-lc-toggle .sas-lc-icon { width: 26px; height: 26px; stroke: #fff; transition: opacity .2s; }
.sas-lc-toggle .sas-lc-toggle__close { color: #fff; font-size: 18px; display: none; }
.sas-lc-toggle--open .sas-lc-icon { display: none; }
.sas-lc-toggle--open .sas-lc-toggle__close { display: block; }

.sas-lc-badge {
	position: absolute; top: -4px; right: -4px;
	width: 18px; height: 18px; border-radius: 50%;
	background: #ff4757; color: #fff;
	font-size: 10px; font-weight: 700;
	display: flex; align-items: center; justify-content: center;
	border: 2px solid var(--sas-bg, #0e0a14);
}

/* ===== Panel ===== */
.sas-lc-panel {
	position: absolute;
	bottom: 70px;
	width: 340px;
	max-height: 520px;
	background: var(--sas-card-flat, #1a1028);
	border: 1px solid var(--sas-border, rgba(232,98,138,.08));
	border-radius: 16px;
	box-shadow: 0 12px 48px rgba(0,0,0,.35);
	display: flex; flex-direction: column;
	overflow: hidden;
	opacity: 0; transform: translateY(12px) scale(.97);
	transition: opacity .25s, transform .25s;
	pointer-events: none;
}
.sas-lc-pos--right  .sas-lc-panel { right: 0; }
.sas-lc-pos--left   .sas-lc-panel { left: 0; }
.sas-lc-pos--bottom-center .sas-lc-panel { left: 50%; transform: translateX(-50%) translateY(12px) scale(.97); }

.sas-lc-panel--open {
	opacity: 1; transform: translateY(0) scale(1);
	pointer-events: all;
}
.sas-lc-pos--bottom-center .sas-lc-panel--open {
	transform: translateX(-50%) translateY(0) scale(1);
}

/* ===== Header ===== */
.sas-lc-header {
	display: flex; align-items: center; justify-content: space-between;
	padding: 14px 16px;
	background: var(--lc-accent, #e8628a);
	flex-shrink: 0;
}
.sas-lc-header__info { display: flex; align-items: center; gap: 10px; }
.sas-lc-header__avatar {
	width: 36px; height: 36px; border-radius: 50%;
	background: rgba(255,255,255,.2);
	display: flex; align-items: center; justify-content: center;
}
.sas-lc-header__avatar .sas-lc-icon { width: 18px; height: 18px; stroke: #fff; }
.sas-lc-header__title { color: #fff; font-weight: 700; font-size: 14px; }
.sas-lc-header__status { color: rgba(255,255,255,.85); font-size: 11px; display: flex; align-items: center; gap: 5px; }
.sas-lc-dot {
	width: 7px; height: 7px; border-radius: 50%;
	background: #4ade80;
	box-shadow: 0 0 0 2px rgba(74,222,128,.3);
	animation: sas-lc-pulse 2s infinite;
}
@keyframes sas-lc-pulse {
	0%,100% { box-shadow: 0 0 0 2px rgba(74,222,128,.3); }
	50%      { box-shadow: 0 0 0 5px rgba(74,222,128,.1); }
}
.sas-lc-close {
	background: none; border: none; color: rgba(255,255,255,.8);
	cursor: pointer; font-size: 16px; padding: 4px; line-height: 1;
	transition: color .2s;
}
.sas-lc-close:hover { color: #fff; }

/* ===== Tab nav ===== */
.sas-lc-tabs-nav {
	display: flex; border-bottom: 1px solid var(--sas-border3, rgba(255,255,255,.06));
	flex-shrink: 0;
}
.sas-lc-tnav {
	flex: 1; padding: 9px 4px; background: none; border: none;
	color: var(--sas-text3, rgba(255,255,255,.5));
	font-size: 12px; font-weight: 600; cursor: pointer;
	border-bottom: 2px solid transparent; margin-bottom: -1px;
	transition: color .2s, border-color .2s;
}
.sas-lc-tnav:hover { color: var(--sas-text2, rgba(255,255,255,.7)); }
.sas-lc-tnav.active { color: var(--lc-accent, #e8628a); border-bottom-color: var(--lc-accent, #e8628a); }

/* ===== Views ===== */
.sas-lc-view { display: none; flex-direction: column; flex: 1; overflow: hidden; }
.sas-lc-view.active { display: flex; }

/* ===== Chat messages ===== */
.sas-lc-messages {
	flex: 1; overflow-y: auto; padding: 14px 12px;
	display: flex; flex-direction: column; gap: 8px;
	scrollbar-width: thin;
}
.sas-lc-messages::-webkit-scrollbar { width: 4px; }
.sas-lc-messages::-webkit-scrollbar-thumb { background: var(--sas-border2, rgba(232,98,138,.15)); border-radius: 2px; }

.sas-lc-msg { display: flex; }
.sas-lc-msg--user { justify-content: flex-end; }
.sas-lc-msg--bot  { justify-content: flex-start; }

.sas-lc-msg__bubble {
	max-width: 82%; padding: 9px 13px;
	border-radius: 14px; font-size: 13px; line-height: 1.55;
}
.sas-lc-msg--user .sas-lc-msg__bubble {
	background: var(--lc-accent, #e8628a); color: #fff;
	border-bottom-right-radius: 4px;
}
.sas-lc-msg--bot .sas-lc-msg__bubble {
	background: var(--sas-bg2, #1a1028);
	border: 1px solid var(--sas-border3, rgba(255,255,255,.06));
	color: var(--sas-text2, rgba(255,255,255,.8));
	border-bottom-left-radius: 4px;
}
.sas-lc-msg--typing .sas-lc-msg__bubble { opacity: .6; font-style: italic; }
.sas-lc-msg__bubble--html { max-width: 100%; }

/* ===== Quick replies ===== */
.sas-lc-quick-replies {
	padding: 6px 12px 10px;
	display: flex; flex-wrap: wrap; gap: 6px;
	flex-shrink: 0;
}
.sas-lc-quick-btn {
	padding: 5px 11px; border-radius: 20px;
	background: none;
	border: 1px solid var(--lc-accent, #e8628a);
	color: var(--lc-accent, #e8628a);
	font-size: 11px; cursor: pointer;
	transition: background .2s, color .2s;
	white-space: nowrap;
}
.sas-lc-quick-btn:hover { background: var(--lc-accent, #e8628a); color: #fff; }

/* ===== Input row ===== */
.sas-lc-input-row {
	display: flex; gap: 6px; padding: 10px 12px;
	border-top: 1px solid var(--sas-border3, rgba(255,255,255,.06));
	flex-shrink: 0;
}
.sas-lc-input {
	flex: 1; padding: 8px 12px;
	background: var(--sas-input-bg, rgba(255,255,255,.05));
	border: 1px solid var(--sas-border3, rgba(255,255,255,.08));
	border-radius: 20px; color: var(--sas-text, #fff);
	font-size: 13px; outline: none;
	transition: border-color .2s;
}
.sas-lc-input:focus { border-color: var(--lc-accent, #e8628a); }
.sas-lc-input::placeholder { color: var(--sas-text4, rgba(255,255,255,.4)); }
.sas-lc-send {
	width: 36px; height: 36px; border-radius: 50%;
	background: var(--lc-accent, #e8628a); border: none;
	display: flex; align-items: center; justify-content: center;
	cursor: pointer; flex-shrink: 0; transition: opacity .2s;
}
.sas-lc-send:hover { opacity: .85; }
.sas-lc-send svg { width: 16px; height: 16px; stroke: #fff; }

/* ===== Channels view ===== */
.sas-lc-channels { padding: 12px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; }
.sas-lc-channel {
	display: flex; align-items: center; gap: 12px;
	padding: 12px 14px; border-radius: 10px;
	background: var(--sas-bg2, #1a1028);
	border: 1px solid var(--sas-border3, rgba(255,255,255,.06));
	color: var(--sas-text, #fff); text-decoration: none;
	transition: border-color .2s, background .2s;
}
.sas-lc-channel:hover { border-color: var(--lc-accent, #e8628a); background: var(--sas-card-hover-bg, rgba(232,98,138,.06)); }
.sas-lc-ch-icon { width: 32px; height: 32px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.sas-lc-ch-icon svg { width: 22px; height: 22px; }
.sas-lc-channel--whatsapp  .sas-lc-ch-icon { color: #25d366; }
.sas-lc-channel--facebook  .sas-lc-ch-icon { color: #0084ff; }
.sas-lc-channel--telegram  .sas-lc-ch-icon { color: #2aabee; }
.sas-lc-channel--instagram .sas-lc-ch-icon { color: #e1306c; }
.sas-lc-channel--twitter   .sas-lc-ch-icon { color: #1da1f2; }
.sas-lc-channel--line      .sas-lc-ch-icon { color: #00c300; }
.sas-lc-channel--email     .sas-lc-ch-icon { color: var(--lc-accent, #e8628a); }
.sas-lc-channel span { font-size: 13px; font-weight: 500; }

/* ===== Order view ===== */
.sas-lc-order-lookup { padding: 14px 12px; display: flex; flex-direction: column; gap: 10px; flex: 1; overflow-y: auto; }
.sas-lc-order-lookup__label { font-size: 13px; color: var(--sas-text2, rgba(255,255,255,.7)); }
.sas-lc-order-result { margin-top: 4px; }
.sas-lc-order-card {
	background: var(--sas-bg2, #1a1028);
	border: 1px solid var(--sas-border3, rgba(255,255,255,.06));
	border-radius: 10px; padding: 12px 14px;
	display: flex; flex-direction: column; gap: 8px;
}
.sas-lc-order-card__row {
	display: flex; justify-content: space-between; align-items: center;
	font-size: 12px; color: var(--sas-text2, rgba(255,255,255,.7));
}
.sas-lc-order-error { font-size: 12px; color: var(--sas-danger, #ff6b6b); padding: 8px 0; }
.sas-lc-loading { font-size: 12px; color: var(--sas-text3, rgba(255,255,255,.5)); padding: 8px 0; }

/* Order status badges */
.sas-lc-status {
	padding: 2px 8px; border-radius: 20px;
	font-size: 11px; font-weight: 600;
}
.sas-lc-status--completed  { background: rgba(74,222,128,.15); color: #4ade80; }
.sas-lc-status--processing { background: rgba(251,191,36,.15);  color: #fbbf24; }
.sas-lc-status--pending    { background: rgba(148,163,184,.15); color: #94a3b8; }
.sas-lc-status--cancelled  { background: rgba(248,113,113,.15); color: #f87171; }
.sas-lc-status--on-hold    { background: rgba(167,139,250,.15); color: #a78bfa; }
.sas-lc-status--refunded   { background: rgba(148,163,184,.15); color: #94a3b8; }

/* ===== Product recommendations ===== */
.sas-lc-recs { margin-top: 4px; }
.sas-lc-recs__label { font-size: 12px; color: var(--sas-text3, rgba(255,255,255,.5)); margin-bottom: 8px; }
.sas-lc-recs__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.sas-lc-rec-card {
	display: flex; flex-direction: column;
	background: var(--sas-bg2, #1a1028);
	border: 1px solid var(--sas-border3, rgba(255,255,255,.06));
	border-radius: 8px; overflow: hidden;
	text-decoration: none; transition: border-color .2s;
}
.sas-lc-rec-card:hover { border-color: var(--lc-accent, #e8628a); }
.sas-lc-rec-card img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.sas-lc-rec-card__name { font-size: 11px; color: var(--sas-text2, rgba(255,255,255,.7)); padding: 5px 7px 2px; line-height: 1.3; }
.sas-lc-rec-card__price { font-size: 11px; color: var(--lc-accent, #e8628a); font-weight: 600; padding: 0 7px 6px; }

/* ===== Compact channel strip (bottom of chat view) ===== */
.sas-lc-chat-channels {
	display: flex; align-items: center; gap: 8px;
	padding: 8px 12px;
	border-top: 1px solid var(--sas-border3, rgba(255,255,255,.06));
	flex-shrink: 0;
}
.sas-lc-chat-channels__label {
	font-size: 11px; color: var(--sas-text3, rgba(255,255,255,.5));
	white-space: nowrap; flex-shrink: 0;
}
.sas-lc-chat-channels__icons { display: flex; gap: 6px; flex-wrap: wrap; }
.sas-lc-chat-ch {
	width: 30px; height: 30px; border-radius: 50%;
	background: var(--sas-bg2, #1a1028);
	border: 1px solid var(--sas-border3, rgba(255,255,255,.06));
	display: flex; align-items: center; justify-content: center;
	text-decoration: none; transition: border-color .2s, background .2s;
}
.sas-lc-chat-ch:hover { border-color: var(--lc-accent, #e8628a); background: var(--sas-card-hover-bg, rgba(232,98,138,.06)); }
.sas-lc-chat-ch .sas-lc-ch-icon { width: 18px; height: 18px; }
.sas-lc-chat-ch .sas-lc-ch-icon svg { width: 16px; height: 16px; }

/* Inline fallback channel suggestion (inside message bubble) */
.sas-lc-chat-channels--inline {
	border-top: none; padding: 4px 0 0;
	background: none; flex-wrap: wrap;
}

body.sas-light .sas-lc-chat-channels { border-color: #f0dce4; }
body.sas-light .sas-lc-chat-ch { background: #fff; border-color: #f0dce4; }

/* ===== Misc ===== */
.sas-lc-link { color: var(--lc-accent, #e8628a); text-decoration: underline; font-size: 12px; }
.sas-lc-empty { padding: 20px; text-align: center; color: var(--sas-text3, rgba(255,255,255,.5)); font-size: 13px; }

/* ===== Email Gate ===== */
.sas-lc-gate {
	position: absolute; inset: 0;
	background: var(--sas-card-flat, #1a1028);
	border-radius: 16px;
	display: flex; align-items: center; justify-content: center;
	z-index: 10;
	padding: 24px 20px;
}
.sas-lc-gate__body {
	width: 100%; text-align: center;
	display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.sas-lc-gate__icon {
	width: 52px; height: 52px; border-radius: 50%;
	background: var(--lc-accent, #e8628a);
	display: flex; align-items: center; justify-content: center;
	margin-bottom: 4px;
}
.sas-lc-gate__icon .sas-lc-icon { width: 24px; height: 24px; stroke: #fff; }
.sas-lc-gate__title {
	font-size: 16px; font-weight: 700;
	color: var(--sas-text, #fff);
	margin: 0;
}
.sas-lc-gate__desc {
	font-size: 12px; color: var(--sas-text3, rgba(255,255,255,.5));
	margin: 0; line-height: 1.5;
}
.sas-lc-gate__form {
	width: 100%; display: flex; flex-direction: column; gap: 8px;
	margin-top: 4px;
}
.sas-lc-gate__form .sas-lc-input { border-radius: 10px; text-align: left; }
.sas-lc-gate__btn {
	display: flex; align-items: center; justify-content: center; gap: 8px;
	width: 100%; padding: 10px 16px;
	background: var(--lc-accent, #e8628a); color: #fff;
	border: none; border-radius: 10px;
	font-size: 14px; font-weight: 600; cursor: pointer;
	transition: opacity .2s;
}
.sas-lc-gate__btn:hover { opacity: .88; }
.sas-lc-gate__btn:disabled { opacity: .55; cursor: not-allowed; }
.sas-lc-gate__btn svg { width: 16px; height: 16px; stroke: #fff; flex-shrink: 0; }
.sas-lc-gate__error {
	font-size: 12px; color: var(--sas-danger, #ff6b6b);
	text-align: left; padding: 2px 4px;
}
.sas-lc-gate__privacy {
	font-size: 11px; color: var(--sas-text4, rgba(255,255,255,.35));
	margin: 0;
}

/* Light mode gate */
body.sas-light .sas-lc-gate,
body.sas-light #sas-lc-gate {
	background: #fff !important;
	--sas-card-flat: #fff;
}
body.sas-light .sas-lc-gate__title { color: #2d2235 !important; }
body.sas-light .sas-lc-gate__desc { color: #9a8a9e !important; }
body.sas-light .sas-lc-gate__privacy { color: #bbaec4 !important; }

/* Light mode panel — also override CSS vars used inside */
body.sas-light .sas-lc-panel {
	--sas-card-flat: #fff;
	--sas-bg2: #f9f0f4;
	--sas-border3: rgba(232,98,138,.1);
	--sas-text: #2d2235;
	--sas-text2: #5a4a62;
	--sas-text3: #9a8a9e;
	--sas-text4: #b0a0b5;
	--sas-input-bg: #f9f0f4;
}

/* ===== Light mode ===== */
body.sas-light .sas-lc-panel {
	background: #fff;
	border-color: #f0dce4;
	box-shadow: 0 12px 48px rgba(45,34,53,.12);
}
body.sas-light .sas-lc-msg--bot .sas-lc-msg__bubble { background: #f9f0f4; border-color: #f0dce4; color: #2d2235; }
body.sas-light .sas-lc-input { background: #f9f0f4; border-color: #e0c8d4; color: #2d2235; }
body.sas-light .sas-lc-input::placeholder { color: #9a8a9e; }
body.sas-light .sas-lc-channel { background: #fff; border-color: #f0dce4; color: #2d2235; }
body.sas-light .sas-lc-order-card { background: #fff; border-color: #f0dce4; }
body.sas-light .sas-lc-order-card__row { color: #5a4a62; }
body.sas-light .sas-lc-rec-card { background: #fff; border-color: #f0dce4; }
body.sas-light .sas-lc-rec-card__name { color: #5a4a62; }
body.sas-light .sas-lc-tabs-nav { border-color: #f0dce4; }
body.sas-light .sas-lc-tnav { color: #9a8a9e; }
body.sas-light .sas-lc-input-row { border-color: #f0dce4; }
body.sas-light .sas-lc-badge { border-color: #f5f0f3; }

/* ===== Mobile ===== */
@media (max-width: 480px) {
	.sas-lc-panel { width: calc(100vw - 24px); max-height: 70vh; }
	.sas-lc-pos--right  .sas-lc-panel { right: 0; }
	.sas-lc-pos--left   .sas-lc-panel { left: 0; }
	.sas-lc-pos--bottom-center .sas-lc-panel { left: 12px; transform: none; }
	.sas-lc-pos--bottom-center .sas-lc-panel--open { transform: none; }
}

/* ===== Mobile: avoid sticky ATC bar + iOS browser chrome ===== */
@media (max-width: 768px) {
	/* Base: lift widget above iOS browser chrome safe area */
	.sas-lc-widget.sas-lc-pos--right,
	.sas-lc-widget.sas-lc-pos--left {
		bottom: calc(var(--lc-y, 80px) + var(--lc-y-offset, 0px) + env(safe-area-inset-bottom, 0px)) !important;
	}
	/* On single product pages: start with sticky ATC height pre-accounted */
	body.single-product .sas-lc-widget {
		bottom: calc(var(--lc-y, 80px) + var(--lc-y-offset, 72px) + env(safe-area-inset-bottom, 0px)) !important;
	}
}
