/* ProdutoAI Searcher — folha de estilo única, sem dependências externas. */

:root {
    color-scheme: light dark;

    --bg: #f6f5f2;
    --surface: #ffffff;
    --surface-alt: #faf9f7;
    --border: #e2ded6;
    --text: #1d1b18;
    --text-muted: #6b6459;
    --accent: #b4532a;
    --accent-soft: #f4e5dd;
    --danger: #a32020;
    --danger-soft: #fbe9e9;
    --warn: #8a6100;
    --warn-soft: #fdf3dd;
    --radius: 14px;
    --shadow: 0 1px 2px rgb(29 27 24 / 6%), 0 8px 24px -12px rgb(29 27 24 / 18%);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #161513;
        --surface: #1f1e1b;
        --surface-alt: #262420;
        --border: #35322c;
        --text: #f0ede7;
        --text-muted: #a29a8d;
        --accent: #e8825a;
        --accent-soft: #3a2419;
        --danger: #f08a8a;
        --danger-soft: #3a1e1e;
        --warn: #e6bd63;
        --warn-soft: #362b12;
        --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px -12px rgb(0 0 0 / 60%);
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
    line-height: 1.6;
}

a {
    color: var(--accent);
}

/* --- shell ---------------------------------------------------------------- */

.app-shell {
    max-width: 62rem;
    margin: 0 auto;
    padding: 0 1.25rem 4rem;
}

.app-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem 1rem;
    padding: 1.75rem 0 1.25rem;
    border-bottom: 1px solid var(--border);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: inherit;
}

.brand-mark {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--accent), #e0a878);
}

