/* =============================================
   MARKET.CSS - Clean Version
   Organized, Optimized, Non-Conflicting
============================================== */

/* =============================================
   1. BASE PRODUCT STYLES
============================================== */

.product-box {
    position: relative;
    transition: all 0.3s ease;
    border: 1px solid #e9ecef;
    background: white;
}

.product-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border-color: #C1018A;
}

.pricing-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
}

.pricing-badge .badge {
    background: #C1018A;
    color: white;
    font-size: 0.75rem;
    padding: 4px 8px;
}

/* =============================================
   /* =============================================
   2. PRODUCT IMAGE CONTAINERS (UNIFORM SIZING)
============================================== */

/* Main product grid images */
.product-img {
    position: relative;
    width: 100%;
    height: 180px; /* Uniform height for all product images */
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 12px !important; /* Override inline p-3 if needed */
}

/* Specific class for product images */
.product-img .product-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    max-width: 100%;
    max-height: 100%;
    cursor: pointer;
    transition: transform 0.3s ease;
}

/* Recent products in sidebar */
.popular-product-box .product-img {
    height: 60px !important;
    width: 60px !important;
    min-width: 60px !important;
    flex-shrink: 0;
    border-radius: 6px;
    margin-bottom: 0;
    padding: 4px !important;
}

