/**
 * Table Layout Styles for Product Display
 * 
 * This file contains styles specific to the table layout.
 * The main wcps-styles.scss is loaded as default for all layouts.
 * 
 * @package Product_Display
 */

// Table layout specific styles will be added here
// Currently empty - styles will be moved from wcps-styles.scss as needed
// Breakpoints
$breakpoint-xs: 480px;
$breakpoint-sm: 576px;
$breakpoint-md: 768px;
$breakpoint-lg: 992px;
$breakpoint-xl: 1200px;

/* -------------- WCPS layout TABLE wcps-layout-table -------------- */
// Feature Matrix  
.wcps-container {
    background: var(--wcps-container-background, #ffffff3b);
    padding: var(--wcps-container-padding, 25px);
    margin: var(--wcps-container-margin, 0px);

    // Feature Matrix  
    &.wcps-layout-table {
        margin: 30px 0;
        position: relative;

        .wcps-products-container {
            background: var(--wcps-container-background, #ffffff3b);
            padding: var(--wcps-container-padding, 25px);
            margin: var(--wcps-container-margin, 0px);
        }



        .wcps-table-container {
            background: var(--wcps-container-background, #ffffff3b);
            padding: var(--wcps-container-padding, 25px);
            margin: var(--wcps-container-margin, 0px);
            border-radius: var(--wcps-border-radius);

            // Dynamic box shadow based on selection
            @if var(--wcps-box-shadow)=="none" {
                box-shadow: none;
            }

            @else if var(--wcps-box-shadow)=="light" {
                box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
            }

            @else if var(--wcps-box-shadow)=="medium" {
                box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
            }

            @else if var(--wcps-box-shadow)=="heavy" {
                box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
            }

            @else {
                box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1); // Default
            }

            // Dynamic border style
            @if var(--wcps-border-style) !="none" {
                border: var(--wcps-border-width) var(--wcps-border-style) var(--wcps-border-color);
            }

            overflow-x: auto; // Enable horizontal scrolling
            cursor: grab; // Show grab cursor for drag scrolling
            user-select: none; // Prevent text selection while dragging

            &:active {
                cursor: grabbing; // Show grabbing cursor when dragging
            }

            &.active-drag {
                cursor: grabbing;
                user-select: none;

                * {
                    cursor: grabbing !important;
                }
            }

            .wcps-table-controls {
                margin-bottom: 15px;
                display: flex;
                justify-content: space-between;
                align-items: center;
                flex-wrap: wrap;
                gap: 10px;

                .dataTables_filter {
                    input {
                        padding: 10px 12px;
                        border: 1px solid #ddd;
                        border-radius: var(--wcps-border-radius);
                        outline: none;
                        width: 100%;
                        max-width: 250px;

                        &:focus {
                            border-color: var(--wcps-product-title);
                            box-shadow: 0 0 0 2px rgba(var(--wcps-product-title), 0.1);
                        }
                    }
                }

                .dataTables_length {
                    select {
                        padding: 10px 12px;
                        border: 1px solid #ddd;
                        border-radius: var(--wcps-border-radius);
                        margin: 0 5px;
                        cursor: pointer;
                    }
                }
            }

            .wcps-table {
                width: 100%;
                border-collapse: separate;
                border-spacing: 0;
                min-width: 800px; // Ensures table doesn't compress too much
                text-align: var(--wcps-text-align);

                thead {
                    tr {
                        th {
                            background-color: var(--wcps-product-title);
                            color: white;
                            font-weight: 600;
                            padding: 14px 16px;
                            text-align: left;
                            border-bottom: 2px solid #ebebeb;
                            position: relative;
                            white-space: nowrap;

                            &:first-child {
                                border-top-left-radius: var(--wcps-border-radius);
                            }

                            &:last-child {
                                border-top-right-radius: var(--wcps-border-radius);
                            }

                            &.sorting_asc,
                            &.sorting_desc {
                                &:after {
                                    content: '';
                                    position: absolute;
                                    right: 8px;
                                    top: 50%;
                                    transform: translateY(-50%);
                                    width: 0;
                                    height: 0;
                                    border-left: 5px solid transparent;
                                    border-right: 5px solid transparent;
                                }
                            }

                            &.sorting_asc:after {
                                border-bottom: 5px solid white;
                            }

                            &.sorting_desc:after {
                                border-top: 5px solid white;
                            }
                        }
                    }
                }

                tbody {
                    tr {
                        transition: all var(--wcps-hover-transition);

                        // Dynamic hover effects
                        &:hover {
                            @if var(--wcps-hover-effect)=="none" {
                                // No hover effect
                            }

                            @else if var(--wcps-hover-effect)=="lift" {
                                transform: translateY(-2px);
                                box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
                            }

                            @else if var(--wcps-hover-effect)=="shadow" {
                                box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
                            }

                            @else if var(--wcps-hover-effect)=="zoom" {
                                transform: scale(1.02);
                            }

                            @else if var(--wcps-hover-effect)=="glow" {
                                box-shadow: 0 0 15px rgba(var(--wcps-product-title), 0.2);
                            }

                            @else {
                                background-color: #ebebeb;
                            }
                        }

                        td {
                            padding: 16px;
                            border-bottom: 1px solid #e0e0e0;
                            vertical-align: middle;

                            &.wcps-product-title-col {
                                min-width: 220px;
                                max-width: 300px;

                                a {
                                    display: block;
                                    color: var(--wcps-price-delete-font-color);
                                    text-decoration: none;
                                    font-weight: var(--wcps-title-weight);
                                    font-size: var(--wcps-title-size);
                                    margin-bottom: 5px;
                                    transition: color 0.2s;

                                    &:hover {
                                        color: var(--wcps-product-title);
                                    }
                                }

                                .wcps-product-excerpt {
                                    font-size: var(--wcps-desc-size);
                                    color: var(--wcps-description-color);
                                    line-height: 1.5;
                                    margin-top: 8px;
                                    display: -webkit-box;
                                    -webkit-line-clamp: 2;
                                    -webkit-box-orient: vertical;
                                    overflow: hidden;
                                    text-overflow: ellipsis;
                                }
                            }

                            &.wcps-product-image-col {
                                width: 250px;
                                min-width: 250px;
                                text-align: center;
                                padding: 12px;

                                a {
                                    display: block;
                                }

                                img {
                                    border-radius: var(--wcps-image-border-radius);
                                    transition: transform 0.3s;
                                    max-height: 180px;
                                    width: 100%;
                                    height: auto;
                                    object-fit: contain;
                                    display: block;
                                    margin: 0 auto;

                                    // Apply aspect ratio if not auto
                                    @if var(--wcps-image-aspect-ratio) !="auto" {
                                        aspect-ratio: var(--wcps-image-aspect-ratio);
                                        object-fit: cover;
                                        height: 180px;
                                    }

                                    @else {
                                        object-fit: contain; // Contain the image without cropping
                                    }

                                    // Image hover effects
                                    @if var(--wcps-image-hover-effect)=="zoom" {
                                        &:hover {
                                            transform: scale(1.05);
                                        }
                                    }

                                    @else if var(--wcps-image-hover-effect)=="fade" {
                                        &:hover {
                                            opacity: 0.8;
                                        }
                                    }

                                    @else if var(--wcps-image-hover-effect)=="blur" {
                                        &:hover {
                                            filter: blur(1px);
                                        }
                                    }
                                }
                            }

                            &.wcps-product-price-col {
                                white-space: nowrap;

                                .woocommerce-Price-amount {
                                    font-weight: var(--wcps-price-font-weight);
                                    color: var(--wcps-price-font-color);
                                    font-size: var(--wcps-price-font-size);
                                }

                                del {
                                    .woocommerce-Price-amount {
                                        color: var(--wcps-price-delete-font-color);
                                        font-weight: normal;
                                        font-size: calc(var(--wcps-price-font-size) * 0.9);
                                        text-decoration: line-through;
                                    }
                                }

                                ins {
                                    text-decoration: none;
                                }
                            }

                            &.wcps-product-rating-col {
                                .star-rating {
                                    color: var(--wcps-star-color);
                                    font-size: 0.9em;
                                }
                            }

                            &.wcps-product-stock-col {
                                white-space: nowrap;

                                .wcps-in-stock {
                                    color: #48A85F;
                                    font-weight: 600;
                                    display: flex;
                                    align-items: center;

                                    &:before {
                                        content: "";
                                        display: inline-block;
                                        width: 8px;
                                        height: 8px;
                                        background-color: #48A85F;
                                        border-radius: 50%;
                                        margin-right: 6px;
                                    }
                                }

                                .wcps-out-of-stock {
                                    color: #E74C3C;
                                    font-weight: 600;
                                    display: flex;
                                    align-items: center;

                                    &:before {
                                        content: "";
                                        display: inline-block;
                                        width: 8px;
                                        height: 8px;
                                        background-color: #E74C3C;
                                        border-radius: 50%;
                                        margin-right: 6px;
                                    }
                                }
                            }

                            &.wcps-product-actions-col {
                                min-width: 170px;

                                .wcps-product-actions {
                                    display: flex;
                                    flex-wrap: wrap;
                                    gap: 8px;
                                    justify-content: flex-start;
                                    flex-direction: column;

                                    @if var(--wcps-text-align)=="center" {
                                        justify-content: center;
                                    }

                                    @else if var(--wcps-text-align)=="right" {
                                        justify-content: flex-end;
                                    }

                                    a {
                                        display: inline-flex;
                                        align-items: center;
                                        justify-content: center;
                                        padding: 8px 10px;
                                        background: linear-gradient(135deg, var(--wcps-button-bg-color) 0%, rgba(var(--wcps-button-bg-color), 0.8) 100%);
                                        color: var(--wcps-button-text-color);
                                        font-size: 12px;
                                        font-weight: 600;
                                        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
                                        white-space: nowrap;
                                        min-width: 35px;
                                        position: relative;
                                        overflow: hidden;
                                        border: none;
                                        text-decoration: none;
                                        letter-spacing: 0.5px;
                                        gap: 3px;

                                        // Modern button styles with enhanced effects
                                        @if var(--wcps-button-style)=="default" {
                                            border-radius: 8px;
                                            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
                                        }

                                        @else if var(--wcps-button-style)=="rounded" {
                                            border-radius: var(--wcps-button-border-radius);
                                            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
                                        }

                                        @else if var(--wcps-button-style)=="pill" {
                                            border-radius: 50px;
                                            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
                                        }

                                        @else if var(--wcps-button-style)=="minimal" {
                                            border-radius: 0;
                                            background: transparent;
                                            border-bottom: 3px solid var(--wcps-button-bg-color);
                                            box-shadow: none;
                                        }

                                        @else {
                                            border-radius: 8px;
                                            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
                                        }

                                        // Add subtle border for better definition
                                        border: 1px solid rgba(255, 255, 255, 0.2);

                                        // Enhanced hover effects
                                        &:hover {
                                            background: linear-gradient(135deg, var(--wcps-button-hover-bg) 0%, rgba(var(--wcps-button-hover-bg), 0.9) 100%);
                                            color: var(--wcps-button-hover-text-color);
                                            transform: translateY(-3px);
                                            box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2), 0 4px 8px rgba(0, 0, 0, 0.15);

                                            // Button hover animations with enhanced effects
                                            @if var(--wcps-button-animation)=="scale" {
                                                transform: translateY(-3px) scale(1.05);
                                            }

                                            @else if var(--wcps-button-animation)=="pulse" {
                                                animation: enhanced-pulse 1.5s infinite;
                                            }

                                            @else if var(--wcps-button-animation)=="fade" {
                                                opacity: 0.95;
                                                transform: translateY(-3px);
                                            }

                                            @else {
                                                transform: translateY(-3px);
                                            }

                                            // Add glow effect on hover
                                            &::before {
                                                content: '';
                                                position: absolute;
                                                top: 0;
                                                left: -100%;
                                                width: 100%;
                                                height: 100%;
                                                background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
                                                transition: left 0.5s;
                                            }

                                            &:hover::before {
                                                left: 100%;
                                            }
                                        }

                                        // Active state for better feedback
                                        &:active {
                                            transform: translateY(-1px);
                                            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
                                            transition: all 0.1s;
                                        }

                                        // Focus state for accessibility
                                        &:focus {
                                            outline: none;
                                            box-shadow: 0 0 0 3px rgba(var(--wcps-button-bg-color), 0.3), 0 4px 12px rgba(0, 0, 0, 0.15);
                                        }

                                        .wcps-icon {
                                            margin-right: 6px;
                                            font-size: 1.1em;
                                            transition: transform 0.3s ease;
                                        }

                                        .wcps-text {
                                            font-weight: 600;
                                            text-transform: uppercase;
                                            font-size: 0.8em;
                                            letter-spacing: 0.5px;
                                        }

                                        // Specific button type enhancements
                                        &.wcps-add-to-cart {
                                            background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
                                            color: white;
                                            border-color: rgba(255, 255, 255, 0.3);

                                            &:hover {
                                                background: linear-gradient(135deg, #218838 0%, #1ea085 100%);
                                                box-shadow: 0 8px 25px rgba(40, 167, 69, 0.3);
                                            }
                                        }

                                        &.wcps-quickview {
                                            background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
                                            color: white;
                                            border-color: rgba(255, 255, 255, 0.3);

                                            &:hover {
                                                background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
                                                box-shadow: 0 8px 25px rgba(0, 123, 255, 0.3);
                                            }
                                        }

                                        &.wcps-wishlist {
                                            background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
                                            color: white;
                                            border-color: rgba(255, 255, 255, 0.3);

                                            &:hover {
                                                background: linear-gradient(135deg, #c82333 0%, #a71e2a 100%);
                                                box-shadow: 0 8px 25px rgba(220, 53, 69, 0.3);
                                            }
                                        }

                                        &.wcps-compare {
                                            background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%);
                                            color: #212529;
                                            border-color: rgba(255, 255, 255, 0.3);

                                            &:hover {
                                                background: linear-gradient(135deg, #e0a800 0%, #d39e00 100%);
                                                box-shadow: 0 8px 25px rgba(255, 193, 7, 0.3);
                                            }
                                        }
                                    }

                                    // Enhanced hover mode for action buttons
                                    &.wcps-actions-hover {
                                        a.wcps-add-to-cart {
                                            @if var(--addtocart-display-mode)=="hidden" {
                                                display: none;
                                            }

                                            @else if var(--addtocart-display-mode)=="icon_only" {
                                                .wcps-text {
                                                    display: none;
                                                }

                                                .wcps-icon {
                                                    margin-right: 0;
                                                }
                                            }

                                            background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
                                            color: white;
                                        }

                                        a.wcps-quickview {
                                            @if var(--quickview-display-mode)=="hidden" {
                                                display: none;
                                            }

                                            @else if var(--quickview-display-mode)=="icon_only" {
                                                .wcps-text {
                                                    display: none;
                                                }

                                                .wcps-icon {
                                                    margin-right: 0;
                                                }
                                            }
                                        }

                                        a.wcps-wishlist {
                                            @if var(--wishlist-displaymode)=="hidden" {
                                                display: none;
                                            }

                                            @else if var(--wishlist-displaymode)=="icon_only" {
                                                .wcps-text {
                                                    display: none;
                                                }

                                                .wcps-icon {
                                                    margin-right: 0;
                                                }
                                            }
                                        }

                                        a.wcps-compare {
                                            @if var(--compare-display-mode)=="hidden" {
                                                display: none;
                                            }

                                            @else if var(--compare-display-mode)=="icon_only" {
                                                .wcps-text {
                                                    display: none;
                                                }

                                                .wcps-icon {
                                                    margin-right: 0;
                                                }
                                            }
                                        }

                                        a:not(.wcps-add-to-cart) {
                                            background: linear-gradient(135deg, rgba(var(--wcps-product-title), 0.1) 0%, rgba(var(--wcps-product-title), 0.05) 100%);
                                            color: var(--wcps-product-title);
                                            border: 1px solid rgba(var(--wcps-product-title), 0.2);
                                            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);

                                            &:hover {
                                                background: linear-gradient(135deg, var(--wcps-button-hover-bg) 0%, rgba(var(--wcps-button-hover-bg), 0.9) 100%);
                                                color: var(--wcps-button-hover-text-color);
                                                border-color: rgba(255, 255, 255, 0.3);
                                                transform: translateY(-3px);
                                                box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
                                            }
                                        }
                                    }
                                }
                            }

                        }

                        &:last-child td {
                            border-bottom: none;
                        }
                    }
                }
            }

            .dataTables_info,
            .dataTables_paginate {
                margin-top: 18px;
                font-size: 0.9em;
            }

            .dataTables_paginate {
                .paginate_button {
                    padding: 8px 12px;
                    margin: 0 3px;
                    border-radius: var(--wcps-border-radius);
                    cursor: pointer;
                    border: 1px solid transparent;

                    &.current {
                        background-color: var(--wcps-product-title);
                        color: white;
                        border-color: var(--wcps-product-title);
                    }

                    &:hover:not(.current) {
                        background-color: #f0f0f0;
                        border-color: #ddd;
                    }
                }
            }
        }

        // Pagination start
        /* Enhanced Pagination Styles */
        .wcps-pagination {
            margin: 30px 0;
            text-align: center;

            ul {
                display: inline-flex;
                align-items: center;
                justify-content: center;
                list-style: none;
                margin: 0;
                padding: 0;
                gap: 8px;
            }

            li {
                display: flex;
                align-items: center;
                justify-content: center;
            }

            a,
            span {
                display: inline-flex;
                align-items: center;
                justify-content: center;
                min-width: 30px;
                height: 35px;
                padding: 0 5px;
                border: 2px solid #e2e8f0;
                border-radius: 10px;
                background: #ffffff;
                text-decoration: none;
                color: #475569;
                font-weight: 500;
                font-size: 15px;
                transition: all 0.2s ease;
                position: relative;
                text-decoration: none !important;

                &:hover {
                    background: var(--wcps-product-title, #0170B9);
                    color: #ffffff;
                    border-color: var(--wcps-product-title, #0170B9);
                    transform: translateY(-1px);
                    box-shadow: 0 4px 12px rgba(1, 112, 185, 0.25);
                }

                &:active {
                    transform: translateY(0);
                }
            }

            // Current/active page styling
            span.current {
                background: var(--wcps-product-title, #0170B9);
                color: #ffffff;
                border-color: var(--wcps-product-title, #0170B9);
                font-weight: 600;
                box-shadow: 0 2px 8px rgba(1, 112, 185, 0.3);

                &:hover {
                    background: var(--wcps-product-title, #0170B9);
                    color: #ffffff;
                    transform: none;
                    box-shadow: 0 2px 8px rgba(1, 112, 185, 0.3);
                }
            }

            // Navigation arrows styling
            .next,
            .prev {
                font-size: 18px;
                font-weight: 600;
                min-width: 44px;

                &:hover {
                    background: var(--wcps-product-title, #0170B9);
                    color: #ffffff;
                    border-color: var(--wcps-product-title, #0170B9);
                }
            }

            // Disabled state
            .disabled {
                opacity: 0.4;
                cursor: not-allowed;

                &:hover {
                    transform: none;
                    box-shadow: none;
                    background: #ffffff;
                    color: #475569;
                    border-color: #e2e8f0;
                }
            }

            // Dots for truncated pagination
            .dots {
                color: #94a3b8;
                cursor: default;
                border: none;
                background: transparent;

                &:hover {
                    background: transparent;
                    color: #94a3b8;
                    transform: none;
                    box-shadow: none;
                    border: none;
                }
            }
        }

        // Responsive design
        @media (max-width: 768px) {
            .wcps-pagination {
                margin: 20px 0;

                ul {
                    gap: 6px;
                }

                a,
                span {
                    min-width: 40px;
                    height: 40px;
                    padding: 0 10px;
                    font-size: 14px;
                }
            }
        }

        @media (max-width: 480px) {
            .wcps-pagination {
                margin: 16px 0;

                ul {
                    gap: 4px;
                }

                a,
                span {
                    min-width: 36px;
                    height: 36px;
                    padding: 0 8px;
                    font-size: 13px;
                }
            }
        }

        // Focus states for accessibility
        .wcps-pagination {

            a:focus,
            span:focus {
                outline: 2px solid var(--wcps-product-title, #0170B9);
                outline-offset: 2px;
            }
        }

        // Optional: Add subtle animation to page numbers
        .wcps-pagination {

            a,
            span {
                &:not(.current):not(.disabled):hover {
                    animation: pulse 0.3s ease;
                }
            }
        }

        @keyframes pulse {
            0% {
                transform: scale(1) translateY(-1px);
            }

            50% {
                transform: scale(1.05) translateY(-1px);
            }

            100% {
                transform: scale(1) translateY(-1px);
            }
        }

        // Pagination end 

        // Responsive grid columns
        .wcps-grid {
            display: grid;
            grid-template-columns: repeat(var(--wcps-columns, 4), minmax(0, 1fr));
            gap: var(--wcps-grid-gap, 20px);
            width: var(--wcps-grid-width, 100%);

            @media (max-width: 992px) {
                grid-template-columns: repeat(min(3, var(--wcps-columns)), 1fr);
            }

            @media (max-width: 768px) {
                grid-template-columns: repeat(min(2, var(--wcps-columns)), 1fr);
            }

            @media (max-width: 480px) {
                grid-template-columns: 1fr;
            }
        }

        // Mobile optimizations with horizontal scrolling
        @media (max-width: 991px) {
            .wcps-table-container {

                // Custom scrollbar for better UX
                &::-webkit-scrollbar {
                    height: 6px;
                }

                &::-webkit-scrollbar-track {
                    background: #f1f1f1;
                    border-radius: 3px;
                }

                &::-webkit-scrollbar-thumb {
                    background: var(--wcps-product-title);
                    border-radius: 3px;
                }

                // Table adjustments for better mobile view
                .wcps-table {
                    td.wcps-product-title-col {
                        .wcps-product-excerpt {
                            -webkit-line-clamp: 1; // Show only one line on smaller screens
                        }
                    }

                    td.wcps-product-actions-col {
                        .wcps-product-actions {
                            a {
                                padding: 6px 10px;

                                .wcps-text {
                                    display: none; // Hide text on buttons for smaller screens
                                }

                                .wcps-icon {
                                    margin-right: 0;
                                }
                            }
                        }
                    }
                }
            }
        }

        // For extremely small screens, allow vertical scrolling with fixed header
        @media (max-width: 480px) {
            .wcps-table-controls {
                flex-direction: column;
                align-items: flex-start;

                .dataTables_filter,
                .dataTables_length {
                    width: 100%;
                    margin-bottom: 10px;

                    input,
                    select {
                        max-width: 100%;
                    }
                }
            }
        }
    }
}