:host {
  width: var(--sidebar-width);
  height: var(--sidebar-height);
  background: var(--sidebar-background);
  background-size: 100% 100%;
  border-right: var(--sidebar-border);
  box-shadow: var(--sidebar-shadow);
  display: flex;
  flex-direction: column;
  z-index: var(--sidebar-z-index);
  flex-shrink: 0;
  overflow-y: auto;
  position: sticky;
  top: 0;
  transition: all var(--sidebar-transition-duration) ease;
  backdrop-filter: var(--sidebar-backdrop-filter);

  // Colored edge accents
  &::before,
  &::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: var(--sidebar-top-line-height);
    background: var(--sidebar-top-line-background);
    z-index: 2;
  }
  
  &::before {
    left: 0;
  }
  
  &::after {
    right: 0;
  }
  
  // Transitions for text elements in expanded state
  .app-name,
  .sidebar-section-title,
  .sidebar-nav span,
  .support-link span {
    opacity: 1;
    visibility: visible;
    width: auto;
    max-width: 180px;
    white-space: nowrap;
    transition: all var(--sidebar-transition-duration) ease;
  }

  @media (max-width: 991px) {
    display: none;
  }

  // When isMobile input is true, ensure component is always visible regardless of screen size
  &.mobile-variant {
    display: flex !important;
    position: static;
    height: 100% !important;
    width: 100% !important;
  }

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

    .app-name,
    .sidebar-section-title,
    .sidebar-nav span,
    .support-link span {
      opacity: 0;
      visibility: hidden;
      width: 0;
      max-width: 0;
      overflow: hidden;
      transition: all var(--sidebar-transition-duration) ease;
    }

    .sidebar-nav li a {
      padding: 0.75rem 0;
      justify-content: center;

      i {
        margin: 0 auto;
        width: 100%;
        display: flex;
        justify-content: center;
      }
    }

    .sponsor-section .support-link {
      padding: 0.75rem 0;
      justify-content: center;

      i {
        margin: 0 auto;
        width: 100%;
        display: flex;
        justify-content: center;
      }
    }

    .sidebar-footer {
      justify-content: center;
    }
  }
}

/* ========================================================================
   LOGO SECTION
   ======================================================================== */

