/**
 * Service Detail Modal
 *
 * Premium hospitality detail view triggered from a catalog card. Renders the
 * service / equipment / grocery item with its full image, formatted price,
 * complete description and a primary CTA that scrolls back to the card's
 * action button so the guest can complete the order.
 *
 * Theming: respects the `data-pp-theme` / `data-theme` attribute carried by
 * the portal shell; never overrides `--lw-*` light tokens directly.
 *
 * @package MphbGuestServices
 * @since 2.1.0
 */

/* ========================================
 * Card affordance — whole card is the detail trigger
 *
 * The card itself carries `data-gs-detail-card` + `role="button"` +
 * `tabindex="0"`. A delegated JS listener intercepts clicks and opens the
 * modal, except when the click originates from an interactive child
 * (order/rent submit, qty stepper, rating star, form input, etc.).
 * This avoids the absolute-overlay z-index trap where the overlay sat
 * below `.mphb-gs-item-thumb` / `.mphb-gs-item-body` (z-index: 2).
 * ======================================== */

.mphb-gs-item-card {
	position: relative;
	cursor: pointer;
}

.mphb-gs-item-card:focus-visible {
	outline: 2px solid var(--gs-color-primary, #b99d75);
	outline-offset: 2px;
	border-radius: 8px;
}

/* The "View details" affordance is a non-interactive label rendered as
 * a <span> — it is NEVER a button or anchor, so themes (CozyStay etc.)
 * cannot inject border/background. Click is captured by the card-level
 * delegated handler. */
.mphb-gs-shell .mphb-gs-item-detail-link {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin: 2px 0 6px;
	padding: 0;
	background: transparent;
	background-color: transparent;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	color: var(--gs-color-primary-strong, #996f0f);
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.01em;
	align-self: flex-start;
	font-family: inherit;
	text-decoration: none;
	pointer-events: none;
}

.mphb-gs-item-card:hover .mphb-gs-item-detail-link,
.mphb-gs-item-card:focus-visible .mphb-gs-item-detail-link {
	color: var(--gs-color-primary-strong-hover, #8f6505);
	text-decoration: underline;
}

.mphb-gs-shell[data-theme="dark"] .mphb-gs-item-detail-link {
	color: var(--gs-color-primary, #d4bb93);
}

.mphb-gs-shell[data-theme="dark"] .mphb-gs-item-card:hover .mphb-gs-item-detail-link,
.mphb-gs-shell[data-theme="dark"] .mphb-gs-item-card:focus-visible .mphb-gs-item-detail-link {
	color: var(--gs-color-primary, #d4bb93);
}

@media (prefers-color-scheme: dark) {
	.mphb-gs-shell[data-theme="auto"] .mphb-gs-item-detail-link,
	.mphb-gs-shell[data-theme="auto"] .mphb-gs-item-card:hover .mphb-gs-item-detail-link,
	.mphb-gs-shell[data-theme="auto"] .mphb-gs-item-card:focus-visible .mphb-gs-item-detail-link {
		color: var(--gs-color-primary, #d4bb93);
	}
}

.mphb-gs-item-detail-link__icon {
	flex-shrink: 0;
}

[dir="rtl"] .mphb-gs-item-detail-link__icon {
	transform: scaleX(-1);
}

/* ========================================
 * Modal overlay
 * ======================================== */

.gs-service-detail-modal {
	position: fixed;
	inset: 0;
	z-index: 100001;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	background: rgba(3, 7, 18, 0.72);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease, visibility 0.25s ease;
	padding: 0;
	box-sizing: border-box;
}

.gs-service-detail-modal--open {
	opacity: 1;
	visibility: visible;
}

/* ========================================
 * Modal dialog
 * ======================================== */

.gs-service-detail-modal__dialog {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 100%;
	max-height: 92vh;
	background: #ffffff;
	color: #0F1111;
	border-radius: 18px 18px 0 0;
	border: 1px solid rgba(185, 157, 117, 0.18);
	border-bottom: 0;
	box-shadow:
		0 -24px 64px -12px rgba(0, 0, 0, 0.55),
		0 -2px 0 rgba(185, 157, 117, 0.22);
	overflow: hidden;
	transform: translateY(100%);
	transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
	box-sizing: border-box;
}

.gs-service-detail-modal--open .gs-service-detail-modal__dialog {
	transform: translateY(0);
}

/* Grab handle (mobile sheet affordance). */
.gs-service-detail-modal__grab {
	width: 44px;
	height: 4px;
	border-radius: 4px;
	background: rgba(15, 17, 17, 0.18);
	margin: 8px auto 0;
	flex-shrink: 0;
}

/* ========================================
 * Hero image
 * ======================================== */

.gs-service-detail-modal__hero {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 10;
	background: #f3f0ea;
	overflow: hidden;
	flex-shrink: 0;
}

.gs-service-detail-modal__hero img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.gs-service-detail-modal__hero--placeholder {
	background:
		linear-gradient(135deg, #f3f0ea 0%, #e8e2d4 100%);
}

/* ========================================
 * Close button
 * ======================================== */

.gs-service-detail-modal__close {
	position: absolute;
	top: 12px;
	right: 12px;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.94);
	color: #0F1111;
	border: 0;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	z-index: 4;
	box-shadow: 0 2px 6px rgba(15, 17, 17, 0.18);
	transition: background 0.15s ease, transform 0.15s ease;
	padding: 0;
}

.gs-service-detail-modal__close:hover {
	background: #ffffff;
	transform: scale(1.05);
}

.gs-service-detail-modal__close:focus-visible {
	outline: 2px solid var(--gs-color-primary, #b99d75);
	outline-offset: 2px;
}

[dir="rtl"] .gs-service-detail-modal__close {
	right: auto;
	left: 12px;
}

/* ========================================
 * Body — scrollable content
 * ======================================== */

.gs-service-detail-modal__body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 20px 22px 16px;
	-webkit-overflow-scrolling: touch;
}

.gs-service-detail-modal__title {
	margin: 0 0 8px;
	font-size: 22px;
	font-weight: 700;
	line-height: 1.25;
	color: #0F1111;
	letter-spacing: -0.005em;
}

.gs-service-detail-modal__price {
	display: inline-flex;
	align-items: baseline;
	gap: 6px;
	margin: 0 0 16px;
	padding: 6px 12px;
	background: rgba(185, 157, 117, 0.12);
	color: #6f5a3e;
	border-radius: 999px;
	font-size: 16px;
	font-weight: 600;
}

.gs-service-detail-modal__description {
	margin: 0;
	color: #2b2b2b;
	font-size: 15px;
	line-height: 1.65;
	white-space: normal;
}

.gs-service-detail-modal__description p {
	margin: 0 0 12px;
}

.gs-service-detail-modal__description p:last-child {
	margin-bottom: 0;
}

/* ========================================
 * Footer — primary CTA
 * ======================================== */

.gs-service-detail-modal__footer {
	flex-shrink: 0;
	padding: 14px 22px calc(14px + env(safe-area-inset-bottom, 0px));
	background: #ffffff;
	border-top: 1px solid #ece8df;
	display: flex;
	flex-direction: column;
	gap: 8px;
}

/* Scope prefix .mphb-gs-shell + !important sur background/color pour
   battre le reset global du thème CozyStay qui appliquait son propre
   styling sombre sur tout <button> non explicitement contraint
   (remontée Ahmed 2026-06-26 : Order button toujours noir mat). */
.mphb-gs-shell button.gs-service-detail-modal__cta,
.gs-service-detail-modal__cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	width: 100%;
	padding: 0.95rem 1.5rem;
	background: linear-gradient(135deg, #b99d75 0%, #a08661 100%) !important;
	color: #1e3750 !important;
	font-size: 1rem;
	font-weight: 700;
	letter-spacing: 0.02em;
	border: 0 !important;
	border-radius: 12px;
	cursor: pointer;
	font-family: inherit;
	text-decoration: none;
	transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
	box-shadow:
		0 6px 14px -4px rgba(185, 157, 117, 0.55),
		0 2px 4px rgba(0, 0, 0, 0.08),
		inset 0 1px 0 rgba(255, 255, 255, 0.18) !important;
}

.mphb-gs-shell button.gs-service-detail-modal__cta:hover,
.mphb-gs-shell button.gs-service-detail-modal__cta:focus-visible,
.gs-service-detail-modal__cta:hover,
.gs-service-detail-modal__cta:focus-visible {
	transform: translateY(-1px);
	filter: brightness(1.04);
	color: #1e3750 !important;
	background: linear-gradient(135deg, #c4a87f 0%, #ab9069 100%) !important;
	box-shadow:
		0 10px 20px -4px rgba(185, 157, 117, 0.6),
		0 3px 6px rgba(0, 0, 0, 0.1),
		inset 0 1px 0 rgba(255, 255, 255, 0.22) !important;
	outline: none;
}

.mphb-gs-shell button.gs-service-detail-modal__cta:focus-visible,
.gs-service-detail-modal__cta:focus-visible {
	outline: 2px solid #1e3750;
	outline-offset: 2px;
}

.gs-service-detail-modal__cta:active {
	transform: translateY(0);
	filter: brightness(0.97);
	box-shadow:
		0 4px 8px -2px rgba(185, 157, 117, 0.45),
		inset 0 1px 2px rgba(0, 0, 0, 0.12);
}

.gs-service-detail-modal__cta--disabled,
.gs-service-detail-modal__cta[disabled] {
	background: #c8c2b5;
	color: #5a5448;
	cursor: not-allowed;
	transform: none;
	filter: none;
	box-shadow: none;
}

/* ========================================
 * Desktop layout — centered dialog
 * ======================================== */

@media (min-width: 720px) {
	.gs-service-detail-modal {
		align-items: center;
		padding: 24px;
	}

	.gs-service-detail-modal__dialog {
		max-width: 640px;
		max-height: 88vh;
		border-radius: 16px;
		border: 1px solid rgba(185, 157, 117, 0.22);
		box-shadow:
			0 24px 64px -12px rgba(0, 0, 0, 0.65),
			0 8px 24px -8px rgba(0, 0, 0, 0.35);
		transform: scale(0.96) translateY(8px);
		transition: transform 0.22s ease, opacity 0.22s ease;
	}

	.gs-service-detail-modal--open .gs-service-detail-modal__dialog {
		transform: scale(1) translateY(0);
	}

	.gs-service-detail-modal__grab {
		display: none;
	}

	.gs-service-detail-modal__hero {
		aspect-ratio: 16 / 9;
	}

	.gs-service-detail-modal__body {
		padding: 24px 28px 18px;
	}

	.gs-service-detail-modal__title {
		font-size: 26px;
	}

	.gs-service-detail-modal__footer {
		padding: 16px 28px;
	}
}

/* ========================================
 * Dark theme overrides — literal hex only
 * ======================================== */

.mphb-gs-shell[data-theme="dark"] .gs-service-detail-modal,
.mphb-gs-shell[data-pp-theme="dark"] .gs-service-detail-modal {
	background: rgba(2, 6, 15, 0.78);
}

.mphb-gs-shell[data-theme="dark"] .gs-service-detail-modal__dialog,
.mphb-gs-shell[data-pp-theme="dark"] .gs-service-detail-modal__dialog {
	background: #1e293b;
	color: #f1ede4;
	border-color: rgba(196, 165, 118, 0.32);
	box-shadow:
		0 -24px 64px -12px rgba(0, 0, 0, 0.8),
		0 -2px 0 rgba(196, 165, 118, 0.35);
}

@media (min-width: 720px) {
	.mphb-gs-shell[data-theme="dark"] .gs-service-detail-modal__dialog,
	.mphb-gs-shell[data-pp-theme="dark"] .gs-service-detail-modal__dialog {
		box-shadow:
			0 24px 64px -12px rgba(0, 0, 0, 0.85),
			0 8px 24px -8px rgba(0, 0, 0, 0.55),
			0 0 0 1px rgba(196, 165, 118, 0.18);
	}
}

.mphb-gs-shell[data-theme="dark"] .gs-service-detail-modal__title,
.mphb-gs-shell[data-pp-theme="dark"] .gs-service-detail-modal__title {
	color: #f7f3ea;
}

.mphb-gs-shell[data-theme="dark"] .gs-service-detail-modal__description,
.mphb-gs-shell[data-pp-theme="dark"] .gs-service-detail-modal__description {
	color: #dad5c8;
}

.mphb-gs-shell[data-theme="dark"] .gs-service-detail-modal__price,
.mphb-gs-shell[data-pp-theme="dark"] .gs-service-detail-modal__price {
	background: rgba(196, 165, 118, 0.22);
	color: #e9d8b6;
}

.mphb-gs-shell[data-theme="dark"] .gs-service-detail-modal__footer,
.mphb-gs-shell[data-pp-theme="dark"] .gs-service-detail-modal__footer {
	background: #1e293b;
	border-top-color: rgba(196, 165, 118, 0.22);
}

.mphb-gs-shell[data-theme="dark"] .gs-service-detail-modal__close,
.mphb-gs-shell[data-pp-theme="dark"] .gs-service-detail-modal__close {
	background: rgba(30, 41, 59, 0.92);
	color: #f7f3ea;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.mphb-gs-shell[data-theme="dark"] .gs-service-detail-modal__close:hover,
.mphb-gs-shell[data-pp-theme="dark"] .gs-service-detail-modal__close:hover {
	background: #1e293b;
}

.mphb-gs-shell[data-theme="dark"] .gs-service-detail-modal__grab,
.mphb-gs-shell[data-pp-theme="dark"] .gs-service-detail-modal__grab {
	background: rgba(196, 165, 118, 0.45);
}

/* Body scroll lock helper, set by JS. */
body.gs-service-detail-modal-open {
	overflow: hidden;
}

/* Reduced-motion support. */
@media (prefers-reduced-motion: reduce) {
	.gs-service-detail-modal,
	.gs-service-detail-modal__dialog {
		transition-duration: 0.01ms !important;
	}
}