.brand-text {
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.brand-text strong {
    font-weight: 700;
}

.brand-text span {
    font-weight: 400;
    color: var(--text-muted);
}

.brand-note {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.app-main {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-top: 2rem;
}

.app-footer {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* --- busca ---------------------------------------------------------------- */

.search-panel h1 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.6rem, 4vw, 2.3rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

.lede {
    margin: 0 0 1.75rem;
    max-width: 44rem;
    color: var(--text-muted);
}

.search-fields {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 0.75rem;
    align-items: end;
}

/* Passo intermediário: os três campos em cima, botão ocupando a linha de baixo. */
@media (max-width: 62rem) {
    .search-fields {
        grid-template-columns: 2fr 1fr 1fr;
    }

    .search-fields .btn-search {
        grid-column: 1 / -1;
    }
}

@media (max-width: 40rem) {
    .search-fields {
        grid-template-columns: 1fr;
    }
}

.field-hint {
    margin: 0.6rem 0 0;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.field > span {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.field input {
    width: 100%;
    padding: 0.7rem 0.85rem;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.field input:focus-visible,
.btn-search:focus-visible,
.chip:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn-search {
    padding: 0.72rem 1.6rem;
    font: inherit;
    font-weight: 600;
    color: #fff;
    background: var(--accent);
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: opacity 120ms ease;
}

.btn-search:hover:not(:disabled) {
    opacity: 0.88;
}

.btn-search:disabled,
.chip:disabled,
.field input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.examples {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.chip {
    padding: 0.28rem 0.7rem;
    font: inherit;
    font-size: 0.85rem;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
}

.chip:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent);
}

.validation-message,
.validation-errors {
    margin: 0.6rem 0 0;
    padding: 0;
    list-style: none;
    color: var(--danger);
    font-size: 0.88rem;
}

/* --- status e alertas ----------------------------------------------------- */

.status-card {
    display: flex;
    gap: 0.9rem;
    align-items: flex-start;
    padding: 1rem 1.15rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.status-card p {
    margin: 0.2rem 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.spinner {
    flex: none;
    width: 1.1rem;
    height: 1.1rem;
    margin-top: 0.35rem;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .spinner { animation-duration: 3s; }
}

.alert {
    padding: 0.9rem 1.15rem;
    border: 1px solid;
    border-radius: var(--radius);
}

.alert p {
    margin: 0.3rem 0 0;
}

.alert-error {
    color: var(--danger);
    background: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}

.alert-warning {
    color: var(--warn);
    background: var(--warn-soft);
    border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}

.suggestions {
    padding: 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.suggestions h2 {
    margin: 0;
    font-size: 1.15rem;
}

.suggestions > div:first-child > p {
    margin: 0.2rem 0 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.suggestion-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 0.75rem;
}

.suggestion-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    padding: 1rem;
    text-align: left;
    color: var(--text);
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
}

.suggestion-card:hover:not(:disabled),
.suggestion-card:focus-visible {
    border-color: var(--accent);
}

.suggestion-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.suggestion-card > span,
.suggestion-card > small {
    color: var(--text-muted);
}

.suggestion-brand {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.suggestion-action {
    margin-top: 0.55rem;
    color: var(--accent) !important;
    font-size: 0.82rem;
    font-weight: 600;
}

/* Rodapé de diagnóstico da chamada: o que foi pesquisado e quanto demorou. */
.result-meta {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.result-meta code {
    font-size: 0.85em;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    background: var(--surface-2, rgba(127, 127, 127, 0.12));
}

/* --- ficha do produto ----------------------------------------------------- */

.product {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.product-hero {
    display: grid;
    grid-template-columns: 15rem 1fr;
    gap: 1.75rem;
    padding: 1.75rem;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border);
}

@media (max-width: 46rem) {
    .product-hero {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
}

.product-photo {
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.product-photo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* --- galeria -------------------------------------------------------------- */

.product-gallery {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

/* Tira horizontal: com muitas imagens, rola dentro de si em vez de esticar a coluna. */
.thumbs {
    display: flex;
    gap: 0.45rem;
    overflow-x: auto;
    padding-bottom: 0.2rem;
    scrollbar-width: thin;
}

.thumb {
    flex: 0 0 auto;
    width: 3.4rem;
    height: 3.4rem;
    display: grid;
    place-items: center;
    padding: 0.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    opacity: 0.65;
    transition: opacity 120ms ease, border-color 120ms ease;
}

.thumb:hover {
    opacity: 1;
}

.thumb.is-active {
    opacity: 1;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

.thumb:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.thumb-caption {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--text-muted);
}

.photo-fallback {
    display: grid;
    place-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
}

.photo-fallback span {
    font-size: 2.4rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.photo-fallback small {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.eyebrow {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--accent);
}

.product-headline h2 {
    margin: 0.25rem 0 0.75rem;
    font-size: clamp(1.35rem, 3vw, 1.85rem);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.badge {
    padding: 0.2rem 0.65rem;
    font-size: 0.8rem;
    background: var(--accent-soft);
    color: var(--accent);
    border-radius: 999px;
}

.badge-price {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.badge-gtin {
    background: transparent;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.04em;
}

.highlights {
    margin: 1rem 0 0;
    padding-left: 1.1rem;
    color: var(--text-muted);
}

.highlights li {
    margin-bottom: 0.25rem;
}

.product-section {
    padding: 1.5rem 1.75rem;
    border-bottom: 1px solid var(--border);
}

.product-section:last-child {
    border-bottom: 0;
}

.product-section > h3 {
    margin: 0 0 0.9rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--text-muted);
}

.product-section p {
    margin: 0 0 0.85rem;
    max-width: 46rem;
}

.product-section p:last-child {
    margin-bottom: 0;
}

.spec-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr));
    gap: 1.5rem;
}

.section-intro {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.sku-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
    gap: 0.8rem;
}

.sku-card {
    padding: 1rem;
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.sku-heading {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: baseline;
}

.sku-heading h4 {
    margin: 0;
    font-size: 0.98rem;
}

.sku-price {
    color: var(--accent);
    font-size: 0.82rem;
    font-weight: 600;
    text-align: right;
}

.sku-identifiers,
.sku-attributes {
    margin: 0.75rem 0 0;
    font-size: 0.82rem;
}

.sku-identifiers > div,
.sku-attributes > div {
    display: grid;
    grid-template-columns: minmax(4rem, 40%) 1fr;
    gap: 0.5rem;
    padding: 0.3rem 0;
    border-top: 1px solid var(--border);
}

.sku-identifiers dt,
.sku-attributes dt {
    color: var(--text-muted);
}

.sku-identifiers dd,
.sku-attributes dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.spec-group h4 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
}

.spec-group dl {
    margin: 0;
}

.spec-row {
    display: grid;
    grid-template-columns: minmax(6rem, 40%) 1fr;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
}

.spec-row dt {
    color: var(--text-muted);
}

.spec-row dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.seo {
    margin: 0;
}

.seo-row {
    display: grid;
    grid-template-columns: minmax(6rem, 25%) 1fr;
    gap: 0.75rem;
    padding: 0.4rem 0;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
}

.seo-row dt {
    color: var(--text-muted);
}

.seo-row dd {
    margin: 0;
    overflow-wrap: anywhere;
}

/* A contagem existe para ver de relance se o texto cabe no snippet do buscador. */
.seo-count {
    font-variant-numeric: tabular-nums;
    font-size: 0.8rem;
    opacity: 0.7;
}

.sources {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.9rem;
}

.sources li {
    margin-bottom: 0.3rem;
    overflow-wrap: anywhere;
}

.notes p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* --- erro do Blazor ------------------------------------------------------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    padding: 0.7rem 1.25rem;
    background: var(--warn-soft);
    color: var(--warn);
    box-shadow: 0 -1px 2px rgb(0 0 0 / 20%);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 0.6rem;
    right: 0.9rem;
    cursor: pointer;
}

/* --- painel de administração ---------------------------------------------- */
/*
   Reaproveita os tokens já definidos em :root, então tema claro e escuro seguem
   funcionando sem nada a mais. Nenhuma dependência nova: o Bootstrap em wwwroot/lib
   continua sem uso.
*/

.app-nav {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-left: auto;
}

.nav-item {
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius);
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.92rem;
}

.nav-item:hover { background: var(--surface-alt); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.app-signout { display: flex; align-items: center; gap: 0.6rem; margin-left: 1rem; }
.app-user { color: var(--text-muted); font-size: 0.85rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; }
.card-narrow { max-width: 26rem; margin: 3rem auto; }

.form-stack { display: flex; flex-direction: column; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; margin: 1rem 0; }

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field > span { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.field-wide { grid-column: 1 / -1; }

.field input, .field select, .field textarea, .filtros input, .filtros select {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    width: 100%;
}

.filtros { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; margin: 1rem 0; }
.filtros input, .filtros select { width: auto; min-width: 12rem; }

.btn {
    padding: 0.55rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn:hover:not(:disabled) { background: var(--surface-alt); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
.btn-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.linklike {
    background: none; border: none; padding: 0 0.25rem;
    color: var(--accent); cursor: pointer; font: inherit; text-decoration: underline;
}

.tabela { width: 100%; border-collapse: collapse; margin: 1rem 0; font-size: 0.92rem; }
.tabela th {
    text-align: left; padding: 0.6rem 0.5rem; border-bottom: 2px solid var(--border);
    color: var(--text-muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em;
}
.tabela td { padding: 0.6rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.tabela tr:hover td { background: var(--surface-alt); }
.tabela .inativo { opacity: 0.55; }
.tabela .linha-invalida td { background: var(--danger-soft); }

.tag {
    display: inline-block; padding: 0.15rem 0.5rem; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600; margin-left: 0.35rem;
}
.tag-ok { background: var(--accent-soft); color: var(--accent); }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-danger { background: var(--danger-soft); color: var(--danger); }
.tag-auto { background: var(--surface-alt); color: var(--text-muted); }
.tag-manual { background: var(--accent-soft); color: var(--accent); }
.tag-import { background: var(--warn-soft); color: var(--warn); }

.mono { font-family: ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace; font-size: 0.88em; }
.muted { color: var(--text-muted); }
.erro { color: var(--danger); }
.ok { color: var(--accent); }
.resumo { margin-top: -0.5rem; }

.paginacao { display: flex; gap: 1rem; align-items: center; justify-content: center; margin: 1.5rem 0; }
.check { display: inline-flex; align-items: center; gap: 0.4rem; }
.check input { width: auto; }

.alert { padding: 0.8rem 1rem; border-radius: var(--radius); margin: 1rem 0; }
.alert-ok { background: var(--accent-soft); color: var(--accent); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }

.chave-nova .chave {
    display: block; margin: 0.6rem 0; padding: 0.7rem;
    background: var(--bg); border: 1px dashed var(--accent);
    border-radius: 8px; word-break: break-all; user-select: all;
}

.detalhe-topo { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.detalhe-topo .acoes { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }

.editor, .perigo { margin: 1.5rem 0; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; }
.editor > summary, .perigo > summary { cursor: pointer; font-weight: 600; }
.perigo { border-color: var(--danger); }

@media (max-width: 46rem) {
    .app-nav { width: 100%; order: 3; }
    .tabela { font-size: 0.82rem; }
    .tabela td, .tabela th { padding: 0.45rem 0.3rem; }
}
