/* ==========================================================================
   Brand Products Bottom Sheet
   Exibição da lista de produtos de uma marca em formato Bottom Sheet fluido
   ========================================================================== */

body.brand-products-sheet-open {
    overflow: hidden !important;
    touch-action: none;
    -webkit-overflow-scrolling: auto;
}

/* Backdrop */
.brand-products-sheet-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 10055; /* Logo abaixo do preview sheet (10060) para permitir preview empilhado */
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                visibility 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    overscroll-behavior: none !important;
}

.brand-products-sheet-backdrop.is-active {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

/* Dialog Bottom Sheet */
.brand-products-sheet {
    position: relative;
    width: 100%;
    max-width: 640px;
    background-color: var(--card-bg, #ffffff);
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -12px 42px rgba(0, 0, 0, 0.22);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                height 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    will-change: transform, height;
    height: 75vh;
    max-height: 85vh;
    overscroll-behavior: contain !important;
}

.brand-products-sheet-backdrop.is-active .brand-products-sheet {
    transform: translateY(0);
}

.brand-products-sheet.is-expanded {
    height: 94vh;
    max-height: 94vh;
}

/* Barra de Arraste (Handle) */
.brand-products-sheet-handle {
    width: 100%;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    touch-action: none;
    flex-shrink: 0;
}

.brand-products-sheet-handle:active {
    cursor: grabbing;
}

.brand-products-sheet-pill {
    width: 40px;
    height: 5px;
    border-radius: 3px;
    background-color: var(--border-color, #d1d5db);
    transition: background-color 0.2s ease, width 0.2s ease;
}

/* Cabeçalho */
.brand-products-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px 14px 20px;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    gap: 12px;
    flex-shrink: 0;
}

.brand-sheet-header-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1;
}

/* Logo Redonda da Marca no Cabeçalho */
.brand-sheet-logo-wrap {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 50% !important;
    background-color: #ffffff;
    border: 1px solid var(--border-color, #e5e7eb);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 3px;
    box-sizing: border-box;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    flex-shrink: 0;
}

.brand-sheet-logo-wrap img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 50%;
}

.brand-sheet-logo-wrap.no-logo {
    background-color: var(--card-bg, #f3f4f6);
}

.brand-sheet-logo-initial {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-color, #111827);
    line-height: 1;
}

.brand-sheet-header-text {
    min-width: 0;
    flex: 1;
}

.brand-sheet-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-color, #111827);
    margin: 0;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-sheet-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted, #6b7280);
    margin-top: 2px;
}

/* Ações do Cabeçalho (Botão Catálogo Geral + Botão Fechar) */
.brand-sheet-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.brand-sheet-catalog-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--primary-color, #0071e3);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 980px;
    background: rgba(0, 113, 227, 0.08);
    white-space: nowrap;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.brand-sheet-catalog-btn:hover {
    background: rgba(0, 113, 227, 0.15);
}

.brand-sheet-catalog-btn:active {
    transform: scale(0.98);
}

.brand-sheet-close {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: var(--text-muted, #6b7280);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, color 0.15s;
    flex-shrink: 0;
}

.brand-sheet-close:hover {
    background-color: var(--bg-hover, #f3f4f6);
    color: var(--text-color, #111827);
}

/* Corpo Rolável */
.brand-products-sheet-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 16px 32px 16px;
    overscroll-behavior: contain;
}

/* Scrollbar fluida */
.brand-products-sheet-body::-webkit-scrollbar {
    width: 6px;
}

.brand-products-sheet-body::-webkit-scrollbar-thumb {
    background: var(--border-color, #d1d5db);
    border-radius: 3px;
}

.brand-products-sheet-body::-webkit-scrollbar-track {
    background: transparent;
}

/* Lista de Produtos (Estilo Contíguo com Separadores de Produtos e Estabelecimentos) */
.brand-products-list {
    display: flex;
    flex-direction: column;
    gap: 0 !important;
    margin: 0;
    padding: 0;
}

.brand-product-row {
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    padding: 12px 6px;
    margin: 0 !important;
    border-radius: 0 !important;
    border: none !important;
    border-bottom: 1px solid var(--border-color) !important;
    background-color: transparent;
    box-shadow: none !important;
    transition: var(--block-transition, background-color 0.1s ease);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.brand-product-row.is-last,
.brand-product-row:last-child {
    border-bottom: none !important;
}

@media (hover: hover) and (pointer: fine) {
    .brand-product-row:hover {
        background-color: var(--block-hover-bg, rgba(0, 0, 0, 0.025));
    }
}

.brand-product-row:active,
.brand-product-row.is-pressed {
    border-radius: 0 !important;
    background-color: var(--block-pressed-bg, #e6e6e6) !important;
    box-shadow: none !important;
}

/* Avatar Redondo dos Produtos na Bottom Sheet */
.brand-product-row .product-avatar {
    width: 72px;
    height: 72px;
    min-width: 72px;
    min-height: 72px;
    border-radius: 50% !important;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: var(--card-bg, #f3f4f6);
    border: 1px solid var(--border-color, #e5e7eb);
    flex-shrink: 0;
    box-sizing: border-box;
}

@media (max-width: 480px) {
    .brand-product-row .product-avatar {
        width: 66px;
        height: 66px;
        min-width: 66px;
        min-height: 66px;
    }
}

.brand-product-row .product-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50% !important;
}

.brand-product-row .product-avatar span {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--text-color, #111827);
    line-height: 1;
}

/* Skeletons */
.brand-sheet-skeleton-wrap {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
}

.brand-skeleton-row {
    height: 72px;
    border-radius: 0;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
}

.brand-skeleton-row:last-child {
    border-bottom: none;
}

.preview-shimmer {
    animation: brandShimmer 1.5s infinite;
}

@keyframes brandShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Estado Vazio */
.brand-sheet-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted, #6b7280);
    font-size: 0.95rem;
}

/* Dark Mode */
[data-theme="dark"] .brand-products-sheet {
    background-color: #1a1a1a;
    box-shadow: 0 -12px 42px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .brand-products-sheet-header {
    border-color: #2e2e2e;
}

[data-theme="dark"] .brand-sheet-logo-wrap {
    background-color: #ffffff; /* Preserva o fundo branco para contraste da logo */
    border-color: #444444;
}

[data-theme="dark"] .brand-sheet-logo-wrap.no-logo {
    background-color: #262626;
    border-color: #3e3e3e;
}

[data-theme="dark"] .brand-sheet-logo-wrap.no-logo .brand-sheet-logo-initial {
    color: #e5e7eb;
}

[data-theme="dark"] .brand-product-row:hover {
    background-color: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .brand-product-row:active,
[data-theme="dark"] .brand-product-row.is-pressed {
    border-radius: 0 !important;
    background-color: #262626 !important;
}

[data-theme="dark"] .brand-product-row .product-avatar {
    background-color: #262626;
    border-color: #383838;
}

[data-theme="dark"] .brand-product-row .product-avatar span {
    color: #e5e7eb;
}

[data-theme="dark"] .brand-skeleton-row {
    border-color: #2e2e2e;
    background: linear-gradient(90deg, #262626 25%, #333333 50%, #262626 75%);
    background-size: 200% 100%;
}
