/* =============================================
   VRTAJ - Comprehensive Mobile Responsive Fixes
   =============================================
   This file provides mobile-first responsive fixes
   across all pages. Include after other CSS files.
   ============================================= */

/* ===== GLOBAL MOBILE FIXES ===== */

/* ===== GLOBAL HEADER FIX (ALL PAGES) ===== */
/* Sticky can break on some pages when ancestors use transforms/overflow.
   Use fixed positioning for consistent “always visible” header across the whole website. */
.main-header {
    position: fixed !important;
    top: var(--header-top, 0px) !important;
    left: 0;
    right: 0;
    z-index: 10010 !important;
    background: #fff;
}

/* Spacer sits in normal flow so page content doesn't start under the fixed header */
.header-spacer {
    display: block;
    width: 100%;
    /* Height = banner height + header height (JS sets these vars, fallback ensures no overlap on load) */
    height: calc(var(--top-banner-height, 28px) + var(--main-header-height, 68px));
    min-height: 95px; /* Minimum fallback: 38px banner + 78px header */
}

/* Ensure first content section after header has proper spacing */
#main-content > section:first-child,
.category-showcase {
    margin-top: 0;
    padding-top: 20px;
}

/* Help anchored jumps not hide behind fixed header */
html {
    scroll-padding-top: calc(var(--top-banner-height, 38px) + var(--main-header-height, 78px) + 10px);
}

/* Prevent horizontal scroll */
html, body {
    overflow-x: hidden;
    overflow-x: clip;
    max-width: 100vw;
}

/* Ensure all images are responsive */
img {
    max-width: 100%;
    height: auto;
}

/* Touch-friendly minimum sizes */
button, 
.btn, 
input[type="submit"], 
input[type="button"],
a.btn {
    min-height: 44px;
}

/* Desktop: hide mobile-only elements */
.mobile-filter-toggle,
.mobile-filter-close {
    display: none;
}

/* ===== TABLET BREAKPOINT (max-width: 992px) ===== */
@media (max-width: 992px) {
    .container {
        padding-left: 20px;
        padding-right: 20px;
    }
}

