/* ERP Assistant — chat bubble + tracking page. Uses the ERP Theme tokens when present. */

.erpa-root, .erpa-track {
	--a-primary: var(--erp-primary, #d0021b);
	--a-ink: var(--erp-ink, #111);
	--a-text: var(--erp-text, #222);
	--a-muted: var(--erp-muted, #5b5b5b);
	--a-line: var(--erp-line, #e4e4e4);
	--a-soft: var(--erp-soft, #f6f6f6);
	--a-bg: var(--erp-bg, #fff);
	--a-green: var(--erp-green, #15803d);
	--a-radius: 14px;
	font-family: var(--erp-font, inherit);
	color: var(--a-text);
}

/* ---- bubble ---- */
.erpa-root { position: fixed; right: 20px; bottom: 20px; z-index: 99990; display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.erpa-fab {
	display: inline-flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 20px 0 14px;
	border: 0; border-radius: 999px; background: var(--a-ink); color: #fff; font: inherit; font-weight: 700; font-size: 15px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, .22); cursor: pointer; transition: transform .15s ease, box-shadow .15s ease;
}
.erpa-fab:hover { transform: translateY(-1px); box-shadow: 0 14px 34px rgba(0, 0, 0, .28); }
.erpa-fab:focus-visible { outline: 3px solid var(--a-primary); outline-offset: 3px; }
.erpa-fab__icon { width: 28px; height: 28px; border-radius: 50%; background: var(--a-primary); position: relative; flex: none; }
.erpa-fab__icon::before { content: ""; position: absolute; inset: 8px 7px 9px; border: 2px solid #fff; border-radius: 6px 6px 6px 2px; }
.erpa-root.is-open .erpa-fab__label { display: none; }
.erpa-root.is-open .erpa-fab { padding: 0 12px; }

/* ---- panel ---- */
.erpa-panel {
	width: min(390px, calc(100vw - 32px)); height: min(620px, calc(100vh - 110px)); display: flex; flex-direction: column;
	background: var(--a-bg); border: 1px solid var(--a-line); border-radius: 18px; overflow: hidden;
	box-shadow: 0 24px 60px rgba(0, 0, 0, .22);
}
.erpa-panel[hidden] { display: none; }
.erpa-head { display: flex; align-items: center; gap: 6px; padding: 14px 12px 14px 18px; background: var(--a-ink); color: #fff; }
.erpa-head__titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.erpa-head__titles strong { font-size: 16px; }
.erpa-head__badge { font-size: 11.5px; color: #ffd27a; }
.erpa-icon-btn { width: 36px; height: 36px; border: 0; border-radius: 10px; background: transparent; color: #fff; font-size: 17px; cursor: pointer; }
.erpa-icon-btn:hover { background: rgba(255, 255, 255, .12); }
.erpa-icon-btn:focus-visible { outline: 2px solid #fff; }

.erpa-log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 8px; background: var(--a-soft); overscroll-behavior: contain; }
.erpa-msg { display: flex; }
.erpa-msg--user { justify-content: flex-end; }
.erpa-msg__bubble { max-width: 85%; padding: 10px 13px; border-radius: var(--a-radius); line-height: 1.45; font-size: 14.5px; white-space: pre-line; }
.erpa-msg--bot .erpa-msg__bubble { background: var(--a-bg); border: 1px solid var(--a-line); border-bottom-left-radius: 4px; color: var(--a-text); }
.erpa-msg--user .erpa-msg__bubble { background: var(--a-ink); color: #fff; border-bottom-right-radius: 4px; }
.erpa-msg--wide > * { width: 100%; }

.erpa-typing { display: inline-flex; gap: 4px; align-items: center; }
.erpa-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--a-muted); animation: erpa-dot 1s infinite ease-in-out; }
.erpa-typing i:nth-child(2) { animation-delay: .15s; }
.erpa-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes erpa-dot { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* chips */
.erpa-chips { display: flex; flex-wrap: wrap; gap: 6px; padding-left: 2px; }
.erpa-chips--menu { flex-direction: column; align-items: stretch; }
.erpa-chip {
	display: inline-flex; align-items: center; min-height: 38px; padding: 7px 14px; border: 1.5px solid var(--a-ink); border-radius: 999px;
	background: var(--a-bg); color: var(--a-ink); font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; text-align: left; line-height: 1.25;
}
.erpa-chips--menu .erpa-chip { border-radius: 12px; min-height: 46px; font-size: 15px; }
.erpa-chip:hover { background: var(--a-ink); color: #fff; }
.erpa-chip:focus-visible { outline: 3px solid var(--a-primary); outline-offset: 2px; }
.erpa-chip--primary { background: var(--a-primary); border-color: var(--a-primary); color: #fff; }
.erpa-chip--primary:hover { filter: brightness(.92); background: var(--a-primary); }
.erpa-chips.is-done .erpa-chip { opacity: .4; cursor: default; pointer-events: none; }
.erpa-chips.is-done .erpa-chip.is-picked { display: none; }
.erpa-chips.is-done a.erpa-chip { opacity: 1; pointer-events: auto; cursor: pointer; }

/* product cards */
.erpa-cards { display: flex; flex-direction: column; gap: 8px; }
.erpa-card {
	display: flex; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--a-line); border-radius: var(--a-radius);
	background: var(--a-bg); color: var(--a-text); text-decoration: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.erpa-card:hover { border-color: var(--a-ink); box-shadow: 0 6px 16px rgba(0, 0, 0, .08); }
.erpa-card:focus-visible { outline: 3px solid var(--a-primary); outline-offset: 2px; }
.erpa-card img { width: 72px; height: 72px; object-fit: contain; border-radius: 10px; background: var(--a-soft); flex: none; }
.erpa-card__body { flex: 1; min-width: 0; }
.erpa-card__body p { margin: 0; }
.erpa-card__title { font-weight: 700; font-size: 14px; line-height: 1.3; color: var(--a-ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.erpa-card__price { font-size: 13.5px; margin-top: 4px !important; }
.erpa-card__price strong { color: var(--a-primary); }
.erpa-card__price span, .erpa-card__meta { color: var(--a-muted); font-size: 12.5px; }
.erpa-card__note { color: #b45309; font-size: 12.5px; font-weight: 600; }
.erpa-card__go { font-size: 24px; color: var(--a-muted); padding-right: 4px; }

/* compose */
.erpa-compose { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--a-line); background: var(--a-bg); }
.erpa-input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; border: 1.5px solid var(--a-line); border-radius: 999px; font: inherit; font-size: 16px; color: var(--a-text); background: var(--a-bg); }
.erpa-input:focus { outline: none; border-color: var(--a-ink); }
.erpa-send { width: 44px; height: 44px; flex: none; border: 0; border-radius: 50%; background: var(--a-primary); color: #fff; font-size: 16px; cursor: pointer; }
.erpa-send:focus-visible { outline: 3px solid var(--a-ink); outline-offset: 2px; }

/* forms (chat + page) */
.erpa-form { display: grid; gap: 10px; padding: 12px; border: 1px solid var(--a-line); border-radius: var(--a-radius); background: var(--a-bg); }
.erpa-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--a-ink); }
.erpa-form input { height: 44px; padding: 0 12px; border: 1.5px solid var(--a-line); border-radius: 10px; font: inherit; font-size: 16px; }
.erpa-form input:focus { outline: none; border-color: var(--a-ink); }
.erpa-form__err { margin: 0; color: #b91c1c; font-size: 13.5px; }
.erpa-form__err:empty { display: none; }
.erpa-btn {
	display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 16px; border: 1.5px solid var(--a-ink); border-radius: 10px;
	background: var(--a-bg); color: var(--a-ink); font: inherit; font-weight: 700; font-size: 14px; text-decoration: none; cursor: pointer;
}
.erpa-btn--primary { background: var(--a-primary); border-color: var(--a-primary); color: #fff; }
.erpa-btn:disabled { opacity: .6; cursor: progress; }

/* order card */
.erpa-order { padding: 14px; border: 1px solid var(--a-line); border-radius: var(--a-radius); background: var(--a-bg); display: grid; gap: 10px; }
.erpa-order__head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.erpa-order__head strong { font-size: 17px; color: var(--a-ink); }
.erpa-order__head span { color: var(--a-muted); font-size: 13px; }
.erpa-order p { margin: 0; }
.erpa-order__msg { font-size: 14.5px; line-height: 1.45; }
.erpa-order__note { padding: 8px 10px; background: var(--a-soft); border-radius: 8px; font-size: 14px; }
.erpa-order__status { font-weight: 700; }
.erpa-order__actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.erpa-order__ship { font-size: 13px; color: var(--a-muted); }
.erpa-order__items summary { cursor: pointer; font-size: 13.5px; font-weight: 600; }
.erpa-order__items ul { margin: 6px 0 0; padding-left: 18px; font-size: 13.5px; }

.erpa-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.erpa-steps__item { position: relative; display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 14px; color: var(--a-muted); }
.erpa-steps__item:not(:last-child)::after { content: ""; position: absolute; left: 8px; top: 24px; bottom: -8px; width: 2px; background: var(--a-line); }
.erpa-steps__dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--a-line); background: var(--a-bg); flex: none; position: relative; z-index: 1; }
.erpa-steps__item.is-done { color: var(--a-text); }
.erpa-steps__item.is-done .erpa-steps__dot { background: var(--a-green); border-color: var(--a-green); }
.erpa-steps__item.is-done .erpa-steps__dot::after { content: ""; position: absolute; left: 4px; top: 1px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.erpa-steps__item.is-done:not(:last-child)::after { background: var(--a-green); }
.erpa-steps__item.is-current { color: var(--a-ink); font-weight: 700; }
.erpa-steps__item.is-current .erpa-steps__dot { border-color: var(--a-primary); box-shadow: 0 0 0 4px color-mix(in srgb, var(--a-primary) 18%, transparent); }
.erpa-steps__item.is-current .erpa-steps__dot::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--a-primary); }

/* tracking page */
.erpa-track { max-width: 560px; display: grid; gap: 14px; margin: 1.5em 0; }
.erpa-track__h { font-size: 1.15em; margin: .6em 0 0; }
.erpa-track .erpa-form { padding: 18px; }

/* how-to page */
.erpa-video { position: relative; margin: 1.2em 0 1.8em; }
.erpa-video iframe { width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 12px; }
.erpa-admin-hint { padding: 10px 14px; border: 1px dashed #b45309; border-radius: 8px; color: #b45309; font-size: 14px; }

/* phones: panel = full screen; bubble above the product page's bottom bar */
@media (max-width: 600px) {
	.erpa-root { right: 12px; bottom: 12px; }
	.single-product .erpa-root { bottom: 88px; }
	.erpa-fab__label { display: none; }
	.erpa-fab { width: 56px; height: 56px; padding: 0; justify-content: center; }
	.erpa-root.is-open { inset: 0; right: 0; bottom: 0; }
	.erpa-root.is-open .erpa-fab { display: none; }
	.erpa-panel { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
}

@media (prefers-reduced-motion: reduce) {
	.erpa-fab, .erpa-card { transition: none; }
	.erpa-typing i { animation: none; opacity: .6; }
}

/* ERP Theme accessibility button: sits above the chat bubble (same corner), hidden while the chat is open */
body:has(#erpa-root):not(.erpt-a11y-left) .erpt-a11y { translate: 0 -72px; }
body:has(.erpa-root.is-open):not(.erpt-a11y-left) .erpt-a11y { display: none; }
@media (max-width: 600px) {
	body:has(#erpa-root):not(.erpt-a11y-left) .erpt-a11y { translate: 0 -64px; }
	body:has(.erpa-root.is-open) .erpt-a11y { display: none; }
}
