/* ===================================================================
   MOBILE-FIRST RESPONSIVE DESIGN
   Core mobile optimizations for Percussion Gears
   ===================================================================*/

/* === ROOT MOBILE VARIABLES === */
:root {
    --mobile-padding: 16px;
    --mobile-nav-height: 60px;
    --tablet-padding: 24px;
    --desktop-padding: 32px;
}

/* === MOBILE-FIRST BASE === */
@media (max-width: 768px) {
    html {
        font-size: 14px; /* Slightly smaller base for mobile */
    }
    
    body {
        font-size: 14px;
        line-height: 1.5;
        -webkit-text-size-adjust: 100%; /* Prevent iOS text size adjustment */
    }
    
    /* Container adjustments */
    .container,
    .site-container,
    .shop-main,
    .checkout-main {
        padding-left: var(--mobile-padding) !important;
        padding-right: var(--mobile-padding) !important;
        max-width: 100% !important;
    }
}

/* === MOBILE HEADER & NAVIGATION === */
@media (max-width: 992px) {
    .main-header {
        height: var(--mobile-nav-height);
        min-height: var(--mobile-nav-height);
        padding: 12px 16px;
        gap: 12px;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .main-header .logo .logo-icon {
        height: 36px; /* Smaller logo on mobile */
    }
}

/* === MOBILE HEADER LAYOUT (Hamburger Menu) === */
@media (max-width: 768px) {
    .main-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: relative;
        padding: 12px 20px;
    }
    
    .main-header .logo {
        position: absolute !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        z-index: 11012;
        margin: 0 !important;
        pointer-events: none; /* Prevent logo from blocking clicks */
    }
    
    .main-header .logo .logo-icon {
        pointer-events: auto; /* Re-enable clicks on the actual logo */
        height: 36px !important; /* Consistent size on mobile */
    }
    
    .mobile-menu-btn {
        z-index: 11015;
        position: relative;
        order: 1;
        margin-right: auto;
    }
    
    /* Hide navbar-left visually but keep it in DOM for JavaScript */
    .navbar-left {
        position: absolute !important;
        left: -9999px !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
    
    /* Hide navbar-right on mobile (it's empty/non-functional) */
    .navbar-right {
        display: none !important;
    }
}

/* === MOBILE HAMBURGER MENU === */
@media (max-width: 768px) {
    :root {
        --mobile-header-h: 56px;
    }

    .mobile-menu-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.1);
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.3s ease;
        position: relative;
        z-index: 11015;
        flex-shrink: 0;
    }
    
    .mobile-menu-btn:hover {
        background: rgba(255, 255, 255, 0.2);
    }
    
    .mobile-menu-btn i {
        color: #fff;
        font-size: 20px;
    }
    
    /* COMPLETELY HIDE the non-working mobile-nav-toggle button */
    .mobile-nav-toggle,
    button.mobile-nav-toggle,
    #mobile-nav-toggle {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        position: absolute !important;
        left: -9999px !important;
    }
    
    /* Hide desktop nav on mobile */
    .navbar-left.desktop-nav {
        display: none;
    }
    
    /* Mobile nav drawer styles moved to tailwind-config.css */
    /* Using HTML-based drawer instead of JavaScript-generated one */

    .mobile-nav-drawer {
        top: var(--mobile-header-h) !important;
        height: calc(100vh - var(--mobile-header-h)) !important;
        height: calc(100dvh - var(--mobile-header-h)) !important;
    }

    .mobile-nav-overlay {
        top: var(--mobile-header-h) !important;
        height: calc(100vh - var(--mobile-header-h)) !important;
        height: calc(100dvh - var(--mobile-header-h)) !important;
    }

    /* Remove GearUp logo/header in mobile drawer */
    .mobile-nav-header {
        background: transparent !important;
        padding: 0 !important;
        min-height: 0 !important;
        height: 0 !important;
        border: 0 !important;
        overflow: visible !important;
    }

    .mobile-nav-logo {
        display: none !important;
    }

    .mobile-nav-close {
        position: absolute !important;
        top: 16px !important;
        right: 16px !important;
        background: rgba(0, 0, 0, 0.05) !important;
        color: #333 !important;
        width: 36px !important;
        height: 36px !important;
        border-radius: 50% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        z-index: 11010 !important;
    }

    .mobile-nav-content {
        padding-top: 60px !important;
    }
}

