/* ================================
   VARIÁVEIS GLOBAIS
   ================================ */
:root {
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 70px;
  --header-height: 60px;
  --footer-height: 60px;
  --primary-color: #0d6efd;
  --sidebar-bg: #1a1d29;
  --sidebar-hover: #252939;
  --transition-speed: 0.3s;
}

/* ================================
   RESET E CONFIGURAÇÕES GLOBAIS
   ================================ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
  margin: 0 !important;
  padding: 0 !important;
}

/* ================================
   HEADER/NAVBAR
   ================================ */
.navbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  width: calc(100% - var(--sidebar-width));
  height: var(--header-height);
  z-index: 1030;
  transition: left var(--transition-speed) ease, width var(--transition-speed) ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
}

.navbar .container-fluid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 1rem;
}

.sidebar.collapsed ~ .navbar {
  left: var(--sidebar-collapsed-width);
  width: calc(100% - var(--sidebar-collapsed-width));
}

.navbar-brand {
  font-weight: 600;
  font-size: 1.25rem;
  transition: all 0.3s ease;
}

.navbar-brand:hover {
  transform: scale(1.02);
}

/* Navbar Content - IMPORTANTE */
.navbar-collapse {
  display: flex !important;
  flex-basis: auto;
  flex-grow: 1;
  align-items: center;
  justify-content: flex-end;
}

.navbar-nav {
  display: flex !important;
  flex-direction: row !important;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
}

.navbar-nav .nav-item {
  display: flex;
  align-items: center;
}

.navbar-nav .nav-link {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: color 0.3s ease;
}

.navbar-nav .nav-link:hover {
  color: #fff;
}

.user-avatar {
  width: 35px;
  height: 35px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-color), #0a58ca);
}

.dropdown-menu {
  border: none;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
  border-radius: 0.5rem;
  margin-top: 0.5rem;
  position: absolute;
  top: 100%;
  right: 0;
}

.dropdown-item {
  padding: 0.5rem 1rem;
  transition: all 0.2s ease;
}

.dropdown-item:hover {
  background-color: rgba(13, 110, 253, 0.1);
  padding-left: 1.5rem;
}

.nav-item.dropdown {
  position: relative;
}

/* ================================
   SIDEBAR
   ================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  z-index: 1040;
  transition: width var(--transition-speed) ease;
  overflow: hidden;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Cabeçalho do Sidebar */
.sidebar-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-toggle {
  background: transparent;
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-toggle:hover {
  background: var(--sidebar-hover);
  transform: scale(1.1);
}

.sidebar.collapsed .btn-toggle i {
  transform: rotate(180deg);
}

/* Navegação do Sidebar */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 0;
}

.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Links do Menu */
.sidebar .nav-link {
  display: flex;
  align-items: center;
  padding: 0.75rem 1.25rem;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: all 0.3s ease;
  position: relative;
  white-space: nowrap;
  border-radius: 0.5rem;
  margin: 0.25rem 0.75rem;
}

.sidebar .nav-link i {
  font-size: 1.25rem;
  min-width: 24px;
  text-align: center;
  transition: all 0.3s ease;
}

.sidebar .nav-link .nav-text {
  margin-left: 1rem;
  font-weight: 500;
  transition: opacity var(--transition-speed) ease;
}

.sidebar.collapsed .nav-link .nav-text {
  opacity: 0;
  pointer-events: none;
}

/* Hover no Link */
.sidebar .nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
  transform: translateX(2px);
}

.sidebar .nav-link:hover i {
  color: var(--primary-color);
  transform: scale(1.1);
}

/* Link Ativo */
.sidebar .nav-link.active {
  background: linear-gradient(90deg, var(--primary-color), #0a58ca);
  color: #fff;
  box-shadow: 0 2px 8px rgba(13, 110, 253, 0.3);
}

.sidebar .nav-link.active i {
  color: #fff;
}

.sidebar .nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  background: #fff;
  border-radius: 0 4px 4px 0;
}

/* Tooltip no Sidebar Colapsado */
.sidebar.collapsed .nav-link:hover .nav-text {
  position: absolute;
  left: var(--sidebar-collapsed-width);
  background: var(--sidebar-hover);
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  opacity: 1;
  pointer-events: all;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  z-index: 1050;
  white-space: nowrap;
}

/* Divisores do Menu */
.nav-divider {
  margin: 1rem 0;
  padding: 0 1.25rem;
  opacity: 0.5;
}

.nav-divider-text {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.5);
  transition: opacity var(--transition-speed) ease;
}

.sidebar.collapsed .nav-divider-text {
  opacity: 0;
}

.nav-divider::after {
  content: '';
  display: block;
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin-top: 0.5rem;
}

/* Rodapé do Sidebar */
.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-btn {
  width: 100%;
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.7);
  transition: all 0.3s ease;
  cursor: pointer;
}

.logout-btn:hover {
  background: rgba(220, 53, 69, 0.1);
  color: #dc3545;
}

