/* RentFast — Chrome: topbar, sidebar, layouts */

/* ── Topbar local antiga ──
   Substituída pelo header global (.gh-bar). Páginas individuais ainda têm
   <header class="topbar"> no markup, mas agora ficam ocultas.
   O header global já provê brand + busca + botão voltar + ações. */
.topbar {
  display: none !important;
}
.topbar-brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 700; font-size: 17px;
  letter-spacing: -0.02em; color: var(--ink-1);
}
.topbar-brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--ink-1); color: var(--bg);
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700; font-size: 14px;
  position: relative; flex-shrink: 0;
}
.topbar-brand-mark::after {
  content: ''; position: absolute; inset: -3px; border-radius: 11px;
  border: 1px solid var(--p); opacity: .55; pointer-events: none;
}
.topbar-nav {
  display: flex; gap: 4px; flex: 1; margin-left: var(--space-6);
}
.topbar-nav a {
  padding: 8px 12px; border-radius: var(--r-sm); font-size: 14px; color: var(--ink-2);
  transition: color var(--t-fast), background var(--t-fast);
}
.topbar-nav a:hover { color: var(--ink-1); background: var(--surface-2); }
.topbar-nav a[aria-current="page"] { color: var(--ink-1); font-weight: 500; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* Topbar compacta (usada em pages internas) */
.topbar-compact {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: var(--space-3);
  height: 56px; padding: 0 var(--space-4);
  background: color-mix(in oklch, var(--bg) 85%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

@media (max-width: 768px) {
  .topbar-nav { display: none; }
  .topbar { padding: 0 var(--space-4); height: 56px; }
}

/* ── Dashboard layout ──
   Header global (.gh-bar) tem ~58px e é sticky no topo;
   sidebar e topbar do dashboard começam ABAIXO dele. */
.dash-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100dvh - 58px);
}

.dash-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 58px; height: calc(100dvh - 58px);
  overflow: hidden;
}

.dash-side-head {
  padding: 20px 18px;
  border-bottom: 1px solid var(--line);
}

.dash-side-nav {
  padding: 10px 8px; flex: 1; overflow-y: auto;
  scrollbar-width: thin;
}

.dash-side-nav .group {
  font-family: var(--font-mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--ink-3);
  padding: 14px 12px 6px;
}

.dash-side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 14px;
  transition: all var(--t-fast);
  position: relative; text-decoration: none; margin-bottom: 1px;
}
.dash-side-link svg, .dash-side-link i { width: 17px; height: 17px; flex-shrink: 0; }
.dash-side-link:hover { background: var(--surface-2); color: var(--ink-1); }
.dash-side-link.active,
.dash-side-link[aria-current="page"] {
  background: var(--surface-2); color: var(--ink-1); font-weight: 500;
}
.dash-side-link.active::before,
.dash-side-link[aria-current="page"]::before {
  content: ''; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px;
  background: var(--p); border-radius: 0 3px 3px 0;
}

.dash-side-badge {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 11px;
  background: var(--p); color: white;
  padding: 1px 7px; border-radius: var(--r-full);
}

.dash-side-foot {
  padding: 14px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}

.dash-main {
  display: flex; flex-direction: column; min-width: 0;
}

