/* PROPOSTA A — CORPORATE BLUE (Mobile First) */
:root {
  /* Cor dinâmica simulando estabelecimentos.cor (barras superior e inferior) */
  --bar-color: #003F69;
  /* Paleta interna fixa */
  --blue-deep: #003F69;
  --blue-head: #005481;
  --blue-action: #006B9F;
  --blue-soft: #99CFE6;
  --blue-tint: #E8F4FA;
  --bg-page: #F5F8FA;
  --surface: #FFFFFF;
  --text-main: #12263A;
  --text-muted: #4E6478;
  --border: #D2E0EA;
  --radius: 6px;
  --shadow: 0 1px 4px rgba(0, 63, 105, 0.08);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.45;
  overflow-x: clip;
}
img { max-width: 100%; display: block; }
a { color: inherit; }

/* Barra de demonstração da cor dinâmica do catálogo */
.demo-color-bar {
  background: #0F1E2E;
  color: #E8F4FA;
  font-size: 0.78rem;
  padding: 8px 12px;
}
.demo-color-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.demo-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.swatch-btn {
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(255,255,255,0.08);
  color: #fff;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
}
.swatch-btn.active {
  background: #fff;
  color: #0F1E2E;
}
.swatch-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.back-portal-link {
  color: #99CFE6;
  text-decoration: none;
  font-weight: 600;
}
.back-portal-link:hover { text-decoration: underline; }

/* Cabeçalho e Rodapé dinâmicos (estabelecimentos.cor) */
.site-header {
  background: var(--bar-color);
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.header-top-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand-link {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  min-height: 44px;
}
.brand-link img {
  height: 34px;
  width: auto;
  background: #fff;
  padding: 3px 6px;
  border-radius: 4px;
}
.brand-title {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}
.brand-sub {
  font-size: 0.75rem;
  opacity: 0.88;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-nav a {
  color: #fff;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 4px;
  background: rgba(255,255,255,0.14);
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}
.header-nav a:hover { background: rgba(255,255,255,0.24); }

/* Pesquisa no cabeçalho / topo */
.search-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  color: var(--text-main);
}
.search-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.search-row .form-control {
  width: auto;
  flex: 1 1 100px;
  min-width: 0;
}
.form-control {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--text-main);
  background: #fff;
}
.form-control:focus {
  outline: 2px solid var(--blue-soft);
  border-color: var(--blue-action);
}
.btn-search {
  min-height: 44px;
  padding: 0 18px;
  background: var(--blue-action);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.btn-search:hover { background: var(--blue-head); }

/* Conteúdo principal */
.main-container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px 12px 40px;
  overflow-x: hidden;
}
.panel-box, .search-box { width: 100%; max-width: 100%; min-width: 0; }
.page-head { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.page-title, .breadcrumb { overflow-wrap: anywhere; }
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.breadcrumb a {
  color: var(--blue-action);
  text-decoration: none;
  font-weight: 600;
}
.page-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--blue-deep);
}
.page-subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Barra de ferramentas da listagem (Filtros, Top Giro, Top Valores, Impressão) */
.toolbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toolbar-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.btn-corp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--blue-action);
  background: #fff;
  color: var(--blue-action);
  text-align: center;
}
.btn-corp:hover, .btn-corp.active {
  background: var(--blue-action);
  color: #fff;
}
.btn-corp.secondary {
  border-color: var(--border);
  background: var(--blue-tint);
  color: var(--blue-deep);
}
.btn-corp.secondary:hover {
  background: var(--blue-soft);
}
.results-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* Grades Mobile First */
.catalog-grid, .category-grid, .product-grid, .product-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.catalog-grid > *, .category-grid > *, .product-grid > *, .product-detail-grid > * {
  min-width: 0;
}

/* Cards de Catálogo (Tela 01) */
.catalog-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s;
}
.catalog-card:hover {
  border-color: var(--blue-action);
  transform: translateY(-2px);
}
.catalog-banner {
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  color: #fff;
}
.catalog-banner img {
  width: 68px;
  height: 68px;
  object-fit: contain;
  background: #fff;
  border-radius: 6px;
  padding: 6px;
}
.catalog-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.catalog-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--blue-deep);
  margin: 0;
}
.catalog-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
}
.catalog-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--blue-tint);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--blue-head);
}

/* Cards de Categoria (Tela 02) */
.category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px;
  min-height: 88px;
}
.category-card:hover { border-color: var(--blue-action); }
.category-card img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 4px;
  flex-shrink: 0;
}
.category-info h3 {
  margin: 0 0 4px;
  font-size: 0.98rem;
  color: var(--blue-deep);
}
.category-info span {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Cards de Produto + Tabela Técnica Permanente (Tela 03) */
.product-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.product-link-top {
  text-decoration: none;
  display: flex;
  flex-direction: column;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.product-link-top:hover .product-title { color: var(--blue-action); }
.product-img-wrap {
  height: 170px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FAFCFE;
  border: 1px solid #E9F0F5;
  border-radius: 4px;
  margin-bottom: 10px;
  padding: 8px;
}
.product-img-wrap img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
}
.product-code {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--blue-head);
  background: var(--blue-tint);
  padding: 2px 7px;
  border-radius: 3px;
  margin-bottom: 5px;
  align-self: flex-start;
  font-variant-numeric: tabular-nums;
}
.product-title {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.35;
  min-height: 2.7em;
}

