/* 
 * CRM Marketplace Styling
 * File: /crm/css/marketplace.css
 * Purpose: marketplace-style responsive product grid and marketplace UI
 */

/* ===== PRODUCTS GRID ===== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* ===== PRODUCTS LIST (EBAY-LIKE STRIPS) ===== */
.products-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 30px;
}

.product-strip {
    display: grid;
    grid-template-columns: 108px 1fr;
    gap: 12px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid var(--bs-border-color, rgba(0, 0, 0, .125));
    background: var(--bs-body-bg);
    box-shadow: var(--bs-box-shadow-sm, 0 .125rem .25rem rgba(0, 0, 0, .075));
}

.product-strip--sold {
    opacity: 0.8;
}

.product-strip__image {
    width: 108px;
    height: 92px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--bs-tertiary-bg, var(--bs-body-bg));
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.product-strip__image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.product-strip__image--placeholder {
    color: var(--bs-secondary-color, var(--bs-secondary));
    font-size: 1.5rem;
}

.product-strip__body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-strip__top {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    align-items: flex-start;
}

.product-strip__title {
    font-weight: 700;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-strip__title a {
    color: inherit;
    text-decoration: none;
}

.product-strip__title a:hover {
    color: var(--bs-primary);
    text-decoration: underline;
}

.product-strip__sub {
    font-size: .9rem;
    color: var(--bs-secondary-color, var(--bs-secondary));
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.product-strip__price {
    text-align: right;
    flex: 0 0 auto;
}

.product-strip__pricePrimary {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--bs-body-color);
}

.product-strip__priceSecondary {
    font-size: .85rem;
    color: var(--bs-secondary-color, var(--bs-secondary));
}

.product-strip__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.product-strip__chips .chip {
    font-size: .78rem;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid rgba(var(--bs-primary-rgb, 13, 110, 253), 0.25);
    background: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.08);
    color: var(--bs-primary);
}

.product-strip__desc {
    color: var(--bs-body-color);
    font-size: .95rem;
}

.product-strip__meta {
    color: var(--bs-secondary-color, var(--bs-secondary));
    font-size: .88rem;
}

.product-strip__metaLine {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-strip__actions {
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

@media (max-width: 576px) {
    .product-strip {
        grid-template-columns: 92px 1fr;
    }
    .product-strip__image {
        width: 92px;
        height: 84px;
    }
    .product-strip__top {
        flex-direction: column;
        align-items: stretch;
    }
    .product-strip__price {
        text-align: left;
    }
}

/* ===== PRODUCT CARDS ===== */
.product-card {
    background: var(--bs-card-bg, var(--bs-body-bg));
    border-radius: 12px;
    border: 1px solid var(--bs-border-color, rgba(0, 0, 0, .125));
    box-shadow: var(--bs-box-shadow-sm, 0 .125rem .25rem rgba(0, 0, 0, .075));
    transition: all 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--bs-box-shadow, 0 .5rem 1rem rgba(0, 0, 0, .15));
}

/* ===== PRODUCT IMAGES ===== */
.product-image-container {
    position: relative;
    height: 200px;
    overflow: hidden;
    background: var(--bs-tertiary-bg, var(--bs-body-bg));
}

.product-image-link {
    display: block;
    width: 100%;
    height: 100%;
    color: inherit;
    text-decoration: none;
    position: relative;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover .product-image {
    transform: scale(1.05);
}

.product-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bs-tertiary-bg, var(--bs-body-bg));
}

.product-title-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: .6rem .75rem;
    font-weight: 700;
    font-size: .95rem;
    line-height: 1.2;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
    background: linear-gradient(to top, rgba(0, 0, 0, .75), rgba(0, 0, 0, 0));
    z-index: 12;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ===== PRODUCT BADGES ===== */
.product-status-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 15;
}

