/* ==========================================================================
   FENIX - B2B CATALOG STYLES
   Adds premium styling, KPI row, accordion filters, Reorder block and grid/list view toggles.
   ========================================================================== */

:root {
    --primary: #7A1E17;
    --primary-50: #fbf1f0;
}

/* --- 1. B2B Header & KPIs --- */
.b2b-header-mode {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--gray-200);
}

.b2b-kpi-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 16px;
}

.b2b-kpi-card {
    flex: 1;
    min-width: 140px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.b2b-kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.08);
}

.b2b-kpi-icon {
    font-size: 1.5rem;
    color: var(--primary); /* Fenix red/burdeos */
    background: var(--primary-50);
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.b2b-kpi-text {
    font-size: 0.9rem;
    color: var(--gray-700);
    line-height: 1.2;
}
.b2b-kpi-text strong {
    display: block;
    font-size: 1.2rem;
    color: var(--gray-900);
}

/* --- 2. B2B Controls Bar & Chips --- */
.b2b-controls-bar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: transparent;
    padding: 0;
    box-shadow: none;
    margin-bottom: 24px;
}

.quick-filters-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 8px;
}

.qf-chip {
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    border: 1px solid transparent;
}

.qf-green { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.qf-red { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.qf-gold { background: #fef9c3; color: #854d0e; border-color: #fef08a; }
.qf-blue { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.qf-purple { background: #f3e8ff; color: #6b21a8; border-color: #e9d5ff; }

/* B2B Toolbar (Results, Sort, Toggles) */
.b2b-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.toolbar-left .results-count {
    font-size: 0.9rem;
    color: var(--gray-600);
    font-weight: 500;
}

.toolbar-right {
    display: flex;
    gap: 16px;
    align-items: center;
}

.view-toggles {
    display: flex;
    background: #e2e8f0;
    border-radius: 6px;
    padding: 2px;
}

.btn-view-toggle {
    background: transparent;
    border: none;
    padding: 4px 10px;
    border-radius: 4px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-view-toggle.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* --- 3. B2B Accordion Filters --- */
.accordion-block {
    margin-bottom: 0 !important;
}

.accordion-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 12px 0;
    user-select: none;
}

.accordion-title:hover {
    color: var(--primary);
}

.accordion-body {
    padding-bottom: 16px;
}

.filters-price-range {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* --- 4. B2B Reorder Block (Carousel) --- */
.b2b-reorder-block {
    margin: 32px 0;
    padding: 24px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.b2b-reorder-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
}

.b2b-reorder-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px 0;
}

.b2b-reorder-subtitle {
    font-size: 0.9rem;
    color: #64748b;
    margin: 0;
}

.b2b-reorder-link {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.b2b-reorder-link:hover {
    text-decoration: underline;
}

.b2b-reorder-carousel {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 12px;
    scrollbar-width: thin;
}

.b2b-reorder-item {
    min-width: 160px;
    width: 160px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f8fafc;
    position: relative;
    transition: transform 0.2s;
}

.b2b-reorder-item:hover {
    transform: translateY(-2px);
    border-color: #cbd5e1;
}

.b2b-reorder-img-wrap {
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 4px;
    overflow: hidden;
}

.b2b-reorder-img-wrap img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.b2b-reorder-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.b2b-reorder-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    margin: 0 0 4px 0;
    line-height: 1.2;
}

.b2b-reorder-brand {
    font-size: 0.75rem;
    color: #94a3b8;
}

.b2b-reorder-add {
    width: 100%;
    margin-top: auto;
}

/* --- 5. Topbar Unificada B2B --- */
.b2b-list-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #6B7280;
}
.topbar-count strong { color: #111827; }
.search-results-text { color: #7A1E17; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.btn-clear-search-inline { background: none; border: none; color: #DC2626; padding: 0; cursor: pointer; }
.topbar-divider { color: #E5E7EB; }

.topbar-center {
    display: flex;
    align-items: center;
    gap: 12px;
}
.sort-label { font-size: 13px; font-weight: 600; color: #6B7280; }
.sort-select-modern, .pagesize-select {
    border-radius: 8px; border: 1px solid #E5E7EB; padding: 6px 32px 6px 12px;
    font-size: 13px; font-weight: 600; color: #111827; cursor: pointer;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 24px;
}
.view-toggles-modern {
    display: flex;
    background: #F8FAFC;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 4px;
}
.view-toggles-modern .btn-view-toggle {
    background: transparent; border: none; padding: 6px 12px; border-radius: 6px;
    color: #6B7280; cursor: pointer; transition: all 0.2s; font-size: 14px;
}
.view-toggles-modern .btn-view-toggle.active {
    background: #ffffff; color: #7A1E17; box-shadow: 0 1px 2px rgba(0,0,0,0.05); font-weight: bold;
}
.pagesize-form { display: flex; align-items: center; gap: 12px; }

/* --- 6. Dual View System (List Mode B2B Table) --- */
/* Hide Table elements in Grid mode */
.products-grid:not(.list-view) .list-view-header,
.products-grid:not(.list-view) .list-view-content { display: none; }

/* Hide Grid elements in List mode */
.products-grid.list-view .grid-view-content { display: none; }

/* List Container Styling */
.products-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 0;
    background: #ffffff;
    border: 1px solid #E5E7EB;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

/* Grid Layout definitions for both header and rows */
.products-grid.list-view .list-view-header,
.products-grid.list-view .list-view-content {
    display: grid;
    grid-template-columns: 2fr 1fr 1.2fr 1fr 1fr 140px 110px;
    gap: 16px;
    align-items: center;
}

/* Header styling */
.products-grid.list-view .list-view-header {
    background: #F8FAFC;
    padding: 12px 20px;
    border-bottom: 1px solid #E5E7EB;
    font-size: 12px;
    font-weight: 700;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Row styling */
.products-grid.list-view .product-card {
    display: block;
    border: none;
    border-bottom: 1px solid #E5E7EB;
    border-radius: 0;
    padding: 0;
    background: #ffffff;
    transition: all 0.2s ease;
}
.products-grid.list-view .product-card:last-child {
    border-bottom: none;
}
.products-grid.list-view .product-card:hover {
    background: #F9FAFB;
}
.products-grid.list-view .list-view-content {
    padding: 18px 20px;
    min-height: 100px;
}

/* Col 1: Product */
.lvc-product { display: flex; gap: 16px; align-items: center; }
.lvc-product-img-box {
    width: 72px; height: 72px; min-width: 72px;
    background: #F8FAFC; border: 1px solid #E5E7EB; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.lvc-img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lvc-product-info { display: flex; flex-direction: column; gap: 2px; }
.lvc-name { font-size: 15px; font-weight: 700; color: #111827; text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lvc-name:hover { color: #7A1E17; text-decoration: underline; }
.lvc-brand { font-size: 13px; color: #374151; }
.lvc-sku { font-size: 12px; color: #6B7280; }

/* Col 2: Format */
.lvc-format { display: flex; flex-direction: column; gap: 2px; }
.lvc-format-main { font-size: 14px; font-weight: 600; color: #111827; }
.lvc-format-sub { font-size: 13px; color: #6B7280; }

/* Col 3: Stock */
.lvc-stock { display: flex; flex-direction: column; gap: 2px; }
.lvc-stock-status { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: #16A34A; }
.dot-orange { background: #F97316; }
.dot-red { background: #DC2626; }
.text-green { color: #16A34A; }
.text-orange { color: #F97316; }
.text-red { color: #DC2626; }
.lvc-stock-qty { font-size: 12px; color: #6B7280; }

/* Col 4: Tags */
.lvc-tags-container { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.lvc-badge {
    padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; gap: 4px;
}
.lvc-badge-promo { background: #FEE2E2; color: #B91C1C; }
.lvc-badge-cart { background: #DCFCE7; color: #166534; }

/* Col 5: Price */
.lvc-price { display: flex; flex-direction: column; gap: 2px; }
.lvc-price-main { font-size: 16px; font-weight: 800; color: #7A1E17; }
.lvc-price-unit { font-size: 14px; font-weight: 600; color: #6B7280; }
.lvc-price-sub { font-size: 12px; color: #6B7280; }
.lvc-login-hint { font-size: 14px; font-weight: 600; color: #DC2626; }

/* Col 6: Qty */
.list-qty-stepper {
    display: flex; align-items: center; width: 130px; height: 42px;
    border: 1px solid #E5E7EB; border-radius: 12px; background: #ffffff;
    overflow: hidden;
}
.list-qty-stepper .qty-btn {
    width: 36px; height: 100%; border: none; background: transparent; color: #4B5563; font-size: 18px; cursor: pointer; transition: background 0.2s;
}
.list-qty-stepper .qty-btn:hover:not(:disabled) { background: #F3F4F6; }
.list-qty-stepper .qty-input {
    flex: 1; height: 100%; border: none; text-align: center; font-size: 15px; font-weight: 700; color: #111827; padding: 0; background: transparent; outline: none;
}
/* Highlight when > 0 */
.list-qty-stepper.has-qty { background: #FFFBEB; border-color: #FDE68A; }

/* Col 7: Actions */
.lvc-actions { display: flex; align-items: center; justify-content: flex-end; }
.list-add-btn {
    background: #7A1E17; color: #ffffff; border: none; border-radius: 10px;
    padding: 10px 16px; font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px;
    cursor: pointer; transition: all 0.2s; width: 100%; justify-content: center;
}
.list-add-btn:hover:not(:disabled) { background: #5F1410; box-shadow: 0 4px 6px rgba(122,30,23,0.2); transform: translateY(-1px); }
.list-remove-btn {
    background: #ffffff; color: #6B7280; border: 1px solid #E5E7EB; border-radius: 10px;
    width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s; font-size: 16px;
}
.list-remove-btn:hover { background: #FEE2E2; color: #DC2626; border-color: #FECACA; }

/* Mobile Fallback for List View */
@media (max-width: 1200px) {
    .products-grid.list-view .list-view-header,
    .products-grid.list-view .list-view-content {
        grid-template-columns: 2fr 1fr 1fr 1fr 120px 50px;
    }
    .lvh-tags, .lvc-tags { display: none; }
}
@media (max-width: 991px) {
    .products-grid.list-view .list-view-header { display: none; }
    .products-grid.list-view .list-view-content {
        grid-template-columns: 1fr; gap: 12px; padding: 16px;
    }
    .lvc-product { border-bottom: 1px solid #f1f5f9; padding-bottom: 12px; }
    .lvc-format, .lvc-stock { display: inline-flex; flex-direction: row; gap: 8px; align-items: center; }
    .lvc-price { align-items: flex-start; margin-top: 8px; }
    .lvc-qty { justify-content: flex-start; margin-top: 8px; }
    .lvc-actions { justify-content: flex-start; margin-top: 8px; }
    .list-qty-stepper { width: 100%; max-width: 200px; }
}

@media (max-width: 768px) {
    .b2b-list-topbar { flex-direction: column; align-items: flex-start; gap: 16px; }
    .topbar-center, .topbar-right { width: 100%; justify-content: space-between; }
    .pagesize-form { display: none; } /* Hide page size selector on small screens */
}

/* --- 7. Public CTA Block --- */
.public-catalog-cta {
    background: linear-gradient(135deg, var(--primary) 0%, #4a0d08 100%);
    color: #ffffff;
    border-radius: 16px;
    padding: 40px;
    margin-top: 40px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(122, 30, 23, 0.2);
}
.public-cta-content h3 {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 12px;
}
.public-cta-content p {
    font-size: 1.1rem;
    color: #fca5a5;
    margin-bottom: 30px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}
.public-cta-actions {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
}
.public-cta-actions .btn {
    border-radius: 12px;
    font-weight: 700;
    padding: 12px 28px;
    transition: all 0.2s;
}
.public-cta-actions .btn-primary {
    background: #ffffff;
    color: var(--primary);
    border: none;
}
.public-cta-actions .btn-primary:hover {
    background: #f1f5f9;
    transform: translateY(-2px);
}
.public-cta-actions .btn-outline-light {
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #ffffff;
    background: transparent;
}
.public-cta-actions .btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #ffffff;
    transform: translateY(-2px);
}

/* Public Locked States */
.lvc-qty-locked {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: #F3F4F6;
    border: 1px dashed #D1D5DB;
    border-radius: 12px;
    color: #9CA3AF;
    font-size: 1.2rem;
}
.btn-public-auth {
    background: #F3F4F6 !important;
    color: #4B5563 !important;
    border: 1px solid #D1D5DB !important;
}
.btn-public-auth:hover {
    background: #E5E7EB !important;
    color: #111827 !important;
    border-color: #9CA3AF !important;
}
