/**
 * Enhanced Mobile Responsiveness - Complete Frontend Optimization
 * Comprehensive mobile-first design for all devices and screen sizes
 * Optimized for touch interactions and modern mobile browsers
 */

/* ==================== GLOBAL MOBILE OPTIMIZATIONS ==================== */

/* Prevent zoom on input focus (iOS Safari) */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
textarea,
select {
    font-size: 16px !important;
}

/* Better touch targets */
button,
.btn,
a[role="button"],
input[type="submit"],
input[type="button"] {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

/* Smooth scrolling with momentum */
* {
    -webkit-overflow-scrolling: touch;
}

/* Prevent text selection on UI elements */
.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* ==================== RESPONSIVE BREAKPOINTS ==================== */

/* Mobile First - Base styles for mobile */
/* Small phones: 320px - 480px */
/* Large phones: 481px - 768px */
/* Tablets: 769px - 1024px */
/* Desktop: 1025px+ */

/* ==================== HEADER ENHANCEMENTS ==================== */

.header-enhanced {
    position: sticky;
    top: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

@media (max-width: 480px) {
    .header-enhanced {
        padding: 0.5rem 1rem;
    }
    
    .header-enhanced .logo-text {
        font-size: 1.125rem;
    }
    
    .header-enhanced .tagline {
        display: none;
    }
    
    .header-enhanced .nav-buttons {
        gap: 0.25rem;
    }
    
    .header-enhanced .nav-btn {
        padding: 0.375rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .header-enhanced .nav-btn span {
        display: none;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .header-enhanced {
        padding: 0.75rem 1rem;
    }
    
    .header-enhanced .logo-text {
        font-size: 1.25rem;
    }
    
    .header-enhanced .nav-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
}

/* ==================== NAVIGATION ENHANCEMENTS ==================== */

/* Mobile Navigation Drawer */
.mobile-nav-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-nav-drawer.active {
    opacity: 1;
    visibility: visible;
}

.mobile-nav-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    background: white;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.mobile-nav-drawer.active .mobile-nav-content {
    transform: translateX(0);
}

.mobile-nav-header {
    padding: 1.5rem 1rem;
    background: linear-gradient(135deg, #dc2626, #ea580c);
    color: white;
}

.mobile-nav-items {
    padding: 1rem 0;
}

.mobile-nav-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    color: #374151;
    text-decoration: none;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f3f4f6;
}

.mobile-nav-item:hover,
.mobile-nav-item:active {
    background-color: #f9fafb;
}

.mobile-nav-item i {
    width: 24px;
    margin-right: 1rem;
    color: #6b7280;
}

/* ==================== PRODUCT GRID ENHANCEMENTS ==================== */

.product-grid-enhanced {
    display: grid;
    gap: 1rem;
    padding: 1rem;
}

/* Mobile: Single column */
@media (max-width: 480px) {
    .product-grid-enhanced {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        padding: 0.75rem;
    }
}

/* Large mobile: 2 columns */
@media (min-width: 481px) and (max-width: 768px) {
    .product-grid-enhanced {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* Tablet: 3 columns */
@media (min-width: 769px) and (max-width: 1024px) {
    .product-grid-enhanced {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.25rem;
    }
}

/* Desktop: 4 columns */
@media (min-width: 1025px) {
    .product-grid-enhanced {
        grid-template-columns: repeat(4, 1fr);
        gap: 1.5rem;
    }
}

/* ==================== PRODUCT CARD ENHANCEMENTS ==================== */

.product-card-enhanced {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
}

/* Mobile: Horizontal layout */
@media (max-width: 480px) {
    .product-card-enhanced {
        display: flex;
        align-items: center;
        padding: 0.75rem;
        border-radius: 8px;
    }
    
    .product-card-enhanced .product-image {
        width: 80px;
        height: 80px;
        flex-shrink: 0;
        margin-right: 0.75rem;
        border-radius: 6px;
        object-fit: cover;
    }
    
    .product-card-enhanced .product-content {
        flex: 1;
        min-width: 0;
    }
    
    .product-card-enhanced .product-title {
        font-size: 0.875rem;
        font-weight: 600;
        line-height: 1.2;
        margin-bottom: 0.25rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .product-card-enhanced .product-description {
        font-size: 0.75rem;
        color: #6b7280;
        line-height: 1.2;
        margin-bottom: 0.5rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .product-card-enhanced .product-price {
        font-size: 1rem;
        font-weight: 700;
        color: #dc2626;
        margin-bottom: 0.5rem;
    }
    
    .product-card-enhanced .product-actions {
        display: flex;
        gap: 0.5rem;
        margin-top: 0.75rem;
    }
    
    .product-card-enhanced .add-btn {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        font-weight: 600;
        border-radius: 8px;
        flex: 1;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        box-shadow: 0 2px 4px rgba(220, 38, 38, 0.2);
    }
    
    .product-card-enhanced .add-btn:active {
        transform: scale(0.98);
        box-shadow: 0 1px 2px rgba(220, 38, 38, 0.3);
    }
}

/* Large mobile and up: Vertical layout */
@media (min-width: 481px) {
    .product-card-enhanced:hover {
        transform: translateY(-4px);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    }
    
    .product-card-enhanced .product-image {
        width: 100%;
        height: 180px;
        object-fit: cover;
    }
    
    .product-card-enhanced .product-content {
        padding: 1rem;
    }
    
    .product-card-enhanced .product-title {
        font-size: 1rem;
        font-weight: 600;
        margin-bottom: 0.5rem;
        line-height: 1.3;
    }
    
    .product-card-enhanced .product-description {
        font-size: 0.875rem;
        color: #6b7280;
        margin-bottom: 0.75rem;
        line-height: 1.4;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .product-card-enhanced .product-price {
        font-size: 1.25rem;
        font-weight: 700;
        color: #dc2626;
        margin-bottom: 1rem;
    }
    
    .product-card-enhanced .product-actions {
        margin-top: 1rem;
    }
    
    .product-card-enhanced .add-btn {
        width: 100%;
        padding: 0.875rem 1.5rem;
        font-size: 0.875rem;
        font-weight: 600;
        border-radius: 8px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
        box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2);
    }
    
    .product-card-enhanced .add-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
    }
    
    .product-card-enhanced .add-btn:active {
        transform: translateY(0);
        box-shadow: 0 2px 4px rgba(220, 38, 38, 0.3);
    }
}

/* ==================== CART ENHANCEMENTS ==================== */

.cart-sidebar-enhanced {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    background: white;
    z-index: 9999;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
}

.cart-sidebar-enhanced.active {
    transform: translateX(0);
}

/* Mobile: Full width cart */
@media (max-width: 768px) {
    .cart-sidebar-enhanced {
        width: 100%;
        left: 0;
        right: 0;
    }
}

/* Desktop: Fixed width cart */
@media (min-width: 769px) {
    .cart-sidebar-enhanced {
        width: 400px;
    }
}

.cart-header-enhanced {
    padding: 1rem 1.5rem;
    border-bottom: 2px solid #f3f4f6;
    background: #f9fafb;
    display: flex;
    justify-content: between;
    align-items: center;
}

.cart-items-enhanced {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    max-height: calc(100vh - 200px);
}

.cart-footer-enhanced {
    padding: 1.5rem;
    border-top: 2px solid #f3f4f6;
    background: white;
    position: sticky;
    bottom: 0;
}

/* Mobile cart item layout */
@media (max-width: 480px) {
    .cart-item-enhanced {
        display: flex;
        align-items: center;
        padding: 0.75rem;
        border-bottom: 1px solid #f3f4f6;
        gap: 0.75rem;
    }
    
    .cart-item-enhanced .item-image {
        width: 60px;
        height: 60px;
        border-radius: 6px;
        object-fit: cover;
        flex-shrink: 0;
    }
    
    .cart-item-enhanced .item-details {
        flex: 1;
        min-width: 0;
    }
    
    .cart-item-enhanced .item-name {
        font-size: 0.875rem;
        font-weight: 600;
        margin-bottom: 0.25rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    .cart-item-enhanced .item-price {
        font-size: 0.875rem;
        color: #dc2626;
        font-weight: 600;
    }
    
    .cart-item-enhanced .quantity-controls {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }
    
    .cart-item-enhanced .qty-btn {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.875rem;
    }
}

/* ==================== FLOATING ACTION BUTTON ==================== */

.fab-enhanced {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #dc2626, #ea580c);
    color: white;
    border: none;
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    z-index: 1000;
    transition: all 0.3s ease;
    cursor: pointer;
}

.fab-enhanced:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 30px rgba(220, 38, 38, 0.4);
}

.fab-enhanced:active {
    transform: scale(0.95);
}

.fab-enhanced .badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #fbbf24;
    color: #92400e;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
    border: 2px solid white;
}

/* Hide on desktop if needed */
@media (min-width: 1025px) {
    .fab-enhanced.mobile-only {
        display: none;
    }
}

/* ==================== BOTTOM NAVIGATION ==================== */

.bottom-nav-enhanced {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 0.5rem 0;
    z-index: 999;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.bottom-nav-items {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    color: #6b7280;
    text-decoration: none;
    transition: color 0.2s ease;
    min-width: 60px;
}

.bottom-nav-item.active {
    color: #dc2626;
}

.bottom-nav-item i {
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.bottom-nav-item span {
    font-size: 0.75rem;
    font-weight: 500;
}

/* Hide on desktop */
@media (min-width: 769px) {
    .bottom-nav-enhanced {
        display: none;
    }
}

/* ==================== SEARCH ENHANCEMENTS ==================== */

.search-enhanced {
    position: sticky;
    top: 0;
    z-index: 900;
    background: white;
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.search-input-enhanced {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 2px solid #e5e7eb;
    border-radius: 25px;
    font-size: 1rem;
    background: #f9fafb;
    transition: all 0.3s ease;
}

.search-input-enhanced:focus {
    outline: none;
    border-color: #dc2626;
    background: white;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.search-icon-enhanced {
    position: absolute;
    left: 1.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 1rem;
}

/* ==================== CATEGORY FILTERS ==================== */

.category-filters-enhanced {
    display: flex;
    overflow-x: auto;
    gap: 0.75rem;
    padding: 1rem;
    background: white;
    border-bottom: 1px solid #e5e7eb;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.category-filters-enhanced::-webkit-scrollbar {
    display: none;
}

.category-filter-enhanced {
    flex-shrink: 0;
    padding: 0.5rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 20px;
    background: white;
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.category-filter-enhanced.active {
    background: linear-gradient(135deg, #dc2626, #ea580c);
    color: white;
    border-color: transparent;
}

.category-filter-enhanced:active {
    transform: scale(0.95);
}

/* ==================== MODAL ENHANCEMENTS ==================== */

.modal-enhanced {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-enhanced.active {
    opacity: 1;
    visibility: visible;
}

.modal-content-enhanced {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.modal-enhanced.active .modal-content-enhanced {
    transform: scale(1);
}

/* Mobile modal adjustments */
@media (max-width: 480px) {
    .modal-enhanced {
        padding: 0.5rem;
    }
    
    .modal-content-enhanced {
        max-height: 95vh;
        border-radius: 8px;
    }
}

/* ==================== FORM ENHANCEMENTS ==================== */

.form-enhanced {
    padding: 1.5rem;
}

.form-group-enhanced {
    margin-bottom: 1.5rem;
}

.form-label-enhanced {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
}

.form-input-enhanced {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: #f9fafb;
}

.form-input-enhanced:focus {
    outline: none;
    border-color: #dc2626;
    background: white;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

.form-select-enhanced {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.5rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

/* ==================== BUTTON ENHANCEMENTS ==================== */

.btn-enhanced {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    min-height: 44px;
    touch-action: manipulation;
}

/* Enhanced Add to Cart Button Styling */
.add-to-cart-btn {
    background: linear-gradient(135deg, #dc2626, #ea580c) !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    touch-action: manipulation !important;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.2) !important;
    text-transform: none !important;
    letter-spacing: 0.025em !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
    min-height: 44px !important;
    padding: 0.75rem 1.5rem !important;
    font-size: 0.875rem !important;
}

.add-to-cart-btn:hover {
    background: linear-gradient(135deg, #b91c1c, #dc2626) !important;
    transform: translateY(-1px) !important;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3) !important;
}

.add-to-cart-btn:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 4px rgba(220, 38, 38, 0.3) !important;
}

.add-to-cart-btn:focus {
    outline: none !important;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.2) !important;
}

.btn-primary-enhanced {
    background: linear-gradient(135deg, #dc2626, #ea580c);
    color: white;
}

.btn-primary-enhanced:hover {
    background: linear-gradient(135deg, #b91c1c, #dc2626);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

.btn-primary-enhanced:active {
    transform: translateY(0);
}

.btn-secondary-enhanced {
    background: #f3f4f6;
    color: #374151;
    border: 2px solid #e5e7eb;
}

.btn-secondary-enhanced:hover {
    background: #e5e7eb;
    border-color: #d1d5db;
}

/* Mobile button adjustments */
@media (max-width: 480px) {
    .btn-enhanced {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
        width: 100%;
    }
    
    .btn-group-enhanced {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .btn-group-enhanced .btn-enhanced {
        width: 100%;
    }
    
    /* Enhanced mobile Add to Cart buttons */
    .add-to-cart-btn {
        padding: 1rem 1.25rem !important;
        font-size: 0.875rem !important;
        font-weight: 700 !important;
        min-height: 48px !important;
        border-radius: 10px !important;
        box-shadow: 0 3px 10px rgba(220, 38, 38, 0.25) !important;
    }
    
    .add-to-cart-btn:active {
        transform: scale(0.97) !important;
        box-shadow: 0 2px 6px rgba(220, 38, 38, 0.3) !important;
    }
    
    /* Product card mobile button improvements */
    .product-card-enhanced .add-btn {
        padding: 0.875rem 1rem !important;
        font-size: 0.875rem !important;
        font-weight: 700 !important;
        min-height: 48px !important;
        border-radius: 10px !important;
        box-shadow: 0 3px 10px rgba(220, 38, 38, 0.25) !important;
    }
}

/* Large mobile adjustments */
@media (min-width: 481px) and (max-width: 768px) {
    .add-to-cart-btn {
        padding: 0.875rem 1.25rem !important;
        font-size: 0.875rem !important;
        min-height: 46px !important;
    }
    
    .product-card-enhanced .add-btn {
        padding: 0.875rem 1.25rem !important;
        font-size: 0.875rem !important;
        min-height: 46px !important;
    }
}

/* ==================== LOADING STATES ==================== */

.skeleton-enhanced {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.loading-spinner-enhanced {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-radius: 50%;
    border-top-color: #dc2626;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== ACCESSIBILITY ENHANCEMENTS ==================== */

/* Focus visible for keyboard navigation */
.focusable-enhanced:focus-visible {
    outline: 2px solid #dc2626;
    outline-offset: 2px;
    border-radius: 4px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .product-card-enhanced,
    .btn-enhanced {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ==================== SAFE AREA SUPPORT ==================== */

@supports (padding: max(0px)) {
    .safe-area-inset-top {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    
    .safe-area-inset-bottom {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .safe-area-inset-left {
        padding-left: max(1rem, env(safe-area-inset-left));
    }
    
    .safe-area-inset-right {
        padding-right: max(1rem, env(safe-area-inset-right));
    }
}

/* ==================== PRINT STYLES ==================== */

@media print {
    .no-print {
        display: none !important;
    }
    
    .print-only {
        display: block !important;
    }
}

/* ==================== DARK MODE SUPPORT ==================== */

@media (prefers-color-scheme: dark) {
    .auto-dark {
        background-color: #1f2937;
        color: #f9fafb;
    }
    
    .auto-dark .bg-white {
        background-color: #374151;
    }
    
    .auto-dark .text-gray-900 {
        color: #f9fafb;
    }
    
    .auto-dark .border-gray-200 {
        border-color: #4b5563;
    }
}