.dash-topbar {
  /* Cola abaixo do header global (.gh-bar, ~58px) */
  position: sticky; top: 58px; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: 44px; padding: 0 var(--space-6);
  background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.dash-page-title {
  font-family: var(--font-display); font-size: 14px; font-weight: 600;
  letter-spacing: -0.01em; color: var(--ink-1); flex: 1;
  min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.dash-content {
  padding: 16px var(--space-6) var(--space-6);
  flex: 1; width: 100%;
}

/* Cabeçalho dentro do conteúdo (h1 + eyebrow + subtítulo).
   Atinge o padrão recorrente de <div><eyebrow><h1><p>...</div> que muitas
   páginas usam — compacta sem precisar editar cada template. */
.dash-content > div:first-child > h1 {
  font-family: var(--font-display);
  font-size: 22px; font-weight: 600;
  letter-spacing: -0.02em; line-height: 1.2;
  margin: 0 0 4px;
}
.dash-content > div:first-child > .eyebrow {
  margin-bottom: 4px;
}
.dash-content > div:first-child > p {
  font-size: 13px; line-height: 1.45; margin: 0;
}
.dash-content > div:first-child:has(> h1) {
  margin-bottom: 16px;
}

/* Mobile: ainda mais compacto */
@media (max-width: 900px) {
  .dash-shell { grid-template-columns: 1fr; }
  .dash-sidebar { display: none; }
  .dash-topbar { height: 40px; padding: 0 var(--space-4); }
  .dash-page-title { font-size: 13px; }
  .dash-content { padding: 12px var(--space-4) var(--space-5); }
  .dash-content > div:first-child > h1 { font-size: 18px; }
  .dash-content > div:first-child > p { font-size: 12px; }
}

/* Override global de h1s gigantes (legacy inline font-size).
   Muitas páginas têm <h1 style="font-size:26px"> ou 30px no padrão antigo.
   Esta regra compacta sem precisar editar cada template. */
h1[style*="font-size:26px"],
h1[style*="font-size: 26px"] { font-size: 22px !important; }
h1[style*="font-size:30px"],
h1[style*="font-size: 30px"] { font-size: 24px !important; }
@media (max-width: 600px) {
  h1[style*="font-size:26px"],
  h1[style*="font-size: 26px"] { font-size: 18px !important; }
  h1[style*="font-size:30px"],
  h1[style*="font-size: 30px"] { font-size: 20px !important; }
}

/* Mobile overlay sidebar */
.dash-sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,.4); backdrop-filter: blur(2px);
}
@media (max-width: 900px) {
  .dash-sidebar.open { display: flex; position: fixed; left: 0; top: 0; bottom: 0; z-index: 100; width: 260px; }
  .dash-sidebar-overlay.open { display: block; }
}

/* ── Compatibilidade com layout antigo (sidebar-layout) ── */
.sidebar-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100dvh;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100dvh;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: var(--r-sm);
  color: var(--ink-2); font-size: 14px;
  transition: all var(--t-fast);
  position: relative; text-decoration: none; margin-bottom: 1px;
}
.sidebar-link i { width: 17px; height: 17px; flex-shrink: 0; }
.sidebar-link:hover { background: var(--surface-2); color: var(--ink-1); }
.sidebar-link.active {
  background: color-mix(in oklch, var(--p) 10%, transparent);
  color: var(--p); font-weight: 600;
}
.sidebar-link.active::before {
  content: ''; position: absolute; left: -8px; top: 8px; bottom: 8px; width: 3px;
  background: var(--p); border-radius: 0 3px 3px 0;
}
.sidebar-badge {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: var(--p); color: #fff; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: var(--r-full); min-width: 18px; text-align: center;
  font-family: var(--font-mono);
}

/* Overlay sidebar mobile (compat) */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 89;
  background: rgba(0,0,0,.4);
}

@media (max-width: 900px) {
  .sidebar-layout { grid-template-columns: 1fr; }
  .sidebar { display: none; position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 90; }
  .sidebar.open { display: flex; }
  .sidebar-overlay.open { display: block; }
}

/* Topbar dashboard compat */
.topbar-compact, .topbar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-5); height: 60px;
  background: color-mix(in oklch, var(--bg) 85%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}

/* Utilitários de visibilidade */
.hide-mobile   { display: block; }
.show-mobile   { display: none; }
@media (max-width: 768px) {
  .hide-mobile { display: none !important; }
  .show-mobile { display: block; }
}
.hide-desktop  { display: none; }
@media (max-width: 900px) {
  .hide-desktop { display: block; }
}

