/**
 * Excel-Style Product Grid CSS
 * 
 * Creates a table-like grid layout with borders and aligned cells
 * resembling an Excel spreadsheet for product display
 *
 * @package Grabit
 * @version 1.0
 */

/* Excel Grid Container */
.cc-excel-grid {
    position: relative;
}

.cc-excel-grid .cc-excel-inner {
    display: grid;
    gap: 1px;
    background-color: #eee;
    border: 1px solid #eee;
}

/* Excel Row */
.cc-excel-grid .cc-excel-row {
    display: contents;
}

/* Excel Header Row */
.cc-excel-header {
    background-color: #f8f8fb;
    border-bottom: 2px solid #5caf90;
    position: sticky;
    top: 0;
    z-index: 10;
}

.cc-excel-header > div {
    padding: 15px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.5px;
    color: #4b5966;
    text-align: center;
    background-color: #fff;
    border-right: 1px solid #eee;
}

.cc-excel-header > div:last-child {
    border-right: none;
}

/* Excel Cell (Product Item) */
.cc-excel-grid .gi-product-box {
    padding: 0 !important;
    background-color: #fff;
}

.cc-excel-grid .gi-product-content {
    padding-bottom: 0 !important;
    height: 100%;
}

.cc-excel-grid .gi-product-inner {
    border-radius: 0 !important;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Uniform Cell Heights */
.cc-excel-grid .gi-pro-image-outer {
    flex: 0 0 auto;
}

.cc-excel-grid .gi-pro-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Cell Borders */
.cc-excel-grid .gi-product-inner {
    border: none !important;
    border-right: 1px solid #eee !important;
    border-bottom: 1px solid #eee !important;
}

/* Remove border on last column */
.cc-excel-grid .gi-product-box:nth-child(3n) .gi-product-inner {
    border-right: none !important;
}

/* Tablet - 2 columns */
@media (min-width: 768px) and (max-width: 991px) {
    .cc-excel-grid .gi-product-box:nth-child(3n) .gi-product-inner {
        border-right: 1px solid #eee !important;
    }
    
    .cc-excel-grid .gi-product-box:nth-child(2n) .gi-product-inner {
        border-right: none !important;
    }
}

/* Mobile - 1 column */
@media (max-width: 767px) {
    .cc-excel-grid .gi-product-box .gi-product-inner {
        border-right: none !important;
    }
}

/* Excel-style alternating row colors (optional) */
.cc-excel-grid.with-stripes .gi-product-box:nth-child(6n+1),
.cc-excel-grid.with-stripes .gi-product-box:nth-child(6n+2),
.cc-excel-grid.with-stripes .gi-product-box:nth-child(6n+3) {
    background-color: #fafafa;
}

/* Align content in cells */
.cc-excel-grid .gi-pro-title {
    min-height: 44px;
    display: flex;
    align-items: center;
}

.cc-excel-grid .gi-pro-title a {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Price alignment */
.cc-excel-grid .gi-price {
    font-size: 16px;
    font-weight: 600;
}

/* Image aspect ratio consistency */
.cc-excel-grid .gi-pro-image img {
    width: 100%;
    height: 250px;
    object-fit: cover;
}

@media (max-width: 767px) {
    .cc-excel-grid .gi-pro-image img {
        height: 200px;
    }
}

/* Hover effects */
.cc-excel-grid .gi-product-inner:hover {
    background-color: #f8f8fb;
    position: relative;
    z-index: 5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Product actions visibility */
.cc-excel-grid .gi-product-inner:hover .gi-pro-actions {
    opacity: 1;
    bottom: 10px;
}

/* Excel Grid Column Widths */
.cc-excel-grid .cc-excel-inner {
    grid-template-columns: repeat(3, 1fr);
}

@media (min-width: 768px) and (max-width: 991px) {
    .cc-excel-grid .cc-excel-inner {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767px) {
    .cc-excel-grid .cc-excel-inner {
        grid-template-columns: 1fr;
    }
}

/* Header alignment for different column counts */
.cc-excel-header.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.cc-excel-header.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.cc-excel-header.grid-cols-1 {
    grid-template-columns: 1fr;
}

/* Stock status in Excel grid */
.cc-excel-grid .gi-stock-status {
    font-size: 12px;
    margin-top: 8px;
    padding: 4px 8px;
    border-radius: 3px;
    display: inline-block;
}

.cc-excel-grid .gi-stock-status.in-stock {
    background-color: #d4edda;
    color: #155724;
}

.cc-excel-grid .gi-stock-status.out-of-stock {
    background-color: #f8d7da;
    color: #721c24;
}

/* Loading state */
.cc-excel-grid[aria-busy="true"] {
    opacity: 0.6;
    pointer-events: none;
}

/* Empty state */
.cc-excel-grid .cc-no-products {
    grid-column: 1 / -1;
    padding: 60px 20px;
}

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

/* Mobile Filter Sidebar */
.gi-shop-sidebar.active {
    transform: translateX(0);
    transition: transform 0.3s ease-in-out;
}

@media (max-width: 991px) {
    .gi-shop-sidebar:not(.active) {
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }
}

/* Filter animations */
.cc-filter-block {
    transition: opacity 0.3s ease-in-out;
}

.cc-filter-block.updating {
    opacity: 0.5;
}

/* Active filter tags */
.cc-active-filter-tag {
    animation: fadeInUp 0.3s ease-in-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Price range slider customization */
.gi-price-slider .noUi-connect {
    background: #5caf90;
}

.gi-price-slider .noUi-handle {
    border: 2px solid #5caf90;
    background: #fff;
    box-shadow: none;
}

.gi-price-slider .noUi-handle:before,
.gi-price-slider .noUi-handle:after {
    display: none;
}

/* Custom checkbox styling */
.cc-filter-input:checked ~ .checked {
    background-color: #5caf90;
    border-color: #5caf90;
}

.cc-filter-input:checked ~ .checked::after {
    content: '✓';
    color: #fff;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* Tag filter button active state */
.cc-tag-filter.active {
    background-color: #5caf90 !important;
    color: #fff !important;
}

/* Mobile filter toggle button */
#cc-mobile-filter-toggle {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

#cc-mobile-filter-toggle:hover {
    animation: none;
    transform: scale(1.05);
}

/* Loading overlay */
#cc-shop-loading {
    backdrop-filter: blur(4px);
}

#cc-shop-loading .loader {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #5caf90;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Pagination active state */
.gi-pro-pagination-inner .cc-page-link.active {
    background-color: #5caf90 !important;
    color: #fff !important;
}

/* Focus states for accessibility */
.cc-filter-input:focus ~ a,
.cc-page-link:focus,
.cc-tag-filter:focus,
#cc-sort-select:focus,
#cc-per-page-select:focus {
    outline: 2px solid #5caf90;
    outline-offset: 2px;
}

/* Smooth transitions */
.gi-product-inner,
.cc-page-link,
.cc-tag-filter,
.gi-select-cancel {
    transition: all 0.3s ease-in-out;
}

/* Responsive adjustments */
@media (max-width: 575px) {
    .cc-excel-grid .gi-pro-content {
        padding: 15px;
    }
    
    .cc-excel-grid .gi-pro-image img {
        height: 180px;
    }
}

/* Notification toast */
.cc-notification {
    min-width: 250px;
    max-width: 400px;
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fade-out {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

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

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

/* Active states for wishlist & compare */
.gi-btn-group.wishlist.is-active,
.gi-btn-group.compare.is-active,
.gi-action-btn[aria-pressed="true"] {
    background-color: #5caf90 !important;
}

.gi-btn-group.wishlist.is-active i,
.gi-btn-group.compare.is-active i,
.gi-action-btn[aria-pressed="true"] i {
    color: #fff !important;
}

/* Loading state */
.gi-action-btn.is-loading {
    opacity: 0.6;
    pointer-events: none;
}

.gi-action-btn.is-loading i {
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Added to cart state */
.gi-action-btn.is-added {
    background-color: #4caf50 !important;
}

.gi-action-btn.is-added i {
    color: #fff !important;
}

/* Disabled state */
.gi-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Wishlist filled heart */
.fi-rr-heart.fill::before {
    content: "\f233"; /* Filled heart icon */
}

/* Focus visible for accessibility */
.gi-action-btn:focus-visible {
    outline: 2px solid #5caf90;
    outline-offset: 2px;
}

/* Notification toast */
.cc-action-notification {
    min-width: 250px;
    max-width: 400px;
    font-size: 14px;
    font-weight: 500;
    pointer-events: none;
}

/* Print styles */
@media print {
    .gi-shop-sidebar,
    .gi-pro-list-top,
    .gi-select-bar,
    .gi-pro-pagination,
    #cc-mobile-filter-toggle,
    #cc-shop-loading,
    .cc-notification {
        display: none !important;
    }
    
    .cc-excel-grid .gi-product-box {
        break-inside: avoid;
    }
}

