/**
 * Gate Access Card Component Styles
 *
 * Guest portal dashboard widget for remote gate opening.
 * Primary CTA (gradient + glow) — tel: fallback + authorized phones chips.
 *
 * @package MphbGuestServices
 */

/* ========================================
 * Card shell
 *
 * .gs-gate-access is a .gs-info-card — base shell styles (padding,
 * border, shadow, dark-mode bg) all come from .gs-info-card in portal.css.
 * Only deltas specific to this widget are declared here.
 * ======================================== */

.gs-gate-access__body {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: 12px;
}

.gs-gate-access__row {
	display: flex;
	flex-direction: row;
	align-items: center;
	gap: 18px;
}

/* ========================================
 * Call-only mode
 *
 * Rendered when $remote_open_enabled is false (Twilio→TN SMS flapping).
 * The widget body becomes a focused single-CTA card: phone number is THE
 * primary action (large tappable pill), authorized-number chip sits right
 * below it as the "you're whitelisted" confirmation.
 *
 * Hierarchy:
 *   eyebrow (small uppercase + phone icon)
 *   number  (XL pill, 44px+ tap target, brand-gold border)
 *   confirm (hint + chip stack)
 * ======================================== */

.gs-gate-access__call-card {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 14px;
	max-width: 380px;
	margin: 0 auto;
	padding: 24px 16px 20px;
	text-align: center;
}

