/**
 * catalogo.css - Catálogo mobile-first
 * Pensado para abrir pelo link enviado no WhatsApp, com milhares de itens.
 */

:root {
    --primary-color: #25D366;
    --primary-dark: #128C7E;
    --primary-darker: #075E54;
    --accent-color: #E8590C;
    --text-dark: #1f1f1f;
    --text-muted: #5f6b76;
    --border-color: #e3e6e8;
    --bg-light: #f4f6f7;
    --altura-topo: 56px;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: white;
    color: var(--text-dark);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    min-height: 100vh;
}

[hidden] {
    display: none !important;
}

main.container-fluid {
    padding: var(--altura-topo) 0 96px 0;
}

/* === CABEÇALHO === */
.navbar {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    height: var(--altura-topo);
    padding: 0 0.25rem;
    z-index: 1030;
}

.navbar .container-fluid {
    flex-wrap: nowrap;
    gap: 0.75rem;
}

.navbar-brand {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
    margin: 0;
    padding: 0;
}

.marca-nome {
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.marca-subtitulo {
    font-size: 0.72rem;
    font-weight: 500;
    opacity: 0.85;
}

.carrinho-topo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.12);
    color: white;
    border-radius: 12px;
    padding: 0.3rem 0.7rem;
    cursor: pointer;
}

.carrinho-topo .bi {
    font-size: 1.25rem;
}

.carrinho-topo-valores {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.15;
}

.carrinho-topo-total {
    font-weight: 800;
    font-size: 0.95rem;
    font-variant-numeric: tabular-nums;
}

.carrinho-topo small {
    font-size: 0.7rem;
    opacity: 0.85;
}

