/**
 * Topbar موبایلی به سبک تلگرام - viraving
 *
 * فقط در صفحات: خانه، ورود، تماس با ما
 * به جای هدر دسکتاپ در موبایل نمایش داده می‌شود
 *
 * @package Viraving
 */

/* ============================================================
   Topbar موبایل - فقط در صفحات انتخاب‌شده
   ============================================================ */
.mobile-app-topbar {
	display: none;
}

@media (max-width: 768px) {
	/* نمایش topbar در صفحات هدف */
	body.is-mobile-topbar-page .mobile-app-topbar {
		display: flex;
		position: sticky;
		top: 0;
		z-index: 1000;
		background: var(--bg-glass-strong);
		backdrop-filter: blur(24px) saturate(200%);
		-webkit-backdrop-filter: blur(24px) saturate(200%);
		border-bottom: 1px solid var(--border-color);
		padding: 0.625rem 0.875rem;
		padding-top: max(0.625rem, env(safe-area-inset-top));
		padding-bottom: max(0.625rem, env(safe-area-inset-bottom, 0.625rem));
		align-items: center;
		justify-content: space-between;
		gap: 0.75rem;
		box-shadow: var(--shadow-sm);
		min-height: 56px;
	}

	/* topbar موبایل مخفی شده (هدر یکپارچه جایگزین شده) */
	.mobile-app-topbar {
		display: none !important;
	}

	/* ساختار داخلی topbar */
	.topbar-left,
	.topbar-right {
		display: flex;
		align-items: center;
		gap: 0.5rem;
		flex-shrink: 0;
	}

	.topbar-center {
		flex: 1;
		min-width: 0;
		text-align: center;
	}

	/* دکمه‌های topbar */
	.topbar-btn {
		width: 40px;
		height: 40px;
		display: flex;
		align-items: center;
		justify-content: center;
		background: transparent;
		border: none;
		border-radius: 12px;
		color: var(--text-primary);
		cursor: pointer;
		transition: all 0.2s ease;
		-webkit-tap-highlight-color: transparent;
		padding: 0;
	}

	.topbar-btn:hover,
	.topbar-btn:active {
		background: rgba(var(--color-primary-rgb), 0.1);
		color: var(--color-primary);
	}

	.topbar-btn svg {
		width: 22px;
		height: 22px;
	}

	/* عنوان topbar */
	.topbar-title {
		font-size: 1.0625rem;
		font-weight: 700;
		color: var(--text-primary);
		margin: 0;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.topbar-subtitle {
		font-size: 0.6875rem;
		color: var(--text-tertiary);
		margin: 0;
		display: block;
		line-height: 1.2;
	}

	/* لوگوی کوچک در topbar */
	.topbar-logo {
		display: inline-flex;
		align-items: center;
		gap: 0.375rem;
		text-decoration: none;
		color: var(--text-primary);
	}

	.topbar-logo-mark {
		width: 32px;
		height: 32px;
		display: flex;
		align-items: center;
		justify-content: center;
		background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
		color: var(--text-inverse);
		border-radius: 12px;
		font-weight: 900;
		font-size: 0.9375rem;
		box-shadow: var(--shadow-primary);
	}

	.topbar-logo-text {
		font-size: 1rem;
		font-weight: 800;
	}

	/* badge روی آیکون (مثل اعلان‌ها) */
	.topbar-btn-badge {
		position: absolute;
		top: 4px;
		right: 4px;
		min-width: 16px;
		height: 16px;
		padding: 0 4px;
		border-radius: 12px;
		background: var(--color-danger);
		color: #ffffff;
		font-size: 0.5625rem;
		font-weight: 700;
		display: flex;
		align-items: center;
		justify-content: center;
		border: 2px solid var(--bg-surface);
	}

	.topbar-btn {
		position: relative;
	}

	/* دکمه بازگشت */
	.topbar-back-btn {
		width: 40px;
		height: 40px;
	}

	.topbar-back-btn svg {
		transform: scaleX(-1);
	}

	/* فضای جستجو در topbar */
	.topbar-search {
		flex: 1;
		display: flex;
		align-items: center;
		gap: 0.5rem;
		background: var(--bg-glass);
		border: 1px solid var(--border-color);
		border-radius: 12px;
		padding: 0.5rem 0.875rem;
		max-width: 280px;
	}

	.topbar-search svg {
		width: 18px;
		height: 18px;
		color: var(--text-tertiary);
		flex-shrink: 0;
	}

	.topbar-search input {
		border: none;
		background: transparent;
		outline: none;
		color: var(--text-primary);
		font-size: 0.875rem;
		font-family: inherit;
		width: 100%;
	}

	.topbar-search input::placeholder {
		color: var(--text-tertiary);
	}

	/* حالت اسکرول‌شده - فشرده‌تر */
	body.is-mobile-topbar-page .mobile-app-topbar.scrolled {
		padding-top: max(0.5rem, env(safe-area-inset-top));
		box-shadow: var(--shadow-md);
	}

	/* محتوای زیر topbar فضای مناسب بگیرد */
	body.is-mobile-topbar-page #primary {
		padding-top: 0;
	}
}

/* === موبایل بسیار کوچک === */
@media (max-width: 480px) {
	body.is-mobile-topbar-page .mobile-app-topbar {
		padding: 0.5rem 0.625rem;
		padding-top: max(0.5rem, env(safe-area-inset-top));
		gap: 0.375rem;
	}

	.topbar-btn {
		width: 36px;
		height: 36px;
	}

	.topbar-btn svg {
		width: 20px;
		height: 20px;
	}

	.topbar-title {
		font-size: 0.9375rem;
	}

	.topbar-logo-mark {
		width: 28px;
		height: 28px;
		font-size: 0.8125rem;
		border-radius: 12px;
	}

	.topbar-logo-text {
		font-size: 0.9375rem;
	}
}

/* === حالت تاریک === */
html[data-theme="dark"] .mobile-app-topbar,
.color-mode-dark .mobile-app-topbar {
	background: rgba(19, 31, 28, 0.85);
	border-bottom-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .topbar-search,
.color-mode-dark .topbar-search {
	background: rgba(255, 255, 255, 0.05);
	border-color: rgba(255, 255, 255, 0.1);
}
