/* Мобильная версия для всех страниц */
/* Базовые настройки */
* {
    -webkit-tap-highlight-color: transparent;
}

/* Мобильные стили для всех устройств */
@media screen and (max-width: 1240px) {
	header div.header_block, main, .container{
		width: calc(100% - 20px);
		left: auto;
		margin: 0px auto;
	}
	
	div.menu.modal{
		right: 10px;
	}
}

@media screen and (max-width: 980px) {
	
	div.menu.modal.open{
		display: none;
	}
	
	header div.header_block div.right div.header_block__right__mobile__header,
	header div.header_block div.right div.header_block__right__mobile__added_menu{

		display: flex;
	}
	
	header div.header_block div.right{
	    position: fixed;
		top: 0px;
		left: 0px;
		width: 100vw;
		height: 100vh;
		z-index: 9999;
		display: none;
		flex-direction: column;
		flex-wrap: nowrap;
		justify-content: flex-start;
		align-items: flex-start;
		gap: 10px;
		background: #f5f5f5;
		box-sizing: border-box;
		padding: 10px;
	}
	
	header div.header_block div.right div.search{
		order: 1;
	}
	header div.header_block div.right div.category{
		order: 2;
		width: 100%;
	}
	header div.header_block div.right div.location{
	    order: 3;
		padding: 10px;
		border-radius: 10px;
		border: 1px solid;
		width: 100%;
	}
	header div.header_block div.right div.profile{
		order: 4;
	}
	
	header div.header_block div.right div.profile,
	header div.header_block div.right div.profile a{
		width: 100%;
	}
	
	div.window_map{
		z-index: 10000;
	}
	div.window_map div.box{
		width: calc(100% - 60px);
	}
	
	header div.header_block div.right div.search input{
		padding: 10px 5px;
	}
	
}

