/* ==========================================================================
   FaturaMes - Estilos de Navegação (Sidebar e Topbar)
   ========================================================================== */

/* Cabeçalho de Área Pública (herdado/reserva) */
.app-header {
  background: rgba(255, 255, 255, 0.8);
  border-bottom: 1px solid rgba(217, 227, 220, 0.4);
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.navbar-brand,
.brand-name {
  color: var(--fm-heading);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.navbar-brand {
  font-size: 1.15rem;
  font-weight: 800;
}

.nav-link {
  color: var(--fm-muted);
  font-weight: 600;
}

.nav-link:hover {
  color: var(--fm-primary);
}

/* ==========================================================================
   1. App Frame & Sidebar (Área Logada)
   ========================================================================== */
.app-frame {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar,
.mobile-sidebar {
  color: #f7fbf9;
  background: #0b110f;
  /* Cor profunda, sólida e premium */
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 16px;
  box-shadow: 10px 0 35px rgba(0, 0, 0, 0.2);
  z-index: 50;
}

/* Brand Mark & Logo Block */
.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--fm-primary), #11bda3);
  box-shadow: 0 8px 20px rgba(0, 109, 91, 0.35);
  text-decoration: none;
}

.brand-mark span {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.app-sidebar .brand-name,
.mobile-sidebar .brand-name {
  display: block;
  color: #fff;
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.brand-subtitle {
  display: block;
  color: var(--fm-sidebar-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 3px;
}

/* Sidebar Links */
.sidebar-nav {
  display: grid;
  gap: 4px;
}

.app-sidebar>.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}

.app-sidebar>.sidebar-nav::-webkit-scrollbar {
  width: 5px;
}

.app-sidebar>.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
}

.sidebar-link {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 10px;
  color: #a3b2a9;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s, color 0.2s, transform 0.2s, border-left 0.2s;
  border-left: 3px solid transparent;
}

.sidebar-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(4px);
}

.sidebar-link.active {
  color: #fff;
  background: rgba(0, 109, 91, 0.16);
  border-left-color: #00d2b4;
  font-weight: 700;
}

/* Tooltips */
.sidebar-tooltip {
  --bs-tooltip-max-width: 260px;
  --bs-tooltip-padding-x: 12px;
  --bs-tooltip-padding-y: 8px;
  --bs-tooltip-font-size: 0.8rem;
  --bs-tooltip-color: #f7fbf8;
  --bs-tooltip-bg: #0b110f;
  --bs-tooltip-border-radius: 8px;
  --bs-tooltip-opacity: 1;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
}

.sidebar-tooltip .tooltip-inner {
  border: 1px solid rgba(255, 255, 255, 0.08);
  line-height: 1.4;
  text-align: left;
}

.sidebar-tooltip.bs-tooltip-end .tooltip-arrow::before,
.sidebar-tooltip.bs-tooltip-auto[data-popper-placement^="right"] .tooltip-arrow::before {
  border-right-color: #0b110f;
}

.nav-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transition: background-color 0.2s;
}

.sidebar-link.active .nav-dot,
.sidebar-link:hover .nav-dot {
  background: #00d2b4;
}

