/*
 * Portal SAMM — tema sobre Bootstrap 5.3
 * Usado pelo portal do cliente (includes/header.php), área interna (vendedor/header.php),
 * formulário público de BGP (bgp.php) e páginas de erro.
 *
 * Padrões:
 *  - Título de página:  .page-head > h1 (+ .page-sub com o nome da empresa)
 *  - Seções/blocos:     .card (cabeçalho .card-header, corpo .card-body)
 *  - Tabelas:           envolvidas automaticamente em .table-responsive (footer)
 *  - Ícones:            Bootstrap Icons (<i class="bi bi-..."></i>)
 */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/includes/vendor/inter/inter-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/includes/vendor/inter/inter-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --samm-navy: #26255f;
  --samm-navy-700: #1d1c4a;
  --samm-indigo: #3b3a9e;
  --samm-indigo-600: #312f86;
  --samm-cyan: #22b8ef;
  --samm-magenta: #e0408f;
  --samm-amber: #f6b52e;
  --samm-gradient: linear-gradient(90deg, #22b8ef 0%, #7b5bd6 38%, #e0408f 70%, #f6b52e 100%);

  --samm-bg: #f4f5f9;
  --samm-surface: #ffffff;
  --samm-border: #e3e5ee;
  --samm-text: #1c1d33;
  --samm-muted: #6b6f86;
  --samm-radius: 12px;
  --samm-shadow: 0 1px 2px rgba(20, 22, 60, .04), 0 2px 8px rgba(20, 22, 60, .04);

  /* Bootstrap */
  --bs-body-font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --bs-body-font-size: .9375rem;
  --bs-body-color: var(--samm-text);
  --bs-secondary-color: var(--samm-muted);
  --bs-border-color: var(--samm-border);
  --bs-border-radius: 8px;
  --bs-border-radius-lg: var(--samm-radius);
  --bs-primary: var(--samm-indigo);
  --bs-primary-rgb: 59, 58, 158;
  --bs-link-color: var(--samm-indigo);
  --bs-link-color-rgb: 59, 58, 158;
  --bs-link-hover-color: var(--samm-navy);
  --bs-link-hover-color-rgb: 38, 37, 95;
  --bs-primary-bg-subtle: #ececfa;
  --bs-primary-border-subtle: #c9c8ef;
  --bs-primary-text-emphasis: var(--samm-navy);
  --bs-focus-ring-color: rgba(59, 58, 158, .25);
}

