/**
 * TTH Concierge — customer-facing widget styles.
 *
 * Navy/gold brand. Every selector is prefixed .tth- and scoped under the
 * .tth-root container to avoid theme collisions. Brand colors arrive as
 * CSS custom properties (--tth-navy / --tth-gold) injected by widget.js.
 *
 * @package tth-concierge
 */

/* ------------------------------------------------------------------ *
 * Root scope, brand tokens & defensive resets
 * ------------------------------------------------------------------ */

.tth-root {
	--tth-navy: #16324C;
	--tth-gold: #D9A441;
	--tth-ink: #1C2733;
	--tth-muted: #5C6B7A;
	--tth-line: #E3E8EE;
	--tth-soft: #F4F6F9;
	--tth-red: #D64545;
	--tth-radius: 16px;
	--tth-shadow: 0 20px 40px rgba(22, 50, 76, 0.18);
	--tth-font: 'Libre Franklin', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

	font-family: var(--tth-font);
	font-size: 16px;
	line-height: 1.5;
	color: var(--tth-ink);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-align: left;
}

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

.tth-root [hidden] {
	display: none !important;
}

.tth-root p,
.tth-root h2,
.tth-root form {
	margin: 0;
	padding: 0;
}

.tth-root button {
	-webkit-appearance: none;
	appearance: none;
	font: inherit;
	color: inherit;
	background: none;
	border: 0;
	margin: 0;
	padding: 0;
	cursor: pointer;
	line-height: inherit;
}

.tth-root input,
.tth-root select,
.tth-root textarea {
	font: inherit;
	color: inherit;
	margin: 0;
}

.tth-root button:focus-visible,
.tth-root input:focus-visible,
.tth-root select:focus-visible,
.tth-root textarea:focus-visible,
.tth-root a:focus-visible {
	outline: 2px solid var(--tth-gold);
	outline-offset: 2px;
}

.tth-visually-hidden {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	border: 0 !important;
	overflow: hidden !important;
	clip: rect(0 0 0 0) !important;
	white-space: nowrap !important;
}

/* ------------------------------------------------------------------ *
 * Launcher bubble — 60px navy circle, gold hover ring, unread badge
 * ------------------------------------------------------------------ */

.tth-launcher {
	position: fixed;
	right: 20px;
	bottom: 20px;
	z-index: 999999;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: var(--tth-navy);
	color: #FFFFFF;
	display: -webkit-flex;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8px 24px rgba(22, 50, 76, 0.35);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
	animation: tth-rise-in 0.2s ease both;
}

.tth-launcher:hover,
.tth-launcher:focus-visible {
	transform: translateY(-2px);
	box-shadow: 0 0 0 3px var(--tth-gold), 0 12px 28px rgba(22, 50, 76, 0.4);
}

.tth-launcher:active {
	transform: translateY(0);
}

.tth-launcher svg {
	display: block;
	pointer-events: none;
}

.tth-glyph-dot {
	fill: var(--tth-navy);
}

.tth-launcher.tth-has-unread::after {
	content: '';
	position: absolute;
	top: -4px;
	left: -4px;
	right: -4px;
	bottom: -4px;
	border-radius: 50%;
	border: 2px solid var(--tth-gold);
	opacity: 0;
	animation: tth-pulse 2s ease-out infinite;
	pointer-events: none;
}

.tth-badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 999px;
	background: var(--tth-gold);
	color: var(--tth-navy);
	font-size: 12px;
	font-weight: 700;
	line-height: 22px;
	text-align: center;
	box-shadow: 0 2px 6px rgba(22, 50, 76, 0.3);
	animation: tth-badge-pop 0.25s cubic-bezier(0.2, 0.8, 0.3, 1.4) both;
	pointer-events: none;
}

/* ------------------------------------------------------------------ *
 * Guest card modal — overlay + card
 * ------------------------------------------------------------------ */

