/* ================================================================
 * Haika KingSize — Auth modal + Header user widget
 * ================================================================ */

/* ─── Safety net: جلوگیری از scroll افقی سراسری ─── */
html, body { overflow-x: hidden; max-width: 100%; }
/* جلوگیری از overflow ستون‌های grid (default min-width: auto مشکل‌ساز است) */
.hkdash__main,
.hkdash__layout > *,
.haika-shop-layout > *,
.hpo-future-grid > *,
.hpo-pillars-grid > *,
.hpo-coop-grid > * { min-width: 0; }

/* ════════════════════════════════════════════════════════════
   HEADER WIDGET (logged-out + logged-in)
   ════════════════════════════════════════════════════════════ */
.hkauth-trigger {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 7px 14px;
	border-radius: 999px;
	background: rgba(255,255,255,.06);
	border: 1px solid rgba(255,255,255,.10);
	color: inherit;
	cursor: pointer;
	font-family: inherit;
	font-size: 13px;
	font-weight: 700;
	text-decoration: none;
	transition: all .15s;
	white-space: nowrap;
}
.hkauth-trigger:hover {
	background: rgba(192,132,252,.18);
	border-color: rgba(192,132,252,.45);
}
.hkauth-trigger > svg { color: var(--ks-purple-glow, #c084fc); flex-shrink: 0; }

/* User dropdown when logged in */
.hkauth-user {
	position: relative;
	display: inline-flex;
}
.hkauth-user__btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 6px 12px 6px 6px;
	border-radius: 999px;
	background: rgba(192,132,252,.12);
	border: 1px solid rgba(192,132,252,.25);
	color: inherit;
	cursor: pointer;
	font-family: inherit;
	font-size: 13px;
	font-weight: 700;
}
[dir="ltr"] .hkauth-user__btn { padding: 6px 6px 6px 12px; }
.hkauth-user__btn:hover { background: rgba(192,132,252,.22); }
.hkauth-user__avatar {
	width: 28px; height: 28px;
	border-radius: 50%;
	background: linear-gradient(135deg, var(--ks-purple-glow, #c084fc), var(--ks-purple, #5b2c87));
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-weight: 800;
	font-size: 12px;
	flex-shrink: 0;
}
.hkauth-user__name {
	max-width: 110px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}
.hkauth-user__caret { color: rgba(255,255,255,.4); transition: transform .2s; flex-shrink: 0; }
.hkauth-user.is-open .hkauth-user__caret { transform: rotate(180deg); }

.hkauth-user__menu {
	position: absolute;
	top: calc(100% + 8px);
	right: 0;
	min-width: 240px;
	background: var(--cb-bg, #15192a);
	border: 1px solid rgba(255,255,255,.1);
	border-radius: 14px;
	box-shadow: 0 18px 60px rgba(0,0,0,.45);
	padding: 6px;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-8px);
	transition: opacity .18s, transform .18s, visibility 0s linear .18s;
	z-index: 9999;
}
[dir="ltr"] .hkauth-user__menu { right: auto; left: 0; }
.hkauth-user.is-open .hkauth-user__menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	transition: opacity .18s, transform .18s, visibility 0s linear 0s;
}
.haika-theme-light .hkauth-user__menu { background: #fff; border-color: rgba(91,44,135,.15); box-shadow: 0 18px 60px rgba(91,44,135,.18); }

.hkauth-user__menu-head {
	padding: 12px 14px 10px;
	border-bottom: 1px dashed rgba(255,255,255,.08);
	margin-bottom: 4px;
}
.haika-theme-light .hkauth-user__menu-head { border-color: rgba(91,44,135,.1); }
.hkauth-user__menu-name { font-size: 14px; font-weight: 800; color: var(--cb-text, #fff); }
.hkauth-user__menu-phone { font-size: 11.5px; color: var(--cb-text-2, rgba(255,255,255,.55)); margin-top: 2px; }
.hkauth-user__menu-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 12px;
	border-radius: 8px;
	color: var(--cb-text, #fff);
	text-decoration: none;
	font-size: 13px;
	font-weight: 600;
	transition: background .12s;
}
.hkauth-user__menu-item:hover { background: rgba(192,132,252,.14); color: var(--ks-purple-glow, #c084fc); }
.hkauth-user__menu-item > svg { color: var(--ks-purple-glow, #c084fc); flex-shrink: 0; }
.hkauth-user__menu-item--danger { color: #ef4444; }
.hkauth-user__menu-item--danger:hover { background: rgba(239,68,68,.12); color: #ef4444; }
.hkauth-user__menu-item--danger > svg { color: #ef4444; }
.hkauth-user__menu-badge {
	margin-inline-start: auto;
	background: var(--ks-purple-glow, #c084fc);
	color: var(--cb-bg, #15192a);
	font-size: 10.5px;
	font-weight: 800;
	padding: 2px 7px;
	border-radius: 999px;
}

/* Mobile: compact icon (different style for logged-in) */
@media (max-width: 720px) {
	.hkauth-trigger__label { display: none; }
	.hkauth-trigger {
		width: 38px; height: 38px;
		padding: 0;
		justify-content: center;
	}
	.hkauth-user__btn {
		width: 38px; height: 38px;
		padding: 0;
		justify-content: center;
		background: linear-gradient(135deg, var(--ks-purple-glow, #c084fc), var(--ks-purple, #5b2c87));
		border-color: transparent;
		color: #fff;
	}
	.hkauth-user__avatar { width: 100%; height: 100%; background: transparent; font-size: 14px; }
	.hkauth-user__name, .hkauth-user__caret { display: none; }
	.hkauth-user__btn::after {
		content: "";
		position: absolute;
		bottom: 0; right: 0;
		width: 9px; height: 9px;
		background: #10b981;
		border-radius: 50%;
		border: 2px solid var(--cb-bg, #15192a);
	}
	[dir="ltr"] .hkauth-user__btn::after { right: auto; left: 0; }

	/* dropdown روی موبایل به‌صورت bottom-sheet (جلوگیری از overflow افقی) */
	.hkauth-user__menu {
		position: fixed;
		top: auto;
		right: 12px;
		left: 12px;
		bottom: 70px;
		min-width: 0;
		width: auto;
		max-width: 360px;
		margin: 0 auto;
		border-radius: 18px;
	}
}

/* ════════════════════════════════════════════════════════════
   AUTH MODAL
   ════════════════════════════════════════════════════════════ */
.haka {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	visibility: hidden;
	transition: opacity .25s, visibility 0s linear .25s;
	pointer-events: none;
}
.haka.is-open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transition: opacity .25s, visibility 0s linear 0s;
}
.haka__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(10, 8, 22, .75);
	-webkit-backdrop-filter: blur(14px);
	backdrop-filter: blur(14px);
}
.haka__card {
	position: relative;
	width: min(440px, 92vw);
	max-height: 92vh;
	overflow-y: auto;
	background: linear-gradient(180deg, #1a0a35, #0a0612);
	border: 1px solid rgba(192, 132, 252, .25);
	border-radius: 24px;
	padding: 36px 28px 28px;
	color: #e9e2f8;
	box-shadow: 0 30px 80px rgba(91, 44, 135, .55);
	transform: scale(.96) translateY(8px);
	transition: transform .28s cubic-bezier(.22,1,.36,1);
}
.haka.is-open .haka__card { transform: scale(1) translateY(0); }

.haka__close {
	position: absolute;
	top: 14px;
	left: 14px;
	width: 36px; height: 36px;
	border-radius: 999px;
	background: rgba(255,255,255,.06);
	border: 0;
	color: #fff;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background .15s;
}
[dir="rtl"] .haka__close { left: auto; right: 14px; }
.haka__close:hover { background: rgba(239,68,68,.2); color: #fca5a5; }

.haka__head { text-align: center; margin-bottom: 22px; }
.haka__brand {
	width: 64px; height: 64px;
	border-radius: 999px;
	background: linear-gradient(135deg, rgba(192,132,252,.25), rgba(91,44,135,.1));
	color: #c084fc;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto 16px;
	border: 1px solid rgba(192,132,252,.3);
	box-shadow: 0 0 30px rgba(192,132,252,.18);
}
.haka__title { font-size: 22px; font-weight: 800; margin: 0 0 6px; color: #fff; }
.haka__sub { font-size: 13px; color: rgba(233, 226, 248, 0.65); margin: 0; line-height: 1.85; }

/* Steps */
.haka__step { display: flex; flex-direction: column; gap: 14px; }
.haka__step[hidden] { display: none; }

/* Field */
.haka__field { display: flex; flex-direction: column; gap: 7px; }
.haka__field > span { font-size: 12px; font-weight: 700; color: #e9e2f8; }
.haka__field input {
	padding: 14px 16px;
	border-radius: 12px;
	border: 1.5px solid rgba(192, 132, 252, .2);
	background: rgba(255,255,255,.05);
	color: #fff;
	font-family: inherit;
	font-size: 15px;
	transition: border-color .15s, box-shadow .15s;
	width: 100%;
	box-sizing: border-box;
	letter-spacing: .02em;
}
.haka__field input::placeholder { color: rgba(233, 226, 248, .35); }
.haka__field input:focus {
	outline: 0;
	border-color: #c084fc;
	box-shadow: 0 0 0 3px rgba(192, 132, 252, .2);
}

/* OTP input — extra large, centered */
.haka__otp-input {
	text-align: center !important;
	letter-spacing: .35em !important;
	font-size: 26px !important;
	font-weight: 800 !important;
	font-family: 'Courier New', monospace !important;
	padding: 18px 16px !important;
	padding-inline-end: calc(18px + .35em) !important; /* جبران letter-spacing برای متعادل بودن دیداری */
}
.haka__otp-input::placeholder {
	letter-spacing: .25em !important;
	color: rgba(192, 132, 252, .35) !important;
	font-weight: 400 !important;
	font-size: 22px !important;
}

/* OTP hint */
.haka__otp-hint {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 11.5px;
	color: rgba(192, 132, 252, .8);
	margin: 0;
	justify-content: center;
	background: rgba(192, 132, 252, .08);
	border: 1px dashed rgba(192, 132, 252, .25);
	border-radius: 8px;
	padding: 8px 12px;
}
.haka__otp-hint[hidden] { display: none; }

/* Password reveal toggle */
.haka__pwd-wrap { position: relative; }
.haka__pwd-toggle {
	position: absolute;
	top: 50%; left: 12px;
	transform: translateY(-50%);
	background: 0;
	border: 0;
	color: rgba(192, 132, 252, .55);
	cursor: pointer;
	padding: 4px;
}
[dir="ltr"] .haka__pwd-toggle { left: auto; right: 12px; }
.haka__pwd-toggle:hover { color: #c084fc; }

/* Phone display chip */
.haka__phone-display {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 7px 14px;
	border-radius: 999px;
	background: rgba(192,132,252,.12);
	color: #c084fc;
	font-size: 13px;
	font-weight: 700;
	align-self: center;
	margin-bottom: 4px;
}
.haka__phone-display > svg { opacity: .8; }
.haka__phone-edit {
	background: 0;
	border: 0;
	color: rgba(233,226,248,.6);
	font-size: 11.5px;
	font-weight: 700;
	margin-inline-start: 6px;
	padding: 0;
	cursor: pointer;
	text-decoration: underline;
}
.haka__phone-edit:hover { color: #fff; }

/* Buttons */
.haka__btn {
	padding: 14px 22px;
	border-radius: 12px;
	border: 0;
	font-family: inherit;
	font-weight: 800;
	font-size: 14.5px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 10px;
	transition: transform .15s, box-shadow .2s;
	letter-spacing: .02em;
}
.haka__btn--primary {
	background: linear-gradient(135deg, #c084fc, #5b2c87);
	color: #fff;
	box-shadow: 0 10px 28px rgba(91,44,135,.5);
}
.haka__btn--primary:hover:not(:disabled) {
	transform: translateY(-2px);
	box-shadow: 0 14px 34px rgba(91,44,135,.7);
}
.haka__btn:disabled { opacity: .6; cursor: wait; }
.haka__btn-spin { display: none; animation: haka-spin .8s linear infinite; transform-origin: 50% 50%; }
.haka__btn.is-loading .haka__btn-text,
.haka__btn.is-loading .haka__btn-arrow { display: none; }
.haka__btn.is-loading .haka__btn-spin   { display: inline-block; }
@keyframes haka-spin { to { transform: rotate(360deg); } }

/* Legal text */
.haka__legal {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	font-size: 11.5px;
	color: rgba(233,226,248,.55);
	margin: 0;
	justify-content: center;
}
.haka__legal > svg { color: #10b981; }

/* Resend group */
.haka__resend {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	flex-wrap: wrap;
	font-size: 12px;
	color: rgba(233,226,248,.55);
}
.haka__resend-btn,
.haka__use-password {
	background: 0;
	border: 0;
	color: #c084fc;
	cursor: pointer;
	font-weight: 700;
	font-size: 12.5px;
	padding: 0;
	font-family: inherit;
}
.haka__resend-btn:disabled { color: rgba(233,226,248,.4); cursor: default; }
.haka__resend-btn:not(:disabled):hover,
.haka__use-password:hover { text-decoration: underline; }
.haka__resend-sep { opacity: .45; }

/* Feedback */
.haka__feedback {
	margin-top: 14px;
	padding: 12px 14px;
	border-radius: 10px;
	font-size: 13px;
	font-weight: 600;
	border: 1px solid;
	animation: haka-slidein .25s ease;
}
.haka__feedback[hidden] { display: none; }
.haka__feedback.is-error   { background: rgba(239,68,68,.1); color: #fda4af; border-color: rgba(239,68,68,.4); }
.haka__feedback.is-success { background: rgba(16,185,129,.1); color: #6ee7b7; border-color: rgba(16,185,129,.4); }
.haka__feedback.is-info    { background: rgba(192,132,252,.1); color: #c084fc; border-color: rgba(192,132,252,.4); }
@keyframes haka-slidein {
	from { opacity: 0; transform: translateY(-6px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* Success state */
.haka__success { text-align: center; gap: 8px; }
.haka__check {
	width: 78px; height: 78px;
	border-radius: 999px;
	background: linear-gradient(135deg, #10b981, #34d399);
	color: #fff;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0 auto 12px;
	box-shadow: 0 12px 36px rgba(16,185,129,.5);
	animation: haka-bounce .55s cubic-bezier(.22,1,.36,1);
}
@keyframes haka-bounce { 0% { transform: scale(0); } 60% { transform: scale(1.1); } 100% { transform: scale(1); } }
.haka__success-title { font-size: 20px; font-weight: 800; margin: 0; color: #fff; }
.haka__success-sub { font-size: 13px; color: rgba(233,226,248,.55); margin: 4px 0 0; }

/* Mobile fine-tuning */
@media (max-width: 480px) {
	.haka__card { padding: 28px 22px 22px; border-radius: 20px 20px 0 0; max-height: 96vh; align-self: flex-end; width: 100%; }
	.haka { align-items: flex-end; }
}
