/* ===== Zoho Items – Card Layout (Dark) ===== */
.product-card-wrapper {
    margin: 10px 0;
    overflow-y: auto;
    position: relative;
}

.product-card-wrapper-inner {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.product-card {
    background: #0b0b0d;
    color: #fff;
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    transition: all 0.3s ease;
    animation: fadeIn 0.3s ease-out;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.logo-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: white;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.logo-wrapper img {
    max-width: 100% !important;
    max-height: 100% !important;
    display: block;
}

.exw-info .label {
    font-size: 11px;
    color: #cfcfd6;
    letter-spacing: 0.06em;
}

.exw-info .value {
    font-size: 13px;
    font-weight: 600;
    color: #ffffff;
}

.card-body {
    margin-top: 6px;
    margin-bottom: 8px;
}

.card-body p {
    line-height: 1.35;
    color: #f5f6fb;
    font-weight: 600;
    margin: 0;
}

.card-footer {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    align-items: start;
}

.footer-info .label {
    font-size: 11px;
    color: #cfcfd6;
}

.footer-info .value {
    margin-top: 3px;
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
}

.footer-info .value.small-text {
    font-size: 11px;
}

.no-items-message {
    text-align: center;
    color: #cfcfd6;
    padding: 20px;
    background: #0b0b0d;
    border-radius: 12px;
}

/* Scrollbar styling */
.product-card-wrapper::-webkit-scrollbar {
    width: 10px;
}

.product-card-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 5px;
}

.product-card-wrapper::-webkit-scrollbar-thumb {
    background-color: #888888;
    border-radius: 5px;
}

.product-card-wrapper::-webkit-scrollbar-thumb:hover {
    background-color: #555555;
}

.product-card-wrapper-inner .product-card:last-child {
    margin-bottom: 64px !important;
}

/* ===== MOBILE STATIC LAYOUT - NO ANIMATION, NO DUPLICATION ===== */
@media (max-width: 767px) {
    .zoho-grid-container {
        display: grid;
        height: auto !important;
        overflow: visible !important;
        grid-template-columns: 1fr !important;
        gap: 16px;
    }
    
    .grid-column {
        display: contents !important;
        -webkit-mask-image: none !important;
        mask-image: none !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    .grid-column-inner {
        display: contents !important;
        position: static !important;
        animation: none !important;
        transform: none !important;
    }
    
    .product-card {
        width: 100%;
        margin-bottom: 0;
    }
    
    /* Ensure proper grid layout for tablet */
    @media (min-width: 481px) and (max-width: 767px) {
        .zoho-grid-container {
            grid-template-columns: repeat(2, 1fr) !important;
        }
    }
    
    /* Remove all hover/pause effects on mobile */
    .grid-column:hover .grid-column-inner,
    .grid-column.paused .grid-column-inner {
        animation-play-state: running !important;
    }
    
    /* Better touch targets for mobile */
    .product-card {
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
        min-height: 120px;
    }
    
    .product-card:active {
        transform: scale(0.98);
        transition: transform 0.1s ease;
    }
    
    /* Auto-scroll container mobile fix */
    .product-card-wrapper {
        max-height: none !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    .product-card-wrapper-inner {
        display: grid;
        gap: 16px;
    }
}

/* ===== DESKTOP ANIMATED LAYOUT ===== */
@media (min-width: 768px) {
    .zoho-grid-container {
        display: grid;
        gap: 20px;
        position: relative;
        overflow: hidden;
        height: 90vh;
    }
    
    .grid-column {
        position: relative;
        height: 100%;
        overflow: hidden;
        -webkit-mask-image: linear-gradient(
            180deg,
            transparent 0,
            #fff 10%,
            #fff 90%,
            transparent 100%
        );
        mask-image: linear-gradient(
            180deg,
            transparent 0,
            #fff 10%,
            #fff 90%,
            transparent 100%
        );
    }
    
    .grid-column-inner {
        position: absolute;
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 16px;
        animation-duration: 800s;
        animation-timing-function: linear;
        animation-iteration-count: infinite;
        animation-name: scroll-up;
        will-change: transform;
        backface-visibility: hidden;
        perspective: 1000;
    }
    
    /* Scroll animation for desktop */
    @keyframes scroll-up {
        0% {
            transform: translateY(0);
        }
        100% {
            transform: translateY(-50%);
        }
    }
    
    /* Pause on hover for desktop */
    .grid-column:hover .grid-column-inner {
        animation-play-state: paused;
    }
}

/* ===== RESPONSIVE BREAKPOINTS ===== */
@media (max-width: 1024px) {
    .zoho-grid-container {
        height: 500px;
        gap: 18px;
    }
    
    .grid-column-inner {
        gap: 14px;
    }
}

@media (max-width: 767px) {
    .zoho-grid-container {
        height: 400px;
        gap: 15px;
    }
    
    .grid-column-inner {
        gap: 12px;
    }
    
    .product-card {
        padding: 12px;
    }
    
    .card-footer {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .footer-info .value {
        font-size: 14px;
    }
    
    /* Mobile single column enhancement */
    .zoho-grid-container[style*="grid-template-columns: repeat(1, 1fr)"] {
        height: 500px;
    }
}

@media (max-width: 480px) {
    .zoho-grid-container {
        height: 400px;
        gap: 12px;
    }
    
    .product-card {
        padding: 10px;
    }
    
    .card-header {
        flex-direction: row;
        align-items: flex-start;
        gap: 8px;
    }
    
    .grid-column-inner {
        gap: 10px;
    }
    
    .card-footer {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }
    
    .footer-info .value {
        font-size: 13px;
    }
    
    .footer-info .value.small-text {
        font-size: 10px;
    }
}

/* ===== ENHANCEMENTS & FIXES ===== */
.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

/* Hide the old table styles if any render elsewhere on the page */
.zoho-items-table-container, .zoho-items-table {
    display: none !important;
}

/* Loading state */
.product-card-wrapper.loading,
.zoho-grid-container.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.product-card-wrapper.loading::after,
.zoho-grid-container.loading::after {
    content: "Loading...";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #cfcfd6;
    font-size: 14px;
    background: #0b0b0d;
    padding: 10px 20px;
    border-radius: 8px;
    z-index: 10;
}

/* Ensure Elementor editor works properly */
.elementor-editor-active .zoho-grid-container,
.elementor-editor-active .product-card-wrapper {
    min-height: 200px;
}

.elementor-editor-active .zoho-grid-container:empty::before,
.elementor-editor-active .product-card-wrapper:empty::before {
    content: "Zoho Order Items - Loading...";
    display: block;
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Ensure smooth scrolling on iOS */
.product-card-wrapper {
    -webkit-overflow-scrolling: touch;
}

/* Better performance for animations */
.grid-column-inner {
    will-change: transform;
    backface-visibility: hidden;
}

/* High-resolution displays */
@media (min-resolution: 192dpi) {
    .product-card {
        box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .product-card {
        transition: none;
    }
    
    .grid-column-inner {
        transition: none;
        animation: none !important;
    }
    
    .grid-column.paused .grid-column-inner {
        transition: none;
    }
}

/* Dark mode adjustments */
@media (prefers-color-scheme: dark) {
    .product-card-wrapper::-webkit-scrollbar-track {
        background: #2a2a2e;
    }
    
    .product-card-wrapper::-webkit-scrollbar-thumb {
        background-color: #555555;
    }
    
    .product-card-wrapper::-webkit-scrollbar-thumb:hover {
        background-color: #777777;
    }
}

/* Print styles */
@media print {
    .product-card {
        background: white !important;
        color: black !important;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
    
    .zoho-grid-container {
        height: auto !important;
        overflow: visible !important;
    }
    
    .grid-column {
        -webkit-mask-image: none !important;
        mask-image: none !important;
        height: auto !important;
    }
    
    .grid-column-inner {
        position: static !important;
        transform: none !important;
        animation: none !important;
    }
}

/* Focus styles for accessibility */
.product-card:focus-within {
    outline: 2px solid #4d90fe;
    outline-offset: 2px;
}

.logo-wrapper:focus,
.exw-info:focus {
    outline: none;
}

/* Animation improvements */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Grid column animations */
.grid-column:nth-child(odd) .product-card {
    animation-delay: 0.1s;
}

.grid-column:nth-child(even) .product-card {
    animation-delay: 0.2s;
}

/* Dynamic column handling */
.zoho-grid-container .grid-column {
    min-width: 0;
}

/* Prevent initial flash */
.zoho-grid-container:not(.loading) {
    opacity: 1;
    transition: opacity 0.3s ease;
}

.zoho-grid-container.loading {
    opacity: 0.7;
}

/* Ensure NO empty columns */
.zoho-grid-container:not(:has(.grid-column)) .no-items-message {
    display: block;
}

/* Hide grid columns if they're empty */
.grid-column:empty {
    display: none !important;
}