/* ============================================================
   APP SHELL DESKTOP — sidebar Pirataria (fonte: pirataria_sidebar_mockup.html)
   Sidebar fixa 200px a partir de 992px; mobile mantém navbar/offcanvas/bottom-nav.
   Tokens: #111111 sidebar | #0d0d0d shell/main | #c9a84c accent | #2a2a2a bordas.
   ============================================================ */

/* Shell sempre presente (conteúdo visível em qualquer largura);
   sidebar e topbar só aparecem no desktop. */
.app-shell {
  display: flex;
  align-items: stretch;
  min-height: 100vh;
  background: #0d0d0d;
}

/* ─── Sidebar ──────────────────────────────────────────────── */
.app-sidebar {
  flex: 0 0 240px;
  width: 240px;
  min-width: 240px;
  background: #111111;
  border-right: 0.5px solid #2a2a2a;
  display: none;               /* mobile: oculta */
  flex-direction: column;
  padding: 20px 0 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 1020;
  overflow: visible;
}

/* ─── Marca/logo da sidebar (ícone + PIRATARIA + tagline) ─── */
.app-sidebar .sidebar-brand,
.app-sidebar .logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  overflow: hidden;
  padding: 0 20px 24px;
  border-bottom: 0.5px solid #2a2a2a;
  text-decoration: none;
  flex-shrink: 0;
}

.app-sidebar .logo-skull {
  width: 32px;
  height: 32px;
  background: #c9a84c;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #111;
  flex-shrink: 0;
}

.app-sidebar .logo-img {
  height: 32px;
  width: auto;
  max-width: 60px;
  object-fit: contain;
  flex-shrink: 0;
}