/* === MOBILE TYPOGRAPHY === */
@media (max-width: 768px) {
    h1 {
        font-size: 1.75rem; /* 28px */
        line-height: 1.2;
    }
    
    h2 {
        font-size: 1.5rem; /* 24px */
        line-height: 1.3;
    }
    
    h3 {
        font-size: 1.25rem; /* 20px */
        line-height: 1.4;
    }
    
    h4 {
        font-size: 1.1rem; /* 17.6px */
    }
    
    p {
        font-size: 14px;
        line-height: 1.6;
    }
}

/* === MOBILE HERO SECTIONS === */
@media (max-width: 768px) {
    .modern-hero,
    .shop-hero {
        padding: 40px 16px !important;
        min-height: auto !important;
    }
    
    .hero-logo-img,
    .store-logo {
        max-width: 200px !important;
        margin-bottom: 20px;
    }
    
    .hero-title {
        font-size: 1.5rem;
        margin-bottom: 12px;
    }
    
    .hero-subtitle {
        font-size: 14px;
        margin-bottom: 20px;
    }
    
    .cta-button {
        padding: 12px 24px;
        font-size: 14px;
        width: 100%;
        max-width: 280px;
        text-align: center;
    }
}

/* === MOBILE QUICK VIEW BUTTON - Hidden on desktop by default === */
.mobile-quick-view-btn {
    display: none;
}

/* === MOBILE PRODUCT GRID === */
@media (max-width: 768px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        padding: 8px !important;
    }
    
    .product-card-modern {
        min-height: auto !important; /* Allow dynamic height for compact view */
        height: auto !important;
        padding: 0;
        border-radius: 12px;
        margin-bottom: 0 !important;
    }

    /* Hide description in mobile first to ensure compactness */
    .product-description {
        display: none !important;
    }
    
    /* Mobile: Show overlay on touch for quick-view */
    .product-card-modern.touch-active .product-overlay,
    .product-card.touch-active .product-overlay {
        opacity: 1 !important;
    }
    
    /* Mobile quick-view button - icon only, hidden until hover/touch */
    .mobile-quick-view-btn {
        display: flex !important;
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        background: rgba(255, 255, 255, 0.92);
        color: #660000;
        border: none;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        font-size: 0;
        cursor: pointer;
        z-index: 100;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        -webkit-tap-highlight-color: transparent;
        opacity: 0;
        transition: opacity 0.2s ease;
        padding: 0;
    }

    .mobile-quick-view-btn i {
        pointer-events: none;
        font-size: 1.25rem;
        color: #660000;
    }

    .product-card-modern:hover .mobile-quick-view-btn,
    .product-card-modern.touch-active .mobile-quick-view-btn,
    .product-card:hover .mobile-quick-view-btn,
    .product-card.touch-active .mobile-quick-view-btn,
    .product-card-modern:hover .product-overlay .quick-view-btn,
    .product-card-modern.touch-active .product-overlay .quick-view-btn,
    .product-card:hover .product-overlay .quick-view-btn,
    .product-card.touch-active .product-overlay .quick-view-btn {
        opacity: 1 !important;
    }
    
    .mobile-quick-view-btn:active {
        transform: translate(-50%, -50%) scale(0.95);
    }
    
    /* Show overlay but keep transparent so icon centers */
    .product-overlay {
        display: flex !important;
        align-items: center;
        justify-content: center;
        opacity: 0 !important;
        background: transparent !important;
        pointer-events: none;
        transition: opacity 0.2s ease;
    }
    .product-card-modern:hover .product-overlay,
    .product-card-modern.touch-active .product-overlay,
    .product-card:hover .product-overlay,
    .product-card.touch-active .product-overlay {
        opacity: 1 !important;
    }
    
    .product-image-container {
        height: 140px !important;
        min-height: 140px !important;
        max-height: 140px !important;
        position: relative;
        overflow: visible !important; /* Ensure button isn't clipped */
    }
    
    .product-card .product-image {
        height: 140px;
        border-radius: 8px;
    }
    
    .product-info {
        padding: 10px !important;
    }
    
    .product-card .product-name {
        font-size: 12px !important;
        margin-top: 6px;
        line-height: 1.3;
        max-height: 2.6em;
        overflow: hidden;
    }
    
    .product-card .product-price {
        font-size: 14px !important;
        font-weight: 600;
        margin-top: 4px;
    }
    
    .product-card .product-actions {
        flex-direction: column;
        gap: 6px;
        padding: 0;
    }
    
    .product-card button {
        width: 100%;
        padding: 8px 10px !important;
        font-size: 12px !important;
    }
    
    .size-dropdown {
        padding: 6px 24px 6px 8px !important;
        font-size: 11px !important;
        min-height: 32px !important;
    }
}

