/**
 * Customer Frontend - Enhanced Responsive Design
 * Complete UI/UX improvements for customer-facing pages
 * Mobile-first approach for better shopping experience
 */

/* ==================== CUSTOMER PAGE ENHANCEMENTS ==================== */

/* Improved Header for Mobile */
@media (max-width: 768px) {
    .customer-header {
        padding: 0.75rem !important;
    }
    
    .customer-header .logo-text {
        font-size: 1.25rem !important;
    }
    
    .customer-header .tagline {
        display: none;
    }
    
    .customer-header .header-actions {
        gap: 0.5rem !important;
    }
    
    .customer-header .header-btn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.875rem !important;
    }
    
    .customer-header .header-btn span {
        display: none;
    }
    
    .customer-header .header-btn i {
        margin-right: 0 !important;
    }
}

/* Customer Account Sidebar - Mobile */
.customer-sidebar > div {
    height: 100%;
    overflow-y: auto;
}

@media (max-width: 1023px) {
    .customer-sidebar {
        position: fixed !important;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
        max-width: 280px;
        width: 80%;
        background: white;
    }
    
    .customer-sidebar.active {
        transform: translateX(0);
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
    }
    
    .customer-sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(4px);
        z-index: 998;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }
    
    .customer-sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
    
    /* Mobile menu button for customer pages */
    .customer-menu-btn {
        position: fixed;
        bottom: 1.5rem;
        left: 1.5rem;
        z-index: 900;
        width: 3.5rem;
        height: 3.5rem;
        border-radius: 50%;
        background: linear-gradient(135deg, #dc2626, #ea580c);
        color: white;
        box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.3);
        border: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        transition: all 0.3s ease;
    }
    
    .customer-menu-btn:hover {
        transform: scale(1.1);
        box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.4);
    }
    
    .customer-menu-btn::before {
        content: '';
        position: absolute;
        inset: -2px;
        border-radius: 50%;
        background: linear-gradient(135deg, #dc2626, #ea580c);
        opacity: 0.3;
        animation: pulse-ring 2s infinite;
    }
}

/* Desktop - hide mobile menu */
@media (min-width: 1024px) {
    .customer-menu-btn {
        display: none !important;
    }
    
    .customer-sidebar-overlay {
        display: none !important;
    }
}

/* ==================== ORDER PAGE ENHANCEMENTS ==================== */

/* Product Cards - Better Mobile Display */
.product-card {
    transition: all 0.3s ease;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

@media (max-width: 768px) {
    .product-card {
        display: flex;
        flex-direction: row;
        align-items: center;
        padding: 0.75rem;
    }
    
    .product-card .product-image {
        width: 80px !important;
        height: 80px !important;
        flex-shrink: 0;
        margin-right: 1rem;
    }
    
    .product-card .product-info {
        flex: 1;
    }
    
    .product-card .product-title {
        font-size: 0.9375rem !important;
        line-height: 1.3 !important;
    }
    
    .product-card .product-description {
        font-size: 0.75rem !important;
        line-height: 1.2 !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    
    .product-card .product-price {
        font-size: 1.125rem !important;
    }
    
    .product-card .add-to-cart-btn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
    }
}

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

/* Sticky Cart Button on Mobile */
@media (max-width: 768px) {
    .mobile-cart-sticky {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 1rem;
        box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.1);
        z-index: 800;
        border-top: 2px solid #dc2626;
    }
    
    .mobile-cart-sticky .cart-summary {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 0.75rem;
    }
    
    .mobile-cart-sticky .cart-total {
        font-size: 1.25rem;
        font-weight: 700;
        color: #dc2626;
    }
    
    .mobile-cart-sticky .cart-items-count {
        font-size: 0.875rem;
        color: #6b7280;
    }
    
    .mobile-cart-sticky .checkout-btn {
        width: 100%;
        padding: 0.875rem;
        font-size: 1rem;
        font-weight: 600;
    }
}

/* Cart Sidebar - Better Mobile Experience */
@media (max-width: 768px) {
    .cart-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 1000;
    }
    
    .cart-sidebar.active {
        transform: translateX(0);
    }
    
    .cart-sidebar .cart-header {
        padding: 1rem;
        border-bottom: 2px solid #e5e7eb;
    }
    
    .cart-sidebar .cart-items {
        max-height: calc(100vh - 250px);
        overflow-y: auto;
        padding: 1rem;
    }
    
    .cart-sidebar .cart-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 1rem;
        box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 0.1);
    }
}

/* ==================== CATEGORY FILTERS - MOBILE ==================== */