/* === BUSCA E FILTROS === */
.filtro-container {
    position: sticky;
    top: var(--altura-topo);
    z-index: 100;
    background: white;
    padding: 0.75rem 0.9rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.busca {
    position: relative;
}

.busca > .bi-search {
    position: absolute;
    left: 0.9rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.busca .form-control {
    height: 48px;
    padding: 0 2.8rem 0 2.6rem;
    border: 2px solid var(--primary-dark);
    border-radius: 12px;
    font-size: 1rem;   /* 16px: evita o zoom automático do iPhone ao focar */
    font-weight: 500;
}

.busca .form-control:focus {
    border-color: var(--primary-darker);
    box-shadow: 0 0 0 0.25rem rgba(18, 140, 126, 0.2);
}

/* esconde o "x" nativo do navegador (usamos o nosso) */
.busca .form-control::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.busca-limpar {
    position: absolute;
    right: 0.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.15rem;
    cursor: pointer;
}

.filtros-linha {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.filtros-linha .form-select {
    flex: 1;
    min-width: 0;
    height: 42px;
    border: 1px solid #c9d0d5;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dark);
    cursor: pointer;
}

.filtros-linha .form-select:focus {
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 0.25rem rgba(18, 140, 126, 0.2);
}

.contagem {
    min-height: 1.2rem;
    margin-top: 0.45rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* === CARREGANDO === */
#loading {
    min-height: 30vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 0;
    color: var(--text-muted);
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    color: var(--primary-dark);
}

/* === LINHA DE PRODUTO === */
#listaProdutos {
    margin: 0;
    padding: 0;
}

.produto-item {
    background: white;
    border-bottom: 1px solid var(--border-color);
    border-left: 4px solid transparent;
}

.produto-item.no-carrinho {
    background-color: #f0fbf5;
    border-left-color: var(--primary-color);
}

.produto-content {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.7rem 0.9rem 0.7rem 0.6rem;
}

.produto-foto {
    position: relative;
    flex-shrink: 0;
    width: 72px;
    height: 72px;
    border-radius: 14px;
    overflow: hidden;
    background: var(--bg-light);
}

.produto-foto img {
    display: block;
    width: 100%;
    height: 100%;
}

/* fotografia de verdade (campo "foto" do produto) */
.produto-foto.foto-real {
    border: 1px solid var(--border-color);
    background: white;
}

.produto-foto.foto-real img {
    object-fit: cover;
}

/* a foto é um botão: abre o detalhe */
button.produto-foto {
    padding: 0;
    border: 0;
    cursor: zoom-in;
    font: inherit;
    color: inherit;
}

button.produto-foto.foto-real {
    border: 1px solid var(--border-color);
}

button.produto-foto:focus-visible {
    outline: 3px solid var(--primary-color, #0f766e);
    outline-offset: 2px;
}

.produto-lupa {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: #0f172a;
    font-size: 0.7rem;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

/* detalhe do produto */
.detalhe-foto {
    position: relative;
    width: 100%;
    max-width: 340px;
    aspect-ratio: 1 / 1;
    margin: 0 auto;
    border-radius: 18px;
    overflow: hidden;
    background: var(--bg-light);
}

.detalhe-foto.foto-real {
    border: 1px solid var(--border-color);
    background: white;
}

.detalhe-foto img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.detalhe-foto.foto-real img {
    object-fit: cover;
}

.detalhe-selo {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0.55rem 0.75rem;
    background: rgba(15, 23, 42, 0.82);
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
    text-align: center;
}

.detalhe-aviso {
    margin: 0.5rem 0 0.9rem;
    font-size: 0.78rem;
    color: var(--text-muted, #64748b);
    text-align: center;
}

.detalhe-info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.3rem 0.9rem;
    margin: 0 0 0.9rem;
    font-size: 0.95rem;
}

.detalhe-info dt {
    font-weight: 600;
    color: var(--text-muted, #64748b);
}

.detalhe-info dd {
    margin: 0;
    font-weight: 600;
}

.detalhe-preco {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-dark, #0f5f58);
}

.detalhe-preco.sob-consulta {
    font-size: 1.15rem;
    color: var(--text-muted, #64748b);
}

/* selo com o modelo do aparelho, por cima da foto do tipo de peça */
.produto-selo {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 3px 3px 4px;
    background: rgba(15, 23, 42, 0.82);
    color: #fff;
    font-size: 0.66rem;
    font-weight: 700;
    line-height: 1.12;
    letter-spacing: 0.01em;
    text-align: center;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
}

.produto-info {
    flex: 1;
    min-width: 0;
}

.produto-nome {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.produto-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 0.1rem 0 0;
    line-height: 1.2;
}

.produto-preco {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--primary-darker);
    margin-top: 0.15rem;
    font-variant-numeric: tabular-nums;
}

.produto-preco.sob-consulta,
.carrinho-item-subtotal.sob-consulta {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--accent-color);
}

/* === CONTROLES (- qtd +) === */
.produto-controles {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.btn-qty {
    width: 44px;
    height: 44px;
    border: 2px solid var(--primary-dark);
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--primary-dark);
    cursor: pointer;
    transition: transform 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
}

.btn-qty:active:not(:disabled) {
    transform: scale(0.9);
}

.btn-qty.btn-mais {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: white;
}

.btn-qty:disabled {
    background: #e0e0e0;
    border-color: #e0e0e0;
    color: #999;
    cursor: not-allowed;
}

.qty-display {
    min-width: 28px;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-dark);
    font-variant-numeric: tabular-nums;
}

/* === MOSTRAR MAIS === */
#maisContainer {
    padding: 1rem;
    text-align: center;
}

#maisContainer .btn {
    width: 100%;
    max-width: 360px;
}

/* === CRÉDITOS === */
.creditos-link {
    text-align: center;
    margin: 0.5rem 0 1rem;
    font-size: 0.75rem;
}

.creditos-link a {
    color: var(--text-muted);
}

/* === ESTADO VAZIO === */
.estado-vazio {
    text-align: center;
    padding: 2.5rem 1.25rem;
}

.estado-vazio-icone {
    font-size: 3rem;
    color: #c2c9ce;
}

.estado-vazio-texto {
    margin: 1rem 0 0.25rem;
    font-size: 1rem;
    overflow-wrap: anywhere;
}

.estado-vazio-dica {
    margin: 0 0 1.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.estado-vazio-acoes {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: 320px;
    margin: 0 auto;
}

.estado-vazio-acoes .btn {
    padding: 0.7rem 1rem;
}

/* === RODAPÉ FIXO === */
#finalizarContainer {
    background: white;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
    padding: 0.7rem 0.9rem;
    padding-bottom: calc(0.7rem + env(safe-area-inset-bottom, 0px));
    z-index: 1020;
}

/* Botão principal */
.btn-acao {
    background: var(--accent-color);
    border: none;
    color: white;
    border-radius: 12px;
    padding: 0.8rem 0.5rem;
    font-weight: 800;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(232, 89, 12, 0.35);
    white-space: nowrap;
    min-width: 0;
}

.btn-acao:hover,
.btn-acao:focus,
.btn-acao:active {
    background: #d14f0a;
    color: white;
}

.btn-acao:disabled {
    background: #e0e0e0;
    color: #8a8a8a;
    box-shadow: none;
}

/* Botão secundário */
.btn-resumo {
    background: white;
    color: var(--primary-darker);
    border: 2px solid var(--primary-dark);
    border-radius: 12px;
    padding: 0.8rem 0.5rem;
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    min-width: 0;
}

.btn-resumo:hover,
.btn-resumo:focus,
.btn-resumo:active {
    background: #eef8f5;
    color: var(--primary-darker);
    border-color: var(--primary-dark);
}

.btn-resumo:disabled {
    border-color: #ddd;
    color: #a5a5a5;
    background: white;
}

.btn-whatsapp {
    background: var(--primary-dark);
    border: none;
    color: white;
    font-weight: 800;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(18, 140, 126, 0.35);
}

.btn-whatsapp:hover,
.btn-whatsapp:focus,
.btn-whatsapp:active {
    background: var(--primary-darker);
    color: white;
}

/* === MODAL DO PEDIDO === */
#modalCarrinho .modal-content {
    border: none;
    border-radius: 16px;
    overflow: hidden;
}