/* Single column on very small screens */
@media (max-width: 480px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }
    
    .product-card-modern {
        min-height: 320px !important;
    }
    
    .product-image-container {
        height: 130px !important;
        min-height: 130px !important;
        max-height: 130px !important;
    }
    
    .product-card .product-image {
        height: 130px;
    }
    
    .product-info {
        padding: 8px !important;
    }
    
    .product-name {
        font-size: 11px !important;
    }
    
    .product-price {
        font-size: 13px !important;
    }
    
    .product-card button {
        padding: 6px 8px !important;
        font-size: 11px !important;
    }
}

/* === MOBILE FILTERS & SORTING === */
@media (max-width: 768px) {
    .filter-section,
    .sort-controls {
        flex-direction: column;
        gap: 12px;
    }
    
    .filter-section select,
    .sort-controls select,
    .filter-section button {
        width: 100%;
        padding: 10px 12px;
    }
    
    .search-bar {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .search-bar input {
        font-size: 14px;
    }
}

/* === MOBILE CART SIDEBAR === */
@media (max-width: 768px) {
    .cart-sidebar {
        width: 100% !important;
        max-width: 100% !important;
        right: -100% !important;
    }
    
    .cart-sidebar.active {
        right: 0 !important;
    }
    
    .cart-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .cart-item-image {
        width: 100%;
        height: 120px;
    }
    
    .cart-item-details {
        width: 100%;
    }
    
    .cart-actions {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }
    
    .cart-actions button {
        width: 100%;
    }
}

/* === MOBILE CHECKOUT === */
@media (max-width: 768px) {
    .checkout-container {
        flex-direction: column !important;
        gap: 24px;
    }
    
    .checkout-form,
    .order-summary {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    .form-row {
        flex-direction: column;
        gap: 16px;
    }
    
    .form-group {
        width: 100% !important;
    }
    
    .payment-methods {
        flex-direction: column;
    }
    
    .payment-option {
        width: 100%;
    }
}

/* === MOBILE FORMS === */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 12px;
    }
    
    button,
    .btn,
    .button {
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px; /* Touch-friendly */
    }
    
    label {
        font-size: 13px;
        margin-bottom: 6px;
    }
}

/* === MOBILE MODALS === */
@media (max-width: 768px) {
    .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 20px auto;
        padding: 20px;
        border-radius: 12px;
    }
    
    .quick-view-modal .modal-content {
        flex-direction: column;
    }
    
    .quick-view-image,
    .quick-view-details {
        width: 100% !important;
    }
    
    .quick-view-image {
        height: 250px;
        margin-bottom: 20px;
    }
}

