/* ===== MOBILE PHONES (до 480px) ===== */
@media screen and (max-width: 1100px) {
    /* ===== BASE MOBILE STYLES ===== */
    body {
        font-size: 14px;
        background: white !important;
        margin: 0;
        padding: 0;
    }
    
    #pagewrap {
        box-shadow: none;
        background: white;
        max-width: 100%;
        margin: 0;
        width: 100%;
    }
    
    #page {
        width: 100%;
        padding: 0;
        margin: 0;
    }
    
    /* ===== HEADER ===== */
    #header {
        display: none;
    }
    
    /* ===== LAYOUT ===== */
    #sidebar {
        display: none !important;
    }
    
    #contentwrap {
        width: 100%;
        float: none;
        background: white;
        margin: 0;
        padding: 0;
    }
    
    #body_area {
        padding: 12px;
        background: white;
        width: 100%;
        margin: 0;
    }
    
    /* ===== MOBILE MENU ===== */
    .mobile-menu-btn {
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1000;
        background: none;
        width: auto;
        height: auto;
        border-radius: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: none;
        padding: 10px;
    }
    
    .menu-icon {
        width: 25px;
        height: 2px;
        background: #2c3e50;
        position: relative;
    }
    
    .menu-icon::before,
    .menu-icon::after {
        content: '';
        position: absolute;
        width: 25px;
        height: 2px;
        background: #2c3e50;
        left: 0;
        transition: all 0.3s ease;
    }
    
    .menu-icon::before {
        top: -8px;
    }
    
    .menu-icon::after {
        top: 8px;
    }
    
    .mobile-menu {
        position: fixed;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100vh;
        background: linear-gradient(180deg, #2c3e50 0%, #34495e 100%);
        z-index: 9999;
        transition: left 0.3s ease;
        overflow-y: auto;
        padding: 20px;
    }
    
    .mobile-menu.active {
        left: 0;
    }
    
    .close-menu-btn {
        position: absolute;
        top: 15px;
        right: 15px;
        color: white;
        font-size: 30px;
        cursor: pointer;
        background: rgba(255,255,255,0.2);
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-menu ul {
        list-style: none;
        margin: 40px 0 20px 0;
        padding: 0;
    }
    
    .mobile-menu ul li {
        margin-bottom: 10px;
    }
    
    .mobile-menu ul li a {
        display: block;
        padding: 15px 20px;
        color: white;
        text-decoration: none;
        background: rgba(255,255,255,0.1);
        border-radius: 8px;
        transition: all 0.3s ease;
        border-left: 4px solid transparent;
        font-size: 16px;
    }
    
    .mobile-menu ul li a:hover {
        background: rgba(255,255,255,0.2);
        border-left: 4px solid #e74c3c;
        padding-left: 30px;
    }
    
    /* ===== PRODUCTS MOBILE - 2 КОЛОНКИ НА 100% ШИРИНЫ ===== */
    .product-area {
        margin-top: 15px;
        width: 100%;
    }
    
    .new-arrivals {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px; /* Минимальный gap для полного заполнения */
        margin-bottom: 30px;
        width: 100%;
    }
    
    .product {
        background: white;
        border-radius: 10px;
        padding: 10px;
        box-shadow: 0 2px 10px rgba(0,0,0,0.08);
        transition: all 0.3s ease;
        position: relative;
        overflow: hidden;
        margin-bottom: 0;
        width: 100%;
        /* Убираем все ограничения */
        min-width: 0;
        max-width: none;
        flex: none;
    }
    
    .product:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 15px rgba(0,0,0,0.12);
    }
    
    .product-image-container {
        position: relative;
        width: 100%;
        height: 140px;
        overflow: hidden;
        border-radius: 6px;
        margin-bottom: 8px;
    }
    
    .product-image {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.3s ease;
    }
    
    .product:hover .product-image {
        transform: scale(1.05);
    }
    
    .favorite {
        position: absolute;
        top: 6px;
        right: 6px;
        font-size: 16px;
        cursor: pointer;
        z-index: 2;
        transition: all 0.3s ease;
        background: rgba(255,255,255,0.9);
        width: 28px;
        height: 28px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .favorite:hover {
        transform: scale(1.1);
    }
    
    .product h3 {
        font-size: 12px;
        font-weight: 600;
        margin-bottom: 5px;
        color: #2c3e50;
        line-height: 1.3;
        height: 32px;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    
    .product p {
        color: #e74c3c;
        font-size: 14px;
        font-weight: bold;
        margin-bottom: 8px;
    }
    
    /* ===== КНОПКА ДОБАВЛЕНИЯ В КОРЗИНУ ===== */
    .product .button {
        display: block;
        padding: 8px 10px;
        background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
        color: white;
        text-decoration: none;
        border-radius: 18px;
        font-weight: 600;
        transition: all 0.3s ease;
        border: none;
        cursor: pointer;
        text-align: center;
        width: 100%;
        font-size: 12px;
    }
    
    .product .button:hover {
        background: linear-gradient(135deg, #2980b9 0%, #3498db 100%);
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
    }
    
    /* ===== SEARCH MOBILE - КНОПКА РЯДОМ С ФОРМОЙ ===== */
    .search-container {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 20px;
        gap: 8px;
        width: 100%;
    }
    
    .search-input-container {
        position: relative;
        flex: 1;
        max-width: none;
        width: auto;
    }
    
    .search-input {
        width: 100%;
        padding: 12px 16px;
        border: 2px solid #e0e0e0;
        border-radius: 25px;
        font-size: 14px;
        transition: all 0.3s ease;
        background: #f8f9fa;
    }
    
    .search-input:focus {
        outline: none;
        border-color: #3498db;
        background: white;
        box-shadow: 0 2px 8px rgba(52, 152, 219, 0.2);
    }
    
    .search-button {
        width: 45px !important;
        height: 45px !important;
        background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
        border: none;
        border-radius: 50% !important;
        color: white;
        font-size: 16px;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
        flex-shrink: 0;
        margin: 0 !important;
    }
    
    .search-button:hover {
        transform: scale(1.05);
        box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
    }
    
    /* ===== FORMS MOBILE ===== */
    #mobile-currency-form,
    #langSelectMobile {
        width: 100%;
        margin-bottom: 15px;
    }
    
    #mobile-currency-form select,
    #langSelectMobile {
        width: 100%;
        padding: 10px 12px;
        border: 2px solid #e0e0e0;
        border-radius: 8px;
        font-size: 14px;
        transition: all 0.3s ease;
        background: #f8f9fa;
        margin-bottom: 8px;
    }
    
    /* ===== PAGINATION MOBILE ===== */
    .pagination {
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 6px;
        margin-top: 25px;
        flex-wrap: wrap;
        width: 100%;
    }
    
    .pagination a {
        display: inline-block;
        padding: 8px 12px;
        background: #ecf0f1;
        color: #2c3e50;
        text-decoration: none;
        border-radius: 6px;
        font-weight: 600;
        transition: all 0.3s ease;
        min-width: 35px;
        text-align: center;
        font-size: 12px;
    }
    
    /* ===== CART MOBILE ===== */
    .cart {
        position: fixed;
        top: 15px;
        right: 15px;
        z-index: 1000;
    }
    
    .cart-icon-container {
        position: relative;
        background: rgba(255,255,255,0.9);
        padding: 6px;
        border-radius: 50%;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
}

/* ===== LANDSCAPE MOBILE (до 480px в ландшафте) ===== */
@media screen and (max-width: 480px) and (orientation: landscape) {
    .new-arrivals {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px;
    }
    
    .product {
        padding: 8px;
    }
    
    .product-image-container {
        height: 120px;
    }
    
    .product h3 {
        font-size: 11px;
        height: 28px;
    }
    
    .product p {
        font-size: 12px;
    }
    
    .product .button {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    .mobile-menu {
        width: 100% !important;
        left: -100% !important;
    }
    
    .mobile-menu.active {
        left: 0 !important;
    }
    
    #body_area {
        padding: 8px;
    }
}

/* ===== TABLETS (481px - 768px) ===== */
@media screen and (min-width: 481px) and (max-width: 482px) {
    /* Для планшетов используем десктопный layout с небольшими изменениями */
    #sidebar {
        display: block !important;
        width: 220px;
    }
    
    #contentwrap {
        width: calc(100% - 220px) !important;
        float: right !important;
    }
    
    #header {
        display: block !important;
    }
    
    .mobile-menu-btn,
    .mobile-menu {
        display: none !important;
    }
    
    /* Сетка для планшетов */
    .new-arrivals {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
    
    .product {
        padding: 15px;
    }
    
    .product-image-container {
        height: 200px;
    }
    
    .product h3 {
        font-size: 16px;
    }
    
    .product p {
        font-size: 18px;
    }
}

/* ===== TOUCH FRIENDLY STYLES ===== */
@media (hover: none) and (pointer: coarse) {
    .product:hover {
        transform: none;
    }
    
    .favorite {
        min-width: 32px;
        min-height: 32px;
    }
    
    .button {
        min-height: 36px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    input, select, textarea {
        font-size: 16px;
    }
}

/* ===== OVERRIDE DESKTOP STYLES FOR MOBILE ===== */
@media screen and (max-width: 480px) {
    /* Убедимся, что десктопные стили не применяются на мобильных */
    #sidebar {
        display: none !important;
    }
    
    #contentwrap {
        width: 100% !important;
        float: none !important;
    }
    
    #header {
        display: none !important;
    }
    
    #logowrap {
        display: none !important;
    }
    
    /* Убедимся, что белый фон применяется везде */
    body, #pagewrap, #contentwrap, #body_area {
        background: white !important;
    }
    
    /* Фикс для поиска - всегда в строку */
    .search-container {
        flex-direction: row !important;
    }
    
    /* Форсируем 2 колонки */
    .new-arrivals {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .product {
        width: 100% !important;
        max-width: none !important;
        flex: none !important;
    }
}