/* Tabela técnica Corporativa (Proposta A: cabeçalho azul profundo + zebra azul claro) */
.tech-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tech-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.69rem;
  font-variant-numeric: tabular-nums;
}
.tech-table th, .tech-table td {
  padding: 4px 5px;
  border: 1px solid var(--border);
  vertical-align: middle;
}
.tech-table th {
  background: var(--blue-deep);
  color: #fff;
  font-weight: 600;
  text-align: left;
  white-space: normal;
  word-break: break-word;
}
.tech-table td {
  text-align: right;
  font-weight: 600;
  color: var(--text-main);
  background: #fff;
  white-space: nowrap;
}
.tech-table tr:nth-child(even) th {
  background: var(--blue-head);
}
.tech-table tr:nth-child(even) td {
  background: var(--blue-tint);
}

/* Tela 04 — Detalhamento do Produto */
.product-detail-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
.panel-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.panel-box h2, .panel-box h3 {
  margin: 0 0 12px;
  font-size: 1.05rem;
  color: var(--blue-deep);
  padding-bottom: 8px;
  border-bottom: 2px solid var(--blue-tint);
}
.gallery-main {
  height: 260px;
  background: #FAFCFE;
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.gallery-main img { max-height: 100%; object-fit: contain; }
.gallery-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.thumb-btn {
  width: 64px;
  height: 64px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: #fff;
  padding: 4px;
  cursor: pointer;
}
.thumb-btn.active { border-color: var(--blue-action); }
.thumb-btn img { width: 100%; height: 100%; object-fit: contain; }

/* Tratamento das tabelas HTML importadas (produtos.detalhes_extras) sem alterar o HTML do banco */
.imported-tables-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
}
.imported-tables-wrap table {
  width: 100% !important;
  border-collapse: collapse !important;
  border: 0 !important;
  font-size: 0.78rem !important;
  font-variant-numeric: tabular-nums;
  margin: 0 !important;
}
.imported-tables-wrap table + table {
  margin-top: 12px !important;
}
.imported-tables-wrap td {
  width: auto !important;
  padding: 7px 9px !important;
  border: 1px solid var(--border) !important;
  vertical-align: middle !important;
  white-space: nowrap;
  text-align: right;
  color: var(--text-main);
}
.imported-tables-wrap td br { display: none; }
.imported-tables-wrap tr[bgcolor="#6699ff"],
.imported-tables-wrap tr[bgcolor="#6699ff"] td {
  background-color: var(--blue-deep) !important;
  color: #FFFFFF !important;
  font-weight: 700 !important;
  text-align: right !important;
}
.imported-tables-wrap tr[bgcolor="#6699ff"] td:first-child {
  text-align: left !important;
}
.imported-tables-wrap tr[bgcolor="#66b3ff"] td {
  background-color: var(--blue-tint) !important;
}
.imported-tables-wrap tr:not([bgcolor="#6699ff"]):not([bgcolor="#66b3ff"]) td {
  background-color: #FFFFFF !important;
}
.imported-tables-wrap td:first-child {
  text-align: left !important;
  font-weight: 600;
  position: sticky;
  left: 0;
  z-index: 1;
}
/* Ocultar tabela separadora literal "_" sem quebrar o restante */
.imported-tables-wrap table:nth-of-type(2) {
  display: none;
}

/* Rodapé dinâmico (estabelecimentos.cor) */
.site-footer {
  background: var(--bar-color);
  color: #fff;
  padding: 18px 14px;
  margin-top: 24px;
  font-size: 0.82rem;
}
.footer-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
}

/* Breakpoints progressivos */
@media (min-width: 600px) {
  .catalog-grid { grid-template-columns: repeat(2, 1fr); }
  .category-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar-actions { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
  .main-container { padding: 22px 20px 48px; }
  .header-inner { flex-direction: row; align-items: center; justify-content: space-between; }
  .search-form { flex-direction: row; align-items: center; }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .product-detail-grid { grid-template-columns: 380px 1fr; align-items: start; }
}
@media (min-width: 1024px) {
  .catalog-grid { grid-template-columns: repeat(3, 1fr); }
  .category-grid { grid-template-columns: repeat(3, 1fr); }
  .toolbar-actions { display: flex; flex-wrap: wrap; }
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1366px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1680px) {
  .catalog-grid { grid-template-columns: repeat(5, 1fr); }
}