.logo-container {
  display: flex;
  align-items: center;
  padding: 20px;
  margin-top: 20px;
  margin-bottom: 20px;
  position: relative;
  flex: 0 0 auto; // Prevent logo container from growing/shrinking
  
  .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--sidebar-logo-size);
    height: var(--sidebar-logo-size);
    margin-right: 15px;
    border-radius: 50%;
    background-color: var(--sidebar-logo-background);
    border: var(--sidebar-logo-border);
    animation: logo-glow 10s infinite ease-in-out;
    transition: all var(--sidebar-transition-duration) ease;

    img {
      width: var(--sidebar-logo-size);
      height: var(--sidebar-logo-size);
    }
  }
  
  h2 {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: var(--sidebar-text-white);
    text-shadow: var(--sidebar-text-shadow);
    letter-spacing: 0.5px;
    background: var(--sidebar-text-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .logo-glow {
    box-shadow: var(--sidebar-logo-glow);
    animation: logo-glow 2s infinite ease-in-out;
  }
}

// Navigation menu
.nav-menu {
  display: block;
  gap: 0; // Remove gap to prevent layout shifts
  transition: opacity 0.2s ease;
  margin-top: 15px; // Add spacing from logo container

  // Keep horizontal overflow hidden to avoid horizontal scrollbar
  overflow-x: hidden;

  // The nav area becomes the scrollable region. Use a calc so the
  // header/logo area remains visible and the nav does not shrink
  // other elements when it scrolls. Default header height can be
  // overridden via the --sidebar-header-height CSS variable.
  height: calc(100% - var(--sidebar-header-height, 120px));
  box-sizing: border-box;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;

  // Navigation items container for smooth animations
  .navigation-items-container {
    display: flex;
    flex-direction: column;
    gap: 8px; // Consistent spacing between navigation items
    position: relative; // Ensure proper stacking context for animations
    width: 100%; // Take full width of parent

    // Prevent horizontal scrollbar when items translate on hover
    overflow-x: hidden;
    padding-right: 8px; // leave space for the scrollbar

    // Keep layout stable: do not force this element to flex-grow
    // so icons and badges won't shrink when the nav scrolls.
    min-height: 0;
  }

  // Loading skeleton
  .nav-skeleton {
    padding: 0;
    
    .skeleton-item {
      height: 60px; // Match actual nav-item height
      padding: 10px 20px; // Match nav-item padding
      margin-bottom: 8px; // Match nav-item spacing
      display: flex;
      align-items: center;
      border-radius: 6px;
      background: linear-gradient(90deg, var(--surface-200) 25%, var(--surface-300) 50%, var(--surface-200) 75%);
      background-size: 200% 100%;
      animation: skeleton-loading 1.5s infinite;
      
      &:last-child {
        margin-bottom: 0;
      }
      
      &.sponsor-skeleton {
        margin-bottom: 15px;
      }
      
      // Add fake icon and text areas to match real content
      &::before {
        content: '';
        width: 40px;
        height: 40px;
        border-radius: 8px;
        background: var(--surface-300);
        margin-right: 15px;
        flex-shrink: 0;
      }
      
      &::after {
        content: '';
        height: 20px;
        background: var(--surface-300);
        border-radius: 4px;
        flex: 1;
        max-width: 120px;
      }
    }
  }
  
  // Sponsor link
  .support-link {
    border-bottom: none;
    margin-bottom: 15px;
    
    .heart-icon i {
      color: var(--sidebar-heart-color) !important;
      transition: all 0.3s ease;
      text-shadow: var(--sidebar-heart-shadow);

      &:hover {
        transform: scale(1.2);
      }
    }
  }

  // Go back button styling
  .go-back-button {
    background-color: var(--surface-200);
    border: 1px solid var(--surface-300);
    margin-bottom: 15px;
    cursor: pointer;
    
    &:hover {
      transform: translateX(2px);
      background-color: var(--surface-300);
      
      .nav-icon-wrapper i {
        transform: translateX(-2px);
      }
    }
  }

  // Breadcrumb styling
  .breadcrumb {
    padding: 8px 20px;
    font-size: 12px;
    color: var(--text-color-secondary);
    border-bottom: 1px solid var(--surface-border);
    margin-bottom: 10px;
    overflow: hidden;
    transition: all 0.25s ease;
    
    span {
      transition: all 0.2s ease;
    }
    
    i {
      margin: 0 8px;
      font-size: 10px;
      transition: all 0.2s ease;
    }
  }
  
  // Section headers for top-level sections
  .nav-section-header {
    display: flex;
    align-items: center;
    padding: 8px 20px 4px;
    color: var(--text-color-secondary);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 15px 0 8px 0;
    border-bottom: 1px solid var(--surface-border);
    
    .nav-icon-wrapper {
      width: 24px;
      height: 24px;
      display: flex;
      justify-content: center;
      align-items: center;
      margin-right: 12px;
      border-radius: 4px;
      background: var(--surface-200);
      flex-shrink: 0;
      
      i {
        font-size: 12px;
        color: var(--text-color-secondary);
      }
    }
    
    span {
      font-size: 11px;
      font-weight: 600;
    }
  }
}

/* ========================================================================
   NAVIGATION SECTION
   ======================================================================== */

// Main navigation items
.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 0 6px 6px 0;
    position: relative;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    margin-bottom: 8px; // Consistent spacing instead of gap
    
    &:last-child {
      margin-bottom: 0;
    }
    
    .nav-icon-wrapper {
      width: 48px;
      height: 48px;
      display: flex;
      justify-content: center;
      align-items: center;
      margin-right: 15px;
      border-radius: 8px;
      background: var(--surface-card);
      border: 1px solid var(--surface-border);
      transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
      flex-shrink: 0; // Prevent icon from shrinking
      
      i {
        font-size: 22px;
        color: var(--text-color-secondary);
        transition: all 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
      }

      /* Stacked image icon (grayscale base + colored top) */
      .icon-stack {
        position: relative;
        width: 24px;
        height: 24px;
      }

      .icon-stack img {
        position: absolute;
        left: 0;
        top: 0;
        width: 24px;
        height: 24px;
        display: block;
        object-fit: contain;
        transition: opacity 180ms ease-in-out, transform 180ms ease-in-out;
        opacity: 1;
      }

      .icon-stack .icon-top {
        opacity: 0;
        transform: scale(1);
      }

      .icon-stack .icon-top.visible {
        opacity: 1;
        transform: scale(1.03);
      }
    }
    
    span {
      white-space: nowrap;
      font-size: 14px;
      overflow: hidden;
      text-overflow: ellipsis;
      flex: 1; // Take available space
    }

    .nav-badge {
      margin-left: auto;
      background-color: var(--primary-color);
      color: var(--primary-color-text);
      border-radius: 12px;
      padding: 2px 8px;
      font-size: 12px;
      font-weight: 600;
      flex-shrink: 0;
    }
    
    &::before {
      content: '';
      position: absolute;
      left: 0;
      top: 0;
      height: 100%;
      width: 3px;
      background: transparent;
      transition: all 0.2s ease;
    }
    
    &:hover {
      transform: translateX(4px);
      background-color: var(--surface-hover);
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
      
      .nav-icon-wrapper {
        background-color: rgba(var(--primary-500-rgb), 0.1);
        border-color: rgba(var(--primary-300-rgb), 0.3);
      }
      
      &::before {
        background-color: var(--primary-300);
      }
    }
    
    &.active {
      background-color: var(--primary-color);
      color: var(--primary-color-text);
      
      .nav-icon-wrapper {
        background-color: rgba(255, 255, 255, 0.2);
        border-color: rgba(255, 255, 255, 0.3);
        
        i {
          color: var(--primary-color-text);
        }
      }
      
      &::before {
        background-color: var(--sidebar-text-white);
      }
    }
  }

  // Parent navigation items (with children)
  .nav-parent {
    cursor: pointer;
    position: relative;
    
    .nav-chevron {
      margin-left: auto;
      opacity: 0.6;
      transition: transform 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
      flex-shrink: 0;
      
      i {
        font-size: 16px;
        transition: transform 0.2s ease;
      }
    }
    
    &:hover .nav-chevron i {
      transform: translateX(3px) scale(1.1);
    }
  }

