/* styles.css */
* {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

html, body {
	height: 100%;
	width: 100%;
	overflow: hidden;
}

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	background: var(--tg-theme-bg-color, #ffffff);
	color: var(--tg-theme-text-color, #000000);
	height: 100vh;
	width: 100vw;
}

#app {
	height: 100vh;
	width: 100vw;
	display: flex;
	flex-direction: column;
}

.loader {
	display: flex;
	justify-content: center;
	align-items: center;
	height: 100vh;
	width: 100vw;
	font-size: 18px;
	background: var(--tg-theme-bg-color, #ffffff);
	color: var(--tg-theme-text-color, #000000);
}

.content {
	display: flex;
	flex-direction: column;
	height: 100vh;
	width: 100vw;
	padding-top: env(safe-area-inset-top);
	padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
.header {
	background: var(--tg-theme-bg-color, #ffffff);
	color: var(--tg-theme-text-color, #000000);
	padding: 12px 16px;
	display: flex;
	justify-content: space-between;
	align-items: center;
	min-height: 56px;
	flex-shrink: 0;
	border-bottom: 1px solid var(--tg-theme-secondary-bg-color, #f0f0f0);
	position: relative;
}

.logo {
	display: flex;
	align-items: center;
	gap: 8px;
}

.logo-icon {
	font-size: 24px;
}

.logo-text {
	font-size: 18px;
	font-weight: 700;
	color: var(--tg-theme-button-color, #0088cc);
}

.header-actions {
	display: flex;
	gap: 8px;
}

.header-btn {
	background: none;
	border: none;
	padding: 8px;
	border-radius: 8px;
	cursor: pointer;
	color: var(--tg-theme-text-color, #000000);
	transition: background 0.2s ease;
	display: flex;
	align-items: center;
	justify-content: center;
}

.header-btn:hover {
	background: var(--tg-theme-secondary-bg-color, #f0f0f0);
}

/* Main Content */
.main {
	flex: 1;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	background: var(--tg-theme-secondary-bg-color, #f0f0f0);
}

.page-container {
	flex: 1;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	background: var(--tg-theme-bg-color, #ffffff);
	padding-bottom: 80px;
}

.page {
	padding: 16px;
	min-height: 100%;
	background: var(--tg-theme-bg-color, #ffffff);
}

.page h2 {
	margin-bottom: 16px;
	color: var(--tg-theme-text-color, #000000);
	font-size: 20px;
	font-weight: 600;
}

/* Navigation */
.navigation {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	background: var(--tg-theme-bg-color, #ffffff);
	border-top: 1px solid var(--tg-theme-secondary-bg-color, #f0f0f0);
	display: flex;
	justify-content: space-around;
	padding: 8px 0;
	z-index: 1000;
}

.nav-button {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 8px 12px;
	border: none;
	background: transparent;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.2s ease;
	min-width: 60px;
	color: var(--tg-theme-text-color, #000000);
	position: relative;
}

.nav-button:hover {
	background: var(--tg-theme-secondary-bg-color, #f0f0f0);
}

.nav-button.active {
	color: var(--tg-theme-button-color, #0088cc);
}

.nav-icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	margin-bottom: 4px;
}

.nav-label {
	font-size: 11px;
	font-weight: 500;
}

/* Primary Action Button */
.nav-button-primary {
	position: relative;
	top: -8px;
	background: var(--tg-theme-button-color, #0088cc);
	color: var(--tg-theme-button-text-color, #ffffff);
	border-radius: 50%;
	width: 56px;
	height: 56px;
	min-width: auto;
	box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3);
}

.nav-button-primary .nav-icon {
	margin-bottom: 0;
	width: 24px;
	height: 24px;
}

.nav-button-primary .nav-label {
	display: none;
}

/* Feed Page */
.feed-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 16px;
}

.feed-stats {
	font-size: 14px;
	color: var(--tg-theme-hint-color, #666666);
}

.ads-filters {
	display: flex;
	gap: 8px;
	margin-bottom: 16px;
	overflow-x: auto;
	padding-bottom: 8px;
	-webkit-overflow-scrolling: touch;
}

.ads-filters::-webkit-scrollbar {
	display: none;
}

.filter-btn {
	background: var(--tg-theme-secondary-bg-color, #f0f0f0);
	border: none;
	padding: 8px 16px;
	border-radius: 20px;
	font-size: 14px;
	cursor: pointer;
	white-space: nowrap;
	transition: all 0.2s ease;
	flex-shrink: 0;
}

.filter-btn.active {
	background: var(--tg-theme-button-color, #0088cc);
	color: var(--tg-theme-button-text-color, #ffffff);
}

/* Ads List */
.ads-list {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

.ad-card {
	background: var(--tg-theme-bg-color, #ffffff);
	border: 1px solid var(--tg-theme-secondary-bg-color, #f0f0f0);
	border-radius: 12px;
	padding: 16px;
	display: flex;
	gap: 12px;
	cursor: pointer;
	transition: all 0.2s ease;
}

.ad-card:hover {
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ad-image {
	width: 80px;
	height: 80px;
	background: var(--tg-theme-secondary-bg-color, #f5f5f5);
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 32px;
	flex-shrink: 0;
	color: var(--tg-theme-hint-color, #666666);
}

.ad-content {
	flex: 1;
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}

.ad-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 8px;
}

.ad-title {
	font-size: 16px;
	font-weight: 600;
	color: var(--tg-theme-text-color, #000000);
	margin: 0;
	flex: 1;
	line-height: 1.3;
	overflow: hidden;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

.favorite-btn {
	background: none;
	border: none;
	padding: 4px;
	cursor: pointer;
	color: var(--tg-theme-hint-color, #999999);
	transition: all 0.2s ease;
	flex-shrink: 0;
}

.favorite-btn.active {
	color: var(--tg-theme-destructive-text-color, #ff3b30);
}

.ad-price {
	font-size: 18px;
	font-weight: 700;
	color: var(--tg-theme-button-color, #0088cc);
}

.ad-meta {
	display: flex;
	gap: 12px;
	font-size: 12px;
	color: var(--tg-theme-hint-color, #666666);
}

.ad-location, .ad-date {
	white-space: nowrap;
}

.ad-seller {
	display: flex;
	justify-content: space-between;
	align-items: center;
	font-size: 12px;
	margin-top: 4px;
}

.seller-name {
	color: var(--tg-theme-text-color, #000000);
	font-weight: 500;
}

.seller-rating {
	color: var(--tg-theme-hint-color, #666666);
	display: flex;
	align-items: center;
	gap: 2px;
}

/* Categories Page */
.categories-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: 12px;
	margin-top: 16px;
}

.category-card {
	background: var(--tg-theme-bg-color, #ffffff);
	border: 1px solid var(--tg-theme-secondary-bg-color, #f0f0f0);
	border-radius: 12px;
	padding: 20px 16px;
	text-align: center;
	cursor: pointer;
	transition: all 0.2s ease;
}

.category-card:hover {
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	transform: translateY(-2px);
}

.category-icon {
	font-size: 32px;
	margin-bottom: 8px;
}

.category-name {
	font-size: 14px;
	font-weight: 600;
	color: var(--tg-theme-text-color, #000000);
	margin-bottom: 4px;
}

.category-count {
	font-size: 12px;
	color: var(--tg-theme-hint-color, #666666);
}

/* Favorites Page */
.favorites-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 20px;
}

.favorites-stats {
	font-size: 14px;
	color: var(--tg-theme-hint-color, #666666);
}

.empty-state {
	text-align: center;
	padding: 60px 20px;
}

.empty-icon {
	font-size: 64px;
	margin-bottom: 16px;
	opacity: 0.5;
	color: var(--tg-theme-hint-color, #666666);
}

.empty-state h3 {
	margin-bottom: 8px;
	color: var(--tg-theme-text-color, #000000);
}

/* Profile Page */
.profile-header {
	display: flex;
	align-items: center;
	gap: 16px;
	margin-bottom: 24px;
}

.profile-avatar {
	width: 64px;
	height: 64px;
	border-radius: 50%;
	background: var(--tg-theme-secondary-bg-color, #f0f0f0);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 28px;
	overflow: hidden;
	flex-shrink: 0;
}

.profile-avatar img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.profile-info h2 {
	margin-bottom: 4px;
}

.profile-stats {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 12px;
	margin-bottom: 24px;
}

.stat-item {
	background: var(--tg-theme-bg-color, #ffffff);
	border: 1px solid var(--tg-theme-secondary-bg-color, #f0f0f0);
	border-radius: 12px;
	padding: 16px;
	text-align: center;
}

.stat-number {
	font-size: 20px;
	font-weight: 700;
	color: var(--tg-theme-text-color, #000000);
	margin-bottom: 4px;
}

.stat-label {
	font-size: 12px;
	color: var(--tg-theme-hint-color, #666666);
}

.profile-actions {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.profile-action-btn {
	background: var(--tg-theme-bg-color, #ffffff);
	border: 1px solid var(--tg-theme-secondary-bg-color, #f0f0f0);
	border-radius: 12px;
	padding: 16px;
	display: flex;
	align-items: center;
	gap: 12px;
	cursor: pointer;
	transition: all 0.2s ease;
	text-align: left;
	width: 100%;
}

.profile-action-btn:hover {
	background: var(--tg-theme-secondary-bg-color, #f0f0f0);
}

.action-icon {
	font-size: 20px;
	width: 24px;
	text-align: center;
}

/* Utility Classes */
.text-hint {
	color: var(--tg-theme-hint-color, #666666);
	font-size: 14px;
	line-height: 1.4;
}

.tg-button {
	background: var(--tg-theme-button-color, #0088cc);
	color: var(--tg-theme-button-text-color, #ffffff);
	border: none;
	padding: 12px 24px;
	border-radius: 8px;
	font-size: 16px;
	font-weight: 500;
	cursor: pointer;
	transition: opacity 0.2s ease;
	text-align: center;
	display: inline-block;
}

.tg-button:hover {
	opacity: 0.9;
}

/* Scrollbar */
.page-container::-webkit-scrollbar {
	width: 4px;
}

.page-container::-webkit-scrollbar-track {
	background: var(--tg-theme-secondary-bg-color, #f1f1f1);
}

.page-container::-webkit-scrollbar-thumb {
	background: var(--tg-theme-hint-color, #c1c1c1);
	border-radius: 2px;
}

/* Animations */
@keyframes fadeIn {
	from { opacity: 0; transform: translateY(10px); }
	to { opacity: 1; transform: translateY(0); }
}

.page {
	animation: fadeIn 0.3s ease;
}

/* Responsive */
@media (max-width: 480px) {
	.header {
		padding: 12px;
	}
	
	.page {
		padding: 12px;
	}
	
	.categories-grid {
		grid-template-columns: 1fr;
		gap: 8px;
	}
	
	.profile-stats {
		grid-template-columns: 1fr;
		gap: 8px;
	}
	
	.navigation {
		padding: 8px 0;
	}
	
	.nav-button {
		min-width: 50px;
		padding: 6px 8px;
	}
	
	.nav-icon {
		width: 20px;
		height: 20px;
	}
	
	.nav-label {
		font-size: 10px;
	}
	
	.nav-button-primary {
		width: 48px;
		height: 48px;
		top: -6px;
	}
}

@media (max-width: 360px) {
	.ad-card {
		padding: 12px;
	}
	
	.ad-image {
		width: 70px;
		height: 70px;
		font-size: 28px;
	}
	
	.ad-title {
		font-size: 15px;
	}
	
	.ad-price {
		font-size: 16px;
	}
}

/* Safe area support */
@supports (padding: max(0px)) {
	.content {
		padding-top: max(env(safe-area-inset-top), 0px);
		padding-bottom: max(env(safe-area-inset-bottom), 0px);
	}
	
	.navigation {
		padding-bottom: max(env(safe-area-inset-bottom), 8px);
	}
}