/**
 * Products Tab Styles
 * Includes shimmer loader, filters, and product cards
 */

/* ===============================================
   Products Tab Wrapper
   =============================================== */
.products-tab-wrapper {
    padding: 1.5rem 0;
}

/* ===============================================
   Filters Section
   =============================================== */
.products-filters-section {
    background: #fff;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.filters-wrapper {
    width: 100%;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.filter-item {
    flex: 1;
    min-width: 200px;
}

.filter-item.filter-search {
    flex: 2;
    min-width: 300px;
}

.filter-item.filter-price {
    min-width: 250px;
}

.filter-item .input-group-text {
    background: #f8f9fa;
    border-right: 0;
}

.filter-item .form-control {
    border-left: 0;
}

.filter-item .form-control:focus,
.filter-item .form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
    border-color: #86b7fe;
}

/* ===============================================
   Results Header
   =============================================== */
.products-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 0 0.5rem;
}

.results-info {
    color: #6c757d;
    font-size: 0.95rem;
}

.results-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* ===============================================
   Products Grid
   =============================================== */
.products-grid-container {
    min-height: 400px;
}

.products-grid-container.loading {
    pointer-events: none;
}

/* ===============================================
   Product Cards
   =============================================== */
.product-card {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.product-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-bottom: 1px solid #eee;
}

.product-card-body {
    padding: 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-card-body h5 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: #212529;
    line-height: 1.4;
}

.product-card-body p {
    font-size: 0.9rem;
    color: #6c757d;
    margin-bottom: 1rem;
    flex: 1;
}

.product-price {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
}

.product-price .price {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0d6efd;
}

.product-price .unit {
    font-size: 0.85rem;
    color: #6c757d;
}

.badge-custom {
    display: inline-block;
    padding: 0.35em 0.65em;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1;
    border-radius: 0.375rem;
    margin-right: 0.5rem;
}

.badge-info {
    background-color: #0dcaf0;
    color: #000;
}

.badge-success {
    background-color: #198754;
    color: #fff;
}

.badge-warning {
    background-color: #ffc107;
    color: #000;
}

.badge-danger {
    background-color: #dc3545;
    color: #fff;
}

.btn-link {
    display: inline-flex;
    align-items: center;
    color: #0d6efd;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-link:hover {
    color: #0a58ca;
    gap: 0.5rem;
}

.btn-link i {
    margin-left: 0.25rem;
    transition: margin-left 0.2s;
}

.btn-link:hover i {
    margin-left: 0.5rem;
}

/*!* ===============================================*/
/*   Shimmer Loader*/
/*   =============================================== *!*/
/*.shimmer-container {*/
/*    width: 100%;*/
/*}*/

/*.shimmer-card {*/
/*    pointer-events: none;*/
/*}*/

/*.shimmer-card .product-card-body {*/
/*    padding: 1.25rem;*/
/*}*/

/*.shimmer-image {*/
/*    width: 100%;*/
/*    height: 200px;*/
/*    background: linear-gradient(*/
/*        90deg,*/
/*        #f0f0f0 25%,*/
/*        #e0e0e0 50%,*/
/*        #f0f0f0 75%*/
/*    );*/
/*    background-size: 200% 100%;*/
/*    animation: shimmer 1.5s infinite;*/
/*}*/

/*.shimmer-line {*/
/*    height: 16px;*/
/*    background: linear-gradient(*/
/*        90deg,*/
/*        #f0f0f0 25%,*/
/*        #e0e0e0 50%,*/
/*        #f0f0f0 75%*/
/*    );*/
/*    background-size: 200% 100%;*/
/*    animation: shimmer 1.5s infinite;*/
/*    border-radius: 4px;*/
/*    margin-bottom: 0.75rem;*/
/*}*/

/*.shimmer-title {*/
/*    height: 24px;*/
/*    width: 80%;*/
/*}*/

/*.shimmer-badge {*/
/*    height: 20px;*/
/*    width: 40%;*/
/*}*/

/*.shimmer-text {*/
/*    height: 14px;*/
/*    width: 100%;*/
/*}*/

/*.shimmer-text:last-of-type {*/
/*    width: 60%;*/
/*}*/

/*.shimmer-button {*/
/*    height: 36px;*/
/*    width: 50%;*/
/*    margin-top: 1rem;*/
/*}*/

/*.shimmer-filter {*/
/*    height: 38px;*/
/*    margin-bottom: 1rem;*/
/*}*/

/*@keyframes shimmer {*/
/*    0% {*/
/*        background-position: -200% 0;*/
/*    }*/
/*    100% {*/
/*        background-position: 200% 0;*/
/*    }*/
/*}*/



/* =====================================================
   SHIMMER LOADER - ORGANIZED GRID LAYOUT
   ===================================================== */

.shimmer-container {
    width: 100%;
    padding: 0;
}

.shimmer-container .row {
    margin: 0 -8px;
}

/* Shimmer Card - Matches Product Card Layout */
.shimmer-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    height: 100%;
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
    animation: shimmerPulse 1.5s ease-in-out infinite;
}

/* Shimmer Image - Matches Product Card Image */
.shimmer-image {
    width: 100%;
    height: 16em;
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmerSlide 1.5s ease-in-out infinite;
}

/* Shimmer Card Body */
.product-card-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Shimmer Lines */
.shimmer-line {
    height: 12px;
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    border-radius: 4px;
    animation: shimmerSlide 1.5s ease-in-out infinite;
}

