/*
 * Мобильные стили для AltAurum Shop
 * Responsive дизайн и touch-friendly UI
 */

.mobile-badge-sm {
    font-size: 10px;
}

/* ===== Общие мобильные стили ===== */
@media (max-width: 768px) {
    /* Увеличиваем размеры кнопок для touch */
    .btn {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 16px;
    }

    /* Увеличиваем input поля */
    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px; /* Предотвращает zoom на iOS */
    }

    /* Мобильная навигация */
    .navbar-collapse {
        max-height: 80vh;
        overflow-y: auto;
    }

    /* Мобильное меню */
    .navbar-nav {
        padding: 1rem 0;
    }

    .nav-link {
        padding: 12px 16px !important;
        font-size: 18px;
    }

    /* Мобильный поиск */
    .navbar .input-group {
        margin: 1rem 0;
    }

    /* Корзина в мобильном меню */
    .navbar .btn-outline-success {
        width: 100%;
        margin-top: 1rem;
        justify-content: center;
    }
}

/* ===== Мобильная панель фильтров ===== */
@media (max-width: 768px) {
    .filters-sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        width: 85%;
        max-width: 320px;
        height: 100vh;
        background: white;
        z-index: 1050;
        transition: left 0.3s ease;
        overflow-y: auto;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }

    .filters-sidebar.show {
        left: 0;
    }

    .filters-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1040;
        display: none;
    }

    .filters-overlay.show {
        display: block;
    }

    .mobile-filters-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 1rem;
        border-bottom: 1px solid #ddd;
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
    }

    .mobile-filters-close {
        background: none;
        border: none;
        font-size: 24px;
        cursor: pointer;
        padding: 0;
        width: 40px;
        height: 40px;
    }

    .filters-body {
        padding: 1rem;
    }

    .mobile-filters-footer {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1rem;
        border-top: 1px solid #ddd;
        display: flex;
        gap: 10px;
    }

    .mobile-filters-footer .btn {
        flex: 1;
    }
}

/* ===== Мобильная кнопка фильтров ===== */
.mobile-filters-toggle {
    display: none;
}

@media (max-width: 768px) {
    .mobile-filters-toggle {
        display: flex;
        position: fixed;
        bottom: 80px;
        right: 20px;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: #198754;
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        z-index: 1030;
        align-items: center;
        justify-content: center;
        font-size: 24px;
    }

    .mobile-filters-toggle:active {
        transform: scale(0.95);
    }
}

/* ===== Мобильная сетка товаров ===== */
@media (max-width: 576px) {
    .product-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .product-card {
        padding: 10px;
    }

    .product-card .product-img-wrap {
        /* высота подгоняется JS по реальным пропорциям картинки */
    }

    .product-card .product-img-wrap img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }

    .product-card .card-title {
        font-size: 14px;
        line-height: 1.3;
        max-height: 2.6em;
        overflow: hidden;
    }

    .product-card .price {
        font-size: 16px;
    }
}

/* ===== Мобильная страница товара ===== */
@media (max-width: 768px) {
    .product-images-gallery {
        margin-bottom: 1rem;
    }

    /* Стрелки чуть меньше на мобильных */
    .product-gallery__arrow {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }

    .product-gallery__arrow--prev { left: 6px; }
    .product-gallery__arrow--next { right: 6px; }

    /* Миниатюры компактнее */
    .product-gallery__thumb-item {
        flex: 0 0 56px;
        width: 56px;
    }

    .product-gallery__thumbs {
        gap: 6px;
    }

    .product-thumbnails {
        display: flex;
        gap: 10px;
        overflow-x: auto;
        padding: 10px 0;
        -webkit-overflow-scrolling: touch;
    }

    .product-thumbnail {
        flex: 0 0 80px;
        height: 80px;
    }

    .product-info {
        padding: 1rem;
    }

    .product-title {
        font-size: 20px;
        margin-bottom: 1rem;
    }

    .product-price {
        font-size: 28px;
        margin-bottom: 1rem;
    }

    .product-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: white;
        padding: 15px;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 1020;
        display: flex;
        gap: 10px;
    }

    .product-actions .btn {
        flex: 1;
    }
}