.gs-gate-access__call-eyebrow {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 1.2px;
	text-transform: uppercase;
	color: var(--gs-color-text-soft, #475569);
}

.gs-gate-access__call-eyebrow-icon {
	width: 14px;
	height: 14px;
	flex-shrink: 0;
}

.mphb-gs-shell .gs-gate-access__call-number {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 56px;
	padding: 14px 28px;
	border: 1.5px solid var(--gs-color-accent, #c49a3a);
	border-radius: var(--gs-radius-full, 9999px);
	background: var(--gs-color-surface, #ffffff);
	color: var(--gs-color-text, #0f172a);
	font-size: clamp(22px, 5.2vw, 28px);
	font-weight: 700;
	letter-spacing: 0.5px;
	font-variant-numeric: tabular-nums;
	text-decoration: none;
	box-shadow: var(--gs-shadow-md, 0 4px 12px rgba(15, 23, 42, 0.12));
	transition: transform 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
	cursor: pointer;
}

.mphb-gs-shell .gs-gate-access__call-number:hover,
.mphb-gs-shell .gs-gate-access__call-number:focus-visible {
	background: color-mix(in srgb, var(--gs-color-accent, #c49a3a) 8%, var(--gs-color-surface, #ffffff));
	box-shadow: var(--gs-shadow-lg, 0 12px 30px rgba(15, 23, 42, 0.15));
	transform: translateY(-1px);
	outline: none;
}

.mphb-gs-shell .gs-gate-access__call-number:focus-visible {
	box-shadow: var(--gs-shadow-lg, 0 12px 30px rgba(15, 23, 42, 0.15)), var(--gs-shadow-focus, 0 0 0 3px rgba(196, 154, 58, 0.3));
}

.mphb-gs-shell .gs-gate-access__call-number:active {
	transform: translateY(0);
	box-shadow: var(--gs-shadow-sm, 0 2px 5px rgba(15, 23, 42, 0.08));
}

.gs-gate-access__call-confirm {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	margin-top: 4px;
}

.gs-gate-access__call-hint {
	font-size: 13px;
	line-height: 1.4;
	color: var(--gs-color-text-soft, #475569);
}

.gs-gate-access__call-card .gs-gate-access__phone-chips {
	justify-content: center;
	margin: 0;
}

/* Cost/no-charge reassurance — subtle trust signal under the CTA.
 * Visually de-emphasized (small, soft surface, success-green tint) so it
 * supports the action without competing with the phone pill. */
.gs-gate-access__call-note {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin: 8px 0 0;
	padding: 10px 14px;
	border-radius: var(--gs-radius-md, 12px);
	background: var(--gs-color-success-bg, #f0fdf4);
	border: 1px solid var(--gs-color-success-border, #bbf7d0);
	color: var(--gs-color-text, #0f172a);
	font-size: 12.5px;
	line-height: 1.5;
	text-align: left;
	max-width: 320px;
}

.gs-gate-access__call-note strong {
	color: var(--gs-color-success, #22c55e);
	font-weight: 700;
}

.gs-gate-access__call-note-icon {
	width: 16px;
	height: 16px;
	flex-shrink: 0;
	margin-top: 1px;
	color: var(--gs-color-success, #22c55e);
}

.mphb-gs-shell[data-theme="dark"] .gs-gate-access__call-note {
	background: rgba(34, 197, 94, 0.10);
	border-color: rgba(34, 197, 94, 0.28);
	color: rgba(255, 255, 255, 0.86);
}

.mphb-gs-shell[data-theme="dark"] .gs-gate-access__call-note strong,
.mphb-gs-shell[data-theme="dark"] .gs-gate-access__call-note-icon {
	color: #4ade80;
}

/* Dark theme overrides — accent gold stays, surface goes glassy, text
 * inverts. The pill keeps its 4.5:1+ contrast in both schemes. */
.mphb-gs-shell[data-theme="dark"] .gs-gate-access__call-eyebrow,
.mphb-gs-shell[data-theme="dark"] .gs-gate-access__call-hint {
	color: rgba(255, 255, 255, 0.65);
}

.mphb-gs-shell[data-theme="dark"] .gs-gate-access__call-number {
	background: rgba(255, 255, 255, 0.04);
	color: #ffffff;
	border-color: var(--gs-color-accent, #c49a3a);
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.mphb-gs-shell[data-theme="dark"] .gs-gate-access__call-number:hover,
.mphb-gs-shell[data-theme="dark"] .gs-gate-access__call-number:focus-visible {
	background: rgba(196, 154, 58, 0.14);
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

/* Tighter on narrow viewports (<= iPhone SE width). Keep the pill big
 * enough to tap but trim padding so the number doesn't wrap. */
@media (max-width: 360px) {
	.gs-gate-access__call-card {
		padding: 18px 8px 16px;
	}
	.mphb-gs-shell .gs-gate-access__call-number {
		padding: 12px 20px;
		font-size: 20px;
		letter-spacing: 0.3px;
	}
}

/* Honor reduced motion: skip the lift/shadow transitions. */
@media (prefers-reduced-motion: reduce) {
	.mphb-gs-shell .gs-gate-access__call-number {
		transition: none;
	}
	.mphb-gs-shell .gs-gate-access__call-number:hover,
	.mphb-gs-shell .gs-gate-access__call-number:active {
		transform: none;
	}
}

/* ========================================
 * Primary CTA — "Ouvrir le portail"
 * Full-width gold pill (mockup validated 2026-07-17). Icon + label
 * on a single row. The green sweep on `::before` still fires during
 * is-loading (8s ~= physical gate opening time) and is-success, so
 * the base is gold and the state overlay is green — the metaphor is
 * "gate opening in progress".
 * ======================================== */

.mphb-gs-shell .gs-gate-access__cta {
	position: relative;
	width: 100%;
	border: 0;
	border-radius: 14px;
	padding: 18px 22px;
	display: flex;
	flex-direction: row;
	align-items: center;
	justify-content: center;
	gap: 12px;
	font-family: inherit;
	font-size: 17px;
	font-weight: 700;
	letter-spacing: 0.01em;
	line-height: 1.2;
	text-align: center;
	color: #1a1a1a;
	cursor: pointer;
	background-color: var(--gs-color-primary, #c49a3a);
	background-image: linear-gradient(135deg, var(--gs-color-primary, #c49a3a) 0%, var(--gs-color-primary-dark, #9e7b2e) 100%);
	box-shadow:
		0 8px 24px rgba(196, 154, 58, 0.28),
		0 0 0 1px rgba(196, 154, 58, 0.18),
		inset 0 1px 0 rgba(255, 255, 255, 0.35);
	transition: transform 0.2s ease, box-shadow 0.3s ease, opacity 0.3s ease;
	overflow: hidden;
}

/* The slider: a lighter-green layer that sweeps from left to right when opening.
 * Lives on a pseudo-element so we don't clobber the base gradient. */
.mphb-gs-shell .gs-gate-access__cta::before {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(90deg, #10b981 0%, #34d399 60%, #6ee7b7 100%);
	transform: translateX(-100%);
	transition: transform 0.3s ease;
	z-index: 0;
	pointer-events: none;
}

/* While loading, the slider drifts across over 8 seconds (gate opening time). */
.mphb-gs-shell .gs-gate-access__cta.is-loading::before {
	transform: translateX(0);
	transition: transform 8s linear;
}

/* Success: slider fully in place. */
.mphb-gs-shell .gs-gate-access__cta.is-success::before {
	transform: translateX(0);
	transition: transform 0.2s ease;
}

.mphb-gs-shell .gs-gate-access__cta-icon,
.mphb-gs-shell .gs-gate-access__cta-label {
	position: relative;
	z-index: 1;
}

.mphb-gs-shell .gs-gate-access__cta:hover:not(:disabled) {
	transform: translateY(-2px);
	box-shadow:
		0 14px 32px rgba(196, 154, 58, 0.38),
		0 0 60px rgba(196, 154, 58, 0.22),
		0 0 0 1px rgba(196, 154, 58, 0.3),
		inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.mphb-gs-shell .gs-gate-access__cta:active:not(:disabled) {
	transform: translateY(0);
	box-shadow:
		0 3px 10px rgba(196, 154, 58, 0.3),
		0 0 0 1px rgba(196, 154, 58, 0.2),
		inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.mphb-gs-shell .gs-gate-access__cta:focus-visible {
	outline: 3px solid rgba(196, 154, 58, 0.45);
	outline-offset: 3px;
}

.mphb-gs-shell .gs-gate-access__cta-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	flex-shrink: 0;
}

.mphb-gs-shell .gs-gate-access__cta-icon svg {
	width: 22px;
	height: 22px;
}

/* Loading state */
.mphb-gs-shell .gs-gate-access__cta.is-loading {
	cursor: wait;
}

.mphb-gs-shell .gs-gate-access__cta.is-loading .gs-gate-access__cta-icon svg {
	animation: gs-gate-spin 1s linear infinite;
}

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

/* Success state */
.mphb-gs-shell .gs-gate-access__cta.is-success {
	animation: gs-gate-pulse 1.5s ease-out;
}

.mphb-gs-shell .gs-gate-access__cta.is-success .gs-gate-access__cta-icon svg {
	animation: gs-gate-check-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes gs-gate-pulse {
	0% {
		box-shadow:
			0 4px 20px rgba(16, 185, 129, 0.35),
			0 0 0 1px rgba(16, 185, 129, 0.2),
			inset 0 1px 0 rgba(255, 255, 255, 0.2);
	}
	50% {
		box-shadow:
			0 4px 40px rgba(16, 185, 129, 0.7),
			0 0 80px rgba(52, 211, 153, 0.5),
			0 0 0 1px rgba(16, 185, 129, 0.3),
			inset 0 1px 0 rgba(255, 255, 255, 0.3);
	}
	100% {
		box-shadow:
			0 4px 20px rgba(16, 185, 129, 0.35),
			0 0 0 1px rgba(16, 185, 129, 0.2),
			inset 0 1px 0 rgba(255, 255, 255, 0.2);
	}
}

@keyframes gs-gate-check-pop {
	0% { transform: scale(0); }
	60% { transform: scale(1.2); }
	100% { transform: scale(1); }
}

/* Helper text under CTA */
.gs-gate-access__helper {
	margin: 10px 0 0 0;
	text-align: center;
	font-size: 13px;
	color: var(--gs-color-text-soft, #475569);
	line-height: 1.4;
}

/* Divider between the primary CTA (Shelly button) and the secondary
 * fallback (call the gate from an authorized number). Introduced
 * 2026-07-17 when the button became the default action and the phone
 * number was demoted to fallback — the divider tells the guest "these
 * are two alternatives, not two required steps". */
.gs-gate-access__divider {
	display: flex;
	align-items: center;
	gap: 12px;
	margin: 20px 0 18px;
	color: var(--gs-color-text-muted, rgba(233, 236, 243, 0.55));
	font-size: 11px;
	letter-spacing: 0.16em;
	text-transform: uppercase;
}
.gs-gate-access__divider::before,
.gs-gate-access__divider::after {
	content: "";
	flex: 1;
	height: 1px;
	background: currentColor;
	opacity: 0.28;
}
.gs-gate-access__divider-label {
	color: inherit;
	white-space: nowrap;
}

/* Error message under CTA.
 * Hidden state collapses to true zero (no padding/border/margin) so the
 * flex parent can center the row correctly. .is-visible re-expands. */
.gs-gate-access__error {
	margin: 0;
	padding: 0;
	border: 0 solid rgba(239, 68, 68, 0.25);
	border-radius: 10px;
	background: rgba(239, 68, 68, 0.08);
	color: var(--gs-color-error, #ef4444);
	font-size: 13px;
	display: flex;
	align-items: center;
	gap: 8px;
	opacity: 0;
	max-height: 0;
	overflow: hidden;
	transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease, border-width 0.3s ease;
}

.gs-gate-access__error.is-visible {
	margin-top: 10px;
	padding: 10px 14px;
	border-width: 1px;
	opacity: 1;
	max-height: 80px;
	animation: gs-gate-shake 0.3s ease-in-out;
}

@keyframes gs-gate-shake {
	0%, 100% { transform: translateX(0); }
	25% { transform: translateX(-4px); }
	75% { transform: translateX(4px); }
}

.gs-gate-access__error::before {
	content: "⚠";
	font-size: 14px;
	flex-shrink: 0;
}

/* ========================================
 * Fallback block (secondary action): intro + phone chips
 * ======================================== */

.gs-gate-access__fallback {
	flex: 1;
	min-width: 0;
	margin: 0;
	color: var(--gs-color-text-soft, #475569);
	text-align: left;
}

.gs-gate-access__fallback-intro {
	margin: 0;
	font-size: 14px;
	line-height: 1.55;
}

.mphb-gs-shell .gs-gate-access__fallback-number {
	font-weight: 600;
	color: var(--gs-color-text, #0f172a);
	text-decoration: none;
	white-space: nowrap;
	border-bottom: 1px dashed currentColor;
	padding-bottom: 1px;
}

.mphb-gs-shell .gs-gate-access__fallback-number:hover {
	border-bottom-style: solid;
	color: #10b981;
}

/* Divider kept for reference, unused after layout simplification. */
.gs-gate-access__divider { display: none; }

/* ========================================
 * Secondary block — direct call + phones
 * ======================================== */

.gs-gate-access__call-label {
	margin: 0 0 10px 0;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.8px;
	text-transform: uppercase;
	color: var(--gs-color-text-soft, #475569);
}

.mphb-gs-shell .gs-gate-access__tel-chip {
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
	padding: 10px 14px;
	border-radius: 10px;
	background: var(--gs-color-surface-alt, #f8fafc);
	border: 1px solid var(--gs-color-border, #e5e7eb);
	color: var(--gs-color-text, #0f172a);
	text-decoration: none;
	transition: transform 0.2s ease, border-color 0.2s ease;
}

.mphb-gs-shell .gs-gate-access__tel-chip:hover {
	border-color: #10b981;
	transform: translateX(2px);
	text-decoration: none;
}

.mphb-gs-shell .gs-gate-access__tel-chip:hover .gs-gate-access__tel-arrow {
	opacity: 1;
}

.gs-gate-access__tel-icon {
	font-size: 18px;
	flex-shrink: 0;
}

.gs-gate-access__tel-number {
	font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
	font-size: 15px;
	font-weight: 600;
	flex: 1;
}

.gs-gate-access__tel-arrow {
	font-size: 14px;
	opacity: 0.5;
	transition: opacity 0.2s ease;
	flex-shrink: 0;
}

.gs-gate-access__tel-helper {
	margin: 6px 0 0 0;
	text-align: center;
	font-size: 11px;
	color: var(--gs-color-text-soft, #475569);
}

.gs-gate-access__phone-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 12px 0 0 0;
	padding: 0;
	list-style: none;
}

.gs-gate-access__phone-chip {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 12px;
	border-radius: 999px;
	background: var(--gs-color-surface, #ffffff);
	border: 1px solid var(--gs-color-border, #e5e7eb);
	font-size: 13px;
	line-height: 1.3;
	color: var(--gs-color-text, #0f172a);
}

.gs-gate-access__phone-chip--ok {
	border-color: rgba(34, 197, 94, 0.35);
	background: rgba(34, 197, 94, 0.05);
}

.gs-gate-access__phone-chip--pending {
	border-color: rgba(245, 158, 11, 0.35);
	background: rgba(245, 158, 11, 0.05);
}

.gs-gate-access__phone-status {
	font-size: 11px;
	font-weight: 700;
	flex-shrink: 0;
	line-height: 1;
}

.gs-gate-access__phone-chip--ok .gs-gate-access__phone-status {
	color: var(--gs-color-success, #22c55e);
}

.gs-gate-access__phone-chip--pending .gs-gate-access__phone-status {
	color: var(--gs-color-warning, #f59e0b);
}

.gs-gate-access__phone-name {
	font-weight: 600;
}

.gs-gate-access__phone-last4 {
	color: var(--gs-color-text-soft, #475569);
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.3px;
}

.mphb-gs-shell[data-theme="dark"] .gs-gate-access__phone-chip {
	background: rgba(255, 255, 255, 0.04);
	border-color: rgba(255, 255, 255, 0.1);
}

.mphb-gs-shell[data-theme="dark"] .gs-gate-access__phone-chip--ok {
	background: rgba(34, 197, 94, 0.1);
	border-color: rgba(34, 197, 94, 0.4);
}

.mphb-gs-shell[data-theme="dark"] .gs-gate-access__phone-chip--pending {
	background: rgba(245, 158, 11, 0.1);
	border-color: rgba(245, 158, 11, 0.4);
}

@media (prefers-color-scheme: dark) {
	.mphb-gs-shell[data-theme="auto"] .gs-gate-access__phone-chip {
		background: rgba(255, 255, 255, 0.04);
		border-color: rgba(255, 255, 255, 0.1);
	}

	.mphb-gs-shell[data-theme="auto"] .gs-gate-access__phone-chip--ok {
		background: rgba(34, 197, 94, 0.1);
		border-color: rgba(34, 197, 94, 0.4);
	}

	.mphb-gs-shell[data-theme="auto"] .gs-gate-access__phone-chip--pending {
		background: rgba(245, 158, 11, 0.1);
		border-color: rgba(245, 158, 11, 0.4);
	}
}

/* ========================================
 * Manual mode panel
 * ======================================== */

.gs-gate-access__manual {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 16px;
	border-radius: 14px;
	background: rgba(245, 158, 11, 0.08);
	border: 1px solid rgba(245, 158, 11, 0.3);
	color: var(--gs-color-text, #0f172a);
	margin: 0;
}

.gs-gate-access__manual-icon {
	font-size: 22px;
	flex-shrink: 0;
	line-height: 1;
}

.gs-gate-access__manual-text {
	margin: 0;
	font-size: 14px;
	line-height: 1.5;
}

/* ========================================
 * Dark theme
 * ======================================== */

.mphb-gs-shell[data-theme="dark"] .gs-gate-access__cta {
	background: linear-gradient(135deg, #047857 0%, #059669 50%, #10b981 100%);
	box-shadow:
		0 4px 24px rgba(16, 185, 129, 0.4),
		0 0 0 1px rgba(52, 211, 153, 0.3),
		inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.mphb-gs-shell[data-theme="dark"] .gs-gate-access__cta:hover:not(:disabled) {
	box-shadow:
		0 8px 40px rgba(16, 185, 129, 0.55),
		0 0 80px rgba(52, 211, 153, 0.4),
		0 0 0 1px rgba(52, 211, 153, 0.4),
		inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.mphb-gs-shell[data-theme="dark"] .gs-gate-access__manual {
	background: rgba(245, 158, 11, 0.12);
	border-color: rgba(245, 158, 11, 0.4);
}

.mphb-gs-shell[data-theme="dark"] .gs-gate-access__error {
	background: rgba(239, 68, 68, 0.15);
	border-color: rgba(239, 68, 68, 0.35);
}

@media (prefers-color-scheme: dark) {
	.mphb-gs-shell[data-theme="auto"] .gs-gate-access__cta {
		background: linear-gradient(135deg, #047857 0%, #059669 50%, #10b981 100%);
		box-shadow:
			0 4px 24px rgba(16, 185, 129, 0.4),
			0 0 0 1px rgba(52, 211, 153, 0.3),
			inset 0 1px 0 rgba(255, 255, 255, 0.1);
	}

	.mphb-gs-shell[data-theme="auto"] .gs-gate-access__cta:hover:not(:disabled) {
		box-shadow:
			0 8px 40px rgba(16, 185, 129, 0.55),
			0 0 80px rgba(52, 211, 153, 0.4),
			0 0 0 1px rgba(52, 211, 153, 0.4),
			inset 0 1px 0 rgba(255, 255, 255, 0.15);
	}

	.mphb-gs-shell[data-theme="auto"] .gs-gate-access__manual {
		background: rgba(245, 158, 11, 0.12);
		border-color: rgba(245, 158, 11, 0.4);
	}

	.mphb-gs-shell[data-theme="auto"] .gs-gate-access__error {
		background: rgba(239, 68, 68, 0.15);
		border-color: rgba(239, 68, 68, 0.35);
	}
}

/* ========================================
 * Reduced motion
 * ======================================== */

@media (prefers-reduced-motion: reduce) {
	.mphb-gs-shell .gs-gate-access__cta,
	.mphb-gs-shell .gs-gate-access__cta.is-success,
	.mphb-gs-shell .gs-gate-access__cta.is-loading .gs-gate-access__cta-icon svg,
	.mphb-gs-shell .gs-gate-access__cta.is-success .gs-gate-access__cta-icon svg,
	.gs-gate-access__error.is-visible,
	.mphb-gs-shell .gs-gate-access__tel-chip {
		animation: none !important;
		transition: opacity 0.1s ease !important;
	}

	.mphb-gs-shell .gs-gate-access__cta:hover:not(:disabled),
	.mphb-gs-shell .gs-gate-access__tel-chip:hover {
		transform: none !important;
	}
}

/* ========================================
 * Mobile
 * ======================================== */

@media (max-width: 480px) {
	.gs-gate-access__row {
		flex-direction: column;
		align-items: stretch;
	}

	.mphb-gs-shell .gs-gate-access__cta {
		align-self: center;
		min-height: 52px;
		font-size: 15px;
	}

	.gs-gate-access__divider {
		margin: 16px 0;
	}
}