/* ── Global header (gh-*) — usado em todas as páginas logadas ── */
.gh-bar {
  position: sticky; top: 0; z-index: 50;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding: 10px 24px;
  background: color-mix(in oklch, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.gh-left {
  display: flex; align-items: center; gap: 12px;
  justify-self: start; min-width: 0;
}
.gh-back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: transparent; border: 1px solid var(--line);
  border-radius: 50%; cursor: pointer;
  color: var(--ink-2);
  transition: all var(--t-fast);
  flex-shrink: 0;
}
.gh-back:hover { background: var(--surface-2); color: var(--ink-1); border-color: var(--ink-3); }

.gh-search {
  display: flex; align-items: center;
  width: 100%; max-width: 640px;
  justify-self: center;
  border: 1px solid var(--line); border-radius: var(--r-full);
  background: var(--surface);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  overflow: hidden;
}
.gh-search:focus-within {
  border-color: var(--ink-2);
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
}
.gh-search-field {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; flex: 1.4; min-width: 0;
  cursor: text;
}
.gh-search-field--city { flex: 1; border-left: 1px solid var(--line); }
.gh-search-field i, .gh-search-field svg { color: var(--ink-3); flex-shrink: 0; }
.gh-search-field input {
  flex: 1; min-width: 0; border: none; background: transparent;
  font-size: 14px; color: var(--ink-1);
  font-family: var(--font-sans); outline: none;
}
.gh-search-field input::placeholder { color: var(--ink-4); }
.gh-search-btn {
  margin: 4px; padding: 8px 18px; border: none; border-radius: var(--r-full);
  background: var(--ink-1); color: var(--bg);
  font-size: 13px; font-weight: 600; font-family: var(--font-sans);
  cursor: pointer; flex-shrink: 0;
  transition: background var(--t-fast);
}
.gh-search-btn:hover { background: color-mix(in oklch, var(--ink-1) 85%, var(--p)); }

.gh-actions {
  display: flex; align-items: center; gap: 10px;
  justify-self: end;
}
.gh-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: transparent; border: 1px solid var(--line);
  border-radius: 50%; cursor: pointer;
  color: var(--ink-2);
  transition: all var(--t-fast);
}
.gh-icon-btn:hover { background: var(--surface-2); color: var(--ink-1); border-color: var(--ink-3); }
.gh-user-btn {
  background: none; border: none; cursor: pointer; padding: 0;
  border-radius: 50%; transition: box-shadow var(--t-fast);
}
.gh-user-btn:hover { box-shadow: 0 0 0 3px color-mix(in oklch, var(--p) 20%, transparent); }
.gh-user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 12px 32px rgba(0,0,0,.16);
  min-width: 240px; z-index: 200; overflow: hidden;
}
.gh-drop-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; font-size: 13px; color: var(--ink-2);
  text-decoration: none; transition: background var(--t-fast);
}
.gh-drop-link:hover { background: var(--surface-2); }
.gh-drop-link i, .gh-drop-link svg { width: 14px; height: 14px; flex-shrink: 0; }
.gh-drop-link.gh-drop-logout { color: var(--red); }
.gh-drop-divider { height: 1px; background: var(--line); margin: 2px 0; }
.gh-drop-badge {
  margin-left: auto;
  background: var(--p); color: #fff;
  border-radius: 99px; padding: 1px 8px;
  font-size: 10px; font-family: var(--font-mono); font-weight: 700;
}
.gh-drop-mode { padding: 8px 16px; border-top: 1px solid var(--line); }

@media (max-width: 900px) {
  .gh-bar { grid-template-columns: auto 1fr auto; padding: 6px 10px; gap: 8px; }
  .gh-search-field--city { display: none; }
  .gh-search-field { padding: 6px 10px; }
  .gh-search-field input { font-size: 13px; }
  .gh-search-btn { padding: 5px 10px; font-size: 12px; }
  .gh-back { width: 32px; height: 32px; }
  .gh-icon-btn { width: 32px; height: 32px; }
  .gh-user-btn .avatar { width: 32px !important; height: 32px !important; font-size: 12px !important; }
}
@media (max-width: 600px) {
  .gh-bar { padding: 5px 8px; }
  .gh-search-btn { display: none; }
  .gh-search { max-width: none; }
  .gh-search-field { padding: 5px 10px; }
}
/* Topbar (sticky abaixo do gh-bar) precisa atualizar o offset quando gh-bar fica menor no mobile */
@media (max-width: 900px) {
  .dash-topbar { top: 46px; }
}
@media (max-width: 600px) {
  .dash-topbar { top: 42px; }
}

/* ── Mode switch pill (partial _mode_switch.html) ── */
.mode-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px; border-radius: var(--r-full);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
  text-decoration: none; border: none; white-space: nowrap;
  font-family: var(--font-sans);
}
.mode-pill--supplier {
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.mode-pill--supplier:hover {
  background: var(--ink-1);
  border-color: var(--ink-1);
  color: var(--bg);
}
.mode-pill--supplier:hover .mode-pill-dot--supplier {
  background: var(--bg);
}
.mode-pill--become {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink-3);
}
.mode-pill--become:hover {
  border-color: var(--ink-3);
  color: var(--ink-1);
}
.mode-pill-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.mode-pill-dot--supplier { background: var(--p); }

/* ── Reputation widget (sidebar mini-card + global) ── */
:root {
  --rep-excellent: #16a34a;
  --rep-good:      #22c55e;
  --rep-fair:      #f59e0b;
  --rep-warning:   #ea580c;
  --rep-risk:      #dc2626;
}
/* Wordmark: troca pro logo branco no tema escuro ou em fundo escuro forçado
   (variant="light") — senão o "Rent" escuro some no escuro. */