/* ===== MOBILE BREAKPOINT (max-width: 768px) ===== */
@media (max-width: 768px) {
    
    /* Homepage products carousel - force 2 columns */
    .products-carousel .products-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        overflow: visible !important;
        padding: 10px 0 !important;
    }
    
    .products-carousel .product-card {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
    
    /* Container */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }
    
    /* Add padding for fixed bottom nav */
    body {
        padding-bottom: 70px;
    }
    
    /* Typography scaling */
    h1 { font-size: 24px !important; }
    h2 { font-size: 20px !important; }
    h3 { font-size: 18px !important; }
    
    /* ===== SHOP PAGE ===== */
    
    /* Shop hero */
    .shop-hero {
        min-height: 150px !important;
    }
    
    .shop-hero__title {
        font-size: 28px !important;
    }
    
    .shop-hero__subtitle {
        font-size: 14px !important;
    }
    
    /* Collections grid */
    .collections-section {
        padding: 30px 0 !important;
    }
    
    .section-header {
        margin-bottom: 25px !important;
    }
    
    .section-subtitle {
        font-size: 11px !important;
    }
    
    .section-title {
        font-size: 22px !important;
    }
    
    .shop-layout {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .shop-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 10000 !important;
        background: #fff !important;
        padding: 70px 20px 20px !important;
        overflow-y: auto !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s ease !important;
    }
    
    .shop-sidebar.active {
        transform: translateX(0) !important;
    }
    
    /* Mobile filter toggle button */
    .mobile-filter-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 8px;
        width: 100%;
        padding: 14px 20px;
        margin-bottom: 20px;
        background: var(--primary-color, #025B59);
        color: #fff;
        border: none;
        border-radius: 10px;
        font-size: 15px;
        font-weight: 600;
        cursor: pointer;
    }
    
    .mobile-filter-close {
        display: block !important;
        position: absolute;
        top: 20px;
        right: 20px;
        width: 40px;
        height: 40px;
        background: #f5f5f5;
        border: none;
        border-radius: 50%;
        font-size: 20px;
        cursor: pointer;
    }
    
    .shop-header {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }
    
    .results-count {
        width: 100% !important;
        text-align: center !important;
    }
    
    /* ===== PRODUCT DETAIL PAGE ===== */
    
    /* Main image container */
    .product-detail-layout {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .product-images {
        position: static !important;
    }
    
    /* Image placeholder - text category name */
    .product-image-placeholder {
        font-size: 48px !important;
        padding: 30px !important;
        word-break: break-word;
        text-align: center;
    }
    
    .main-image {
        border-radius: 12px;
        margin-bottom: 15px;
    }
    
    .main-image img {
        border-radius: 12px;
    }
    
    /* Thumbnails */
    .gallery-thumbnails {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 8px !important;
    }
    
    .thumbnail img {
        height: 55px !important;
        object-fit: cover;
    }
    
    /* Product info */
    .product-info-detail {
        padding: 0 !important;
    }
    
    .product-title {
        font-size: 22px !important;
        line-height: 1.3 !important;
        margin-bottom: 10px !important;
    }
    
    .product-short-desc {
        font-size: 14px !important;
        line-height: 1.6 !important;
    }
    
    /* Price section */
    .product-price-section {
        margin-bottom: 15px !important;
    }
    
    .product-price-section .product-price {
        font-size: 26px !important;
    }
    
    .product-price-section .old-price {
        font-size: 16px !important;
    }
    
    /* Pack options - horizontal scroll on mobile */
    .pack-options {
        display: flex !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        gap: 10px !important;
        padding-bottom: 5px;
    }
    
    .pack-options::-webkit-scrollbar {
        display: none;
    }
    
    .pack-option {
        flex-shrink: 0;
    }
    
    .pack-option label,
    .pack-option .pack-option__title {
        padding: 10px 14px !important;
        min-width: 100px;
        white-space: nowrap;
    }
    
    /* Quantity + Add to Cart */
    .product-actions {
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    .product-actions form {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        width: 100% !important;
    }
    
    .product-actions form > * {
        width: 100% !important;
    }
    
    .quantity-selector {
        display: flex !important;
        justify-content: center !important;
        width: 100% !important;
    }
    
    .qty-btn {
        width: 50px !important;
        height: 48px !important;
        font-size: 18px !important;
    }
    
    #productQty,
    .qty-input {
        width: 70px !important;
        height: 48px !important;
        font-size: 16px !important;
        text-align: center;
    }
    
    .add-to-cart-btn-large {
        width: 100% !important;
        min-height: 50px !important;
        font-size: 15px !important;
        padding: 14px 20px !important;
    }
    
    .wishlist-btn {
        width: 100% !important;
        height: 48px !important;
        font-size: 18px !important;
    }
    
    /* Share buttons */
    .product-share {
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 10px !important;
    }
    
    .share-icon {
        width: 44px !important;
        height: 44px !important;
    }
    
    /* ===== PRODUCT GRID (Shop/Collections) ===== */
    
    /* Product grid - 2 columns */
    .products-grid,
    .product-grid,
    .collections-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    
    .product-card {
        border-radius: 12px !important;
    }
    
    .product-card__content,
    .product-body {
        padding: 12px !important;
    }
    
    .product-card__title,
    .product-title:not(.product-detail-section .product-title) {
        font-size: 13px !important;
        line-height: 1.3 !important;
    }
    
    .product-card__price .price-current,
    .product-price:not(.product-detail-section .product-price) {
        font-size: 16px !important;
    }
    
    .product-card__code {
        font-size: 10px !important;
    }
    
    .product-card__add-btn {
        padding: 10px 12px !important;
        font-size: 12px !important;
    }

    /* Ensure product cards are equal height on mobile */
    .products-grid .product-card,
    .product-grid .product-card,
    .collections-grid .product-card {
        display: flex !important;
        flex-direction: column !important;
        height: 100% !important;
        align-items: stretch !important;
    }

    .product-card__content,
    .product-body {
        display: flex !important;
        flex-direction: column !important;
        flex: 1 1 auto !important;
    }

    /* Give product title a consistent min-height so cards line up */
    .product-card__title,
    .product-title:not(.product-detail-section .product-title) {
        min-height: 44px !important;
        display: block !important;
    }

    /* Push price/actions to the bottom of the card */
    .product-card__price,
    .product-card__actions,
    .product-actions {
        margin-top: auto !important;
    }

    /* Ensure thumbnail/image area doesn't force taller cards unevenly */
    .product-card img,
    .product-card__thumb img {
        width: 100% !important;
        height: auto !important;
        max-height: 160px !important;
        object-fit: contain !important;
        display: block !important;
    }
    
    /* Collection cards */
    .collection-card {
        border-radius: 12px !important;
    }
    
    .collection-card__image {
        padding-top: 100% !important;
    }
    
    .collection-card__content {
        padding: 12px !important;
    }
    
    .collection-card__title {
        font-size: 13px !important;
    }
    
    .collection-card__cta {
        font-size: 11px !important;
        opacity: 1 !important;
        transform: none !important;
    }

    /* ===== REVIEWS SECTION ===== */
    
    .reviews-section {
        padding: 30px 0 !important;
    }
    
    .reviews-layout {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .rating-summary,
    .write-review,
    .reviews-list {
        padding: 20px !important;
        border-radius: 12px !important;
    }
    
    /* Rating bars */
    .average-rating {
        text-align: center !important;
        margin-bottom: 20px !important;
    }
    
    .average-rating .rating-number {
        font-size: 42px !important;
    }
    
    .average-rating .rating-stars {
        font-size: 20px !important;
    }
    
    /* Rating breakdown */
    .rating-bars {
        max-width: 100% !important;
    }
    
    .rating-bar {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        margin-bottom: 8px !important;
    }
    
    .rating-bar .star-label {
        min-width: 40px !important;
        font-size: 13px !important;
    }
    
    .rating-bar .bar {
        flex: 1 !important;
        height: 8px !important;
    }
    
    .rating-bar .bar-count {
        min-width: 30px !important;
        text-align: right !important;
        font-size: 13px !important;
    }
    
    /* Write review section */
    .write-review h3,
    .reviews-list h3 {
        font-size: 18px !important;
        margin-bottom: 15px !important;
    }
    
    /* Star rating input - larger for touch */
    .star-rating-input label {
        font-size: 32px !important;
        min-width: 44px !important;
        min-height: 44px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .review-form input[type="text"],
    .review-form textarea {
        padding: 14px !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
        border-radius: 10px !important;
    }
    
    .submit-review-btn {
        width: 100% !important;
        min-height: 48px !important;
        font-size: 15px !important;
    }
    
    /* Login prompt */
    .login-prompt,
    .already-reviewed {
        padding: 25px 20px !important;
        border-radius: 12px !important;
    }
    
    .login-prompt i,
    .already-reviewed i {
        font-size: 28px !important;
    }
    
    /* Reviews list */
    .review-item {
        padding: 18px 0 !important;
    }
    
    .review-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }
    
    .reviewer-info {
        display: flex !important;
        align-items: center !important;
        gap: 10px !important;
        width: 100% !important;
    }
    
    .reviewer-avatar {
        width: 40px !important;
        height: 40px !important;
    }
    
    .reviewer-name {
        font-size: 14px !important;
    }
    
    .review-date {
        font-size: 12px !important;
    }
    
    .review-title {
        font-size: 15px !important;
    }
    
    .review-text {
        font-size: 14px !important;
        line-height: 1.6 !important;
    }
    
    /* No reviews state */
    .no-reviews {
        padding: 40px 20px !important;
        text-align: center !important;
    }
    
    .no-reviews i {
        font-size: 40px !important;
        margin-bottom: 15px !important;
    }
    
    .no-reviews p {
        font-size: 14px !important;
    }
    
    /* Customer Feedback title */
    .reviews-list h3 {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }
    
    /* ===== SHOP PAGE ===== */
    
    .shop-layout {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .shop-sidebar {
        position: static !important;
        order: -1;
    }
    
    /* Mobile filter toggle */
    .shop-sidebar {
        display: none;
    }
    
    .shop-sidebar.active {
        display: block;
    }
    
    .shop-header {
        flex-wrap: wrap !important;
        gap: 10px !important;
    }
    
    .results-count {
        width: 100% !important;
        text-align: center !important;
    }
    
    /* ===== PRODUCT DETAIL PAGE ===== */
    .products-grid,
    .product-grid,
    .collections-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    
    .product-card {
        border-radius: 12px !important;
    }
    
    .product-card__content,
    .product-body {
        padding: 12px !important;
    }
    
    .product-card__title,
    .product-title {
        font-size: 13px !important;
        line-height: 1.3 !important;
    }
    
    .product-card__price .price-current,
    .product-price {
        font-size: 16px !important;
    }
    
    /* ===== CART PAGE ===== */
    
    .cart-page {
        padding: 20px 0 40px !important;
    }
    
    .cart-shell {
        grid-template-columns: 1fr !important;
    }
    
    .cart-summary {
        position: static !important;
    }
    
    .cart-item {
        grid-template-columns: 70px 1fr !important;
        gap: 12px !important;
        padding: 14px !important;
    }
    
    .cart-item__thumb {
        width: 70px !important;
        height: 70px !important;
    }
    
    .cart-item__title {
        font-size: 15px !important;
    }
    
    .cart-item__total {
        grid-column: 1 / -1 !important;
        text-align: left !important;
        padding-top: 10px !important;
        border-top: 1px dashed var(--border-lighter) !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }
    
    .cart-qty__btn {
        width: 36px !important;
        height: 36px !important;
    }
    
    .cart-qty__input {
        width: 50px !important;
        padding: 8px !important;
    }
    
    /* ===== ORDERS PAGE ===== */
    
    .orders-page {
        padding: 20px 0 40px !important;
    }
    
    .orders-stats {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }
    
    .orders-stat {
        padding: 14px !important;
    }
    
    .orders-stat-value {
        font-size: 20px !important;
    }
    
    .order-card {
        padding: 16px !important;
    }
    
    .order-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
    }
    
    .order-items {
        flex-direction: column !important;
    }
    
    .order-item-thumb {
        width: 60px !important;
        height: 60px !important;
    }
    
    /* ===== PROFILE PAGE ===== */
    
    .profile-page {
        padding: 20px 0 !important;
    }
    
    .profile-header {
        padding: 25px 20px !important;
        border-radius: 16px !important;
    }
    
    .profile-header-content {
        flex-direction: column !important;
        text-align: center !important;
        gap: 20px !important;
    }
    
    .profile-avatar {
        width: 100px !important;
        height: 100px !important;
        font-size: 36px !important;
    }
    
    .profile-name {
        font-size: 22px !important;
    }
    
    .profile-email {
        font-size: 14px !important;
    }
    
    .profile-stats {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    
    .profile-content {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    /* ===== CHECKOUT PAGE ===== */
    
    .checkout-layout {
        grid-template-columns: 1fr !important;
    }
    
    .checkout-section {
        padding: 20px !important;
    }
    
    /* ===== BREADCRUMB ===== */
    
    .breadcrumb {
        padding: 10px 0 !important;
    }
    
    .breadcrumb .container {
        font-size: 12px !important;
        gap: 6px !important;
        flex-wrap: wrap !important;
    }
    
    /* ===== FOOTER ===== */
    
    .main-footer {
        padding-bottom: 80px; /* Space for bottom nav */
    }
    
    .footer-top {
        flex-direction: column !important;
        gap: 30px !important;
    }
    
    .footer-columns {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 20px !important;
    }
    
    .footer-heading {
        font-size: 16px !important;
    }
    
    .footer-links li {
        margin-bottom: 8px !important;
    }
    
    .footer-bottom {
        flex-direction: column !important;
        text-align: center !important;
        gap: 15px !important;
    }
    
    /* ===== ABOUT PAGE ===== */
    
    .about-hero {
        padding: 40px 0 !important;
    }
    
    .about-hero h1 {
        font-size: 28px !important;
    }
    
    .about-grid {
        grid-template-columns: 1fr !important;
    }
    
    /* ===== CONTACT PAGE ===== */
    
    .contact-layout {
        grid-template-columns: 1fr !important;
        gap: 30px !important;
    }
    
    .contact-form {
        padding: 25px !important;
    }
}

/* ===== SMALL MOBILE (max-width: 480px) ===== */
@media (max-width: 480px) {
    
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    /* Typography */
    h1 { font-size: 22px !important; }
    h2 { font-size: 18px !important; }
    h3 { font-size: 16px !important; }
    
    /* Product detail */
    .product-title {
        font-size: 20px !important;
    }
    
    .product-price-section .product-price {
        font-size: 24px !important;
    }
    
    .product-image-placeholder {
        font-size: 36px !important;
    }
    
    .gallery-thumbnails {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
    }
    
    .thumbnail img {
        height: 45px !important;
    }
    
    /* Reviews */
    .average-rating .rating-number {
        font-size: 36px !important;
    }
    
    .star-rating-input label {
        font-size: 28px !important;
    }
    
    /* Products grid */
    .products-grid,
    .product-grid,
    .collections-grid {
        gap: 10px !important;
    }
    
    .product-card__title,
    .product-title {
        font-size: 12px !important;
    }
    
    .product-card__price .price-current,
    .product-price {
        font-size: 14px !important;
    }
    
    /* Footer columns */
    .footer-columns {
        grid-template-columns: 1fr !important;
    }
    
    /* Cart */
    .cart-item {
        grid-template-columns: 60px 1fr !important;
    }
    
    .cart-item__thumb {
        width: 60px !important;
        height: 60px !important;
    }
    
    .cart-item__title {
        font-size: 14px !important;
    }
}

/* ===== EXTRA SMALL SCREENS (max-width: 380px) ===== */
@media (max-width: 380px) {
    
    .product-title {
        font-size: 18px !important;
    }
    
    .product-price-section .product-price {
        font-size: 22px !important;
    }
    
    .qty-btn {
        width: 44px !important;
        height: 44px !important;
    }
    
    #productQty,
    .qty-input {
        width: 60px !important;
    }
    
    /* Stacked thumbnails */
    .gallery-thumbnails {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ===== LANDSCAPE PHONE FIXES ===== */
@media (max-width: 768px) and (orientation: landscape) {
    
    .product-detail-layout {
        grid-template-columns: 1fr 1fr !important;
        gap: 20px !important;
    }
    
    .product-images {
        max-height: 60vh;
        overflow: hidden;
    }
    
    .main-image {
        max-height: 50vh;
    }
    
    .main-image img {
        max-height: 50vh;
        object-fit: contain;
    }
}

/* ===== IOS SAFE AREA INSETS ===== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    body {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }
    
    .main-footer {
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }
    
    .mobile-bottom-bar {
        padding-bottom: calc(8px + env(safe-area-inset-bottom)) !important;
    }
}

/* ===== PREVENT IOS ZOOM ON INPUT FOCUS ===== */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ===== TOUCH DEVICE OPTIMIZATIONS ===== */
@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects that can cause issues on touch */
    .btn:hover,
    a:hover {
        transform: none !important;
    }
    
    /* Larger tap targets */
    .nav-item,
    .category-list a,
    .footer-links a {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .mobile-bottom-bar,
    .top-banner,
    .hamburger,
    .mobile-close-btn {
        display: none !important;
    }
    
    body {
        padding-bottom: 0 !important;
    }
}
