/* ===== АДАПТИВНЫЕ СТИЛИ PHARMANEXT ===== */

/* Крупные экраны (Large desktops) */
@media (min-width: 1400px) {
    .container { max-width: 1320px; }
    .hero-title { font-size: 3.5rem; }
    .section-title { font-size: 3rem; }
    .categories-grid { grid-template-columns: repeat(4, 1fr); }
    .products-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Обычные десктопы */
@media (min-width: 1200px) and (max-width: 1399px) {
    .container { max-width: 1140px; }
    .categories-grid { grid-template-columns: repeat(4, 1fr); }
    .products-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Средние экраны - исправление обрезания корзины */
@media (min-width: 992px) and (max-width: 1199px) {
    .container { max-width: 960px; padding: 0 15px; }
    .hero-title { font-size: 2.5rem; }
    .section-title { font-size: 2.2rem; }
    .categories-grid { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
    .products-grid { grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
    .hero { padding: 3rem 1.5rem; }
    
    /* Скрываем навигационные ссылки для экономии места */
    .nav-links li:nth-child(1), 
    .nav-links li:nth-child(3), 
    .nav-links li:nth-child(5) { display: none; }
    .nav-links { gap: 1rem; }
    .search-bar-compact { max-width: 180px; margin: 0 8px; }
}

/* Планшеты - двухрядная компоновка */
@media (min-width: 769px) and (max-width: 991px) {
    .container { max-width: 720px; padding: 0 15px; }
    
    .nav {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 10px;
        align-items: center;
    }
    
    .logo { grid-column: 1; grid-row: 1; justify-self: start; }
    .cart-icon { grid-column: 2; grid-row: 1; justify-self: end; position: static; margin: 0; }
    .search-bar-compact { grid-column: 1; grid-row: 2; justify-self: start; max-width: 300px; margin: 0; }
    .auth-section { grid-column: 2; grid-row: 2; justify-self: end; }
    .nav-links { display: none; }
    
    .hero { padding: 2.5rem 1rem; margin-bottom: 3rem; }
    .hero-title { font-size: 2.2rem; padding-top: 1rem; }
    .categories-grid { grid-template-columns: repeat(2, 1fr); }
    .products-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Мобильные устройства - исправленная компоновка */
@media (max-width: 768px) {
    .container { padding: 0 10px; }
    .header { padding: 1rem 0; }
    
    .nav {
        display: flex;
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }
    
    /* Первая строка: лого по центру */
    .logo {
        order: 1;
        align-self: center;
        font-size: 1.5rem;
    }
    
    /* Вторая строка: авторизация слева, корзина справа */
    .mobile-row-2 {
        order: 2;
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
        padding: 0 10px;
    }
    
    .auth-section {
        flex: 1 1 auto;
        min-width: 0;
        position: relative;
    }
    
    /* Убеждаемся, что кнопка входа видна на мобильных */
    .auth-btn {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    
    /* Компактная версия кнопки на очень маленьких экранах */
    @media (max-width: 360px) {
        .auth-btn {
            font-size: 0.85rem;
            padding: 8px 12px;
        }
        
        .auth-btn::before {
            content: '👤';
            margin-right: 4px;
        }
        
        .login-btn {
            /* Скрываем текст на очень маленьких экранах, оставляем только иконку */
        }
    }
    
    .cart-icon {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        transform: none !important;
        margin: 0;
        flex: 0 0 auto;
    }
    
    /* Третья строка: поиск на всю ширину */
    .search-bar-compact {
        order: 3;
        width: calc(100% - 20px);
        max-width: none;
        margin: 0 10px;
        padding: 0;
    }
    
    .search-bar-compact input {
        width: 100%;
        padding: 12px 50px 12px 15px;
        font-size: 0.9rem;
        box-sizing: border-box;
    }
    
    .search-bar-compact .search-btn {
        right: 5px;
        padding: 10px 15px;
        font-size: 1rem;
    }
    
    .nav-links { display: none; }
    .main { margin-top: 220px; }
}

/* Очень маленькие экраны */
@media (max-width: 360px) {
    .container { padding: 0 5px; }
    .hero-title { font-size: 1.5rem; }
    .section-title { font-size: 1.5rem; }
}

/* Компактная строка поиска - базовые стили */
.search-bar-compact {
    position: relative;
    display: none;
}

.search-bar-compact input {
    width: 100%;
    padding: 8px 40px 8px 15px;
    border: none;
    border-radius: 25px;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow-light);
}

.search-bar-compact .search-btn {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--secondary-color);
    border: none;
    padding: 6px 12px;
    border-radius: 20px;
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
}