[data-mode="dark"] .rf-brand-img--dark { display: none !important; }
[data-mode="dark"] .rf-brand-img--light { display: block !important; }
.rf-brand--force-light .rf-brand-img--dark { display: none !important; }
.rf-brand--force-light .rf-brand-img--light { display: block !important; }

[data-mode="dark"] {
  --rep-excellent: #4ade80;
  --rep-good:      #86efac;
  --rep-fair:      #fbbf24;
  --rep-warning:   #fb923c;
  --rep-risk:      #f87171;
}
.rep-mini-card {
  display: block; text-decoration: none;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: var(--r-md);
  transition: background var(--t-fast);
}
.rep-mini-card:hover { background: color-mix(in oklch, var(--p) 6%, var(--surface-2)); }
.rep-mini-bar {
  height: 6px; border-radius: 99px;
  background: color-mix(in oklch, var(--ink-3) 20%, transparent);
  overflow: hidden;
}
.rep-mini-bar-fill {
  height: 100%; border-radius: 99px;
  transition: width var(--t-fast);
}
.rep-mini-excellent { background: var(--rep-excellent); }
.rep-mini-good      { background: var(--rep-good); }
.rep-mini-fair      { background: var(--rep-fair); }
.rep-mini-warning   { background: var(--rep-warning); }
.rep-mini-risk      { background: var(--rep-risk); }

/* Badge de reputação inline (ex: card de cliente).
   Fundo sólido leve + texto sólido escuro/claro pra contraste em ambos os temas. */
.rep-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
/* Light mode: tons claros do tier + texto escuro */
.rep-pill-excellent { background: #dcfce7; color: #166534; border-color: #86efac; }
.rep-pill-good      { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.rep-pill-fair      { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.rep-pill-warning   { background: #ffedd5; color: #9a3412; border-color: #fdba74; }
.rep-pill-risk      { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
/* Dark mode: fundo translúcido + texto claro do tier */
[data-mode="dark"] .rep-pill-excellent { background: rgba(34,197,94,0.18);  color: #86efac; border-color: rgba(34,197,94,0.4); }
[data-mode="dark"] .rep-pill-good      { background: rgba(16,185,129,0.18); color: #6ee7b7; border-color: rgba(16,185,129,0.4); }
[data-mode="dark"] .rep-pill-fair      { background: rgba(245,158,11,0.18); color: #fbbf24; border-color: rgba(245,158,11,0.4); }
[data-mode="dark"] .rep-pill-warning   { background: rgba(234,88,12,0.20);  color: #fdba74; border-color: rgba(234,88,12,0.4); }
[data-mode="dark"] .rep-pill-risk      { background: rgba(220,38,38,0.20);  color: #fca5a5; border-color: rgba(220,38,38,0.4); }

/* ── Bottom nav fixo (mobile, estilo Instagram) ── */
.dash-bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0;
  z-index: 90;
  background: color-mix(in oklch, var(--surface) 95%, transparent);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px env(safe-area-inset-right) max(8px, env(safe-area-inset-bottom)) env(safe-area-inset-left);
}
.dash-bnav-item {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 4px;
  background: transparent; border: none; cursor: pointer;
  color: var(--ink-3); text-decoration: none;
  font-size: 10px; font-family: var(--font-mono); font-weight: 500;
  position: relative;
  transition: color var(--t-fast);
}
.dash-bnav-item:hover { color: var(--ink-1); }
.dash-bnav-item.active { color: var(--p); }
.dash-bnav-item.active i,
.dash-bnav-item.active svg { color: var(--p); }
.dash-bnav-item i,
.dash-bnav-item svg { width: 22px; height: 22px; flex-shrink: 0; }
.dash-bnav-item span { white-space: nowrap; }
.dash-bnav-badge {
  position: absolute; top: 4px; left: 50%; margin-left: 4px;
  background: var(--red); color: #fff;
  min-width: 16px; height: 16px;
  padding: 0 5px; border-radius: 99px;
  font-size: 9px; font-weight: 700; font-family: var(--font-mono);
  display: flex; align-items: center; justify-content: center;
  line-height: 1;
}

@media (max-width: 900px) {
  .dash-bottom-nav { display: flex; }
  /* Espaço no body inteiro pra conteúdo não ficar atrás do bottom nav.
     Aplica globalmente (dashboard E não-dashboard). */
  body { padding-bottom: calc(58px + env(safe-area-inset-bottom)) !important; }
  /* Mantém dash-main com padding extra também, redundância segura */
  .dash-main { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
}
/* Pra páginas que escondem o bottom nav (print, etc), zera o padding */
body:not(:has(.dash-bottom-nav)) { padding-bottom: 0 !important; }