.tth-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 999999;
	background: rgba(13, 25, 38, 0.55);
	display: -webkit-flex;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
}

.tth-overlay:not([hidden]) {
	animation: tth-fade-in 0.2s ease both;
}

.tth-overlay.tth-closing {
	animation: tth-fade-out 0.18s ease both;
}

.tth-modal {
	position: relative;
	width: 100%;
	max-width: 520px;
	max-height: calc(100vh - 40px);
	overflow-y: auto;
	background: #FFFFFF;
	border-radius: var(--tth-radius);
	box-shadow: var(--tth-shadow), 0 2px 8px rgba(22, 50, 76, 0.12);
	padding: 32px 30px 26px;
}

/* Gold top accent bar. */
.tth-modal::before {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 5px;
	background: linear-gradient(90deg, var(--tth-gold), #EFC87E 55%, var(--tth-gold));
}

.tth-overlay:not([hidden]) .tth-modal {
	animation: tth-rise-in 0.22s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.tth-modal-close {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	color: var(--tth-muted);
	font-size: 22px;
	line-height: 1;
	display: -webkit-flex;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.tth-modal-close:hover {
	background: var(--tth-soft);
	color: var(--tth-ink);
}

.tth-modal-head {
	margin-bottom: 20px;
	padding-right: 28px;
}

.tth-eyebrow {
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--tth-gold);
	margin-bottom: 8px;
}

.tth-modal-title {
	font-size: 24px;
	font-weight: 800;
	line-height: 1.25;
	color: var(--tth-navy);
	margin-bottom: 8px;
}

.tth-modal-sub {
	font-size: 14px;
	color: var(--tth-muted);
}

/* ------------------------------------------------------------------ *
 * Form — two-column grid collapsing to one column on small screens
 * ------------------------------------------------------------------ */

.tth-form-grid {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 14px;
}

.tth-field--full {
	grid-column: 1 / -1;
}

.tth-field label {
	display: block;
	font-size: 12.5px;
	font-weight: 600;
	color: var(--tth-navy);
	margin-bottom: 6px;
}

.tth-req {
	color: var(--tth-gold);
}

.tth-field input,
.tth-field select,
.tth-field textarea {
	display: block;
	width: 100%;
	padding: 11px 12px;
	font-size: 14px;
	line-height: 1.4;
	color: var(--tth-ink);
	background-color: #FFFFFF;
	border: 1px solid var(--tth-line);
	border-radius: 10px;
	box-shadow: none;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tth-field input::placeholder,
.tth-field textarea::placeholder {
	color: #9AA7B4;
	opacity: 1;
}

.tth-field input:focus,
.tth-field select:focus,
.tth-field textarea:focus {
	outline: none;
	border-color: var(--tth-gold);
	box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.22);
}

.tth-field select {
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	padding-right: 36px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235C6B7A' d='M1.4.6 6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 13px center;
	cursor: pointer;
}

.tth-field textarea {
	resize: vertical;
	min-height: 74px;
}

/* Red-accent validation states. */
.tth-field.tth-invalid input,
.tth-field.tth-invalid select,
.tth-field.tth-invalid textarea {
	border-color: var(--tth-red);
	box-shadow: 0 0 0 3px rgba(214, 69, 69, 0.14);
}

.tth-field.tth-invalid label {
	color: var(--tth-red);
}

.tth-err {
	font-size: 12px;
	line-height: 1.4;
	color: var(--tth-red);
	margin-top: 5px;
	animation: tth-err-in 0.2s ease both;
}

/* Honeypot — visually removed, still in the DOM for bots. */
.tth-hp {
	position: absolute !important;
	left: -9999px !important;
	top: auto !important;
	width: 1px !important;
	height: 1px !important;
	overflow: hidden !important;
}

.tth-form-alert {
	margin-top: 14px;
	padding: 10px 12px;
	font-size: 13px;
	color: var(--tth-red);
	background: rgba(214, 69, 69, 0.08);
	border: 1px solid rgba(214, 69, 69, 0.35);
	border-radius: 10px;
	animation: tth-err-in 0.2s ease both;
}

/* ------------------------------------------------------------------ *
 * Buttons
 * ------------------------------------------------------------------ */

.tth-btn {
	position: relative;
	display: inline-block;
	width: 100%;
	padding: 13px 18px;
	font-size: 15px;
	font-weight: 700;
	letter-spacing: 0.02em;
	text-align: center;
	border-radius: 10px;
	transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.tth-btn--primary {
	margin-top: 16px;
	background: var(--tth-navy);
	color: #FFFFFF;
	box-shadow: 0 6px 16px rgba(22, 50, 76, 0.28);
}

.tth-btn--primary:hover {
	background: #1D4064;
	box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.35), 0 8px 18px rgba(22, 50, 76, 0.3);
}

.tth-btn--primary:active {
	transform: translateY(1px);
}

.tth-btn--primary:disabled {
	opacity: 0.85;
	cursor: wait;
}

.tth-btn--ghost {
	width: auto;
	margin-top: 18px;
	padding: 11px 28px;
	background: transparent;
	color: var(--tth-navy);
	border: 1.5px solid var(--tth-navy);
}

.tth-btn--ghost:hover {
	background: var(--tth-soft);
	box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.25);
}

.tth-btn.tth-loading .tth-btn-label {
	visibility: hidden;
}

.tth-btn.tth-loading::after {
	content: '';
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	margin: auto;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	border: 2px solid rgba(255, 255, 255, 0.35);
	border-top-color: #FFFFFF;
	animation: tth-spin 0.7s linear infinite;
}

.tth-consent {
	margin-top: 12px;
	font-size: 11.5px;
	line-height: 1.5;
	color: var(--tth-muted);
	text-align: center;
}

/* ------------------------------------------------------------------ *
 * Success state — quiet celebration, animated check, no confetti
 * ------------------------------------------------------------------ */

.tth-success {
	text-align: center;
	padding: 22px 6px 10px;
	animation: tth-fade-in 0.25s ease both;
}

.tth-check {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 10px;
	border-radius: 50%;
	background: rgba(217, 164, 65, 0.12);
	margin-bottom: 16px;
	animation: tth-badge-pop 0.3s cubic-bezier(0.2, 0.8, 0.3, 1.4) both;
}

.tth-check-svg {
	display: block;
	width: 72px;
	height: 72px;
}

.tth-check-circle {
	stroke: var(--tth-gold);
	stroke-width: 3;
	stroke-linecap: round;
	stroke-dasharray: 151;
	stroke-dashoffset: 151;
	animation: tth-draw 0.5s ease-out 0.1s forwards;
}

.tth-check-mark {
	stroke: var(--tth-navy);
	stroke-width: 4;
	stroke-linecap: round;
	stroke-linejoin: round;
	stroke-dasharray: 40;
	stroke-dashoffset: 40;
	animation: tth-draw 0.35s ease-out 0.5s forwards;
}

.tth-success-title {
	font-size: 20px;
	font-weight: 800;
	line-height: 1.35;
	color: var(--tth-navy);
	margin-bottom: 10px;
	outline: none;
}

.tth-success-sub {
	font-size: 14px;
	color: var(--tth-muted);
}

/* ------------------------------------------------------------------ *
 * Chat panel — 360×520 desktop card, full-width bottom sheet on mobile
 * ------------------------------------------------------------------ */

.tth-chat {
	position: fixed;
	right: 20px;
	bottom: 92px;
	z-index: 999999;
	width: 360px;
	height: 520px;
	max-height: calc(100vh - 112px);
	background: #FFFFFF;
	border-radius: var(--tth-radius);
	box-shadow: 0 24px 48px rgba(22, 50, 76, 0.28), 0 2px 8px rgba(22, 50, 76, 0.12);
	display: -webkit-flex;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	transform-origin: bottom right;
}

.tth-chat:not([hidden]) {
	animation: tth-pop-in 0.2s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}

.tth-chat.tth-closing {
	animation: tth-pop-out 0.18s ease both;
}

.tth-chat-head {
	display: -webkit-flex;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 13px 14px;
	background: linear-gradient(135deg, var(--tth-navy), #1D4064);
	color: #FFFFFF;
	border-bottom: 3px solid var(--tth-gold);
	flex-shrink: 0;
}

.tth-chat-avatar {
	display: -webkit-flex;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	background: var(--tth-gold);
	color: var(--tth-navy);
	font-size: 12px;
	font-weight: 800;
	letter-spacing: 0.03em;
	flex-shrink: 0;
	box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.25);
}

.tth-chat-id {
	display: -webkit-flex;
	display: flex;
	flex-direction: column;
	min-width: 0;
	flex: 1;
}

.tth-chat-id strong {
	font-size: 14px;
	font-weight: 700;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.tth-chat-id span {
	font-size: 11.5px;
	line-height: 1.3;
	color: rgba(255, 255, 255, 0.75);
}

.tth-chat-min {
	width: 30px;
	height: 30px;
	border-radius: 8px;
	color: #FFFFFF;
	font-size: 16px;
	line-height: 1;
	display: -webkit-flex;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background-color 0.15s ease;
}

.tth-chat-min:hover {
	background: rgba(255, 255, 255, 0.14);
}

/* Messages list. */

.tth-chat-msgs {
	flex: 1;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 16px 14px;
	background: var(--tth-soft);
	display: -webkit-flex;
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.tth-msg {
	animation: tth-msg-in 0.2s ease both;
}

.tth-msg-bubble {
	padding: 10px 13px;
	font-size: 14px;
	line-height: 1.45;
	border-radius: 14px;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: break-word;
}

/* Customer: navy, right-aligned. */
.tth-msg--me {
	align-self: flex-end;
	max-width: 82%;
}

.tth-msg--me .tth-msg-bubble {
	background: var(--tth-navy);
	color: #FFFFFF;
	border-bottom-right-radius: 4px;
}

/* Agent: light, left-aligned, gold avatar dot. */
.tth-msg--agent {
	align-self: flex-start;
	max-width: 86%;
	display: -webkit-flex;
	display: flex;
	align-items: flex-end;
	gap: 8px;
}

.tth-msg--agent .tth-msg-bubble {
	background: #FFFFFF;
	color: var(--tth-ink);
	border: 1px solid var(--tth-line);
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 3px rgba(22, 50, 76, 0.06);
}

.tth-msg-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--tth-gold);
	box-shadow: 0 0 0 2px rgba(217, 164, 65, 0.25);
	flex-shrink: 0;
	margin-bottom: 6px;
}

/* System notices: centered, subtle. */
.tth-msg--sys {
	align-self: center;
	max-width: 92%;
}

.tth-msg--sys .tth-msg-bubble {
	background: transparent;
	color: var(--tth-muted);
	font-size: 12px;
	text-align: center;
	padding: 2px 8px;
}

/* Typing indicator — three bouncing dots. */

.tth-typing-bubble {
	display: -webkit-flex;
	display: flex;
	align-items: center;
	gap: 5px;
	min-height: 38px;
}

.tth-typing-dot {
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: #A9B4BF;
	animation: tth-bounce 1.2s ease-in-out infinite;
}

.tth-typing-dot:nth-child(2) {
	animation-delay: 0.15s;
}

.tth-typing-dot:nth-child(3) {
	animation-delay: 0.3s;
}

/* Input bar. */

.tth-chat-bar {
	display: -webkit-flex;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px;
	background: #FFFFFF;
	border-top: 1px solid var(--tth-line);
	flex-shrink: 0;
}

.tth-chat-input {
	flex: 1;
	min-width: 0;
	padding: 10px 15px;
	font-size: 14px;
	line-height: 1.4;
	color: var(--tth-ink);
	background: #FFFFFF;
	border: 1px solid var(--tth-line);
	border-radius: 999px;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.tth-chat-input::placeholder {
	color: #9AA7B4;
	opacity: 1;
}

.tth-chat-input:focus {
	outline: none;
	border-color: var(--tth-gold);
	box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.22);
}

.tth-chat-input:disabled {
	background: var(--tth-soft);
	color: var(--tth-muted);
	cursor: not-allowed;
}

.tth-chat-send {
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: var(--tth-navy);
	color: #FFFFFF;
	display: -webkit-flex;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.tth-chat-send svg {
	display: block;
	margin-left: 2px;
	pointer-events: none;
}

.tth-chat-send:hover {
	background: #1D4064;
	box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.35);
}

.tth-chat-send:active {
	transform: scale(0.94);
}

.tth-chat-send:disabled {
	opacity: 0.5;
	cursor: not-allowed;
	box-shadow: none;
}

/* ------------------------------------------------------------------ *
 * Animations
 * ------------------------------------------------------------------ */

@keyframes tth-fade-in {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes tth-fade-out {
	from { opacity: 1; }
	to   { opacity: 0; }
}

@keyframes tth-rise-in {
	from {
		opacity: 0;
		transform: translateY(14px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes tth-pop-in {
	from {
		opacity: 0;
		transform: translateY(12px) scale(0.97);
	}
	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

@keyframes tth-pop-out {
	from {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
	to {
		opacity: 0;
		transform: translateY(12px) scale(0.97);
	}
}

@keyframes tth-msg-in {
	from {
		opacity: 0;
		transform: translateY(6px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes tth-err-in {
	from {
		opacity: 0;
		transform: translateY(-3px);
	}
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@keyframes tth-badge-pop {
	from {
		opacity: 0;
		transform: scale(0.4);
	}
	to {
		opacity: 1;
		transform: scale(1);
	}
}

@keyframes tth-pulse {
	0% {
		opacity: 0.9;
		transform: scale(1);
	}
	70% {
		opacity: 0;
		transform: scale(1.35);
	}
	100% {
		opacity: 0;
		transform: scale(1.35);
	}
}

@keyframes tth-bounce {
	0%, 60%, 100% {
		transform: translateY(0);
		opacity: 0.55;
	}
	30% {
		transform: translateY(-5px);
		opacity: 1;
	}
}

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

@keyframes tth-draw {
	to { stroke-dashoffset: 0; }
}

/* ------------------------------------------------------------------ *
 * Mobile — bottom sheet chat, single-column form
 * ------------------------------------------------------------------ */

@media (max-width: 640px) {
	.tth-launcher {
		right: 16px;
		bottom: 16px;
	}

	.tth-chat {
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		height: 78vh;
		max-height: none;
		border-radius: var(--tth-radius) var(--tth-radius) 0 0;
		transform-origin: bottom center;
	}

	.tth-overlay {
		padding: 14px;
	}

	.tth-modal {
		max-height: calc(100vh - 28px);
		padding: 28px 20px 22px;
	}

	/* 16px inputs prevent iOS Safari's focus zoom. */
	.tth-field input,
	.tth-field select,
	.tth-field textarea,
	.tth-chat-input {
		font-size: 16px;
	}
}

@media (max-width: 560px) {
	.tth-form-grid {
		grid-template-columns: 1fr;
		gap: 12px;
	}

	.tth-modal-title {
		font-size: 21px;
	}
}

/* ------------------------------------------------------------------ *
 * Reduced motion & print
 * ------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.tth-root,
	.tth-root *,
	.tth-root *::before,
	.tth-root *::after {
		animation: none !important;
		transition: none !important;
	}

	/* Keep the drawn check visible without its animation. */
	.tth-check-circle,
	.tth-check-mark {
		stroke-dashoffset: 0 !important;
	}
}

@media print {
	.tth-root {
		display: none !important;
	}
}
