/**
 * 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;
}

/* ========================================
 * Primary CTA — "Ouvrir le portail"
 * Square button, left column. Slider fills left-to-right over 8s
 * (the physical gate's opening time) while in is-loading state.
 * ======================================== */

.mphb-gs-shell .gs-gate-access__cta {
	position: relative;
	width: 140px;
	height: 140px;
	flex-shrink: 0;
	border: 0;
	border-radius: 16px;
	padding: 12px;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.3px;
	line-height: 1.2;
	text-align: center;
	color: #ffffff;
	cursor: pointer;
	background-color: #047857;
	background-image: linear-gradient(135deg, #047857 0%, #065f46 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);
	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 8px 30px rgba(16, 185, 129, 0.5),
		0 0 60px rgba(52, 211, 153, 0.3),
		0 0 0 1px rgba(16, 185, 129, 0.3),
		inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.mphb-gs-shell .gs-gate-access__cta:active:not(:disabled) {
	transform: translateY(0);
	box-shadow:
		0 2px 10px rgba(16, 185, 129, 0.3),
		0 0 0 1px rgba(16, 185, 129, 0.2),
		inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.mphb-gs-shell .gs-gate-access__cta:focus-visible {
	outline: 3px solid rgba(16, 185, 129, 0.4);
	outline-offset: 3px;
}

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

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

/* 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;
}

/* 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;
	}
}