#modalCarrinho .modal-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
    color: white;
    border-bottom: none;
}

#modalCarrinho .modal-header .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.9;
}

#modalCarrinho .modal-body {
    padding: 0.5rem 0;
}

#modalCarrinho .modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem;
}

.carrinho-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.carrinho-item:last-child {
    border-bottom: none;
}

.carrinho-item-foto {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
    background: var(--bg-light);
}

.carrinho-item-corpo {
    flex: 1;
    min-width: 0;
}

.carrinho-item-nome {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.carrinho-item-unitario {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.carrinho-item-linha {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.carrinho-qty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-qty-mini {
    width: 36px;
    height: 36px;
    border: 1px solid var(--primary-dark);
    background: white;
    color: var(--primary-darker);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
}

.btn-qty-mini:active {
    background: var(--primary-dark);
    color: white;
}

.carrinho-qty-valor {
    min-width: 28px;
    text-align: center;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.carrinho-item-subtotal {
    font-weight: 800;
    color: var(--primary-darker);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.btn-remover {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: #c62f3d;
    border-radius: 8px;
    font-size: 1.05rem;
    cursor: pointer;
}

.btn-remover:active {
    background: rgba(220, 53, 69, 0.1);
}

.carrinho-total {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-darker);
    font-variant-numeric: tabular-nums;
}

.carrinho-aviso-consulta {
    margin-top: 0.15rem;
    text-align: right;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-color);
}

/* === DADOS DO CLIENTE === */
.carrinho-form {
    padding: 0.75rem 1rem 0.25rem;
}

.carrinho-resumo-curto {
    background: var(--bg-light);
    border-radius: 12px;
    padding: 0.7rem 0.9rem;
    margin-bottom: 1rem;
}

.carrinho-resumo-curto .carrinho-total {
    font-size: 1.2rem;
}

.carrinho-form .form-label {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.campo-opcional {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.carrinho-form .form-control {
    font-size: 1rem;   /* 16px: evita o zoom automático do iPhone */
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
}

.carrinho-form .form-control:focus {
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 0.25rem rgba(18, 140, 126, 0.2);
}

.carrinho-dica {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin: 0 0 0.5rem;
    line-height: 1.4;
}

/* === PEDIDO ENVIADO === */
.confirmacao {
    text-align: center;
    padding: 1.5rem 1.25rem 0.5rem;
}

.confirmacao-icone {
    font-size: 3.5rem;
    color: var(--primary-dark);
    line-height: 1;
}

.confirmacao-numero {
    margin: 0.8rem 0 0.6rem;
    font-size: 1.15rem;
}

.confirmacao-texto {
    font-size: 0.92rem;
    margin: 0 0 0.6rem;
    line-height: 1.45;
}

/* === AVISO RÁPIDO (TOAST) === */
.toast-feedback {
    position: fixed;
    left: 50%;
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    transform: translate(-50%, 12px);
    max-width: 88vw;
    padding: 0.7rem 1.2rem;
    border-radius: 24px;
    background: rgba(31, 31, 31, 0.94);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1090;
}

.toast-feedback.visivel {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast-feedback.toast-aviso {
    background: rgba(196, 73, 8, 0.97);
}

.toast-feedback.toast-erro {
    background: rgba(176, 32, 46, 0.97);
}

/* === TELAS MAIORES === */
@media (min-width: 768px) {
    .filtro-container > *,
    #listaProdutos,
    #finalizarContainer > .d-flex {
        max-width: 720px;
        margin-left: auto;
        margin-right: auto;
    }

    .filtro-container .filtros-linha,
    .filtro-container .contagem {
        margin-top: 0.5rem;
    }

    .produto-item {
        border: 1px solid var(--border-color);
        border-left: 4px solid transparent;
        border-radius: 12px;
        margin-top: 0.6rem;
    }

    .produto-item.no-carrinho {
        border-left-color: var(--primary-color);
    }

    .produto-nome {
        font-size: 1rem;
    }

    .produto-foto {
        width: 84px;
        height: 84px;
    }

    .produto-selo {
        font-size: 0.72rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}
