/* =====================================================
   VARIÁVEIS
===================================================== */

@import url("https://fonts.googleapis.com/css2?family=Google+Sans+Flex:opsz,wght@6..144,1..1000&display=swap");

:root {
  --navbar-height: 56px;
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 88px;
}

.border-alfa{--bs-border-opacity:1;border-color:var(--cor_destaque,var(--bs-border-opacity))!important}
.bg-alfa{--bs-bg-opacity:1;background-color:var(--cor_destaque)!important}
.text-danger-alfa{--bs-text-opacity:1;color:var(--cor_destaque)!important}

/* =====================================================
   BASE
===================================================== */
* { 
  box-sizing: border-box; 
  font-family: "Google Sans Flex", sans-serif;
  font-weight: 500;
  font-size: 0.95rem;
  font-style: normal;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* =====================================================
   Botões
===================================================== */
.btn-primario {
  background: var(--cor_destaque);
  border-color: var(--cor_destaque);
  border-radius: 999px;
  color: #fff;
  font-weight: 600;
  padding: 0.5rem 1rem;
}
.btn-primario:hover {
  background: var(--alfa-cor_secundaria);
  border-color: var(--alfa-cor_secundaria);
  color: var(--alfa-yellow);
}
.btn-secundario {
  background: transparent;
  border: 2px solid var(--cor_destaque);
  border-radius: 999px;
  color: var(--cor_destaque);
  font-weight: 600;
  padding: 0.5rem 1rem;
  transition: all 0.2s ease-in-out;
}
.btn-secundario:hover {
  background: var(--cor_destaque);
  color: #fff;
}

/* =====================================================
   NAVBAR
===================================================== */
.app-navbar {
  min-height: var(--navbar-height);
  position: sticky;
  top: 0;
  z-index: 1030; /* acima da sidebar */
}

/* =====================================================
   LOGOS
===================================================== */
.logo-navbar {
  width: 100px;
  height: 40px;
  object-fit: contain;
  aspect-ratio: 5 / 2;
}

.logo-navbar-menu {
  width: 40px;
  height: auto;
  aspect-ratio: 5 / 2;
}

/* Dark mode logo */
[data-bs-theme="dark"] .logo-dark-adjust {
  filter: brightness(0) invert(1);
}

/* =====================================================
   THEME BUTTON
===================================================== */
#themeIcon {
  transition: transform 0.3s ease, opacity 0.3s ease;
}
#themeToggle:active #themeIcon {
  transform: rotate(180deg);
}

/* =====================================================
   KPI CARDS
===================================================== */
.card.kpi {
  border: 1px solid var(--bs-border-color);
  transition: all 0.2s ease;
  cursor: pointer;
}
.card.kpi:hover {
  transform: translateY(-3px);
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* Ícone circular dos KPI */
.icon-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  border: 1px solid var(--bs-border-color);
}

/* =====================================================
   LAYOUT DESKTOP
===================================================== */
@media (min-width: 992px) {

  /* Body não rola: rola o conteúdo e o body da sidebar */
  body { overflow-y: hidden; }

  /* Sidebar fixa */
  .sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--navbar-height));
    background: var(--bs-body-bg);
    border-right: 1px solid var(--bs-border-color);
    z-index: 1020;

    display: flex;
    flex-direction: column;

    overflow: visible; /* IMPORTANTE: dropdown não corta */
  }

  /* Header fixo */
  .sidebar-header {
    flex: 0 0 auto;
    background: var(--bs-body-bg);
    position: sticky;
    top: 0;
    z-index: 20;
  }

  /* Body com scroll */
  .sidebar-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 12px;
  }

  /* Footer fixo */
  .sidebar-footer {
    flex: 0 0 auto;
    background: var(--bs-body-bg);
  }

  /* Links */
  .sidebar .nav-link {
    border-radius: 12px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    gap: .6rem;
  }

  .sidebar .nav-link i {
    width: 22px;
    display: inline-flex;
    justify-content: center;
    font-size: 1.05rem;
  }

  /* ====== Conteúdo (colado ao lado) ====== */
  .content {
    margin-left: var(--sidebar-width);
    width: calc(100vw - var(--sidebar-width));
    max-width: calc(100vw - var(--sidebar-width));
    height: calc(100vh - var(--navbar-height));
    overflow-y: auto;
    overflow-x: hidden;
    min-width: 0;
  }

  /* ====== Botão/Selector Propriedade ====== */
  .sidebar-prop-btn {
    border-radius: 14px;
    padding: 12px 12px;
    border: 1px solid var(--bs-border-color);
  }

  .sidebar-prop-icon {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(13,110,253,.12);
  }

  .sidebar-alert {
    border-radius: 12px;
  }

  /* Dropdown ocupa a largura do sidebar */
  .sidebar-dropdown {
    width: 100%;
    min-width: 0 !important;
    max-width: 100%;
    border-radius: 14px;
  }

  .sidebar-dropdown-scroll {
    max-height: 320px;
    overflow: auto;
    padding-right: 4px;
  }

  .sidebar-dropdown-item {
    border-radius: 12px;
    padding: 10px 10px;
  }

  .sidebar-action-btn {
    border-radius: 12px;
  }

  /* =================================================
     SIDEBAR RECOLHIDA (classe no container .app)
     Use: document.querySelector('.app').classList.toggle('sidebar-collapsed')
  ================================================= */
  .app.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
  }

  .app.sidebar-collapsed .content {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100vw - var(--sidebar-collapsed-width));
    max-width: calc(100vw - var(--sidebar-collapsed-width));
  }

  /* Esconde textos quando recolhida */
  .app.sidebar-collapsed .sidebar-title,
  .app.sidebar-collapsed .sidebar .link-text,
  .app.sidebar-collapsed .sidebar .text-uppercase {
    display: none !important;
  }

  /* Esconde seletor de propriedade no recolhido (evita espremido feio) */
  .app.sidebar-collapsed .sidebar-prop-btn,
  .app.sidebar-collapsed .sidebar-alert,
  .app.sidebar-collapsed .sidebar .dropdown-menu {
    display: none !important;
  }

  /* Centraliza o header quando recolhida */
  .app.sidebar-collapsed .sidebar-header .d-flex {
    justify-content: center !important;
  }

  .app.sidebar-collapsed .sidebar-toggle {
    margin: 0 auto !important;
    display: grid !important;
    place-items: center !important;
  }

  /* Centraliza links/ícones */
  .app.sidebar-collapsed .sidebar .nav-link {
    justify-content: center;
    padding: 0.75rem 0;
  }

  .app.sidebar-collapsed .sidebar .nav-link i {
    margin-right: 0 !important;
    font-size: 1.25rem;
  }

  /* Footer compacto no recolhido */
  .app.sidebar-collapsed .sidebar-footer {
    justify-content: center !important;
  }
  .app.sidebar-collapsed .sidebar-footer span:last-child {
    display: none !important;
  }
}

/* =====================================================
   MOBILE / TABLET
===================================================== */
@media (max-width: 991.98px) {
  body { overflow-y: auto; }

  .app { height: auto; }

  .content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  .content .py-4 {
    padding-top: 1rem !important;
    padding-bottom: 1rem !important;
  }
}

@media (max-width: 576px) {
    .username {
        display: none;
        max-width: 0ch; /* aproximadamente 7 caracteres */
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
}

/* =====================================================
   TABELAS
===================================================== */
.table > :not(caption) > * > * {
  padding-top: 0.85rem;
  padding-bottom: 0.85rem;
}