html { scroll-behavior: smooth; }
body {
  background-color: var(--samm-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}
main.app-main { flex: 1 0 auto; }
a { text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
hr { border-color: var(--samm-border); opacity: 1; margin: 1.25rem 0; }
h1, h2, h3, h4, h5, h6 { color: var(--samm-navy); font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.0625rem; }
small, .small { color: var(--samm-muted); }
code { color: var(--samm-magenta); }

/* ---------- Barra superior ---------- */
.app-topbar {
  background: var(--samm-navy);
  position: sticky;
  top: 0;
  z-index: 1030;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04);
}
.app-topbar::after {
  content: '';
  display: block;
  height: 3px;
  background: var(--samm-gradient);
}
.app-topbar .navbar { padding: .5rem 0; min-height: 64px; }
.app-brand { display: flex; align-items: center; gap: .75rem; color: #fff; text-decoration: none !important; }
.app-brand img { height: 34px; width: auto; }
.app-brand-label {
  color: rgba(255, 255, 255, .78);
  font-weight: 500;
  font-size: .9375rem;
  padding-left: .75rem;
  border-left: 1px solid rgba(255, 255, 255, .22);
  line-height: 1.2;
  white-space: nowrap;
}
.app-topbar .navbar-nav .nav-link {
  color: rgba(255, 255, 255, .78);
  font-weight: 500;
  border-radius: 8px;
  padding: .5rem .8rem;
  transition: background-color .15s, color .15s;
}
.app-topbar .navbar-nav .nav-link:hover,
.app-topbar .navbar-nav .nav-link:focus,
.app-topbar .navbar-nav .show > .nav-link {
  color: #fff;
  background: rgba(255, 255, 255, .08);
  text-decoration: none;
}
.app-topbar .navbar-nav .active > .nav-link,
.app-topbar .navbar-nav .nav-link.active {
  color: #fff;
  background: rgba(255, 255, 255, .12);
}
.app-topbar .navbar-toggler {
  border: 1px solid rgba(255, 255, 255, .25);
  color: #fff;
  padding: .35rem .6rem;
  font-size: 1.35rem;
  line-height: 1;
}
.app-topbar .navbar-toggler:focus { box-shadow: 0 0 0 .2rem rgba(255, 255, 255, .25); }
.app-topbar .dropdown-menu {
  border: 1px solid var(--samm-border);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(20, 22, 60, .14);
  padding: .4rem;
  min-width: 14rem;
}
.dropdown-item { border-radius: 6px; padding: .5rem .75rem; font-weight: 500; }
.dropdown-item i { width: 1.25rem; display: inline-block; color: var(--samm-muted); }
.dropdown-item:active { background: var(--samm-indigo); }
.dropdown-item:active i { color: #fff; }

.app-user {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
}
.app-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .28);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-transform: uppercase;
}
.app-lang {
  display: inline-flex;
  border: 1px solid rgba(255, 255, 255, .25);
  border-radius: 999px;
  padding: 2px;
}
.app-lang a {
  color: rgba(255, 255, 255, .7);
  font-size: .75rem;
  font-weight: 600;
  padding: .2rem .55rem;
  border-radius: 999px;
  text-decoration: none !important;
  letter-spacing: .03em;
}
.app-lang a:hover { color: #fff; }
.app-lang a.active { background: #fff; color: var(--samm-navy); }

@media (max-width: 991.98px) {
  .app-topbar .navbar-collapse {
    border-top: 1px solid rgba(255, 255, 255, .12);
    margin-top: .5rem;
    padding: .5rem 0 .75rem;
  }
  .app-topbar .dropdown-menu {
    background: rgba(255, 255, 255, .06);
    border: 0;
    box-shadow: none;
    padding: 0 0 0 .75rem;
  }
  .app-topbar .dropdown-item { color: rgba(255, 255, 255, .78); }
  .app-topbar .dropdown-item i { color: rgba(255, 255, 255, .5); }
  .app-topbar .dropdown-item:hover,
  .app-topbar .dropdown-item:focus { background: rgba(255, 255, 255, .08); color: #fff; }
  .app-topbar .dropdown-divider { border-color: rgba(255, 255, 255, .12); }
  .app-topbar .nav-tools { padding-top: .75rem; margin-top: .5rem; border-top: 1px solid rgba(255, 255, 255, .12); }
}
@media (max-width: 575.98px) {
  .app-brand img { height: 28px; }
  .app-brand-label { font-size: .8125rem; padding-left: .6rem; }
}

/* ---------- Conteúdo ---------- */
.app-main { padding-top: 2rem; padding-bottom: 3rem; }
@media (max-width: 575.98px) { .app-main { padding-top: 1.25rem; } }

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: .75rem 1.5rem;
  margin-bottom: 1.5rem;
}
.page-head h1 {
  font-size: 1.625rem;
  font-weight: 700;
  margin: 0;
}
.page-head .page-sub {
  margin: .25rem 0 0;
  color: var(--samm-muted);
  font-weight: 500;
}
.page-head .page-sub i { margin-right: .35rem; }
.page-head .page-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
@media (max-width: 575.98px) { .page-head h1 { font-size: 1.375rem; } }

.section-title {
  font-size: .8125rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--samm-muted);
  margin: 2rem 0 .75rem;
}
.section-title:first-child { margin-top: 0; }

/* Cards */
.card {
  --bs-card-border-color: var(--samm-border);
  --bs-card-border-radius: var(--samm-radius);
  --bs-card-inner-border-radius: calc(var(--samm-radius) - 1px);
  --bs-card-cap-bg: var(--samm-surface);
  --bs-card-spacer-y: 1.125rem;
  --bs-card-spacer-x: 1.25rem;
  box-shadow: var(--samm-shadow);
}
.card-header { font-weight: 600; color: var(--samm-navy); }
.card-header .card-title { font-size: 1rem; font-weight: 600; margin: 0; }
.card-header a[data-bs-toggle="collapse"] {
  display: flex;
  align-items: center;
  gap: .5rem;
  color: inherit;
  text-decoration: none;
}
.card-header a[data-bs-toggle="collapse"]::after {
  content: '\F282'; /* bi-chevron-down */
  font-family: 'bootstrap-icons';
  margin-left: auto;
  font-size: .875rem;
  color: var(--samm-muted);
  transition: transform .2s;
}
.card-header a[data-bs-toggle="collapse"]:has(.ms-auto)::after { margin-left: .75rem; }
.card-header a[data-bs-toggle="collapse"][aria-expanded="true"]::after { transform: rotate(180deg); }
.card.card-body { display: block; } /* antigo .well: texto corrido, não flex */
.card-soft {
  background: #f8f9fc;
  box-shadow: none;
}
.card + .card { margin-top: 0; }

/* Lista de detalhes (chave: valor) */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { font-weight: 600; color: var(--samm-muted); font-size: .875rem; }
.kv dd { margin: 0; word-break: break-word; }


/* Botões */
.btn { font-weight: 600; border-radius: 8px; --bs-btn-padding-x: 1rem; }
.btn-sm { border-radius: 6px; --bs-btn-padding-x: .65rem; }
.btn-lg { border-radius: 10px; --bs-btn-font-size: 1rem; --bs-btn-padding-y: .7rem; --bs-btn-padding-x: 1.4rem; }
.btn i + span, .btn i:first-child { margin-right: .15rem; }
.btn-primary {
  --bs-btn-bg: var(--samm-indigo);
  --bs-btn-border-color: var(--samm-indigo);
  --bs-btn-hover-bg: var(--samm-indigo-600);
  --bs-btn-hover-border-color: var(--samm-indigo-600);
  --bs-btn-active-bg: var(--samm-navy);
  --bs-btn-active-border-color: var(--samm-navy);
  --bs-btn-disabled-bg: var(--samm-indigo);
  --bs-btn-disabled-border-color: var(--samm-indigo);
  --bs-btn-focus-shadow-rgb: 59, 58, 158;
}
.btn-outline-primary {
  --bs-btn-color: var(--samm-indigo);
  --bs-btn-border-color: #c9c8ef;
  --bs-btn-hover-bg: var(--samm-indigo);
  --bs-btn-hover-border-color: var(--samm-indigo);
  --bs-btn-active-bg: var(--samm-navy);
  --bs-btn-active-border-color: var(--samm-navy);
  --bs-btn-focus-shadow-rgb: 59, 58, 158;
}
.btn-light {
  --bs-btn-bg: #fff;
  --bs-btn-border-color: var(--samm-border);
  --bs-btn-hover-bg: #f1f2f8;
  --bs-btn-hover-border-color: #d5d8e5;
}

/* Formulários */
.form-group { margin-bottom: 1rem; }
.form-label, label { font-weight: 600; font-size: .875rem; color: #35374f; margin-bottom: .35rem; }
.form-check-label { font-weight: 400; font-size: inherit; color: inherit; }
.form-control, .form-select {
  border-color: #d7dae6;
  border-radius: 8px;
  padding: .55rem .8rem;
}
.form-control-lg { border-radius: 10px; font-size: 1rem; padding: .75rem 1rem; }
.form-control:focus, .form-select:focus {
  border-color: #8f8ee0;
  box-shadow: 0 0 0 .2rem rgba(59, 58, 158, .15);
}
.form-control::placeholder { color: #9a9db1; }
.form-check-input { border-color: #b4b8ca; }
.form-check-input:checked { background-color: var(--samm-indigo); border-color: var(--samm-indigo); }
/* Substituto simples do antigo .form-inline do Bootstrap 3 */
.form-inline { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.form-inline .form-control, .form-inline .form-select { width: auto; flex: 1 1 14rem; }
.form-inline .form-group { margin-bottom: 0; }

/* Alertas */
.alert { border-radius: 10px; font-weight: 500; border-width: 1px; }
.alert i.bi:first-child { margin-right: .4rem; }

/* Tabelas */
.table {
  --bs-table-bg: var(--samm-surface);
  --bs-table-border-color: var(--samm-border);
  --bs-table-striped-bg: #f8f9fc;
  --bs-table-hover-bg: #f3f4fa;
  vertical-align: middle;
  margin-bottom: 0;
}
.table > thead th {
  background: #f8f9fc;
  color: var(--samm-muted);
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.table-wrap {
  background: var(--samm-surface);
  border: 1px solid var(--samm-border);
  border-radius: var(--samm-radius);
  box-shadow: var(--samm-shadow);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.table-wrap > .table-responsive { margin: 0; }
.table-wrap .table { border-width: 0; border-color: var(--bs-table-border-color); }
@media (max-width: 767.98px) {
  .table-wrap .table > :not(caption) > * > * { white-space: nowrap; }
}
.table-wrap .table > :not(caption) > * > * { border-left: 0; border-right: 0; padding: .7rem 1rem; }
.table-wrap .table.table-sm > :not(caption) > * > * { padding: .5rem 1rem; }
.table-wrap .table > tbody > tr:last-child > * { border-bottom: 0; }
.card .table-wrap { box-shadow: none; }

/* Badges de status */
.badge { font-weight: 600; letter-spacing: .02em; }
.badge-dot::before {
  content: '';
  display: inline-block;
  width: .45rem;
  height: .45rem;
  border-radius: 50%;
  background: currentColor;
  margin-right: .4rem;
  vertical-align: middle;
}

/* Modal */
.modal-content { border: 0; border-radius: 14px; box-shadow: 0 20px 50px rgba(20, 22, 60, .25); }
.modal-header { border-bottom-color: var(--samm-border); }
.modal-title { font-size: 1.125rem; font-weight: 650; }
.modal-footer { border-top-color: var(--samm-border); }

/* ---------- Empresas (home do cliente) ---------- */
.company-card .card-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1rem 1.25rem;
  background: var(--samm-surface);
}
.company-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bs-primary-bg-subtle);
  color: var(--samm-indigo);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex: 0 0 auto;
}
.company-name { font-size: 1.0625rem; font-weight: 650; margin: 0; color: var(--samm-navy); line-height: 1.3; }
.company-code { font-size: .8125rem; color: var(--samm-muted); font-weight: 500; }
.action-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .75rem;
}
@media (max-width: 991.98px) { .action-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 420px) { .action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; } }
.action-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: 1rem .5rem;
  border: 1px solid var(--samm-border);
  border-radius: 10px;
  background: #fff;
  color: var(--samm-navy);
  font-weight: 600;
  font-size: .875rem;
  text-align: center;
  text-decoration: none !important;
  transition: border-color .15s, box-shadow .15s, transform .15s, background-color .15s;
}
.action-tile i { font-size: 1.7rem; color: var(--samm-indigo); }
.action-tile:hover, .action-tile:focus-visible {
  border-color: #b9b8ea;
  background: #fafaff;
  box-shadow: 0 4px 14px rgba(59, 58, 158, .12);
  transform: translateY(-1px);
}

/* ---------- Telas de autenticação ---------- */
.auth-wrap {
  max-width: 440px;
  margin: 1rem auto 2rem;
}
.auth-card { padding: 2rem; }
@media (max-width: 575.98px) { .auth-card { padding: 1.5rem 1.25rem; } }
.auth-card h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: .25rem; }
.auth-card .auth-sub { color: var(--samm-muted); margin-bottom: 1.5rem; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: var(--samm-muted);
  font-size: .8125rem;
  margin: 1.25rem 0;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--samm-border); }

