/* ===================================
   KINTA LOJA - OTIMIZAÇÕES MOBILE E PWA
   =================================== */

/* Touch-friendly interactions */
@media (max-width: 768px) {
    /* Aumentar área de toque para botões */
    .btn-highlight,
    .btn-apply,
    .btn-clear,
    .btn-add-cart,
    .btn-quick-view,
    .page-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 12px 20px;
    }

    /* Melhorar usabilidade dos filtros */
    .filter-select,
    .search-box input {
        min-height: 48px;
        font-size: 16px; /* Evita zoom no iOS */
        padding: 15px;
    }

    /* Cards de produto otimizados para toque */
    .product-card {
        margin-bottom: 20px;
        border-radius: 12px;
        overflow: hidden;
    }

    .product-image-container {
        height: 200px;
        position: relative;
    }

    /* Overlay sempre visível no mobile */
    .product-overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
        align-items: flex-end;
        padding: 20px;
    }

    .btn-quick-view {
        transform: translateY(0);
        background: rgba(255,255,255,0.9);
        backdrop-filter: blur(10px);
        border-radius: 20px;
        font-size: 14px;
        padding: 8px 16px;
    }

    /* Informações do produto mais compactas */
    .product-info {
        padding: 15px;
    }

    .product-name {
        font-size: 1.1rem;
        line-height: 1.3;
        margin-bottom: 8px;
    }

    .product-rating {
        margin-bottom: 8px;
    }

    .product-producer,
    .product-location {
        font-size: 0.85rem;
        margin-bottom: 6px;
    }

    .product-price {
        margin: 12px 0;
    }

    .current-price {
        font-size: 1.2rem;
    }

    /* Botão de adicionar ao carrinho mais proeminente */
    .btn-add-cart {
        font-size: 1rem;
        padding: 14px;
        border-radius: 10px;
        font-weight: 700;
    }
}

/* Otimizações para telas muito pequenas */
@media (max-width: 360px) {
    .container {
        padding: 0 10px;
    }

    .hero-title {
        font-size: 1.6rem;
    }

    .highlight-card {
        padding: 15px;
    }

    .filters-grid {
        gap: 10px;
    }

    .filter-actions {
        gap: 10px;
    }

    .products-grid {
        gap: 15px;
    }

    .product-card {
        border-radius: 8px;
    }

    .product-info {
        padding: 12px;
    }
}

/* Otimizações para tablets */
@media (min-width: 769px) and (max-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 25px;
    }

    .filters-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .hero-highlights {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Melhorias de performance */
.product-image {
    will-change: transform;
    backface-visibility: hidden;
}

.product-card {
    will-change: transform;
    backface-visibility: hidden;
}

/* Lazy loading para imagens */
.product-image[data-src] {
    opacity: 0;
    transition: opacity 0.3s;
}

.product-image.loaded {
    opacity: 1;
}

/* Skeleton loading para produtos */
.product-skeleton {
    background: #f0f0f0;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
}

.product-skeleton::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    animation: skeleton-loading 1.5s infinite;
}

@keyframes skeleton-loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

.skeleton-image {
    height: 220px;
    background: #e0e0e0;
}

.skeleton-content {
    padding: 20px;
}

.skeleton-line {
    height: 16px;
    background: #e0e0e0;
    border-radius: 4px;
    margin-bottom: 10px;
}

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

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

/* Otimizações de scroll */
.kinta-loja-container {
    scroll-behavior: smooth;
}

/* Infinite scroll indicator */
.infinite-scroll-indicator {
    text-align: center;
    padding: 40px 20px;
    display: none;
}

.infinite-scroll-indicator.active {
    display: block;
}