/* === MOBILE TABLES === */
@media (max-width: 768px) {
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Card-style tables for mobile */
    .mobile-table-card {
        display: block;
        margin-bottom: 16px;
        background: #fff;
        border-radius: 8px;
        padding: 16px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .mobile-table-card tr {
        display: flex;
        justify-content: space-between;
        padding: 8px 0;
        border-bottom: 1px solid #eee;
    }
    
    .mobile-table-card tr:last-child {
        border-bottom: none;
    }
    
    .mobile-table-card th {
        font-weight: 600;
        text-align: left;
    }
    
    .mobile-table-card td {
        text-align: right;
    }
}

/* === MOBILE FOOTER === */
@media (max-width: 768px) {
    .footer-content {
        flex-direction: column !important;
        text-align: center;
    }
    
    .footer-column {
        width: 100% !important;
        margin-bottom: 24px;
    }

    .footer-column h3 {
        text-align: center !important;
    }

    .footer-column h3::after {
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
    
    .footer-links {
        list-style: none;
        padding: 0;
    }
    
    .footer-links li {
        margin-bottom: 12px;
    }
    
    .social-links {
        justify-content: center;
        gap: 16px;
    }
}

/* === MOBILE AUTH FORM SPACING === */
@media (max-width: 768px) {
    .auth-page .form-actions .form-small {
        display: inline-flex !important;
        align-items: center !important;
        gap: 2px !important;
        padding: 0 !important;
        margin: 0 0 6px 0 !important;
    }

    .auth-page .form-actions .form-small input[type="checkbox"] {
        margin-right: 2px !important;
    }
}

/* === MOBILE USER DASHBOARD === */
@media (max-width: 768px) {
    .dashboard-container {
        flex-direction: column;
    }
    
    .dashboard-sidebar {
        width: 100% !important;
        position: relative;
        margin-bottom: 20px;
    }
    
    .dashboard-main {
        width: 100% !important;
    }
    
    .stat-card {
        flex: 0 0 calc(50% - 8px);
    }
    
    .order-card {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .order-actions {
        width: 100%;
        justify-content: space-between;
        margin-top: 12px;
    }
}

/* === MOBILE ADMIN === */
@media (max-width: 768px) {
    .admin-container {
        flex-direction: column;
    }
    
    .admin-sidebar {
        width: 100%;
        position: relative;
    }
    
    .admin-content {
        width: 100% !important;
        padding: 16px;
    }
    
    .admin-card {
        padding: 16px;
    }
    
    .admin-table {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Consistent alignment across admin pages */
    .main,
    .topbar,
    .card,
    .stat-card,
    .msg,
    .table-container,
    .admin-table,
    .form-grid,
    form,
    .form-actions,
    .modal-actions,
    .actions-grid,
    .action-card {
        text-align: left !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
    }

    .topbar > *,
    .card > *,
    .stat-card > *,
    .msg > *,
    .form-grid > *,
    form > *,
    .action-card > * {
        width: 100% !important;
    }

    .actions-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .action-card {
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
    }

    .action-card > div {
        justify-content: flex-start !important;
        align-items: center !important;
    }

    /* Tables: force left alignment */
    table th,
    table td,
    .admin-table th,
    .admin-table td,
    .modern-table th,
    .modern-table td {
        text-align: left !important;
        vertical-align: middle !important;
    }

    table {
        display: table !important;
        table-layout: auto !important;
        border-collapse: collapse !important;
    }

    thead {
        display: table-header-group !important;
    }

    tbody {
        display: table-row-group !important;
    }

    tr {
        display: table-row !important;
        width: auto !important;
    }

    th,
    td {
        display: table-cell !important;
    }

    table th[style*="text-align: center"],
    table td[style*="text-align: center"],
    .modern-table th[style*="text-align: center"],
    .modern-table td[style*="text-align: center"],
    .admin-table th[style*="text-align: center"],
    .admin-table td[style*="text-align: center"] {
        text-align: left !important;
    }

    table td > *,
    .admin-table td > *,
    .modern-table td > * {
        margin-left: 0 !important;
        margin-right: auto !important;
    }

    /* Badges/chips alignment */
    .badge,
    .badge-pill,
    .tag,
    .pill,
    .status-badge {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
    }
}

/* === TOUCH-FRIENDLY INTERACTIONS === */
@media (max-width: 768px) {
    /* Larger tap targets */
    a,
    button,
    .btn,
    input[type="submit"],
    input[type="button"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Better spacing for touch */
    .icon-button {
        padding: 12px;
    }
    
    /* Prevent double-tap zoom on buttons */
    button {
        touch-action: manipulation;
    }
}

/* === MOBILE PERFORMANCE === */
@media (max-width: 768px) {
    /* Mobile performance optimizations - keep essential animations */
    /* Re-enable essential animations for modals and navigation */
    .cart-sidebar,
    .mobile-nav-drawer,
    .modal,
    .modal-quick-view,
    .quick-view-content,
    .mobile-nav-overlay,
    .cart-success-toast {
        animation-duration: 0.3s !important;
        transition-duration: 0.3s !important;
    }
    
    /* Optimize non-critical animations */
    .product-card-modern:hover {
        transform: none !important;
    }
}

/* === MOBILE IMAGES === */
@media (max-width: 768px) {
    img {
        max-width: 100%;
        height: auto;
        display: block;
    }
    
    /* Lazy loading optimization */
    img[loading="lazy"] {
        opacity: 0;
        transition: opacity 0.3s ease;
    }
    
    img[loading="lazy"].loaded {
        opacity: 1;
    }
}

/* === MOBILE UTILITIES === */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: block !important;
    }
    
    .mobile-full-width {
        width: 100% !important;
    }
    
    .mobile-text-center {
        text-align: center !important;
    }
    
    .mobile-stack {
        flex-direction: column !important;
    }
}

/* === TABLET BREAKPOINT === */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        padding-left: var(--tablet-padding) !important;
        padding-right: var(--tablet-padding) !important;
    }
    
    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* === PREVENT HORIZONTAL SCROLL === */
@media (max-width: 768px) {
    html,
    body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    
    * {
        max-width: 100%;
    }
    
    /* Fix common overflow culprits */
    .container,
    .row,
    .col {
        overflow-x: visible;
    }
}

/* === SMOOTH SCROLLING === */
@media (max-width: 768px) {
    html {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Momentum scrolling for iOS */
    body,
    .cart-sidebar,
    .mobile-nav-drawer {
        -webkit-overflow-scrolling: touch;
    }
}

/* === MOBILE LOGO OPTIMIZATION === */
@media (max-width: 768px) {
    .logo-icon {
        height: 32px !important;
        width: auto !important;
        object-fit: contain;
    }
    
    .hero-logo-img {
        max-width: 200px !important;
        width: 80% !important;
    }
    
    .sidebar-logo-img {
        height: 40px !important;
        width: auto !important;
    }
}

/* === MOBILE ACCOUNT DROPDOWN === */
@media (max-width: 768px) {
    .account-dropdown {
        position: relative;
    }
    
    .account-menu {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        border-radius: 16px 16px 0 0 !important;
        padding: 20px !important;
        max-height: 50vh !important;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        z-index: 11050 !important;
    }
    
    .account-dropdown:hover .account-menu,
    .account-dropdown.active .account-menu {
        transform: translateY(0);
    }
    
    .account-menu a {
        padding: 16px 20px !important;
        font-size: 16px !important;
    }
}

/* === MOBILE BUTTONS POLISH === */
@media (max-width: 768px) {
    .btn,
    .button,
    button:not(.mobile-menu-btn):not(.account-btn):not(.close-quick-view) {
        border-radius: 10px;
        font-weight: 600;
        letter-spacing: 0.3px;
    }
    
    .hero-btn {
        width: 100% !important;
        max-width: 280px !important;
        padding: 14px 24px !important;
        font-size: 14px !important;
        border-radius: 50px !important;
    }
    
    .hero-buttons {
        flex-direction: column !important;
        align-items: center !important;
        gap: 12px !important;
    }
}

/* === MOBILE STATS CONTAINER === */
@media (max-width: 768px) {
    .stats-container {
        gap: 24px !important;
        padding: 0 16px !important;
    }
    
    .stat-item {
        flex: 0 0 auto;
    }
    
    .stat-number {
        font-size: 1.5rem !important;
    }
    
    .stat-label {
        font-size: 0.7rem !important;
    }
}

/* === MOBILE STORE CARDS (Homepage) === */
@media (max-width: 768px) {
    .stores-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
        padding: 0 16px !important;
    }
    
    .store-card {
        padding: 24px 20px !important;
        border-radius: 16px !important;
    }
    
    .store-logo {
        max-width: 150px !important;
        height: auto !important;
    }
}

/* === MOBILE SEARCH BAR === */
@media (max-width: 768px) {
    .search-section {
        padding: 12px 16px !important;
    }
    
    .search-bar {
        border-radius: 50px !important;
    }
    
    .search-bar input {
        padding: 12px 16px !important;
        font-size: 15px !important;
    }
}

/* === MOBILE FILTER BAR === */
@media (max-width: 768px) {
    .filter-bar,
    .filter-section {
        flex-wrap: wrap !important;
        gap: 8px !important;
        padding: 12px !important;
    }
    
    .filter-bar select,
    .filter-section select {
        flex: 1 1 calc(50% - 4px) !important;
        min-width: calc(50% - 4px) !important;
        padding: 10px 12px !important;
        font-size: 13px !important;
        border-radius: 8px !important;
    }
}

/* === MOBILE TOAST NOTIFICATIONS === */
@media (max-width: 768px) {
    .cart-success-toast,
    .toast,
    .notification-toast {
        left: 16px !important;
        right: 16px !important;
        bottom: 80px !important;
        max-width: calc(100% - 32px) !important;
        font-size: 14px !important;
        padding: 14px 18px !important;
        border-radius: 12px !important;
    }
}

/* === MOBILE JOYBOT CHAT === */
@media (max-width: 768px) {
    .joybot-container,
    .chat-widget {
        bottom: 70px !important;
        right: 12px !important;
    }
    
    .joybot-window,
    .chat-window {
        width: calc(100vw - 24px) !important;
        max-width: 100% !important;
        height: 60vh !important;
        max-height: 60vh !important;
        right: 0 !important;
        bottom: 60px !important;
        border-radius: 16px 16px 0 0 !important;
    }
}

/* === MOBILE CART TOGGLE BUTTON === */
@media (max-width: 768px) {
    .cart-toggle-btn {
        top: auto !important;
        bottom: 16px !important;
        right: 16px !important;
        position: fixed !important;
        background: linear-gradient(135deg, #800000 0%, #a00000 100%) !important;
        border-radius: 50% !important;
        width: 56px !important;
        height: 56px !important;
        box-shadow: 0 4px 20px rgba(128, 0, 0, 0.4) !important;
        z-index: 10500 !important;
    }
    
    .cart-toggle-btn i {
        font-size: 22px !important;
    }
    
    .cart-count {
        top: -4px !important;
        right: -4px !important;
        font-size: 11px !important;
        min-width: 20px !important;
        height: 20px !important;
    }
}

/* === MOBILE ACCESSIBILITY === */
@media (max-width: 768px) {
    /* Ensure focus states are visible */
    a:focus,
    button:focus,
    input:focus,
    select:focus {
        outline: 2px solid #800000 !important;
        outline-offset: 2px !important;
    }
    
    /* Better contrast for placeholder text */
    ::placeholder {
        color: #888 !important;
        opacity: 1 !important;
    }
}

/* === MOBILE LOADING STATES === */
@media (max-width: 768px) {
    .loading-spinner,
    .loader {
        width: 32px !important;
        height: 32px !important;
    }
    
    .skeleton-loader {
        border-radius: 8px !important;
    }
}

/* =====================================================
   ENHANCED MOBILE-FIRST SHOP LAYOUT
   Optimized for touch interactions and mobile UX
   ===================================================== */

/* === MOBILE HEADER IMPROVEMENTS === */
@media (max-width: 768px) {
    .main-header {
        height: 56px !important;
        padding: 0 12px !important;
        gap: 8px !important;
    }

    .main-header .logo {
        position: static !important;
        transform: none !important;
    }

    .main-header .logo .logo-icon {
        height: 28px !important;
    }

    /* Hide desktop nav links */
    .navbar-left a:not(:first-child),
    .navbar-right a[id*="btn"] {
        display: none !important;
    }

    /* Mobile nav icons only */
    .navbar-right {
        gap: 4px !important;
    }

    .navbar-right a {
        padding: 8px !important;
    }

    /* Account dropdown mobile fix */
    .account-dropdown .account-menu {
        right: 0 !important;
        left: auto !important;
        min-width: 180px !important;
    }
}

/* === MOBILE SHOP HERO === */
@media (max-width: 768px) {
    .shop-hero {
        padding: 56px 16px 24px !important;
        min-height: auto !important;
    }

    .shop-hero-content {
        padding: 0 !important;
    }

    .hero-logo-img {
        max-width: 200px !important;
        margin: 0 auto 16px !important;
    }

    .stats-container {
        gap: 24px !important;
        margin-top: 16px !important;
    }

    .stat-item {
        text-align: center;
    }

    .stat-number {
        font-size: 1.25rem !important;
    }

    .stat-label {
        font-size: 0.7rem !important;
    }
}

/* === MOBILE SEARCH & FILTERS === */
@media (max-width: 768px) {
    .search-bar-top {
        flex-direction: column !important;
        gap: 12px !important;
        padding: 12px 0 !important;
    }

    .shop-logos {
        display: none !important;
    }

    .search-wrapper {
        width: 100% !important;
    }

    .modern-search-input {
        width: 100% !important;
        font-size: 16px !important;
        padding: 12px 12px 12px 40px !important;
    }

    .sort-group-top {
        width: 100% !important;
        justify-content: space-between !important;
    }

    .filter-label {
        display: none !important;
    }

    .minimal-select {
        flex: 1 !important;
        font-size: 14px !important;
        padding: 10px 12px !important;
    }

    /* Hide sidebar filters on mobile */
    .filters-sidebar {
        display: none !important;
    }

    .shop-layout {
        display: block !important;
    }

    .shop-products {
        width: 100% !important;
    }
}

/* === MOBILE FILTER DRAWER === */
.mobile-filter-btn {
    display: none;
    position: fixed;
    bottom: 80px;
    left: 16px;
    z-index: 1000;
    background: #800000;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(128, 0, 0, 0.3);
    cursor: pointer;
}

@media (max-width: 768px) {
    .mobile-filter-btn {
        display: flex;
        align-items: center;
        gap: 8px;
    }
}

/* === MOBILE PRODUCT GRID ENHANCEMENTS === */
@media (max-width: 768px) {
    .container,
    .shop-main .container {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }

    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        padding: 0 !important;
        padding-bottom: 100px !important;
    }

    .product-card-modern {
        border-radius: 10px !important;
        overflow: hidden !important;
        background: #fff !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06) !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: auto !important;
    }

    /* Mobile product image */
    .product-image-container {
        height: 140px !important;
        min-height: 140px !important;
        max-height: 140px !important;
        border-radius: 0 !important;
        position: relative !important;
    }

    .product-image {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    /* Hide desktop overlay */
    .product-overlay {
        display: none !important;
    }

    /* Mobile quick view button */
    .mobile-quick-view-btn {
        display: flex !important;
        position: absolute !important;
        bottom: 6px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        background: rgba(128, 0, 0, 0.9) !important;
        color: white !important;
        border: none !important;
        padding: 6px 12px !important;
        border-radius: 15px !important;
        font-size: 11px !important;
        font-weight: 600 !important;
        gap: 4px !important;
        align-items: center !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25) !important;
        white-space: nowrap !important;
    }

    .mobile-quick-view-btn i {
        font-size: 10px !important;
    }

    /* Mobile product badge */
    .product-badge {
        top: 6px !important;
        left: 6px !important;
        padding: 3px 8px !important;
        font-size: 9px !important;
    }

    /* Mobile product info */
    .product-info {
        padding: 10px !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .product-category {
        font-size: 9px !important;
        margin-bottom: 2px !important;
    }

    .product-title {
        font-size: 12px !important;
        line-height: 1.3 !important;
        margin-bottom: 4px !important;
        display: -webkit-box !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        min-height: 32px !important;
    }

    .product-description {
        display: none !important;
    }

    .product-type-tag {
        display: none !important;
    }

    /* Mobile price display */
    .price-container {
        margin: 4px 0 8px !important;
    }

    .product-price,
    .sale-price {
        font-size: 14px !important;
        font-weight: 700 !important;
        color: #800000 !important;
    }

    .original-price {
        font-size: 11px !important;
    }

    /* Hide variant selection on card (show in quick view) */
    .size-selection,
    .custom-option-container {
        display: none !important;
    }

    /* Mobile product actions */
    .product-actions {
        margin-top: auto !important;
        padding-top: 8px !important;
        border-top: 1px solid #f0f0f0 !important;
    }

    .quantity-selector {
        display: none !important;
    }

    .add-to-cart-btn {
        width: 100% !important;
        padding: 10px !important;
        font-size: 12px !important;
        font-weight: 600 !important;
        border-radius: 6px !important;
        gap: 6px !important;
    }

    .add-to-cart-btn i {
        font-size: 14px !important;
    }

    .add-to-cart-btn span {
        display: none !important;
    }

    .add-to-cart-btn::after {
        content: 'Add';
        font-size: 12px;
    }
}

/* Very small screens - 1 column option */
@media (max-width: 360px) {
    .product-grid {
        gap: 6px !important;
    }

    .product-image-container {
        height: 120px !important;
        min-height: 120px !important;
        max-height: 120px !important;
    }

    .product-title {
        font-size: 11px !important;
        min-height: 28px !important;
    }
}

/* === MOBILE QUICK VIEW MODAL === */
@media (max-width: 768px) {
    .modal-quick-view,
    .quick-view-modal {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    .quick-view-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 90vh !important;
        border-radius: 20px 20px 0 0 !important;
        flex-direction: column !important;
        margin: 0 !important;
    }

    .quick-view-image {
        width: 100% !important;
        height: 250px !important;
        flex-shrink: 0 !important;
    }

    .quick-view-image img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }

    .quick-view-details {
        width: 100% !important;
        padding: 20px !important;
        overflow-y: auto !important;
        max-height: calc(90vh - 250px) !important;
    }

    .quick-view-title {
        font-size: 18px !important;
    }

    .quick-view-price {
        font-size: 20px !important;
    }

    /* Show variants in quick view */
    .quick-view-details .size-selection,
    .quick-view-details .custom-option-container {
        display: block !important;
    }

    .quick-view-actions {
        display: flex !important;
        gap: 12px !important;
        margin-top: 16px !important;
    }

    .quick-view-actions .quantity-selector {
        display: flex !important;
    }

    .quick-view-actions .add-to-cart-btn {
        flex: 1 !important;
    }

    .quick-view-actions .add-to-cart-btn span {
        display: inline !important;
    }

    .quick-view-actions .add-to-cart-btn::after {
        content: '' !important;
    }

    .quick-view-close {
        position: absolute !important;
        top: 12px !important;
        right: 12px !important;
        width: 36px !important;
        height: 36px !important;
        background: rgba(0, 0, 0, 0.5) !important;
        color: white !important;
        border: none !important;
        border-radius: 50% !important;
        font-size: 18px !important;
        z-index: 10 !important;
    }
}

/* === MOBILE CART SIDEBAR IMPROVEMENTS === */
@media (max-width: 768px) {
    .cart-sidebar {
        width: 100% !important;
        right: -100% !important;
        border-radius: 0 !important;
    }

    .cart-sidebar.active {
        right: 0 !important;
    }

    .cart-sidebar-header {
        padding: 16px !important;
        border-bottom: 1px solid #eee !important;
    }

    .cart-sidebar-header h3 {
        font-size: 18px !important;
    }

    .cart-sidebar-content {
        padding: 12px !important;
    }

    .cart-sidebar-item {
        padding: 12px !important;
        border-radius: 10px !important;
        background: #f8f8f8 !important;
        margin-bottom: 10px !important;
    }

    .cart-sidebar-item-image {
        width: 70px !important;
        height: 70px !important;
        border-radius: 8px !important;
    }

    .cart-sidebar-item-info h4 {
        font-size: 13px !important;
        line-height: 1.3 !important;
    }

    .cart-sidebar-item-info p {
        font-size: 12px !important;
    }

    .quantity-selector-cart {
        height: 32px !important;
    }

    .quantity-btn-cart {
        width: 28px !important;
        height: 28px !important;
    }

    .cart-sidebar-item-quantity {
        width: 36px !important;
        font-size: 13px !important;
    }

    .cart-sidebar-footer {
        padding: 16px !important;
        padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
    }

    .checkout-btn-sidebar,
    .shop-now-btn-sidebar {
        padding: 14px !important;
        font-size: 15px !important;
        border-radius: 10px !important;
    }
}

/* === MOBILE CHECKOUT IMPROVEMENTS === */
@media (max-width: 768px) {
    .checkout-main {
        padding-top: 70px !important;
        padding-bottom: 100px !important;
    }

    .checkout-container {
        flex-direction: column !important;
        gap: 16px !important;
    }

    .checkout-form {
        order: 1 !important;
    }

    .order-summary {
        order: 2 !important;
        position: relative !important;
        top: auto !important;
    }

    .checkout-form,
    .order-summary {
        width: 100% !important;
        border-radius: 12px !important;
    }

    .form-section-title {
        font-size: 16px !important;
        margin-bottom: 12px !important;
    }

    .form-row {
        flex-direction: column !important;
        gap: 12px !important;
    }

    .form-group {
        width: 100% !important;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px !important;
        padding: 14px !important;
    }

    .payment-methods {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    .payment-option {
        padding: 12px !important;
    }

    .payment-option-name {
        font-size: 11px !important;
    }

    .place-order-btn {
        padding: 16px !important;
        font-size: 16px !important;
        border-radius: 10px !important;
    }
}

/* === SAFE AREA SUPPORT === */
@supports (padding: max(0px)) {
    @media (max-width: 768px) {
        .main-header {
            padding-top: max(12px, env(safe-area-inset-top)) !important;
        }

        .cart-toggle-btn {
            bottom: max(16px, calc(env(safe-area-inset-bottom) + 16px)) !important;
        }

        .mobile-filter-btn {
            bottom: max(80px, calc(env(safe-area-inset-bottom) + 80px)) !important;
        }

        .cart-sidebar-footer {
            padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
        }

        .checkout-main {
            padding-bottom: max(100px, calc(env(safe-area-inset-bottom) + 100px)) !important;
        }
    }
}