@media (max-width: 768px) {
    .category-filters {
        display: flex;
        overflow-x: auto;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        background: white;
        box-shadow: 0 2px 4px rgb(0 0 0 / 0.1);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .category-filters::-webkit-scrollbar {
        display: none;
    }
    
    .category-filter-btn {
        flex-shrink: 0;
        padding: 0.5rem 1rem;
        border-radius: 9999px;
        font-size: 0.875rem;
        font-weight: 500;
        border: 2px solid #e5e7eb;
        background: white;
        color: #6b7280;
        transition: all 0.2s ease;
        white-space: nowrap;
    }
    
    .category-filter-btn.active {
        background: linear-gradient(135deg, #dc2626, #ea580c);
        color: white;
        border-color: transparent;
    }
    
    .category-filter-btn:active {
        transform: scale(0.95);
    }
}

/* ==================== SEARCH BAR - MOBILE ==================== */

@media (max-width: 768px) {
    .search-bar {
        position: sticky;
        top: 0;
        z-index: 700;
        padding: 0.75rem 1rem;
        background: white;
        box-shadow: 0 2px 4px rgb(0 0 0 / 0.1);
    }
    
    .search-input {
        width: 100%;
        padding: 0.75rem 1rem 0.75rem 2.5rem;
        border: 2px solid #e5e7eb;
        border-radius: 9999px;
        font-size: 0.9375rem;
    }
    
    .search-input:focus {
        outline: none;
        border-color: #dc2626;
        box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
    }
    
    .search-icon {
        position: absolute;
        left: 1.75rem;
        top: 50%;
        transform: translateY(-50%);
        color: #9ca3af;
    }
}

/* ==================== ORDER STATUS TRACKER ==================== */

.order-tracker {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    padding: 2rem 0;
}

.order-tracker::before {
    content: '';
    position: absolute;
    top: 2.5rem;
    left: 10%;
    right: 10%;
    height: 2px;
    background: #e5e7eb;
    z-index: 0;
}

.tracker-step {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    z-index: 1;
}

.tracker-step-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: #f3f4f6;
    border: 3px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.tracker-step.active .tracker-step-icon {
    background: linear-gradient(135deg, #dc2626, #ea580c);
    border-color: #dc2626;
    color: white;
}

.tracker-step.completed .tracker-step-icon {
    background: #10b981;
    border-color: #10b981;
    color: white;
}

.tracker-step-label {
    font-size: 0.75rem;
    color: #6b7280;
    text-align: center;
    font-weight: 500;
}

.tracker-step.active .tracker-step-label {
    color: #dc2626;
    font-weight: 600;
}

@media (max-width: 768px) {
    .order-tracker {
        flex-wrap: wrap;
        gap: 1rem;
    }
    
    .tracker-step {
        flex-basis: calc(33.333% - 0.75rem);
    }
    
    .tracker-step-icon {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
    }
    
    .tracker-step-label {
        font-size: 0.625rem;
    }
}

/* ==================== QUICK VIEW MODAL - MOBILE ==================== */

@media (max-width: 768px) {
    .quick-view-modal {
        padding: 0 !important;
    }
    
    .quick-view-modal .modal-content {
        max-width: 100%;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    
    .quick-view-modal .product-image-gallery {
        height: 50vh;
    }
    
    .quick-view-modal .product-details {
        max-height: 50vh;
        overflow-y: auto;
    }
}

/* ==================== LOADING STATES - CUSTOMER PAGES ==================== */

.product-loading {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
}

.product-skeleton {
    display: flex;
    gap: 1rem;
    background: white;
    padding: 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgb(0 0 0 / 0.1);
}

.product-skeleton-image {
    width: 80px;
    height: 80px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
    flex-shrink: 0;
}

.product-skeleton-content {
    flex: 1;
}

.product-skeleton-line {
    height: 1rem;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.25rem;
    margin-bottom: 0.5rem;
}

.product-skeleton-line.short {
    width: 60%;
}

.product-skeleton-line.medium {
    width: 80%;
}

/* ==================== TOUCH INTERACTIONS ==================== */

@media (hover: none) and (pointer: coarse) {
    /* Remove hover effects on touch devices */
    .product-card:hover {
        transform: none;
    }
    
    /* Add active state for touch */
    .product-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    button:active,
    .btn-enhanced:active {
        transform: scale(0.95);
    }
    
    /* Larger tap targets */
    .touch-target {
        min-height: 44px;
        min-width: 44px;
    }
}

/* ==================== SMOOTH SCROLLING ==================== */

html {
    scroll-behavior: smooth;
}

/* Hide scrollbar but keep functionality */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* ==================== SAFE AREA FOR NOTCH DEVICES ==================== */

@supports (padding-top: env(safe-area-inset-top)) {
    .customer-header {
        padding-top: calc(1rem + env(safe-area-inset-top));
    }
    
    .mobile-cart-sticky {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    }
}

/* ==================== CUSTOMER RESPONSIVE UTILITIES ==================== */

/* Container adjustments */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
}

/* Grid adjustments for products */
@media (max-width: 640px) {
    .product-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }
}

@media (min-width: 641px) and (max-width: 1024px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }
}

@media (min-width: 1025px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 1.5rem !important;
    }
}

/* ==================== ANIMATIONS ==================== */

@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.animate-slide-up {
    animation: slideInUp 0.3s ease-out;
}

.animate-slide-right {
    animation: slideInRight 0.3s ease-out;
}

.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}

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

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

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

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