:root {
  --sidebar-width: 350px;
  --sidebar-collapsed-width: 70px;
  --sidebar-bg: linear-gradient(180deg, #004a8f 0%, #0056a3 100%);
  --sidebar-color: #ffffff;
  --sidebar-hover: rgba(255, 255, 255, 0.15);
  --sidebar-active: rgba(255, 255, 255, 0.25);
  --transition-speed: 0.35s;
  --transition-timing: cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-soft: 0 10px 25px rgba(0, 0, 0, 0.15);
  --shadow-strong: 0 20px 40px rgba(0, 0, 0, 0.2);
}

/* ===== RESET DE PÁGINAS DE AUTENTICAÇÃO ===== */
body.auth-page .sidebar,
body.auth-page .mobile-menu-toggle,
body.auth-page .sidebar-overlay {
  display: none !important;
}

body.auth-page .main-content {
  margin-left: 0 !important;
  width: 100% !important;
}

body.auth-page .main-content.full-width {
  margin-left: 0 !important;
  width: 100% !important;
}

/* ===== LAYOUT CONTAINER ===== */
.layout-container {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ===== SIDEBAR PRINCIPAL ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-color);
  transition: all var(--transition-speed) var(--transition-timing);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 1100;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

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

/* ===== SIDEBAR HEADER ===== */
.sidebar-header {
  padding: 1.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.sidebar-logo {
  font-size: 1.3rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  background: linear-gradient(135deg, #ffffff 0%, #e6f3ff 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.sidebar-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--sidebar-color);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem;
  border-radius: 8px;
  transition: all 0.3s var(--transition-timing);
  backdrop-filter: blur(5px);
}

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

.sidebar-toggle:active {
  transform: scale(0.95);
}

/* ===== SIDEBAR CONTENT ===== */
.sidebar-content {
  padding: 1.5rem 0;
}

.sidebar-menu {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-item {
  margin-bottom: 0.5rem;
  padding: 0 1rem;
}

.sidebar-item.sidebar-bottom {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  padding-top: 1.5rem;
  margin-top: 2rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  color: var(--sidebar-color);
  text-decoration: none;
  transition: all 0.3s var(--transition-timing);
  position: relative;
  border-radius: 12px;
  overflow: hidden;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  transform: translateX(3px);
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.1);
}

.sidebar-link.active {
  background: var(--sidebar-active);
  box-shadow: 0 6px 20px rgba(255, 255, 255, 0.2);
  transform: translateX(5px);
}

.sidebar-link.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, #ffffff 0%, #e6f3ff 100%);
  border-radius: 0 2px 2px 0;
}

.sidebar-link i {
  width: 22px;
  text-align: center;
  margin-right: 1.25rem;
  font-size: 1.2rem;
  transition: all 0.3s var(--transition-timing);
}

.sidebar-link:hover i {
  transform: scale(1.1);
}

.sidebar-link span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  letter-spacing: 0.025em;
  transition: all 0.3s var(--transition-timing);
}

/* ===== ESTADOS COLAPSADO (DESKTOP) ===== */
.sidebar.collapsed .sidebar-link span {
  opacity: 0;
  transform: translateX(-10px);
  visibility: hidden;
}

.sidebar.collapsed .sidebar-logo {
  opacity: 0;
  transform: translateX(-10px);
  visibility: hidden;
}

.sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 1rem 0.75rem;
}

.sidebar.collapsed .sidebar-link i {
  margin-right: 0;
}

/* ===== NOTIFICATION BADGE ===== */
.notification-badge {
  position: absolute;
  top: 50%;
  right: 15px;
  transform: translateY(-50%);
  font-size: 10px;
  background: linear-gradient(135deg, #ff4757 0%, #ff3742 100%);
  color: white;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(255, 71, 87, 0.4);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% {
    transform: translateY(-50%) scale(1);
  }
  50% {
    transform: translateY(-50%) scale(1.1);
  }
  100% {
    transform: translateY(-50%) scale(1);
  }
}

.notification-badge.hidden {
  display: none;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-speed) var(--transition-timing);
  padding: 1rem;
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
}

.main-content.expanded {
  margin-left: var(--sidebar-collapsed-width);
  width: calc(100% - var(--sidebar-collapsed-width));
}

.main-content.full-width {
  margin-left: 0;
  width: 100%;
}

/* ===== RESPONSIVIDADE MOBILE ===== */
@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform var(--transition-speed) var(--transition-timing);
    z-index: 1200;
    box-shadow: var(--shadow-strong);
  }

  .sidebar.mobile-visible {
    transform: translateX(0);
  }

  .sidebar.mobile-visible .sidebar-link span {
    opacity: 1 !important;
    visibility: visible !important;
    display: inline-block !important;
    transform: translateX(0) !important;
  }

  .sidebar.mobile-visible .sidebar-logo {
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
    transform: translateX(0) !important;
  }

  .main-content {
    margin-left: 0;
    width: 100%;
    padding: 1rem 0.75rem;
  }

  /* ===== OVERLAY ===== */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1150;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s var(--transition-timing);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
  }

  .sidebar-overlay.visible {
    opacity: 1;
    visibility: visible;
  }

  /* ===== MOBILE MENU TOGGLE ===== */
  .mobile-menu-toggle {
    position: fixed;
    top: 1.25rem;
    left: 1.25rem;
    z-index: 1300;
    background: var(--sidebar-bg);
    color: white;
    border: none;
    border-radius: 12px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    transition: all 0.3s var(--transition-timing);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
  }

  .mobile-menu-toggle:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-strong);
  }

  .mobile-menu-toggle:active {
    transform: scale(0.95);
  }

  .mobile-menu-toggle i {
    font-size: 1.3rem;
    transition: transform 0.3s var(--transition-timing);
  }

  /* ===== ESCONDER DESKTOP TOGGLE NO MOBILE ===== */
  .sidebar-toggle {
    display: none;
  }
}

/* ===== MOBILE MUITO PEQUENO ===== */
@media (max-width: 480px) {
  .mobile-menu-toggle {
    top: 1rem;
    left: 1rem;
    width: 44px;
    height: 44px;
  }

  .mobile-menu-toggle i {
    font-size: 1.2rem;
  }

  .main-content {
    padding: 0.75rem 0.5rem;
  }

  .sidebar-header {
    padding: 1.5rem 1.25rem;
  }

  .sidebar-content {
    padding: 1.25rem 0;
  }
}

/* ===== DESKTOP - MOSTRAR TOGGLE ===== */
@media (min-width: 769px) {
  .mobile-menu-toggle {
    display: none !important;
  }

  .sidebar-toggle {
    display: flex !important;
  }

  .sidebar-overlay {
    display: none !important;
  }
}

/* ===== MELHORIAS VISUAIS EXTRAS ===== */

/* Scroll personalizado para webkit */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

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

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

/* Animação suave para links */
.sidebar-link::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%
  );
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.sidebar-link:hover::after {
  transform: translateX(100%);
}

/* Focus states melhorados para acessibilidade */
.sidebar-link:focus,
.sidebar-toggle:focus,
.mobile-menu-toggle:focus {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 2px;
}

/* Suporte para reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .sidebar-link,
  .sidebar-toggle,
  .mobile-menu-toggle,
  .sidebar-overlay,
  .main-content {
    transition: none;
    animation: none;
  }
}
