/* Touch-Friendly Enhancements */

/* Larger tap targets for mobile */
@media (max-width: 768px) {
    .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1.25rem;
        font-size: 1rem;
    }
    
    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 0.75rem;
    }
    
    .nav-link {
        padding: 0.75rem 1rem;
    }
    
    /* Larger checkboxes and radio buttons */
    input[type="checkbox"],
    input[type="radio"] {
        width: 20px;
        height: 20px;
    }
    
    /* Touch ripple effect */
    .btn-touch {
        position: relative;
        overflow: hidden;
    }
    
    .btn-touch::after {
        content: '';
        position: absolute;
        top: 50%;
        left: 50%;
        width: 0;
        height: 0;
        border-radius: 50%;
        background: rgba(255, 255, 255, 0.5);
        transform: translate(-50%, -50%);
        transition: width 0.6s, height 0.6s;
    }
    
    .btn-touch:active::after {
        width: 300px;
        height: 300px;
    }
}

/* Pull to refresh indicator */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
    z-index: 1000;
}

.pull-to-refresh.active {
    transform: translateY(0);
}

/* Swipe gestures */
.swipeable {
    touch-action: pan-y;
}

/* Image optimization */
img {
    max-width: 100%;
    height: auto;
}

img[loading="lazy"] {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

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

/* Skeleton loading for cards */
.skeleton-card {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
    border-radius: 15px;
    height: 300px;
}

/* Better touch scrolling */
.touch-scroll {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
}

/* Prevent text selection on buttons */
.btn,
.card {
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Bottom navigation for mobile */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    padding: 0.5rem 0;
    z-index: 1000;
    display: none;
}

@media (max-width: 768px) {
    .bottom-nav {
        display: block;
    }
    
    main {
        padding-bottom: 70px;
    }
}

.bottom-nav-item {
    text-align: center;
    color: #6c757d;
    text-decoration: none;
    transition: all 0.3s ease;
}

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

.bottom-nav-item i {
    font-size: 1.5rem;
    display: block;
    margin-bottom: 0.25rem;
}

.bottom-nav-item small {
    font-size: 0.7rem;
    display: block;
}

/* Improved dropdown on mobile */
@media (max-width: 768px) {
    .dropdown-menu {
        position: fixed !important;
        top: auto !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 15px 15px 0 0 !important;
        margin: 0 !important;
        transform: none !important;
        box-shadow: 0 -5px 20px rgba(0,0,0,0.2) !important;
    }
}

/* Sticky header on scroll */
.navbar.scrolled {
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

/* Product card image aspect ratio */
.product-image {
    position: relative;
    width: 100%;
    padding-bottom: 75%; /* 4:3 aspect ratio */
    overflow: hidden;
    background: #f0f0f0;
}

.product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* WhatsApp floating button */
.whatsapp-float {
    position: fixed;
    width: 60px;
    height: 60px;
    bottom: 80px;
    right: 20px;
    background-color: #25D366;
    color: white;
    border-radius: 50%;
    text-align: center;
    font-size: 30px;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.3);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    text-decoration: none;
}

.whatsapp-float:hover {
    background-color: #128C7E;
    color: white;
    transform: scale(1.1);
}

/* Improved alerts for mobile */
@media (max-width: 768px) {
    .alert {
        border-radius: 10px;
        font-size: 0.9rem;
    }
}

/* Card stack effect */
.card-stack {
    position: relative;
}

.card-stack::before,
.card-stack::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 8px;
    right: 8px;
    height: 100%;
    background: #f8f9fa;
    border-radius: 15px;
    z-index: -1;
}

.card-stack::after {
    top: 16px;
    left: 16px;
    right: 16px;
    background: #e9ecef;
    z-index: -2;
}

/* Empty state illustrations */
.empty-state {
    padding: 3rem 1rem;
    text-align: center;
}

.empty-state i {
    font-size: 4rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

@media (max-width: 768px) {
    .empty-state i {
        font-size: 3rem;
    }
}

/* Loading dots animation */
.loading-dots::after {
    content: '.';
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Improved pagination for mobile */
@media (max-width: 768px) {
    .pagination {
        font-size: 0.875rem;
    }
    
    .page-link {
        padding: 0.5rem 0.75rem;
    }
}

/* Smooth transitions */
* {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

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