/* Specific Shimmer Line Types */
.shimmer-title {
    width: 85%;
    height: 16px;
    margin-bottom: 4px;
}

.shimmer-badge {
    width: 40%;
    height: 20px;
    border-radius: 6px;
    margin-bottom: 8px;
}

.shimmer-text {
    width: 100%;
    height: 10px;
    margin-bottom: 6px;
}

.shimmer-text:last-of-type {
    width: 70%;
}

.shimmer-button {
    width: 60%;
    height: 14px;
    margin-top: auto;
    border-radius: 4px;
}

/* Shimmer Animations */
@keyframes shimmerSlide {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

@keyframes shimmerPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.95;
    }
}

/* Staggered Animation for Cards */
.shimmer-card:nth-child(1) { animation-delay: 0s; }
.shimmer-card:nth-child(2) { animation-delay: 0.1s; }
.shimmer-card:nth-child(3) { animation-delay: 0.2s; }
.shimmer-card:nth-child(4) { animation-delay: 0.3s; }
.shimmer-card:nth-child(5) { animation-delay: 0.4s; }
.shimmer-card:nth-child(6) { animation-delay: 0.5s; }
.shimmer-card:nth-child(7) { animation-delay: 0.6s; }
.shimmer-card:nth-child(8) { animation-delay: 0.7s; }
.shimmer-card:nth-child(9) { animation-delay: 0.8s; }
.shimmer-card:nth-child(10) { animation-delay: 0.9s; }
.shimmer-card:nth-child(11) { animation-delay: 1s; }
.shimmer-card:nth-child(12) { animation-delay: 1.1s; }

/* Loading State */
.products-grid-container.loading {
    pointer-events: none;
    opacity: 1;
}

/* Responsive Shimmer Grid */
@media (max-width: 1200px) {
    .shimmer-image {
        height: 14em;
    }
}

@media (max-width: 992px) {
    .shimmer-image {
        height: 18em;
    }

    .shimmer-container .row {
        margin: 0 -6px;
    }
}

@media (max-width: 768px) {
    .shimmer-image {
        height: 20em;
    }

    .shimmer-card {
        margin-bottom: 12px;
    }

    .product-card-body {
        padding: 14px;
        gap: 10px;
    }
}

@media (max-width: 576px) {
    .shimmer-image {
        height: 16em;
    }
}

/* Premium Shimmer Variant (Optional Enhancement) */
.shimmer-card.premium {
    box-shadow: var(--shadow-md);
}

.shimmer-card.premium .shimmer-image,
.shimmer-card.premium .shimmer-line {
    background: linear-gradient(
        90deg,
        #f8f9fa 0%,
        #e9ecef 20%,
        #f8f9fa 40%,
        #f8f9fa 100%
    );
    background-size: 200% 100%;
}

/* Smooth Fade In When Content Loads */
.products-grid-container {
    animation: fadeIn 0.3s ease-in;
}

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


/* ===============================================
   Empty State
   =============================================== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

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

.empty-state h4 {
    color: #495057;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: #6c757d;
    margin-bottom: 1.5rem;
}

/* ===============================================
   Pagination
   =============================================== */
.products-pagination-container {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #dee2e6;
}

.pagination {
    margin-bottom: 0;
}

.page-link {
    color: #0d6efd;
    border-color: #dee2e6;
    padding: 0.5rem 0.75rem;
    transition: all 0.2s;
}

.page-link:hover {
    background-color: #e9ecef;
    border-color: #dee2e6;
    color: #0a58ca;
}

.page-item.active .page-link {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

.page-item.disabled .page-link {
    color: #6c757d;
    pointer-events: none;
    background-color: #fff;
    border-color: #dee2e6;
}

/* ===============================================
   Loading Overlay (Optional)
   =============================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 3rem;
    height: 3rem;
    border: 0.3rem solid #f3f3f3;
    border-top: 0.3rem solid #0d6efd;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ===============================================
   Responsive Design
   =============================================== */
@media (max-width: 1200px) {
    .filters-row {
        flex-direction: column;
    }

    .filter-item,
    .filter-item.filter-search,
    .filter-item.filter-price {
        width: 100%;
        min-width: 100%;
    }
}

@media (max-width: 768px) {
    .products-filters-section {
        padding: 1rem;
    }

    .products-results-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .results-controls {
        width: 100%;
        justify-content: space-between;
    }

    .product-card img {
        height: 180px;
    }

    .pagination {
        font-size: 0.9rem;
    }

    .page-link {
        padding: 0.375rem 0.625rem;
    }
}

@media (max-width: 576px) {
    .products-tab-wrapper {
        padding: 1rem 0;
    }

    .product-card img {
        height: 160px;
    }

    .product-card-body {
        padding: 1rem;
    }

    .product-card-body h5 {
        font-size: 1rem;
    }

    .empty-state {
        padding: 3rem 1rem;
    }

    .empty-state i {
        font-size: 3rem;
    }
}

/* ===============================================
   Accessibility
   =============================================== */
.filter-item .form-control:focus,
.filter-item .form-select:focus,
.page-link:focus {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .product-card,
    .btn-link,
    .page-link,
    .shimmer-image,
    .shimmer-line {
        transition: none;
        animation: none;
    }
}

/* ===============================================
   Print Styles
   =============================================== */
@media print {
    .products-filters-section,
    .products-pagination-container,
    .results-controls {
        display: none;
    }

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