/* Global Styles */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #f8f9fa;
  margin: 0;
  padding: 0;
}

.btn:active {
  border: none !important;
}

/* Sidebar Styles */
.sidebar {
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  width: 250px;
  background-color: #ffffff;
  border-right: 1px solid #e9ecef;
  overflow: hidden;
  z-index: 1000;
  transition: width 0.3s ease;
  display: flex;
  flex-direction: column;
}

/* Sidebar Menu - Área com scroll */
.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

/* Scrollbar customizada para o menu */
.sidebar-menu::-webkit-scrollbar {
  width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.35);
}

.sidebar.collapsed {
  width: 80px;
}

.sidebar.collapsed .sidebar-header h5,
.sidebar.collapsed .nav-section,
.sidebar.collapsed .sidebar-footer .avatar-text {
  opacity: 0;
  visibility: hidden;
  width: 0;
  overflow: hidden;
  transition:
    opacity 0.2s ease,
    visibility 0.2s ease;
}

.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 10px;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar.collapsed .nav-link i {
  margin: 0 !important;
  font-size: 20px !important;
}

.sidebar.collapsed .nav-link span {
  display: none;
}

.sidebar.collapsed .sidebar-footer .avatar {
  margin: 0 auto;
}

.sidebar-header {
  border-bottom: 1px solid #e9ecef;
  flex-shrink: 0;
}

.sidebar-header h5 {
  color: #2c3e50;
  font-weight: 600;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: none;
  color: #21c45d;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-section {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.nav-link {
  color: #6c757d;
  padding: 10px 0;
  border-radius: 6px;
  transition: all 0.2s ease;
  text-decoration: none;
  font-size: 16px;
}

.nav-link:hover {
  background-color: #f8f9fa;
  color: #495057;
}

.nav-link.active {
  background-color: #e8f5e8;
  color: #28a745;
  font-weight: 500;
}

.nav-link i {
  width: 16px;
  font-size: 16px;
}

.sidebar-footer {
  border-top: 1px solid #e9ecef;
  background-color: #ffffff;
  flex-shrink: 0;
}

/* Main Content */
.main-content {
  margin-left: 250px;
  min-height: 100vh;
  width: calc(100% - 250px);
  background-color: #f8f9fa;
  transition:
    margin-left 0.3s ease,
    width 0.3s ease;
}

.main-content.sidebar-collapsed {
  margin-left: 70px;
  width: calc(100% - 70px);
}