/* ===== Мобильная корзина ===== */
@media (max-width: 768px) {
    .cart-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .cart-item-image {
        width: 100%;
        max-width: 150px;
        margin-bottom: 1rem;
    }

    .cart-item-info {
        width: 100%;
    }

    .cart-summary {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1rem;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
}

/* ===== Мобильное оформление заказа ===== */
@media (max-width: 768px) {
    .checkout-steps {
        display: flex;
        overflow-x: auto;
        margin-bottom: 1rem;
        -webkit-overflow-scrolling: touch;
    }

    .checkout-step {
        flex: 0 0 auto;
        padding: 10px 20px;
        white-space: nowrap;
    }

    .order-summary {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1rem;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }
}

/* ===== Touch-friendly элементы ===== */
@media (max-width: 768px) {
    /* Увеличенные чекбоксы и радио */
    .form-check-input {
        width: 24px;
        height: 24px;
        margin-top: 0;
    }

    .form-check-label {
        padding-left: 10px;
        font-size: 16px;
    }

    /* Увеличенные селекты */
    .form-select {
        background-size: 20px 20px;
        padding-right: 40px;
    }

    /* Удобные переключатели количества */
    .quantity-control {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .quantity-control button {
        width: 44px;
        height: 44px;
        padding: 0;
        font-size: 20px;
    }

    .quantity-control input {
        width: 60px;
        text-align: center;
        font-size: 18px;
    }
}

/* ===== Мобильная навигация снизу ===== */
@media (max-width: 768px) {
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 65px;
        background: white;
        border-top: 1px solid #ddd;
        display: flex;
        justify-content: space-around;
        align-items: center;
        z-index: 1010;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }

    .mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: #666;
        text-decoration: none;
        flex: 1;
        padding: 8px;
    }

    .mobile-bottom-nav a.active,
    .mobile-bottom-nav a:hover {
        color: #198754;
    }

    .mobile-bottom-nav i {
        font-size: 24px;
        margin-bottom: 4px;
    }

    .mobile-bottom-nav span {
        font-size: 11px;
    }

    /* Добавляем padding внизу для контента */
    body {
        padding-bottom: 65px;
    }
}

/* ===== Swipe gestures для галереи ===== */
@media (max-width: 768px) {
    .swipeable-gallery {
        position: relative;
        overflow: hidden;
        touch-action: pan-y;
    }

    .swipeable-gallery-track {
        display: flex;
        transition: transform 0.3s ease;
    }

    .swipeable-gallery-item {
        flex: 0 0 100%;
        width: 100%;
    }

    .swipeable-gallery-dots {
        display: flex;
        justify-content: center;
        gap: 8px;
        padding: 10px 0;
    }

    .swipeable-gallery-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: #ddd;
        border: none;
        padding: 0;
        cursor: pointer;
    }

    .swipeable-gallery-dot.active {
        background: #198754;
    }
}

/* ===== Pull-to-refresh индикатор ===== */
@media (max-width: 768px) {
    .pull-to-refresh {
        position: absolute;
        top: -60px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: top 0.3s ease;
    }

    .pull-to-refresh.pulling {
        top: 10px;
    }

    .pull-to-refresh .spinner {
        border: 3px solid #f3f3f3;
        border-top: 3px solid #198754;
        border-radius: 50%;
        width: 30px;
        height: 30px;
        animation: spin 1s linear infinite;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Адаптивная типографика ===== */
@media (max-width: 768px) {
    h1 { font-size: 24px; }
    h2 { font-size: 20px; }
    h3 { font-size: 18px; }
    h4 { font-size: 16px; }

    body {
        font-size: 14px;
    }
}

/* ===== Скрываем десктопные элементы ===== */
@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

/* ===== Показываем только мобильные элементы ===== */
.mobile-only {
    display: none !important;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }

    .mobile-only.inline {
        display: inline !important;
    }

    .mobile-only.flex {
        display: flex !important;
    }
}

/* AltAurum 2026: component-specific mobile corrections */
@media (max-width: 768px) {
    .site-header .btn,
    .product-card .btn,
    .delivery-city-modal .btn,
    .signup-bonus-strip .btn {
        min-height: 0;
        font-size: inherit;
    }
    .product-card__cart {
        width: 38px !important;
        min-width: 38px !important;
        height: 38px !important;
        min-height: 38px !important;
        padding: 0 !important;
    }
    .product-actions {
        position: static !important;
        width: auto !important;
        padding: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
    }
    .product-mobile-sticky .btn { min-height: 44px; padding: 9px 14px; font-size: .9rem; }
    .site-main-header .form-control { min-height: 42px; font-size: 16px; }
}

/* AltAurum 2026 r2: eliminate legacy mobile collisions */
@media (max-width: 768px) {
    .product-card { padding: 0; }
    nav.mobile-bottom-nav.mobile-only { display: flex !important; }
    .mobile-bottom-nav a { min-width: 0; min-height: 62px; padding: 7px 4px; }
    .mobile-bottom-nav i { font-size: 21px; margin-bottom: 2px; }
    .mobile-bottom-nav span { max-width: 100%; overflow: hidden; font-size: 10px; white-space: nowrap; text-overflow: ellipsis; }
    .site-mobile-links a { min-height: 44px; }
    .site-mobile-city { min-height: 48px; }
}

/* r4: явное состояние текущего раздела в нижней навигации */
@media (max-width: 767.98px) {
    .mobile-bottom-nav a.is-active {
        color: #198754;
        font-weight: 750;
    }
    .mobile-bottom-nav a.is-active i {
        transform: translateY(-1px);
    }
    .mobile-bottom-nav a.is-active::before {
        content: "";
        position: absolute;
        top: 5px;
        left: 50%;
        width: 22px;
        height: 3px;
        border-radius: 999px;
        background: #198754;
        transform: translateX(-50%);
    }
}
