/* PrintSale AI asistents — čata logiņš */
#psai-chat-root { position: fixed; inset: 0; pointer-events: none; z-index: 99999; font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
#psai-chat-root * { box-sizing: border-box; }

#psai-chat-root .screen-reader-text {
	position: absolute; width: 1px; height: 1px; overflow: hidden;
	clip: rect(0 0 0 0); white-space: nowrap;
}

/* --- Palaidējs --- */
.psai-launcher {
	pointer-events: auto;
	position: fixed; right: 20px; bottom: 20px;
	width: 60px; height: 60px; border-radius: 50%;
	border: 0; background: #ba0035; color: #fff;
	cursor: pointer; display: flex; align-items: center; justify-content: center;
	box-shadow: 0 8px 24px rgba(186, 0, 53, .35);
	transition: transform .15s ease, background .2s ease;
	visibility: visible; /* fallback bez scroll-state atbalsta */
}
.psai-launcher:hover { background: #E61B4D; transform: scale(1.05); }

.psai-badge {
	position: absolute; top: -2px; right: -2px;
	min-width: 20px; height: 20px; padding: 0 5px;
	background: #111317; color: #fff; border-radius: 999px;
	font-size: 11px; font-weight: 700; line-height: 20px; text-align: center;
	border: 2px solid #fff;
}

/* --- Proaktīvais teaser --- */
.psai-teaser {
	pointer-events: auto;
	position: fixed; right: 92px; bottom: 32px;
	max-width: 240px;
	background: #fff; color: #1a1b1f;
	padding: 12px 16px; border-radius: 16px 16px 4px 16px;
	box-shadow: 0 8px 28px rgba(17, 19, 23, .16);
	font-size: .9rem; font-weight: 600; line-height: 1.35;
	cursor: pointer;
	border: 1px solid #E2E8F0;
}
.psai-teaser[hidden] { display: none; }
.psai-teaser:hover { border-color: #ba0035; color: #ba0035; }

/* --- Panelis --- */
.psai-panel {
	pointer-events: auto;
	position: fixed; right: 20px; bottom: 92px;
	width: min(400px, calc(100vw - 40px));
	height: min(600px, calc(100vh - 130px));
	background: #F8F9FB; border-radius: 20px;
	box-shadow: 0 24px 48px rgba(17, 19, 23, .18);
	display: flex; flex-direction: column; overflow: hidden;
	border: 1px solid #E2E8F0;
}
.psai-panel[hidden] { display: none; }

.psai-header {
	display: flex; align-items: center; gap: 12px;
	padding: 14px 16px; background: #111317; color: #fff;
}
.psai-header__text { display: flex; flex-direction: column; line-height: 1.25; flex: 1; }
.psai-header__text strong { font-family: 'Sora', sans-serif; font-size: .98rem; }
.psai-header__status { font-size: .75rem; color: #9CA3AF; }
.psai-close {
	background: none; border: 0; color: #fff; font-size: 24px; line-height: 1;
	cursor: pointer; padding: 4px 8px; border-radius: 8px; opacity: .8;
}
.psai-close:hover { opacity: 1; background: rgba(255, 255, 255, .1); }

.psai-avatar {
	display: inline-flex; align-items: center; justify-content: center;
	width: 38px; height: 38px; border-radius: 50%;
	background: #ba0035; color: #fff;
	font-family: 'Sora', sans-serif; font-weight: 800; font-size: 1rem;
	flex: 0 0 auto;
}
.psai-avatar--sm { width: 28px; height: 28px; font-size: .8rem; }

/* --- Ziņas --- */
.psai-messages { flex: 1; overflow-y: auto; padding: 18px 14px; display: flex; flex-direction: column; gap: 12px; }
.psai-row { display: flex; gap: 8px; align-items: flex-end; }
.psai-row--user { justify-content: flex-end; }

.psai-msg {
	margin: 0; padding: 11px 15px; border-radius: 16px;
	max-width: 82%; line-height: 1.5; white-space: pre-wrap;
	font-size: .92rem; word-break: break-word;
}
.psai-msg--user { background: #ba0035; color: #fff; border-bottom-right-radius: 4px; }
.psai-msg--assistant { background: #fff; color: #1a1b1f; border: 1px solid #E5E7EB; border-bottom-left-radius: 4px; }
.psai-msg a { color: #ba0035; }

/* --- Rašanas indikators --- */
.psai-typing { display: inline-flex; gap: 5px; align-items: center; min-height: 20px; }
.psai-typing span {
	width: 7px; height: 7px; border-radius: 50%; background: #9CA3AF;
	animation: psai-bounce 1.2s infinite ease-in-out;
}
.psai-typing span:nth-child(2) { animation-delay: .15s; }
.psai-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes psai-bounce {
	0%, 60%, 100% { transform: translateY(0); opacity: .5; }
	30% { transform: translateY(-4px); opacity: 1; }
}

/* --- Ātrās atbildes --- */
.psai-quick {
	display: flex; gap: 8px; flex-wrap: wrap;
	padding: 4px 14px 10px; background: #F8F9FB;
}
.psai-quick[hidden] { display: none; }
.psai-chip {
	border: 1.5px solid #ba0035; background: #fff; color: #ba0035;
	border-radius: 999px; padding: 7px 14px;
	font-size: .82rem; font-weight: 600; cursor: pointer;
	transition: background .15s ease, color .15s ease;
}
.psai-chip:hover { background: #ba0035; color: #fff; }

/* --- Produktu kartītes --- */
.psai-cards { display: flex; flex-direction: column; gap: 8px; padding: 0 2px; }
.psai-card {
	display: flex; gap: 12px; align-items: center;
	background: #fff; border: 1px solid #E2E8F0; border-radius: 12px;
	padding: 10px; text-decoration: none; color: inherit;
	transition: border-color .15s ease, box-shadow .15s ease;
}
.psai-card:hover { border-color: #ba0035; box-shadow: 0 4px 12px rgba(17, 19, 23, .08); }
.psai-card img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; background: #F3F4F6; }
.psai-card__ph {
	display: inline-flex; width: 56px; height: 56px; border-radius: 8px;
	background: #F3F4F6; color: #ba0035;
	align-items: center; justify-content: center;
	font-family: 'Sora', sans-serif; font-weight: 800; font-size: 1.3rem;
}
.psai-card__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.psai-card__name { font-weight: 700; font-size: .9rem; color: #1a1b1f; line-height: 1.3; }
.psai-card__price { font-family: 'Sora', sans-serif; font-weight: 700; font-size: .85rem; color: #ba0035; }

/* --- Statuss / kļūda --- */
.psai-status { padding: 0 16px 8px; font-size: .82rem; color: #6B7280; background: #F8F9FB; }
.psai-status[hidden] { display: none; }
.psai-error { color: #b91c1c; }

/* --- Forma --- */
.psai-form {
	display: flex; gap: 8px; padding: 12px 14px;
	background: #fff; border-top: 1px solid #E5E7EB;
}
.psai-input {
	flex: 1; resize: none; height: 44px; padding: 11px 14px;
	border: 1px solid #D1D5DB; border-radius: 999px;
	font: inherit; font-size: .92rem; background: #fff;
}
.psai-input:focus { outline: none; border-color: #ba0035; box-shadow: 0 0 0 3px rgba(186, 0, 53, .15); }
.psai-send {
	width: 44px; height: 44px; border-radius: 50%; flex: 0 0 auto;
	display: inline-flex; align-items: center; justify-content: center;
	background: #ba0035; color: #fff; cursor: pointer;
	transition: background .15s ease, opacity .15s ease;
	padding: 0; border: none; outline: none;
}
.psai-send:hover { background: #E61B4D; }
.psai-send:disabled { opacity: .5; cursor: default; }

/* --- Mobilie --- */
@media (max-width: 480px) {
	.psai-panel {
		right: 0; bottom: 0; width: 100vw; height: 85vh;
		border-radius: 20px 20px 0 0;
	}
	.psai-teaser { right: 88px; bottom: 28px; }
}

/* Pulsējošs launcheris, kamēr gaida uzmanību */
@keyframes psai-pulse-ring {
	0% { box-shadow: 0 8px 24px rgba(186, 0, 53, .35), 0 0 0 0 rgba(186, 0, 53, .35); }
	70% { box-shadow: 0 8px 24px rgba(186, 0, 53, .35), 0 0 0 16px rgba(186, 0, 53, 0); }
	100% { box-shadow: 0 8px 24px rgba(186, 0, 53, .35), 0 0 0 0 rgba(186, 0, 53, 0); }
}
.psai-launcher.psai-pulse { animation: psai-pulse-ring 1.8s ease-out infinite; }

/* Kartīte ar darbības pogu */
.psai-card { display: flex; align-items: center; }
.psai-card__link { display: flex; gap: 12px; align-items: center; flex: 1; min-width: 0; text-decoration: none; color: inherit; }
.psai-card__btn {
	flex: 0 0 auto; border-radius: 999px; padding: 8px 14px;
	font-size: .78rem; font-weight: 700; text-decoration: none;
	background: #ba0035; color: #fff; white-space: nowrap;
}
.psai-card__btn:hover, .psai-card__btn:focus { background: #E61B4D; color: #fff; }
.psai-card__btn--quote { background: #111317; }
.psai-card__btn--quote:hover, .psai-card__btn--quote:focus { background: #000; color: #fff; }

/* Asistenta markdown atbalsts */
.psai-msg--assistant a { color: #C8102E; text-decoration: underline; }
.psai-msg--assistant strong { font-weight: 700; }
.psai-msg--assistant ul { margin: 6px 0; padding-left: 18px; list-style: disc; }
.psai-msg--assistant li { margin-bottom: 2px; }

/* Pieprasījuma forma čatā */
.psai-qform { background: #fff; border: 1px solid #E5E7EB; border-radius: 14px; padding: 14px; margin: 8px 0 4px 40px; display: flex; flex-direction: column; gap: 10px; }
.psai-qform__row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.psai-qform label { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; font-weight: 600; color: #3f3f46; }
.psai-qform__input { height: 40px; border: 1px solid #E5E7EB; border-radius: 10px; padding: 8px 12px; font: inherit; font-size: .92rem; box-sizing: border-box; background: #fff; color: #18181B; }
.psai-qform__input:focus { outline: none; border-color: #ba0035; box-shadow: 0 0 0 3px rgba(186,0,53,.12); }
.psai-qform__input[readonly] { background: #F8F9FB; color: #52525B; }
.psai-qform__print { display: flex; align-items: center; gap: 14px; font-size: .85rem; flex-wrap: wrap; }
.psai-qform__print > span { font-weight: 600; color: #3f3f46; font-size: .78rem; }
.psai-qform__print label { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
.psai-qform__submit { background: #ba0035; color: #fff; border: 0; border-radius: 10px; padding: 11px; font-weight: 600; font-size: .92rem; cursor: pointer; }
.psai-qform__submit:hover { background: #8f0029; }
.psai-qform__submit:disabled { opacity: .6; cursor: default; }
.psai-qform__status { margin: 0; font-size: .85rem; color: #b91c1c; }
.psai-qform__status--ok { color: #065F46; }
@media (max-width: 480px) { .psai-qform__row { grid-template-columns: 1fr; } }

/* FINĀL: forma čatā — lauki viens zem otra, nekas neiziet ārā */
.psai-qform { margin-left: 0; }
.psai-qform__row { grid-template-columns: 1fr !important; gap: 10px !important; }
.psai-qform__row label { flex-direction: column; }

/* "Saņemt piedāvājumu" kā poga kartītē */
.psai-card__quote-btn { border: 0; cursor: pointer; font: inherit; width: 100%; }

/* Produkta modal */
.psai-modal { position: fixed; inset: 0; z-index: 100000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.psai-modal[hidden] { display: none; }
.psai-modal__backdrop { position: absolute; inset: 0; background: rgba(17,19,23,.55); }
.psai-modal__box {
	position: relative; background: #fff; border-radius: 18px; max-width: 720px; width: 100%;
	max-height: 90vh; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 20px; padding: 24px;
	box-shadow: 0 32px 64px rgba(0,0,0,.25);
}
.psai-modal__close { position: absolute; top: 10px; right: 12px; border: 0; background: transparent; font-size: 28px; line-height: 1; color: #71717A; cursor: pointer; }
.psai-modal__close:hover { color: #ba0035; }
.psai-modal__img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; border: 1px solid #F0F0F2; border-radius: 14px; }
.psai-modal__thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.psai-modal__thumbs img { width: 56px; height: 56px; object-fit: contain; border: 1px solid #E5E7EB; border-radius: 8px; cursor: pointer; }
.psai-modal__thumbs img:hover { border-color: #ba0035; }
.psai-modal__cat { margin: 0; font-size: .75rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: #ba0035; }
.psai-modal__name { margin: 6px 0 10px; font-size: 1.25rem; line-height: 1.25; }
.psai-modal__price { margin: 0 0 12px; font-size: 1.35rem; font-weight: 700; color: #ba0035; }
.psai-modal__desc { margin: 0 0 12px; color: #3f3f46; font-size: .95rem; line-height: 1.55; }
.psai-modal__stock { margin: 0 0 14px; font-size: .85rem; color: #b45309; }
.psai-modal__quote {
	display: block; width: 100%; background: #ba0035; color: #fff; border: 0; border-radius: 10px;
	padding: 12px; font-weight: 600; font-size: .95rem; cursor: pointer; text-align: center;
}
.psai-modal__quote:hover { background: #8f0029; }
.psai-modal__full { display: inline-block; margin-top: 10px; font-size: .85rem; color: #ba0035; }
@media (max-width: 640px) {
	.psai-modal__box { grid-template-columns: 1fr; padding: 18px; }
}

/* FINĀL 2: kartītes kolonnas izkārtojums — bilde+teksts augšā, poga apakšā */
.psai-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.psai-card { flex-direction: column !important; align-items: stretch !important; gap: 8px !important; }
.psai-card__link { width: 100%; box-sizing: border-box; }
.psai-card__open { cursor: pointer; }
.psai-card img { width: 100% !important; height: 90px !important; object-fit: contain; }
.psai-card__ph { width: 100% !important; height: 90px !important; }
.psai-card__body { flex-direction: column; align-items: flex-start; gap: 2px; }
.psai-card__name { font-size: .85rem; line-height: 1.25; }
.psai-card__price { font-size: .85rem; }
.psai-card__quote-btn { margin-top: auto; width: 100%; border-radius: 8px; padding: 9px 10px; font-size: .8rem; white-space: normal; }

/* FINĀL 3: kartītes fiksēta, kompakta izmēra — nevis pa visu platumu */
.psai-cards { grid-template-columns: repeat(auto-fill, minmax(140px, 165px)) !important; justify-content: start; }

/* FINĀL 4: kartītes pilnā čata platumā — bilde kreisajā, teksts vidū, poga labajā */
.psai-cards { display: flex !important; flex-direction: column; grid-template-columns: none !important; }
.psai-card { flex-direction: row !important; align-items: center !important; gap: 12px !important; width: 100%; box-sizing: border-box; }
.psai-card img { width: 64px !important; height: 64px !important; object-fit: contain; flex: 0 0 auto; }
.psai-card__ph { width: 64px !important; height: 64px !important; flex: 0 0 auto; }
.psai-card__open { flex: 1; min-width: 0; align-items: center !important; }
.psai-card__body { flex: 1; min-width: 0; }
.psai-card__name { display: block; }
.psai-card__quote-btn { flex: 0 0 auto; width: auto !important; margin-top: 0 !important; white-space: nowrap; }