/* ---------- Área interna (vendedor) ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.tool-grid .card-header { display: flex; align-items: center; gap: .5rem; font-size: .9375rem; }
.tool-grid .card-header i { color: var(--samm-indigo); }
.tool-grid .list-group-item { border-left: 0; border-right: 0; font-weight: 500; }
.tool-grid .list-group-item:first-child { border-top: 0; }
.tool-grid .list-group-item:last-child { border-bottom: 0; }
.tool-grid .list-group-item-action { color: var(--samm-text); display: flex; align-items: center; justify-content: space-between; }
.tool-grid .list-group-item-action::after { content: '\F285'; font-family: 'bootstrap-icons'; color: #b6b9cc; font-size: .75rem; }
.tool-grid .list-group-item-action[target="_blank"]::after { content: '\F1C5'; }
.tool-grid .list-group-item-action:hover { color: var(--samm-indigo); text-decoration: none; }

/* ---------- Rodapé ---------- */
.app-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--samm-border);
  background: var(--samm-surface);
  color: var(--samm-muted);
  font-size: .8125rem;
  padding: 1.1rem 0;
}
.app-footer .container { display: flex; flex-wrap: wrap; gap: .25rem 1.5rem; justify-content: space-between; align-items: center; }
.app-footer a { color: var(--samm-muted); font-weight: 500; }
.app-footer a:hover { color: var(--samm-navy); }
.app-footer .footer-links { display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
@media (max-width: 575.98px) { .app-footer .container, .app-footer .footer-links { justify-content: center; text-align: center; } }

/* ---------- Aviso de cookies ---------- */
.cookie-banner {
  position: fixed;
  z-index: 1080;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  max-width: 440px;
  margin-left: auto;
  background: var(--samm-navy-700);
  color: rgba(255, 255, 255, .85);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: 0 12px 40px rgba(10, 10, 40, .3);
  font-size: .8125rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}
.cookie-banner a { color: #fff; text-decoration: underline; }
.cookie-banner strong { display: block; color: #fff; font-size: .875rem; margin-bottom: .15rem; }
.cookie-banner .btn { flex: 0 0 auto; }

/* ---------- Status G8 ---------- */
.status-dot {
  display: inline-block;
  width: .7rem;
  height: .7rem;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, .04);
}

/* ---------- Utilidades ---------- */
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .875em; }
.text-navy { color: var(--samm-navy) !important; }
.min-w-0 { min-width: 0; }
img.escalation { border-radius: var(--samm-radius); border: 1px solid var(--samm-border); }

/* Paginação */
.pagination {
  --bs-pagination-color: var(--samm-indigo);
  --bs-pagination-hover-color: var(--samm-navy);
  --bs-pagination-active-bg: var(--samm-indigo);
  --bs-pagination-active-border-color: var(--samm-indigo);
  --bs-pagination-focus-box-shadow: 0 0 0 .2rem rgba(59, 58, 158, .2);
}

/* Linhas de detalhe recolhidas (ex.: lista de BGP) não ocupam espaço */
.table > tbody > tr:has(> td > .collapse:not(.show):only-child) > td { padding: 0; border-bottom-width: 0; }

/* Campos "crus" (sem classe) nas telas internas antigas */
.app-main select:not([class]),
.app-main textarea:not([class]),
.app-main input:not([class]):not([type=hidden]):not([type=checkbox]):not([type=radio]):not([type=submit]):not([type=button]) {
  border: 1px solid #d7dae6;
  border-radius: 8px;
  padding: .4rem .65rem;
  background-color: #fff;
  color: var(--samm-text);
  max-width: 100%;
}
.app-main select:not([class]):focus,
.app-main textarea:not([class]):focus,
.app-main input:not([class]):focus { outline: 0; border-color: #8f8ee0; box-shadow: 0 0 0 .2rem rgba(59, 58, 158, .15); }
.app-main input[type=submit]:not([class]),
.app-main button:not([class]) {
  border: 1px solid var(--samm-indigo);
  background: var(--samm-indigo);
  color: #fff;
  font-weight: 600;
  border-radius: 8px;
  padding: .4rem 1rem;
}
.app-main input[type=submit]:not([class]):hover,
.app-main button:not([class]):hover { background: var(--samm-indigo-600); }