.image-count-badge {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(var(--bs-black-rgb, 0, 0, 0), 0.7);
    color: var(--bs-white, #fff);
    padding: 4px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    z-index: 15;
}

/* ===== PRODUCT INFO ===== */
.product-info {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-title {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-title a:hover {
    color: var(--bs-primary) !important;
}

/* ===== PRICING ===== */
.product-price {
    margin-bottom: 10px;
}

.buy-now-price {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--bs-success);
}

.sold-price {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--bs-secondary-color, var(--bs-secondary));
    text-decoration: line-through;
}

.current-bid {
    color: var(--bs-primary);
    font-weight: 500;
}

/* ===== PRODUCT META ===== */
.product-meta {
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--bs-border-color, rgba(0, 0, 0, .125));
}

.condition-badge {
    display: inline-block;
    background: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.12);
    color: var(--bs-primary);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-top: 4px;
}

.location {
    margin-top: 4px;
}

/* ===== PRODUCT ACTIONS ===== */
.product-actions {
    padding: 15px;
    padding-top: 0;
}

/* ===== SEARCH FORM ENHANCEMENTS ===== */
.marketplace-page .form-label {
    font-weight: 600;
    color: var(--bs-body-color);
    margin-bottom: 5px;
}

.marketplace-page .input-group-text {
    background: var(--bs-tertiary-bg, var(--bs-body-bg));
    border-color: var(--bs-border-color, rgba(0, 0, 0, .125));
    color: var(--bs-secondary-color, var(--bs-secondary));
}

.marketplace-page .form-control:focus,
.marketplace-page .form-select:focus {
    border-color: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.55);
    box-shadow: 0 0 0 0.25rem rgba(var(--bs-primary-rgb, 13, 110, 253), 0.15);
}

/* ===== FILTER + RESULTS PANELS (marketplace.php) ===== */
.marketplace-page .filters-panel,
.marketplace-page .results-header,
.marketplace-page .cta-card {
    background: var(--bs-tertiary-bg, var(--bs-body-bg));
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color, rgba(0, 0, 0, .125));
    border-radius: 16px;
    box-shadow: var(--bs-box-shadow-sm, 0 .125rem .25rem rgba(0, 0, 0, .075));
}

.marketplace-page .filters-panel {
    padding: 1.25rem;
}

.marketplace-page .results-header {
    display: flex;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    margin-top: 1.25rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.marketplace-page .results-meta {
    color: var(--bs-secondary-color, var(--bs-body-color));
}

.marketplace-page .results-meta strong {
    color: var(--bs-body-color);
}

.marketplace-page .results-sort {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.marketplace-page .results-sort .form-select {
    min-width: 220px;
}

/* ===== ACTIVE FILTER CHIPS ===== */
.marketplace-page .active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    background: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.06);
    border: 1px solid rgba(var(--bs-primary-rgb, 13, 110, 253), 0.18);
    border-radius: 12px;
    padding: .75rem;
}

.marketplace-page .filter-chip {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .25rem .6rem;
    border-radius: 999px;
    background: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.12);
    color: var(--bs-body-color);
    border: 1px solid rgba(var(--bs-primary-rgb, 13, 110, 253), 0.18);
    font-size: 0.875rem;
}

.marketplace-page .filter-chip a {
    color: inherit;
    opacity: 0.75;
    text-decoration: none;
}

.marketplace-page .filter-chip a:hover {
    opacity: 1;
}

/* ===== EMPTY STATE ===== */
.marketplace-page .empty-state {
    text-align: center;
    padding: 3.5rem 1.5rem;
    border-radius: 16px;
    border: 1px dashed rgba(var(--bs-border-color-rgb, 0, 0, 0), 0.6);
    background: var(--bs-tertiary-bg, var(--bs-body-bg));
    color: var(--bs-body-color);
}

.marketplace-page .empty-state .empty-state-icon {
    font-size: 2.5rem;
    color: var(--bs-secondary-color, var(--bs-body-color));
    margin-bottom: .75rem;
}

/* ===== CTA CARD ===== */
.marketplace-page .cta-section {
    margin-top: 1.75rem;
}