.scroll-spinner {
    width: 30px;
    height: 30px;
    border: 3px solid #f0f0f0;
    border-top: 3px solid #8BC34A;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

/* Sticky filters no mobile */
@media (max-width: 768px) {
    .kinta-filters-section.sticky {
        position: sticky;
        top: 0;
        z-index: 100;
        background: white;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        margin-bottom: 20px;
    }

    .filters-wrapper.collapsed {
        max-height: 60px;
        overflow: hidden;
        transition: max-height 0.3s ease;
    }

    .filters-wrapper.expanded {
        max-height: 500px;
        transition: max-height 0.3s ease;
    }

    .filters-toggle {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 15px 0;
        cursor: pointer;
        border-bottom: 1px solid #f0f0f0;
    }

    .filters-toggle h3 {
        margin: 0;
        font-size: 1.1rem;
        color: #2c5530;
    }

    .filters-toggle-icon {
        font-size: 1.2rem;
        transition: transform 0.3s ease;
    }

    .filters-wrapper.expanded .filters-toggle-icon {
        transform: rotate(180deg);
    }
}

/* Swipe gestures para produtos */
.product-card.swipe-enabled {
    touch-action: pan-y;
    position: relative;
}

.product-card.swiping {
    transition: none;
}

.product-card.swipe-left {
    transform: translateX(-100px);
}

.product-card.swipe-right {
    transform: translateX(100px);
}

/* Quick actions no swipe */
.swipe-actions {
    position: absolute;
    top: 0;
    right: -100px;
    width: 100px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #8BC34A;
    z-index: 1;
}

.swipe-action {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: background 0.2s;
}

.swipe-action:hover {
    background: #689F38;
}

.swipe-action.favorite {
    background: #ff6b6b;
}

.swipe-action.cart {
    background: #8BC34A;
}

/* Pull to refresh */
.pull-to-refresh {
    position: relative;
    overflow: hidden;
}

.pull-indicator {
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: top 0.3s ease;
}

.pull-indicator.active {
    top: 20px;
}

.pull-icon {
    font-size: 1.2rem;
    color: #8BC34A;
    transition: transform 0.3s ease;
}

.pull-indicator.loading .pull-icon {
    animation: spin 1s linear infinite;
}

/* Otimizações para PWA */
@media (display-mode: standalone) {
    /* Ajustes para quando a página é aberta como PWA */
    .kinta-loja-hero {
        padding-top: 80px; /* Compensar status bar */
    }

    /* Adicionar padding para safe areas */
    .container {
        padding-left: max(20px, env(safe-area-inset-left));
        padding-right: max(20px, env(safe-area-inset-right));
    }

    .kinta-loja-hero {
        padding-top: max(60px, env(safe-area-inset-top) + 60px);
    }

    /* Ajustar modal para PWA */
    .modal-content {
        margin-top: max(20px, env(safe-area-inset-top));
        margin-bottom: max(20px, env(safe-area-inset-bottom));
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .kinta-loja-container {
        background: #1a1a1a;
        color: #ffffff;
    }

    .kinta-loja-hero {
        background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
    }

    .hero-title {
        color: #ffffff;
    }

    .hero-subtitle {
        color: #cccccc;
    }

    .highlight-card {
        background: #2a2a2a;
        border-color: #444444;
    }

    .kinta-filters-section {
        background: #2a2a2a;
        border-color: #444444;
    }

    .filter-select,
    .search-box input {
        background: #333333;
        border-color: #555555;
        color: #ffffff;
    }

    .product-card {
        background: #2a2a2a;
        border-color: #444444;
    }

    .product-name {
        color: #ffffff;
    }

    .modal-content {
        background: #2a2a2a;
    }
}

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

    .loading-spinner,
    .scroll-spinner {
        animation: none;
        border: 3px solid #8BC34A;
    }

    .title-icon {
        animation: none;
    }
}

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

    .btn-highlight,
    .btn-apply,
    .btn-add-cart {
        border: 2px solid #000000;
    }

    .filter-select,
    .search-box input {
        border: 2px solid #000000;
    }
}

/* Print styles */
@media print {
    .kinta-filters-section,
    .products-pagination,
    .btn-add-cart,
    .btn-quick-view,
    .product-overlay {
        display: none !important;
    }

    .product-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000000;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

/* Accessibility improvements */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus indicators */
.product-card:focus-within {
    outline: 2px solid #8BC34A;
    outline-offset: 2px;
}

/* Skip links */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #8BC34A;
    color: white;
    padding: 8px;
    text-decoration: none;
    border-radius: 4px;
    z-index: 10000;
}

.skip-link:focus {
    top: 6px;
}

/* Loading states */
.loading-state {
    pointer-events: none;
    opacity: 0.6;
    position: relative;
}

.loading-state::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f0f0f0;
    border-top: 2px solid #8BC34A;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1;
}

/* Error states */
.error-state {
    text-align: center;
    padding: 40px 20px;
    color: #ff6b6b;
}

.error-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.error-message {
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.retry-button {
    background: #ff6b6b;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.retry-button:hover {
    background: #ff5252;
    transform: translateY(-2px);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-message {
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.empty-suggestion {
    font-size: 1rem;
    color: #999;
}

/* Network status indicator */
.network-status {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #ff6b6b;
    color: white;
    text-align: center;
    padding: 10px;
    z-index: 10000;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.network-status.offline {
    transform: translateY(0);
}

.network-status.online {
    background: #8BC34A;
    transform: translateY(0);
}

/* Performance optimizations */
.product-image {
    content-visibility: auto;
    contain-intrinsic-size: 220px;
}

.product-card {
    contain: layout style paint;
}

/* Intersection observer loading */
.lazy-load {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.lazy-load.loaded {
    opacity: 1;
    transform: translateY(0);
}