.sidebar-footer {
  display: grid;
  gap: 4px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-eyebrow {
  color: var(--fm-accent);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-left: 14px;
  margin-bottom: 4px;
}

.sidebar-note {
  color: var(--fm-sidebar-muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

/* ==========================================================================
   2. Topbar (Barra Superior Administrativa)
   ========================================================================== */
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 12px 28px;
  background: rgba(255, 255, 255, 0.85);
  border-bottom: 1px solid rgba(217, 227, 220, 0.5);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.topbar-title {
  display: grid;
  gap: 2px;
  min-width: 0;
  margin-right: auto;
}

.topbar-title span {
  color: var(--fm-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.topbar-title strong {
  color: var(--fm-heading);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-toggle {
  display: none;
}

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

/* ==========================================================================
   3. Dropdowns Switchers (Empresa e Usuário)
   ========================================================================== */
.company-switcher {
  flex: 0 1 250px;
}

.company-switch-button {
  min-height: 44px;
  width: 100%;
  max-width: 250px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 5px;
  border: 1px solid #e3e9e5;
  border-radius: 10px;
  color: var(--fm-heading);
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s, background-color 0.2s;
}

.company-switch-button:hover,
.company-switch-button:focus {
  border-color: var(--fm-primary);
  background-color: var(--fm-primary-soft);
}

.company-switch-button::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: auto;
  border-right: 2px solid #738077;
  border-bottom: 2px solid #738077;
  transform: rotate(45deg);
  transition: transform 0.2s;
}

.company-initial {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--fm-primary), var(--fm-accent));
  font-weight: 800;
  font-size: 0.85rem;
}

.company-logo-img {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
}

.company-copy {
  display: grid;
  min-width: 0;
  text-align: left;
  line-height: 1.2;
}

.company-copy small {
  color: var(--fm-muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
}

.company-copy strong {
  color: var(--fm-heading);
  font-size: 0.85rem;
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.company-dropdown {
  min-width: 240px;
  padding: 6px;
  border: 1px solid rgba(217, 227, 220, 0.9);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(17, 26, 22, 0.08);
}

.company-dropdown .dropdown-item {
  border-radius: 8px;
  font-weight: 650;
  font-size: 0.88rem;
  padding: 8px 12px;
}

.active-company {
  color: var(--fm-primary-dark) !important;
  background: var(--fm-primary-soft) !important;
}

/* User Menu */
.user-menu-button {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px 5px 5px;
  border: 1px solid #e3e9e5;
  border-radius: 10px;
  color: var(--fm-heading);
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color 0.2s, background-color 0.2s;
}

.user-menu-button:hover,
.user-menu-button:focus {
  border-color: var(--fm-primary);
  background-color: var(--fm-primary-soft);
}

.user-menu-button::after {
  content: "";
  width: 6px;
  height: 6px;
  margin-left: 4px;
  border-right: 2px solid #738077;
  border-bottom: 2px solid #738077;
  transform: rotate(45deg);
  transition: transform 0.2s;
}

.user-avatar {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #15211b;
  background: #f4c87c;
  font-weight: 800;
  font-size: 0.85rem;
}

.user-avatar-img {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
  border-radius: 50%;
  object-fit: cover;
}

.user-menu-copy {
  display: grid;
  min-width: 0;
  text-align: left;
  line-height: 1.2;
}

.user-menu-copy strong {
  font-size: 0.85rem;
  font-weight: 750;
  color: var(--fm-heading);
}

.user-menu-copy small {
  color: var(--fm-muted);
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown {
  min-width: 200px;
  padding: 6px;
  border: 1px solid rgba(217, 227, 220, 0.9);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(17, 26, 22, 0.08);
}

.user-dropdown .dropdown-item {
  border-radius: 8px;
  font-weight: 650;
  font-size: 0.88rem;
  padding: 8px 12px;
}

.user-dropdown .dropdown-divider {
  margin: 6px 0;
  border-top-color: #cbd7ce;
}

/* ==========================================================================
   4. Utilitários Públicos (WhatsApp e Loader)
   ========================================================================== */
.whatsapp-float {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 99;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #25d366;
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 10px 24px rgba(22, 38, 32, 0.2);
  text-decoration: none;
  transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
}

.whatsapp-float:hover {
  color: #fff;
  background: #1ebe5d;
  transform: translateY(-3px);
  box-shadow: 0 15px 30px rgba(22, 38, 32, 0.25);
}

.whatsapp-float svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

/* ==========================================================================
   5. Responsividade
   ========================================================================== */
@media (max-width: 992px) {
  .app-frame {
    display: block;
  }

  .app-sidebar {
    display: none;
  }

  .app-topbar {
    min-height: 64px;
    padding: 12px 16px;
    gap: 12px;
  }

  .topbar-actions {
    gap: 8px;
  }

  .sidebar-toggle {
    width: 38px;
    height: 38px;
    display: grid;
    align-content: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    border: 1px solid #cbd7ce;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
  }

  .sidebar-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: var(--fm-heading);
  }

  .topbar-title span {
    display: none;
  }
}

@media (max-width: 720px) {
  .user-menu-button {
    width: 36px;
    height: 36px;
    min-height: 36px;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
  }

  .user-avatar {
    width: 100%;
    height: 100%;
  }

  .user-menu-copy,
  .user-menu-button::after {
    display: none;
  }

  .company-switcher {
    flex: 1 1 auto;
    min-width: 0;
  }

  .company-switch-button {
    max-width: none;
    width: 100%;
    min-height: 38px;
  }

  .company-initial {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    font-size: 0.75rem;
  }

  .company-copy strong {
    font-size: 0.8rem;
  }
}

/* Rebranding - Blue Theme */
.app-frame {
  grid-template-columns: 260px minmax(0, 1fr);
}

.app-sidebar,
.mobile-sidebar {
  background: linear-gradient(170deg, #3574d4 0%, #2455b8 60%, #1e47a0 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.12);
}

.app-sidebar {
  padding: 24px 16px;
  box-shadow: 6px 0 24px rgba(21, 55, 150, 0.28);
}

.brand-block {
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-mark {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  color: #fff;
}

.app-sidebar .brand-name,
.mobile-sidebar .brand-name {
  color: #ffffff;
}

.brand-subtitle {
  color: rgba(255, 255, 255, 0.6);
}

.sidebar-link {
  position: relative;
  min-height: 44px;
  gap: 11px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 600;
  transition: background .18s, color .18s, transform .15s, border-color .18s;
}

.sidebar-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateX(3px);
}

.sidebar-link.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.32);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
  font-weight: 700;
  text-shadow: none;
}

.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
}

.nav-icon {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.88);
  background: rgba(255, 255, 255, 0.12);
  font-size: .85rem;
  font-weight: 850;
  line-height: 1;
  transition: background-color .18s, color .18s, border-color .18s;
}

.nav-icon::before {
  content: "·";
}

.sidebar-link[href*="Dashboard"] .nav-icon::before { content: "P"; }
.sidebar-link[href*="Clientes"] .nav-icon::before { content: "C"; }
.sidebar-link[href*="Funcionarios"] .nav-icon::before { content: "E"; }
.sidebar-link[href*="Fornecedores"] .nav-icon::before { content: "F"; }
.sidebar-link[href*="Planos"] .nav-icon::before { content: "L"; }
.sidebar-link[href*="Assinaturas"] .nav-icon::before { content: "A"; }
.sidebar-link[href*="Cobrancas"] .nav-icon::before { content: "$"; }
.sidebar-link[href*="Financeiro"] .nav-icon::before { content: "R$"; font-size: .64rem; }
.sidebar-link[href*="Comissoes"] .nav-icon::before { content: "%"; }
.sidebar-link[href*="Templates"] .nav-icon::before { content: "T"; }
.sidebar-link[href*="Relatorios"] .nav-icon::before { content: "G"; }
.sidebar-link[href*="Configuracoes"] .nav-icon::before { content: "#"; }

.sidebar-link.active .nav-icon,
.sidebar-link:hover .nav-icon {
  color: #2455b8;
  background: #ffffff;
  border-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-eyebrow {
  color: rgba(255, 255, 255, 0.52);
}

.sidebar-tooltip {
  --bs-tooltip-bg: #1e293b;
  --bs-tooltip-color: #f8fafc;
}

.sidebar-tooltip.bs-tooltip-end .tooltip-arrow::before,
.sidebar-tooltip.bs-tooltip-auto[data-popper-placement^="right"] .tooltip-arrow::before {
  border-right-color: #1e293b;
}

.app-topbar {
  padding: 12px 32px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 6px rgba(15, 23, 42, 0.06);
}

.topbar-title strong {
  color: #0f172a;
}

.topbar-title span {
  color: #94a3b8;
}

.company-switch-button,
.user-menu-button {
  border-color: #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.company-switch-button:hover,
.company-switch-button:focus,
.user-menu-button:hover,
.user-menu-button:focus {
  border-color: var(--fm-primary);
  background-color: var(--fm-primary-soft);
}

.company-initial {
  border-radius: 7px;
  background: linear-gradient(135deg, var(--fm-primary), var(--fm-primary-dark));
}

.user-avatar {
  background: linear-gradient(135deg, #f1ca77, #d69a3a);
}

.active-company {
  color: var(--fm-primary-dark) !important;
  background: var(--fm-primary-soft) !important;
}

@media (max-width: 992px) {
  .app-frame {
    display: block;
  }

  .app-topbar {
    padding: 12px 16px;
  }
}