.popular-product-box .product-img .recent-product-image {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* For avatar images in sidebar */
.avatar-md .product-img {
    height: 80px !important;
    width: 80px !important;
}

.avatar-md .product-img img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* =============================================
   3. LAZY LOADING SPECIFIC STYLES
============================================== */

.lazy-image {
    opacity: 0;
    transition: opacity 0.4s ease;
    background-color: #f8f9fa;
}

.lazy-image.lazy-loaded {
    opacity: 1;
}

.lazy-image.lazy-loading {
    opacity: 0.7;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

.lazy-image.lazy-error {
    opacity: 1;
    object-fit: contain !important;
    padding: 20px;
    background-color: #f8f9fa;
}

/* Product image hover effect */
.product-img:hover .product-image {
    transform: scale(1.05);
}

/* =============================================
   SPECIFIC OVERRIDES FOR INLINE STYLES
============================================== */

/* Override any problematic inline styles */
[style*="height:"].product-image,
[style*="object-fit:"].product-image {
    height: 100% !important;
    object-fit: cover !important;
}

/* Ensure bg-light class doesn't interfere */
.bg-light.product-img {
    background-color: #f8f9fa !important;
}

/* Override Bootstrap's img-fluid if needed */
.img-fluid.product-image {
    max-width: 100%;
    height: auto; /* This gets overridden by !important above */
}

/* STRONG OVERRIDES FOR PRODUCT IMAGES */
.product-img {
    height: 180px !important;
    min-height: 180px !important;
    max-height: 180px !important;
}

.product-img img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    max-width: 100% !important;
    max-height: 100% !important;
}

/* Override any inline styles */
.product-img img[style] {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* For recent products */
.popular-product-box .product-img {
    height: 60px !important;
    width: 60px !important;
    min-width: 60px !important;
}

.popular-product-box .product-img img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* =============================================
   4. PRODUCT CONTENT AREA
============================================== */

.product-content {
    padding: 0 4px;
}

.product-content .text-muted {
    font-size: 0.75rem;
    margin-bottom: 6px;
    min-height: 1.2em;
}

.product-content h6 {
    margin-bottom: 8px;
    min-height: 2.8em;
    line-height: 1.4;
}

.product-link {
    display: block;
    color: #374151;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: color 0.2s;
}

.product-link:hover {
    color: #C1018A;
}

/* Price styling */
.product-content .text-primary {
    font-size: 1rem;
    font-weight: 600;
    color: #C1018A !important;
    margin-bottom: 0;
}

/* =============================================
   5. RECENT PRODUCTS SIDEBAR
============================================== */

.popular-product-box {
    transition: all 0.2s ease;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid transparent;
}

.popular-product-box:hover {
    background-color: #f8f9fa;
    border-color: #dee2e6;
}

.popular-product-box .flex-grow-1 {
    min-width: 0; /* Allow text truncation */
}

.popular-product-box h6 {
    font-size: 0.85rem;
    margin-bottom: 4px;
    line-height: 1.3;
}

.popular-product-box .text-muted {
    font-size: 0.8rem;
}

/* =============================================
   6. MODAL & FORM WIZARD STYLES
============================================== */

/* Step indicators */
.step-indicator {
    text-align: center;
    flex: 1;
    position: relative;
}

.step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #e9ecef;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-weight: 600;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
}

.step-connector {
    flex: 1;
    height: 2px;
    background: #e9ecef;
    margin: 0 10px;
    align-self: center;
}

.step-indicator.active .step-circle {
    background: #fd7e14;
    border-color: #fd7e14;
    color: white;
}

.step-indicator.completed .step-circle {
    background: #C1018A;
    border-color: #C1018A;
    color: white;
}

.step-indicator.processing .step-circle {
    background: #fd7e14;
    border-color: #fd7e14;
    animation: pulse 2s infinite;
}

.step-indicator.success .step-circle {
    background: #C1018A;
    border-color: #C1018A;
}

.step-indicator.error .step-circle {
    background: #dc3545;
    border-color: #dc3545;
}

.step-label {
    color: #6c757d;
    font-size: 0.875rem;
}

.step-content {
    display: none;
}

.step-content.active {
    display: block;
}

/* Form controls */
.form-control:focus,
.form-select:focus {
    border-color: #C1018A;
    box-shadow: 0 0 0 3px rgba(193, 1, 138, 0.1);
}

.form-control:read-only,
.form-select:disabled {
    background-color: #f8f9fa !important;
    cursor: not-allowed;
    opacity: 0.8;
}

/* =============================================
   7. AUTO-COMPLETE STYLES
============================================== */

.autocomplete-suggestions {
    border: 1px solid #e9ecef;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
    background: white;
    font-size: 0.875rem;
    margin-top: -1px;
    z-index: 1000;
}

.autocomplete-item {
    transition: all 0.15s ease;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    padding: 0.75rem;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background-color: #f8f9fa;
    border-left: 3px solid #C1018A;
}

.autocomplete-item:last-child {
    border-bottom: none;
    border-radius: 0 0 0.375rem 0.375rem;
}

/* Compact layout */
.compact-product {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.compact-product-image {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid #e9ecef;
}

.compact-product-info {
    flex: 1;
    min-width: 0;
}

.compact-product-name {
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.compact-product-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    font-size: 0.75rem;
    color: #6b7280;
}

.meta-badge {
    background: #f3f4f6;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-weight: 500;
    font-size: 0.6875rem;
}

/* Loading and empty states */
.autocomplete-loading {
    padding: 1.5rem;
    text-align: center;
    color: #6b7280;
}

.autocomplete-empty {
    padding: 1.5rem;
    text-align: center;
    color: #6b7280;
}

.autocomplete-empty i {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* Text highlighting */
.highlight-match {
    background-color: #fef3c7;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-weight: 600;
    color: #92400e;
}

/* =============================================
   8. ANIMATIONS & TRANSITIONS
============================================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes bounceIn {
    0% {
        transform: scale(0.3);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* =============================================
   9. UTILITY & HELPER CLASSES
============================================== */

.bg-light {
    background-color: #f8f9fa !important;
}

.input-group {
    position: relative;
}

/* Form feedback states */
.form-submitting {
    opacity: 0.7;
    pointer-events: none;
}

.submission-error-alert {
    animation: shake 0.5s ease-in-out;
}

.auto-save-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #C1018A;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.875rem;
    z-index: 1070;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.auto-save-indicator.show {
    opacity: 1;
}

/* Checkmark animation */
.checkmark {
    animation: bounceIn 0.6s ease-out;
}

.request-details {
    animation: slideInUp 0.5s ease-out;
}

.action-buttons {
    animation: fadeIn 0.5s ease-out 0.3s both;
}

/* =============================================
   10. MOBILE RESPONSIVENESS
============================================== */

@media (max-width: 992px) {
    .product-img {
        height: 160px;
    }
}

@media (max-width: 768px) {
    /* Product grid adjustments */
    .product-img {
        height: 140px;
    }
    
    .product-content h6 {
        min-height: 2.4em;
        font-size: 0.85rem;
    }
    
    .product-link {
        font-size: 0.85rem;
    }
    
    .product-content .text-primary {
        font-size: 0.9rem;
    }
    
    /* Container adjustments */
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    /* Auto-complete mobile optimizations */
    .autocomplete-suggestions {
        position: fixed !important;
        left: 1rem !important;
        right: 1rem !important;
        width: auto !important;
        max-height: 50vh !important;
        z-index: 1060 !important;
        border-radius: 0.5rem;
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
        margin-top: 0.5rem;
    }
    
    .autocomplete-item {
        padding: 1rem;
    }
}

@media (max-width: 576px) {
    .product-img {
        height: 120px;
    }
    
    #productsGrid .col-6 .product-img {
        height: 100px;
    }
    
    .product-content h6 {
        min-height: 2rem;
        font-size: 0.8rem;
    }
    
    .product-link {
        font-size: 0.8rem;
        line-height: 1.2;
    }
    
    .product-content .text-primary {
        font-size: 0.85rem;
    }
    
    .product-box {
        padding: 0.75rem !important;
    }
    
    /* Recent products on mobile */
    .popular-product-box .product-img {
        height: 50px;
        width: 50px;
        min-width: 50px;
    }
}

/* =============================================
   11. SPECIFIC OVERRIDES & FIXES
============================================== */

/* Ensure product name truncation works */
.product-content h6 {
    width: 100%;
}

.product-link {
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
}

/* Fix any inline style conflicts */
.product-img[style*="height"],
.product-img img[style*="height"] {
    height: 100% !important;
    max-height: 100% !important;
}

.product-img img[style] {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
}

/* Breadcrumb and navigation */
.breadcrumb {
    background: transparent;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
}

.breadcrumb-item a {
    color: #6c757d;
    text-decoration: none;
}

.breadcrumb-item.active {
    color: #C1018A;
}

/* Product count display */
#productCountDisplay {
    font-size: 0.875rem;
    color: #6c757d;
}

/* Load more button */
#loadMoreBtn {
    min-width: 200px;
}

/* Modal improvements */
.modal-header.bg-primary {
    background: #C1018A !important;
}

.user-info-card {
    border-color: #C1018A;
}

/* =============================================
   12. ERROR DEBUG PANEL
============================================== */

#errorDebugPanel {
    font-size: 0.8rem;
}

#errorDebugPanel .card {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

#errorList {
    max-height: 150px;
    overflow-y: auto;
}

/* Smooth transitions for filter removal */
.filter-badge {
    transition: opacity 0.3s ease;
}

.filter-badge:hover {
    opacity: 0.8;
}

/* =============================================
   END OF MARKET.CSS
============================================== */