/* Мобильные стили для всех устройств */
@media screen and (max-width: 768px) {
    
	 /* Фикс для header - убираем overflow-x */
    html, body {
        overflow-x: hidden;
        width: 100%;
    }
    
    /* Шапка сайта */
    header {
        width: 100%;
        overflow-x: hidden;
    }
    
    header .header_block {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
        width: 100%;
    }
    
    header .left {
        justify-content: center;
        width: 100%;
    }
    
    header .right {
        flex-direction: column;
        width: 100%;
        gap: 8px;
        padding: 0;
    }
    
    /* Категория и поиск - делаем гибкими */
    header .right .category,
    header .right .search,
    header .right .location,
    header .right .profile {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    /* Поиск */
    .search-container {
        width: 100%;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 5px;
    }
    
    .search-container img {
        width: 20px;
        height: 20px;
    }
    
    .search-container input {
        flex: 1;
        width: auto;
        padding: 8px;
        font-size: 14px;
    }
    
    /* Локация */
    .location {
        display: flex;
        align-items: center;
        gap: 5px;
    }
    
    .location img {
        /*width: 20px;
        height: 20px;*/
    }
    
    /* Профиль */
    .profile {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 15px;
    }
    
    .profile .favorites-link,
    .profile .messages-link {
        font-size: 22px;
        margin-right: 0;
    }
    
    .profile .ad_add {
        /*font-size: 14px;
        padding: 6px 12px;*/
    }
    
    .profile .ad_add span {
        display: inline;
    }
    
    .profile .setting img {
        width: 32px;
        height: 32px;
    }
    
    /* Кнопка входа */
    .profile .auth {
        padding: 6px 15px;
        font-size: 14px;
    }
	
    /* Общие настройки */
    body {
        padding: 0;
        margin: 0;
        font-size: 14px;
    }
    
    .container {
        padding: 10px;
        max-width: 100%;
    }
    
    /* Шапка сайта */
    header .header_block {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
    }
    
    header .left {
        justify-content: center;
        width: 100%;
    }
    
    header .left img {
        width: 35px;
        height: 35px;
    }
    
    header .left span {
        font-size: 18px;
    }
    
    header .right {
        flex-direction: column;
        width: 100%;
        gap: 10px;
    }
    
    header .right .category,
    header .right .search,
    header .right .location,
    header .right .profile {
        width: 100%;
    }
    
    /* Поиск */
    .search-container {
        width: 100%;
    }
    
    .search-container input {
        width: calc(100% - 40px);
        padding: 8px;
        font-size: 14px;
    }
    
    /* Сетка объявлений */
    .ads-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    /* Карточка объявления */
    .ad-card,
    .element {
        margin: 0 10px;
    }
    
    .ad-card .ad-image,
    .element img {
        height: 180px;
    }
    
    .ad-card .ad-title,
    .element #name {
        font-size: 16px;
        height: auto;
    }
    
    .ad-card .ad-price,
    .element #price {
        font-size: 18px;
    }
    
    /* Меню категорий */
    .list_category {
        width: 90%;
        max-width: 300px;
        left: auto;
        right: 0;
    }
    
    .list_category .category {
        padding: 12px;
        font-size: 14px;
    }
    
    .list_category .subcategories {
        padding: 10px;
    }
    
    .list_category .subcategory {
        padding: 10px;
        font-size: 14px;
    }
    
    /* Окно карты */
    .window_map .box {
        width: 95%;
        margin: 20px;
    }
    
    .window_map .box #map {
        height: 300px;
    }
    
    .window_map .box .search_city input {
        font-size: 14px;
    }
    
    .window_map .box .radius-control label {
        font-size: 14px;
    }
    
    /* Модальное меню профиля */
    .menu.modal {
        width: 80%;
        max-width: 280px;
        right: 10px;
        left: auto;
        top: 60px;
    }
    
    .menu.modal a {
        padding: 12px;
        font-size: 14px;
    }
    
    /* Страница просмотра объявления */
    .view-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
        padding: 15px;
    }
    
    .view-header h1 {
        font-size: 20px;
    }
    
    .view-actions {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .view-actions .btn {
        padding: 8px 15px;
        font-size: 12px;
    }
    
    .gallery {
        padding: 10px;
    }
    
    .main-image {
        max-height: 300px;
    }
    
    .thumbnails {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    }
    
    .thumbnail {
        height: 70px;
    }
    
    .view-info {
        padding: 15px;
    }
    
    .price-section .current-price {
        font-size: 24px;
    }
    
    .address-full {
        font-size: 14px;
    }
    
    .address-badge {
        font-size: 12px;
        padding: 3px 8px;
    }
    
    .seller-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    .seller-avatar,
    .seller-avatar-placeholder {
        width: 80px;
        height: 80px;
        font-size: 32px;
    }
    
    .seller-name {
        font-size: 18px;
    }
    
    .contacts-grid {
        grid-template-columns: 1fr;
    }
    
    .contact-card {
        padding: 15px;
    }
    
    .contact-value {
        font-size: 14px;
    }
    
    .show-contacts-btn {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    /* Страница профиля */
    .profile-header {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    
    .profile-avatar,
    .profile-avatar-placeholder {
        width: 100px;
        height: 100px;
        font-size: 40px;
    }
    
    .profile-name {
        font-size: 22px;
    }
    
    .tabs {
        flex-direction: column;
        border-radius: 12px;
        gap: 5px;
    }
    
    .tab {
        padding: 10px;
        border-radius: 8px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .button-group .btn {
        width: 100%;
        text-align: center;
    }
    
    /* Страница избранного */
    .favorites-header {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .favorites-grid {
        grid-template-columns: 1fr;
    }
    
    /* Страница сообщений */
    .messages-container {
        padding: 0 10px;
    }
    
    .messages-header {
        flex-direction: column;
        text-align: center;
    }
    
    .dialog-item {
        flex-direction: column;
        text-align: center;
        gap: 10px;
        padding: 15px;
    }
    
    .dialog-avatar,
    .dialog-avatar-placeholder {
        margin-right: 0;
    }
    
    .dialog-ad-image {
        display: none;
    }
    
    .chat-container {
        height: 100vh;
        margin: 0;
        padding: 0;
    }
    
    .chat-header {
        padding: 15px;
    }
    
    .chat-header-avatar,
    .chat-header-avatar-placeholder {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    .chat-header-name {
        font-size: 16px;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .message {
        max-width: 85%;
    }
    
    .message-bubble {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .chat-input {
        padding: 15px;
    }
    
    .chat-input textarea {
        height: 50px;
        font-size: 14px;
    }
    
    .chat-input button {
        padding: 0 20px;
    }
    
    /* Пагинация */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-link {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    /* Кнопки */
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    /* Поисковые результаты */
    .search-result-item {
        padding: 10px;
    }
    
    .search-result-image {
        width: 40px;
        height: 40px;
    }
    
    .search-result-name {
        font-size: 14px;
    }
    
    .search-result-price {
        font-size: 12px;
    }
    
    /* Формы */
    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 10px;
        font-size: 14px;
    }
    
    .form-group label {
        font-size: 14px;
    }
    
    /* Загрузка изображений */
    .upload-area {
        padding: 20px;
    }
    
    .current-images {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    
    .image-item img {
        height: 120px;
    }
}

/* Для очень маленьких экранов (до 480px) */
@media screen and (max-width: 480px) {
    .view-actions {
        flex-direction: column;
        width: 100%;
    }
    
    .view-actions .btn {
        width: 100%;
    }
    
    .ad-actions {
        grid-template-columns: 1fr;
    }
    
    .ad-actions .btn {
        width: 100%;
    }
    
    .favorite-actions {
        grid-template-columns: 1fr;
    }
    
    .bulk-actions {
        flex-direction: column;
        align-items: stretch;
    }
    
    .bulk-actions select {
        width: 100%;
    }
    
    .bulk-actions button {
        width: 100%;
    }
	
	.profile .ad_add span {
        display: none;
    }
    
    .profile .ad_add {
        /*font-size: 20px;
        padding: 0;
        background: none;
        color: #007bff;*/
    }
    
    .profile .ad_add:hover {
        background: none;
        transform: scale(1.1);
    }
}