/* ========================================================================
   SPONSOR SECTION
   ======================================================================== */

.sponsor-section {
  padding: 0.5rem 1rem 1rem;

  .support-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    color: var(--sidebar-text-white);
    text-decoration: none;
    transition: background-color 0.2s;

    &:hover {
      background-color: rgba(255, 255, 255, 0.1);
    }

    i {
      color: #ff5a5f;
      margin-right: 0.75rem;
    }
  }
}

// Sidebar footer with toggle button
.sidebar-footer {
  display: flex;
  justify-content: flex-end;
  padding: 1rem;
  margin-top: auto;

  .sidebar-toggle {
    color: var(--sidebar-text-white);
    background-color: rgba(255, 255, 255, 0.1);

    &:hover {
      background-color: rgba(255, 255, 255, 0.2);
    }
  }
}

/* ========================================================================
   ANIMATIONS
   ======================================================================== */

@keyframes logo-glow {
  0% { box-shadow: 0 0 15px #8e44ad, 0 0 5px rgba(142, 68, 173, 0.4); }
  20% { box-shadow: 0 0 15px #9b59b6, 0 0 5px rgba(155, 89, 182, 0.4); }
  40% { box-shadow: 0 0 15px #673ab7, 0 0 5px rgba(103, 58, 183, 0.4); }
  60% { box-shadow: 0 0 15px #5e35b1, 0 0 5px rgba(94, 53, 177, 0.4); }
  80% { box-shadow: 0 0 15px #7e57c2, 0 0 5px rgba(126, 87, 194, 0.4); }
  100% { box-shadow: 0 0 15px #8e44ad, 0 0 5px rgba(142, 68, 173, 0.4); }
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

@keyframes heart-pulse {
  0% {
    transform: scale(1);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.2);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 0.7;
  }
}

::ng-deep {
  .p-drawer.mobile-sidebar {
    background: var(--sidebar-background) !important;
    border: none !important;

    .p-drawer-content {
      padding: 0 !important;
      background: var(--sidebar-background) !important;
      color: var(--sidebar-text-white) !important;

      .sidebar-header {
        padding: 1.5rem 1rem;
        display: flex;
        align-items: center;
        justify-content: center;

        .sidebar-logo {
          display: flex;
          align-items: center;

          .sidebar-icon {
            font-size: 1.5rem;
            color: #ffcc00;
          }

          .app-name {
            font-size: 1.25rem;
            font-weight: 700;
            margin-left: 0.5rem;
            color: var(--sidebar-text-white);
          }
        }
      }

      .sidebar-nav {
        padding: var(--sidebar-nav-padding);
        overflow-y: auto;
        flex: 1;

        .sidebar-section-title {
          padding: 0 1rem;
          margin: 0 0 0.5rem 0;
          font-size: 0.75rem;
          font-weight: 600;
          color: rgba(255, 255, 255, 0.5);
          letter-spacing: 0.5px;
        }

        ul {
          list-style: none;
          padding: 0;
          margin: 0;

          li {
            a {
              display: flex;
              align-items: center;
              padding: 0.75rem 1rem;
              color: rgba(255, 255, 255, 0.8);
              text-decoration: none;
              transition: background-color 0.2s;

              &:hover {
                background-color: rgba(255, 255, 255, 0.05);
              }

              i {
                font-size: 1.25rem;
                width: 1.5rem;
                margin-right: 0.75rem;
                text-align: center;
              }

              span {
                font-size: 0.95rem;
              }
            }

            &.active a {
              background-color: rgba(255, 255, 255, 0.1);
              color: var(--sidebar-text-white);
              font-weight: 600;
              border-left: 3px solid #4299e1;
              padding-left: calc(1rem - 3px);

              i {
                color: #4299e1;
              }
            }
          }
        }
      }

      .sponsor-section {
        padding: 0.5rem 1rem 1rem;
        margin-top: auto;

        .support-link {
          display: flex;
          align-items: center;
          padding: 0.75rem 1rem;
          background-color: rgba(255, 255, 255, 0.05);
          border-radius: 4px;
          color: var(--sidebar-text-white);
          text-decoration: none;
          transition: background-color 0.2s;

          &:hover {
            background-color: rgba(255, 255, 255, 0.1);
          }

          i {
            color: #ff5a5f;
            margin-right: 0.75rem;
          }
        }
      }
    }
  }
}