.marketplace-page .cta-card {
    display: flex;
    gap: 1.25rem;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    flex-wrap: wrap;
}

.marketplace-page .cta-card p {
    color: var(--bs-secondary-color, var(--bs-body-color));
}

/* ===== PAGINATION STYLING ===== */
.pagination .page-link {
    border-radius: 8px;
    margin: 0 2px;
    border: 1px solid var(--bs-border-color, rgba(0, 0, 0, .125));
    color: var(--bs-primary);
    transition: all 0.2s ease;
}

.pagination .page-link:hover {
    background-color: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.10);
    border-color: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.35);
    transform: translateY(-1px);
}

.pagination .page-item.active .page-link {
    background-color: var(--bs-primary);
    border-color: var(--bs-primary);
    box-shadow: 0 2px 4px rgba(var(--bs-primary-rgb, 13, 110, 253), 0.3);
}

/* ===== RESPONSIVE BREAKPOINTS ===== */

/* Large Tablets and Small Desktops */
@media (max-width: 992px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
    }

    .product-image-container {
        height: 180px;
    }
}

/* Tablets */
@media (max-width: 768px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 15px;
    }

    .product-image-container {
        height: 160px;
    }

    .product-info {
        padding: 12px;
    }

    .product-actions {
        padding: 12px;
        padding-top: 0;
    }

    .product-title {
        font-size: 0.9rem;
    }

    .buy-now-price {
        font-size: 1.1rem;
    }
}

/* Mobile Phones */
@media (max-width: 576px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 10px;
    }

    .product-image-container {
        height: 140px;
    }

    .product-info {
        padding: 10px;
    }

    .product-actions {
        padding: 10px;
        padding-top: 0;
    }

    .product-title {
        font-size: 0.85rem;
        -webkit-line-clamp: 3;
    }

    .buy-now-price {
        font-size: 1rem;
    }

    /* Stack search form on mobile */
    .col-md-2,
    .col-md-4 {
        margin-bottom: 10px;
    }
}

/* Extra Small Mobile */
@media (max-width: 400px) {
    .products-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .product-image-container {
        height: 120px;
    }

    .product-title {
        font-size: 0.8rem;
    }

    .buy-now-price {
        font-size: 0.9rem;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.product-card {
    animation: fadeInUp 0.3s ease-out;
}

/* Stagger animation for grid items */
.product-card:nth-child(1) {
    animation-delay: 0.1s;
}

.product-card:nth-child(2) {
    animation-delay: 0.2s;
}

.product-card:nth-child(3) {
    animation-delay: 0.3s;
}

.product-card:nth-child(4) {
    animation-delay: 0.4s;
}

.product-card:nth-child(5) {
    animation-delay: 0.5s;
}

.product-card:nth-child(6) {
    animation-delay: 0.6s;
}

/* ===== LOADING STATES ===== */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }

    100% {
        background-position: -200% 0;
    }
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
.product-card:focus-within {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.product-title a:focus {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ===== PRINT STYLES ===== */
@media print {
    .product-card {
        break-inside: avoid;
        margin-bottom: 20px;
        border: 1px solid #ddd;
    }

    .product-actions {
        display: none;
    }

    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    .product-card {
        background: #343a40;
        color: #fff;
    }

    .product-image-placeholder {
        background: linear-gradient(135deg, #495057 0%, #6c757d 100%);
    }

    .product-meta {
        border-top-color: #495057;
    }

    .condition-badge {
        background: #1e3a5f;
        color: #86b7fe;
    }
}

/* ===== UTILITY CLASSES ===== */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.shadow-hover {
    transition: box-shadow 0.3s ease;
}

.shadow-hover:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15) !important;
}

/* ===== NO RESULTS STATE ===== */
.no-results {
    text-align: center;
    padding: 60px 20px;
}

.no-results i {
    opacity: 0.5;
    margin-bottom: 20px;
}

/* Legacy filter-tag styles were replaced by .filter-chip in marketplace.php */