.header {
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header h2 {
  color: #2c3e50;
  font-weight: 600;
  font-size: 24px;
}

.search-section {
  background-color: #f8f9fa;
}

.search-section .input-group {
  max-width: 400px;
}

.search-section .form-control {
  background-color: #ffffff;
  border: 1px solid #dee2e6;
}

.search-section .form-control:focus {
  border-color: #28a745;
  box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

/* Metric Cards */
.metric-card {
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.metric-card .card-body {
  padding: 1.5rem;
}

.metric-card h3 {
  font-weight: 700;
  color: #2c3e50;
}

.metric-card .text-success {
  font-weight: 600;
  font-size: 0.875rem;
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.metric-icon .text-primary {
  background-color: rgba(0, 123, 255, 0.1);
}

.metric-icon .text-success {
  background-color: rgba(40, 167, 69, 0.1);
}

.metric-icon .text-warning {
  background-color: rgba(255, 193, 7, 0.1);
}

/* Charts Section */
.charts-section .card {
  border: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.charts-section .card-header {
  border-bottom: 1px solid #e9ecef;
  padding: 1rem 1.5rem;
}

.charts-section .card-header h6 {
  color: #2c3e50;
  font-weight: 600;
}

/* Buttons */
.btn-success {
  background-color: #28a745;
  border-color: #28a745;
  font-weight: 500;
}

.btn-success:hover {
  background-color: #218838;
  border-color: #1e7e34;
}

.btn-outline-secondary {
  color: #6c757d;
  border-color: #6c757d;
  font-weight: 500;
}

.btn-outline-secondary:hover {
  background-color: #6c757d;
  border-color: #6c757d;
}

/* Mobile Menu Toggle Button */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1001;
  background-color: #28a745;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 10px 15px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
  background-color: #218838;
  transform: scale(1.05);
}

.mobile-menu-toggle i {
  font-size: 20px;
}

/* Hide hamburger button when sidebar is open */
.mobile-menu-toggle.hide {
  display: none !important;
}

/* Mobile close button (X) in sidebar */
.mobile-close-btn {
  display: none;
  color: #dc3545;
  font-size: 22px;
  padding: 5px 10px;
  border: none;
  background: transparent;
  transition: all 0.2s ease;
}

.mobile-close-btn:hover {
  background-color: rgba(220, 53, 69, 0.1);
  color: #c82333;
  transform: scale(1.1);
}

.mobile-close-btn i {
  font-weight: bold;
}

/* Desktop toggle button (chevron) */
.desktop-toggle-btn {
  display: block;
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* Responsive Design */
@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    width: 250px !important;
  }

  .sidebar.show {
    transform: translateX(0);
  }

  /* Hide desktop toggle button on mobile */
  .sidebar .desktop-toggle-btn {
    display: none !important;
  }

  /* Show mobile close button when sidebar is open */
  .sidebar.show .mobile-close-btn {
    display: block;
  }

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .main-content.sidebar-collapsed {
    margin-left: 0 !important;
    width: 100% !important;
  }

  .header {
    padding: 1rem !important;
  }

  .header {
    padding: 12px 15px !important;
  }

  .header .d-flex.justify-content-between {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 15px;
  }

  /* Linha Superior: Menu | Título | Sino */
  .header > div:first-of-type {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100%;
    gap: 10px;
  }

  /* Forçar o primeiro div a se comportar como row no mobile */
  .header > div:first-child h2,
  .header > div:first-child h4 {
    font-size: 1.1rem !important;
    margin: 0 !important;
    text-align: center;
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header p {
    display: none; /* Esconder subtítulo no mobile para ganhar espaço */
  }

  /* Botão de Menu dentro do Header */
  .mobile-menu-toggle {
    position: relative !important;
    order: -1;
    margin: 0 !important;
    background: #28a745 !important;
    color: white !important;
    border: none;
    width: 38px !important;
    height: 38px !important;
    border-radius: 8px;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
  }

  /* Sino de Notificações no Mobile */
  #notificationToggle {
    margin: 0 !important;
    width: 38px;
    height: 38px;
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Área de Sino (Direita) */
  .header div:last-child {
    display: flex !important;
    justify-content: flex-end !important;
    gap: 0 !important;
    min-width: 40px;
  }
}

/* Desktop styles */
@media (min-width: 769px) {
  .mobile-close-btn {
    display: none !important;
  }

  .desktop-toggle-btn {
    display: block !important;
  }
}

/* Custom Scrollbar */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* Animation for cards */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.metric-card {
  animation: fadeInUp 0.6s ease forwards;
}

.metric-card:nth-child(1) {
  animation-delay: 0.1s;
}

.metric-card:nth-child(2) {
  animation-delay: 0.2s;
}

.metric-card:nth-child(3) {
  animation-delay: 0.3s;
}

.metric-card:nth-child(4) {
  animation-delay: 0.4s;
}

/* Notification Drawer (Right Side) */
.notification-drawer {
  position: fixed !important;
  top: 0;
  right: -400px; /* Escondido à direita */
  width: 380px;
  height: 100vh;
  z-index: 10001;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.notification-drawer.open {
  right: 0;
}

.notification-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
  z-index: 10000;
  animation: fadeIn 0.3s ease;
}

.notification-list-scroll {
  flex-grow: 1;
  overflow-y: auto;
  scrollbar-width: thin;
}

.notification-item {
  padding: 16px 20px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: all 0.2s;
  display: block;
  text-decoration: none;
  color: inherit;
}

.notification-item:hover {
  background-color: #f8fafc;
  transform: translateX(-4px);
}

.notification-item.unread {
  background-color: #f0f9ff;
  border-left: 4px solid #007bff;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 576px) {
  .notification-drawer {
    width: 100%;
    right: -100%;
  }
}