/* Overlay Mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1035;
  opacity: 0;
  transition: opacity var(--transition-speed) ease;
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ================================
   CONTEÚDO PRINCIPAL
   ================================ */
.main-content {
  margin-left: var(--sidebar-width);
  margin-top: 0;
  padding-top: var(--header-height);
  min-height: calc(100vh - var(--footer-height));
  transition: margin-left var(--transition-speed) ease;
  background: #0d1117;
}

.main-content.no-sidebar {
  margin-left: 0;
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

.content-wrapper {
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

.content-wrapper .d-flex:first-child {
  margin-top: 0 !important;
}

/* Alertas */
.alert-container {
  margin-bottom: 1.5rem;
}

.alert {
  border: none;
  border-radius: 0.5rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ================================
   FOOTER
   ================================ */
.footer {
  margin-left: var(--sidebar-width);
  height: var(--footer-height);
  background: var(--sidebar-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  padding: 1rem 2rem;
  transition: margin-left var(--transition-speed) ease;
}

.footer.no-sidebar {
  margin-left: 0;
}

.sidebar.collapsed ~ .footer {
  margin-left: var(--sidebar-collapsed-width);
}

/* ================================
   TABELAS
   ================================ */
.table-responsive {
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nowrap-table {
  table-layout: auto;
  width: 100%;
  min-width: max-content;
}

.nowrap-table td,
.nowrap-table th,
.no-wrap {
  white-space: nowrap !important;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.table-hover tbody tr {
  transition: all 0.2s ease;
}

.table-hover tbody tr:hover {
  transform: scale(1.01);
  box-shadow: 0 2px 8px rgba(13, 110, 253, 0.2);
}

/* ================================
   BOTÕES
   ================================ */
.btn {
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  font-weight: 500;
  transition: all 0.3s ease;
  border: none;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn-group .btn {
  border-radius: 0;
}

.btn-group .btn:first-child {
  border-radius: 0.5rem 0 0 0.5rem;
}

.btn-group .btn:last-child {
  border-radius: 0 0.5rem 0.5rem 0;
}

/* ================================
   CARDS
   ================================ */
.card {
  border: none;
  border-radius: 0.75rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  overflow: hidden;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.card-header {
  background: linear-gradient(135deg, var(--primary-color), #0a58ca);
  color: #fff;
  font-weight: 600;
  border: none;
}

/* ================================
   FORMULÁRIOS
   ================================ */
.form-control,
.form-select {
  border-radius: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.625rem 1rem;
  transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
}

.input-group {
  border-radius: 0.5rem;
  overflow: hidden;
}

.input-group .form-control:not(:last-child),
.input-group .form-select:not(:last-child) {
  border-radius: 0.5rem 0 0 0.5rem;
}

.input-group .btn {
  border-radius: 0 0.5rem 0.5rem 0;
}

/* ================================
   PAGINAÇÃO
   ================================ */
.pagination {
  gap: 0.25rem;
}

.page-link {
  border: none;
  border-radius: 0.5rem;
  color: rgba(255, 255, 255, 0.7);
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.3s ease;
  padding: 0.5rem 0.75rem;
  margin: 0 0.125rem;
}

.page-link:hover {
  background: var(--primary-color);
  color: #fff;
  transform: translateY(-2px);
}

.page-item.active .page-link {
  background: var(--primary-color);
  color: #fff;
  box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

.page-item.disabled .page-link {
  opacity: 0.3;
}

/* ================================
   BREADCRUMB
   ================================ */
.breadcrumb {
  background: transparent;
  padding: 0;
  margin-bottom: 1.5rem;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "›";
  font-size: 1.25rem;
}

/* ================================
   BADGES
   ================================ */
.badge {
  padding: 0.375rem 0.75rem;
  font-weight: 500;
  border-radius: 0.375rem;
}

/* ================================
   RESPONSIVO
   ================================ */
@media (max-width: 576px) {
  .sidebar {
    left: calc(-1 * var(--sidebar-width));
    width: var(--sidebar-width);
  }

  .sidebar.show {
    left: 0;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
  }

  .navbar {
    left: 0 !important;
    width: 100% !important;
  }

  .main-content {
    margin-left: 0 !important;
  }

  .footer {
    margin-left: 0 !important;
  }

  .content-wrapper {
    padding: 1rem;
  }

  .btn-toggle.d-block {
    display: flex !important;
  }
}

@media (max-width: 768px) {
  .content-wrapper {
    padding: 1.5rem;
  }
}

/* ================================
   ANIMAÇÕES
   ================================ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease;
}

/* ================================
   UTILITÁRIOS
   ================================ */
.text-gradient {
  background: linear-gradient(135deg, var(--primary-color), #0a58ca);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.shadow-sm-hover {
  transition: box-shadow 0.3s ease;
}

.shadow-sm-hover:hover {
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* Scrollbar personalizada */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}
