/* ===========================
   MOBILE MENU ICON
   =========================== */
.menu-icon {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  background: var(--primary);
  border-radius: var(--radius-full);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  padding: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 101;
  transition: var(--transition);
}

.menu-icon:hover {
  background: var(--primary-dark);
  transform: scale(1.05);
}

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

.menu-icon div {
  width: 20px;
  height: 2.5px;
  background: white;
  border-radius: 2px;
  transition: var(--transition);
}

.menu-icon.active div:nth-child(1) {
  transform: translateY(7.5px) rotate(45deg);
}

.menu-icon.active div:nth-child(2) {
  opacity: 0;
  transform: translateX(-20px);
}

.menu-icon.active div:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
}

/* Hide on desktop */
@media (min-width: 1024px) {
  .menu-icon {
    display: none;
  }
}

/* ===========================
   SIDEBAR OVERLAY
   =========================== */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 199;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

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

/* ===========================
   MODERN SIDEBAR
   =========================== */
.modern-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 320px;
  max-width: 85vw;
  background: var(--white);
  z-index: 999999;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-2xl);
  overflow: hidden;
}

.modern-sidebar.active {
  transform: translateX(0);
}

/* Desktop styles */
@media (min-width: 1024px) {
  .modern-sidebar {
    position: sticky;
    top: 90px;
    height: calc(100vh - 110px);
    transform: translateX(0);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    width: 280px;
    max-width: 280px;
    margin-top: 0;
  }
  
  .sidebar-overlay {
    display: none !important;
  }
}

/* ===========================
   SIDEBAR HEADER
   =========================== */
.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  position: relative;
  background: linear-gradient(135deg, var(--primary-ultra-light), var(--white));
}

.sidebar-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--gray-100);
  border: none;
  color: var(--gray-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  transition: var(--transition);
  z-index: 10;
}

.sidebar-close:hover {
  background: var(--gray-200);
  color: var(--gray-900);
  transform: rotate(90deg);
}

.sidebar-close:active {
  transform: rotate(90deg) scale(0.9);
}

/* Hide close button on desktop */
@media (min-width: 1024px) {
  .sidebar-close {
    display: none;
  }
}

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 8px;
}

.sidebar-avatar {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 3px solid var(--primary);
  background: var(--gray-100);
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-info h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0 0 0.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-user-info p {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===========================
   SIDEBAR CONTENT
   =========================== */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300) transparent;
}

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

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

.sidebar-content::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: var(--radius-full);
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-section:last-child {
  margin-bottom: 0;
}

.sidebar-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.75rem;
  padding: 0 0.5rem;
}

/* ===========================
   SIDEBAR NAVIGATION
   =========================== */
.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar-nav li {
  margin-bottom: 0.25rem;
  animation: slideIn 0.3s ease backwards;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.sidebar-nav li:nth-child(1) { animation-delay: 0.05s; }
.sidebar-nav li:nth-child(2) { animation-delay: 0.1s; }
.sidebar-nav li:nth-child(3) { animation-delay: 0.15s; }
.sidebar-nav li:nth-child(4) { animation-delay: 0.2s; }
.sidebar-nav li:nth-child(5) { animation-delay: 0.25s; }
.sidebar-nav li:nth-child(6) { animation-delay: 0.3s; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  padding: 0.875rem 1rem;
  color: var(--gray-700);
  text-decoration: none;
  border-radius: var(--radius-lg);
  transition: var(--transition);
  position: relative;
  font-weight: 500;
  font-size: 0.9375rem;
}

.sidebar-nav a:hover {
  background: var(--gray-100);
  color: var(--gray-900);
  transform: translateX(4px);
}

.sidebar-nav a.active {
  background: linear-gradient(135deg, var(--primary-light), var(--primary-ultra-light));
  color: var(--primary);
  font-weight: 600;
}

.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 28px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
}

.sidebar-nav i {
  width: 24px;
  font-size: 1.125rem;
  margin-right: 1rem;
  flex-shrink: 0;
  text-align: center;
  transition: var(--transition);
}

.sidebar-nav a:hover i {
  transform: scale(1.15);
}

.sidebar-nav span {
  flex: 1;
  font-size: 0.9375rem;
}

.nav-badge {
  background: var(--red);
  color: white;
  font-size: 0.6875rem;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  box-shadow: var(--shadow-sm);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.05);
  }
}

/* ===========================
   SIDEBAR DIVIDER
   =========================== */
.sidebar-divider {
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    var(--gray-200) 20%,
    var(--gray-200) 80%,
    transparent
  );
  margin: 1rem 0;
}

/* ===========================
   SIDEBAR LOGOUT
   =========================== */
.sidebar-logout {
  display: flex;
  align-items: center;
  padding: 0.875rem 1rem;
  color: var(--red);
  text-decoration: none;
  border-radius: var(--radius-lg);
  background: var(--red-light);
  transition: var(--transition);
  font-weight: 600;
  font-size: 0.9375rem;
  margin: 1rem;
  border: 1px solid transparent;
}

.sidebar-logout:hover {
  background: var(--red);
  color: white;
  border-color: var(--red-dark);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.sidebar-logout:active {
  transform: translateY(0);
}

.sidebar-logout i {
  font-size: 1.125rem;
  margin-right: 1rem;
  transition: var(--transition);
}

.sidebar-logout:hover i {
  transform: translateX(-4px);
}

.sidebar-logout span {
  font-size: 0.9375rem;
}

/* ===========================
   SIDEBAR FOOTER
   =========================== */
.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.sidebar-footer-info {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-bottom: 0.5rem;
  text-align: center;
  line-height: 1.5;
}

.sidebar-footer-info a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: var(--transition);
}

.sidebar-footer-info a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.sidebar-footer-brand {
  font-size: 0.6875rem;
  color: var(--gray-400);
  text-align: center;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* ===========================
   DARK MODE SUPPORT
   =========================== */
@media (prefers-color-scheme: dark) {
  .modern-sidebar {
    background: #1a1a1a;
    border-right-color: #2d2d2d;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.3);
  }

  .modern-sidebar-overlay {
    background: rgba(0, 0, 0, 0.7);
  }

  .modern-sidebar-header {
    background: #252525;
    border-bottom-color: #2d2d2d;
  }

  .close-sidebar-btn {
    color: #d4d4d4;
  }

  .close-sidebar-btn:hover {
    background: #2d2d2d;
  }

  .sidebar-menu li a {
    color: #d4d4d4;
    border-left-color: transparent;
  }

  .sidebar-menu li a:hover {
    background: #2d2d2d;
    color: #28a745;
    border-left-color: #28a745;
  }

  .sidebar-menu li a.active {
    background: linear-gradient(90deg, #28a745 0%, #1e7e34 100%);
    color: white;
    border-left-color: #28a745;
  }

  .sidebar-menu li a i {
    color: inherit;
  }

  .sidebar-divider {
    background: #2d2d2d;
  }

  .sidebar-footer {
    background: #252525;
    border-top-color: #2d2d2d;
  }

  .sidebar-logout {
    color: #ef4444;
    border-color: #2d2d2d;
  }

  .sidebar-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ff6b6b;
  }

  .sidebar-footer-info {
    color: #b3b3b3;
  }

  .sidebar-footer-info p {
    color: #999999;
  }

  .sidebar-footer-info a {
    color: #28a745;
  }

  .sidebar-footer-info a:hover {
    color: #1e7e34;
  }

  .sidebar-footer-brand {
    color: #5a5a5a;
  }
}