.app-sidebar .brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-sidebar .brand-title,
.app-sidebar .logo-text {
  font-size: 13px;
  font-weight: 500;
  color: #f5f5f5;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-sidebar .brand-subtitle,
.app-sidebar .logo-sub {
  font-size: 10px;
  color: #888;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-sidebar .nav-section {
  padding: 16px 12px 0;
  flex: 1;
  min-height: 0;               /* permite encolher e rolar em viewports baixas */
  display: flex;
  flex-direction: column;
  overflow-y: auto;            /* rola internamente em vez de empurrar o rodapé */
  scrollbar-width: thin;
}

.app-sidebar .nav-label {
  font-size: 10px;
  color: #555;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 8px;
  margin-bottom: 4px;
  font-weight: 600;
}

.app-sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 7px;
  font-size: 13px;
  color: #888;
  cursor: pointer;
  margin-bottom: 2px;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.app-sidebar .nav-item:hover { background: #1e1e1e; color: #ccc; }

.app-sidebar .nav-item.active {
  background: #1e1a0f;
  color: #c9a84c;
}

.app-sidebar .nav-item i { font-size: 16px; flex-shrink: 0; line-height: 1; }

.app-sidebar .nav-badge {
  margin-left: auto;
  background: #c9a84c;
  color: #111;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.app-sidebar .nav-badge.nav-badge-danger {
  background: #e05c5c;
  color: #fff;
}

/* toggle "Mais" (esconde caret do Bootstrap) */
.app-sidebar .dropdown-toggle::after { display: none !important; }

.app-sidebar .sidebar-footer {
  padding: 12px 12px max(16px, env(safe-area-inset-bottom));
  border-top: 0.5px solid #2a2a2a;
  margin-top: 8px;
  flex-shrink: 0;
}

/* ─── Meu status (popover) ─────────────────────────────── */
.app-sidebar .dropstart-presence {
  position: relative;
}

.app-sidebar .presence-popover {
  background: #17181c;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  min-width: 250px;
  max-width: 250px;
  padding: 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  margin-bottom: 8px;
  overflow: hidden;
}

.app-sidebar .presence-popover-header {
  align-items: center;
  border-bottom: 0.5px solid #2a2a2a;
  display: flex;
  font-size: 13px;
  font-weight: 600;
  justify-content: space-between;
  padding: 10px 14px;
  color: #f4f4f5;
}

.app-sidebar .presence-popover-dot {
  border-radius: 50%;
  display: inline-block;
  height: 9px;
  width: 9px;
}

.app-sidebar .presence-opt {
  align-items: center;
  cursor: pointer;
  display: flex;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 0.5px solid #22262c;
  transition: background 0.12s;
}

.app-sidebar .presence-opt:hover {
  background: #20242b;
}

.app-sidebar .presence-opt-dot {
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  height: 11px;
  width: 11px;
}

.app-sidebar .presence-opt-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 1px;
}

.app-sidebar .presence-opt-title {
  color: #f4f4f5;
  font-size: 13px;
  font-weight: 500;
}

.app-sidebar .presence-opt-desc {
  color: #9ca3af;
  font-size: 12px;
}

.app-sidebar .presence-opt > i {
  color: #6b7280;
  font-size: 13px;
}

.app-sidebar .presence-popover-footer {
  color: #9ca3af;
  font-size: 11.5px;
  padding: 9px 14px;
  text-align: center;
}

.app-sidebar .user-row { position: relative; }

.app-sidebar .user-row-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.app-sidebar .user-row-inner:hover { background: #1e1e1e; }

.app-sidebar .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #c9a84c;
  font-weight: 500;
  flex-shrink: 0;
}

.app-sidebar .user-name {
  font-size: 12px;
  color: #aaa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-sidebar .user-chev {
  margin-left: auto;
  font-size: 12px;
  color: #444;
  flex-shrink: 0;
}

/* Dropdowns da sidebar (usuário + Mais) */
.app-sidebar .dropdown-menu.app-user-menu,
.app-sidebar .dropdown-menu.app-more-menu {
  background: #1a1a1a;
  border: 0.5px solid #2a2a2a;
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
}

.app-sidebar .dropdown-menu .dropdown-item {
  font-size: 0.8rem;
  font-weight: 500;
  color: #ccc;
  padding: 7px 10px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.app-sidebar .dropdown-menu .dropdown-item i {
  font-size: 0.9rem;
  width: 1rem;
  text-align: center;
  color: #888;
}

.app-sidebar .dropdown-menu .dropdown-item:hover,
.app-sidebar .dropdown-menu .dropdown-item.active {
  background: rgba(255, 255, 255, 0.05);
  color: #c9a84c;
}

.app-sidebar .dropdown-menu .dropdown-item:hover i,
.app-sidebar .dropdown-menu .dropdown-item.active i { color: #c9a84c; }

.app-sidebar .dropdown-menu .dropdown-divider { border-color: rgba(255, 255, 255, 0.06); margin: 4px 0; }

.app-sidebar .dropdown-menu .dropdown-item-text {
  font-size: 0.7rem;
  color: #777;
  padding: 0.3rem 0.75rem;
}

.app-sidebar .dropdown-menu .dropdown-more-title {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #777;
  padding: 6px 10px 4px;
  cursor: default;
}

.app-sidebar .dropdown-menu.app-more-menu {
  min-width: 252px;
  width: 252px;
  max-width: 90vw;
  max-height: 60vh;
  overflow-y: auto;
}

/* ─── Main + Topbar ────────────────────────────────────────── */
.app-main {
  flex: 1;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  background: #0d0d0d;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Conteúdo do main: nunca soma a sidebar — respeita a largura
   disponível e não vaza para a direita (nem gera scroll horizontal). */
.app-main > .container,
.app-main > .container-fluid {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
}

/* Grids internos do dashboard nunca podem estourar o container. */
.app-main .dash-metrics,
.app-main .dash-overview-grid,
.app-main .cc-wrap .row,
.app-main .vendas-grid {
  min-width: 0;
  max-width: 100%;
}

.app-topbar {
  display: none;               /* mobile: oculta */
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 0.5px solid #2a2a2a;
  position: sticky;
  top: 0;
  z-index: 1010;
  background: #0d0d0d;
  gap: 12px;
}

.app-topbar .page-title {
  font-size: 15px;
  font-weight: 500;
  color: #f0f0f0;
  white-space: nowrap;
}

.app-topbar .topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.app-topbar .search-box {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #1a1a1a;
  border: 0.5px solid #2a2a2a;
  border-radius: 7px;
  padding: 0 12px;
  color: #555;
  font-size: 12px;
  position: relative;
}

.app-topbar .search-box .search-icon { color: #666; font-size: 14px; }

.app-topbar .search-box .search-input {
  border: none;
  background: transparent;
  color: #eee;
  font-size: 12px;
  height: 30px;
  min-height: 30px;
  width: 160px;
  padding: 0 6px;
  outline: none;
  font-family: inherit;
  line-height: normal;
}

.app-topbar .search-box .search-input::placeholder { color: #555; opacity: 1; }

.app-topbar .search-box .search-dropdown {
  left: auto;
  right: 0;
  width: 320px;
  top: calc(100% + 8px);
  z-index: 9999;
}

.app-topbar .icon-btn {
  width: 32px;
  height: 32px;
  background: #1a1a1a;
  border: 0.5px solid #2a2a2a;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  cursor: pointer;
  font-size: 15px;
  padding: 0;
  text-decoration: none;
  position: relative;
}

.app-topbar .icon-btn:hover { border-color: #3a3a3a; color: #aaa; }

.app-topbar .icon-btn i { font-size: 15px; line-height: 1; }

.app-topbar .icon-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #dc3545;
  color: #fff;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  font-size: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  line-height: 1;
}

/* ─── Desktop: liga sidebar + topbar e esconde navbar horizontal ─── */
@media (min-width: 992px) {
  .app-shell { display: flex; }
  .app-sidebar { display: flex; }
  .app-topbar { display: flex; }
  .navbar.app-navbar { display: none !important; }
  /* Rodapé central "Pirataria BodyArt" é decorativo; no desktop com sidebar ele
     fica solto no fim do main. Oculta (o footer público/landing não usa essa classe). */
  .footer-studio { display: none; }
}

/* ─── Mobile: reforça ocultação da sidebar/topbar (navbar antiga + bottom-nav) ─── */
@media (max-width: 991.98px) {
  .app-sidebar { display: none; }
  .app-topbar { display: none; }
  .app-shell { display: block; }
}

/* ============================================================
   CENTRAL DE VENDAS / PIPELINE — proteção contra overflow
   ============================================================ */
/* Grade Receita | Pipeline: colunas iguais, nunca mais largas que o pai. */
.app-main .cc-wrap .row,
.vendas-container,
.dash-vendas-grid {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}

.app-main .cc-wrap .row {
  display: grid;
  margin-right: 0;
  margin-left: 0;
}

.app-main .cc-wrap .row > [class*="col-"] {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  flex: 0 0 100%;
  padding-right: 0;
  padding-left: 0;
}

/* Painéis da Central de Vendas respeitam a largura do card. */
.app-main .section-card,
.app-main .cc-card,
.pipeline-panel {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  position: relative;
  box-sizing: border-box;
}

/* Itens do pipeline: rótulo flexível, número fixo, sem compressão. */
.cc-pipe-item {
  min-width: 0;
  width: 100%;
}

.cc-pipe-item > span {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cc-pipe-item > strong {
  flex-shrink: 0;
  margin-left: auto;
  padding-left: 0.75rem;
}

/* Título nunca quebra por cima do contador/ícone. */
.cc-pipe-item i {
  flex-shrink: 0;
}

/* Chips do pipeline quebram com segurança. */
.cc-pipe-chips {
  min-width: 0;
  max-width: 100%;
}

/* ============================================================
   PRÓXIMAS AÇÕES — botões alinhados, ícones centralizados
   ============================================================ */
.cc-item-actions,
.action-buttons-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.cc-item-actions .btn,
.action-buttons-row .btn,
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  box-sizing: border-box;
  white-space: nowrap;
}

.cc-item-actions .btn i,
.action-buttons-row .btn i,
.action-btn i {
  line-height: 1;
  flex-shrink: 0;
}

/* Nome do cliente + badges não estouram o card. */
.cc-item-name {
  min-width: 0;
  max-width: 100%;
}

.cc-item-top {
  min-width: 0;
  max-width: 100%;
}

.cc-item-receita {
  flex-shrink: 0;
}

/* Mobile: Receita e Pipeline empilham em coluna única (regra no fim do arquivo
   para vencer a grade de 2 colunas acima). */
@media (max-width: 991.98px) {
  .app-main .cc-wrap .row,
  .vendas-container,
  .dash-vendas-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
