@import url('root.css');

:root {
  --sidebar-width-expanded: 280px;
  --sidebar-width-collapsed: 90px;
  --sidebar-transition-speed: 0.4s;
}

/* Main Content & Body Adjustments */
body {
  padding-left: var(--sidebar-width-collapsed);
  transition: padding-left var(--sidebar-transition-speed) cubic-bezier(0.4, 0, 0.2, 1) !important;
}

body.sidebar-expanded {
  padding-left: var(--sidebar-width-expanded);
}

/* Sidebar Container */
#sidebar {
  width: var(--sidebar-width-collapsed);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  background: var(--dark-bg);
  border-right: 1px solid rgba(255, 255, 255, 0.05) !;
  display: flex;
  flex-direction: column;
  z-index: 2000;
  transition: width var(--sidebar-transition-speed) cubic-bezier(0.4, 0, 0.2, 1),
              transform var(--sidebar-transition-speed) ease;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

body.sidebar-expanded #sidebar {
  width: var(--sidebar-width-expanded);
}

/* Logo and Header */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.70rem;
  height: 70px; /* Fixed height */
  flex-shrink: 0;
  transition: all var(--sidebar-transition-speed) ease;
}

.logo a {
  display: flex;
  align-items: center;
  gap: 15px;
  color: var(--text);
}
.logo-icon {
  width: 35px; /* Slightly larger for better visibility when collapsed */
  height: 35px;
  flex-shrink: 0;
  margin-right: 0;
  transition: all var(--sidebar-transition-speed) ease;
  color: var(--logo-color);
}
.logo-text {
  font-size: 1.5rem;
  font-weight: bold;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease 0.1s;
}
.logo-text span {
  color: var(--logo-color);
}

body.sidebar-expanded .logo-text {
  opacity: 1;
}

/* Sidebar Toggle Button */
#sidebar-toggle {
  background: rgba(255, 255, 255, 0.05);
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, background-color 0.3s ease;
  opacity: 0;
  position: absolute;
  top: 20px;
  right: 15px;
}
body.sidebar-expanded #sidebar-toggle {
  opacity: 1;
  position: static;
}
#sidebar-toggle:hover {
  background: var(--primary);
  color: white;
}

/* Search Container */
.search-container {
  display: flex;
  align-items: center;
  margin: 0 1.25rem 1rem;
  padding: 0.6rem;
  background-color: var(--dark);
  border-radius: var(--border-radius);
  position: relative;
  cursor: pointer;
  transition: all var(--sidebar-transition-speed) ease;
}
.search-container i {
  color: var(--text-secondary);
  margin: 0 0.5rem;
}
.search-container input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  outline: none;
  opacity: 0;
  transition: opacity 0.3s ease 0.1s;
  cursor: pointer;
}
body.sidebar-expanded .search-container input {
  opacity: 1;
  cursor: text;
}

/* Search on website button */
.search-website-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
    padding: 10px 15px;
    background: var(--primary);
    color: white;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    text-align: center;
}

.search-website-btn:hover {
    background: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.no-results {
    padding: 15px;
    text-align: center;
    color: var(--text-secondary);
}

.no-results p {
    margin-bottom: 10px;
}

/* Navigation Links */
.sidebar-nav {
  flex-grow: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 1.25rem;
  transition: all var(--sidebar-transition-speed) ease;
}

.sidebar-nav ul {
  list-style: none;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  padding: 0.9rem;
  color: var(--text-secondary);
  border-radius: var(--border-radius);
  margin-bottom: 0.5rem;
  white-space: nowrap;
  transition: background-color 0.3s, color 0.3s;
  position: relative;
  transform: translateZ(0); /* Added to prevent hover jiggle */
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background-color: var(--primary);
  color: white;
}

.sidebar-nav a i {
  font-size: 1.3rem;
  width: 25px;
  text-align: center;
  margin-right: 20px;
  transition: margin-right var(--sidebar-transition-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-nav a span {
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease 0.1s;
}

/* Tooltips for collapsed state */
.sidebar-nav a::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 10px); /* Changed */
  top: 50%;
  transform: translateY(-50%);
  background: var(--dark);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.9rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 1000;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  pointer-events: none;
}

.sidebar-nav a:hover::after {
  opacity: 1;
  visibility: visible;
}

body.sidebar-expanded .sidebar-nav a span {
  opacity: 1;
}

body.sidebar-expanded .sidebar-nav a::after {
  display: none;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  transition: all var(--sidebar-transition-speed) ease;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sidebar-footer .icon-button {
  display: flex;
  align-items: center;
  padding: 0.9rem;
  width: 100%;
  border-radius: var(--border-radius);
  color: var(--text-secondary);
  background-color: transparent;
  transition: all 0.3s ease;
  position: relative;
  min-height: 48px;
  box-sizing: border-box;
  transform: translateZ(0); /* Added to prevent hover jiggle */
}

.sidebar-footer .icon-button:hover {
  color: white;
}
.sidebar-footer .icon-button.discord-btn:hover {
  background-color: #5865F2;
}
.sidebar-footer .icon-button.hlogin-btn:hover {
  background-color: var(--accent);
}
.sidebar-footer .icon-button i {
  font-size: 1.3rem;
  width: 25px;
  text-align: center;
  margin-right: 20px;
}
.sidebar-footer .icon-button span {
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease 0.1s;
}

/* Tooltips for footer buttons */
.sidebar-footer .icon-button::after {
  content: attr(title);
  position: absolute;
  left: calc(100% + 10px); /* Changed */
  top: 50%;
  transform: translateY(-50%);
  background: var(--dark);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 0.9rem;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 1000;
  box-shadow: 0 3px 10px rgba(0,0,0,0.2);
  pointer-events: none;
}

.sidebar-footer .icon-button:hover::after {
  opacity: 1;
  visibility: visible;
}

body.sidebar-expanded .sidebar-footer .icon-button span {
  opacity: 1;
}

body.sidebar-expanded .sidebar-footer .icon-button::after {
  display: none;
}

/* Mobile Header */
#mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  background-color: var(--dark-bg);
  backdrop-filter: blur(10px);
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 1500;
  transition: background-color 0.3s ease, backdrop-filter 0.3s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.mobile-header-content {
  display: flex;
  align-items: center;
  width: 100%;
  justify-content: space-between;
  gap: 10px;
}

.mobile-logo-container {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.mobile-logo-icon {
  width: 30px;
  height: 30px;
  color: var(--logo-color);
}

.mobile-logo {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--text);
  white-space: nowrap;
}

.mobile-logo span {
  color: var(--logo-color);
}

/* Mobile Search Container */
.mobile-search-container {
  display: flex;
  align-items: center;
  flex-grow: 1;
  max-width: 400px;
  padding: 0.5rem;
  background-color: var(--dark);
  border-radius: var(--border-radius);
  position: relative;
  margin: 0 10px;
}

.mobile-search-container i {
  color: var(--text-secondary);
  margin: 0 0.5rem;
  flex-shrink: 0;
}

.mobile-search-container input {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  outline: none;
  font-size: 0.9rem;
}

#mobile-menu-toggle {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

/* Sidebar Overlay for mobile */
#sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  z-index: 1999;
}

/* Search Results */
.search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--dark-bg);
  border-radius: var(--border-radius);
  box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
  margin-top: 5px;
  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--primary) var(--dark);
}

/* Webkit browsers (Chrome, Safari, Edge) */
.search-results::-webkit-scrollbar {
  width: 8px;
}

.search-results::-webkit-scrollbar-track {
  background: var(--dark);
  border-radius: 0 4px 4px 0;
}

.search-results::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* Firefox */
.search-results {
  scrollbar-width: thin;
  scrollbar-color: var(--primary) var(--dark);
}

.search-result-item {
  display: flex;
  align-items: center;
  padding: 10px;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  transition: background-color 0.2s;
}

.search-result-item:hover {
  background-color: var(--primary);
}

.search-result-image {
  width: 40px;
  height: 40px;
  margin-right: 10px;
  flex-shrink: 0;
}

.search-result-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.search-result-info {
  flex-grow: 1;
}

.search-result-title {
  font-weight: 500;
  margin-bottom: 4px;
}

.search-result-rating {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.no-results, .search-error {
  padding: 15px;
  text-align: center;
  color: var(--text-secondary);
}

/* User Profile Section */
.user-profile-section {
    display: none;
    padding: 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    transition: all var(--sidebar-transition-speed) ease;
}

.user-profile-container {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.user-details {
    flex-grow: 1;
    overflow: hidden;
}

.username {
    font-weight: 500;
    color: var(--text);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
}

.user-role {
    color: var(--text-secondary);
    margin: 0;
    font-size: 0.75rem;
    text-transform: capitalize;
}

.logout-btn {
    display: flex;
    align-items: center;
    padding: 0.7rem;
    width: 100%;
    border-radius: var(--border-radius);
    color: var(--text-secondary);
    background-color: transparent;
    transition: all 0.3s ease;
    position: relative;
    text-decoration: none;
    min-height: 48px;
    box-sizing: border-box;
    transform: translateZ(0); /* Added to prevent hover jiggle */
}

.logout-btn:hover {
    background-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.logout-btn i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
    margin-right: 15px;
}

.logout-btn span {
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease 0.1s;
}

/* Tooltips for logout button */
.logout-btn::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 10px); /* Changed */
    top: 50%;
    transform: translateY(-50%);
    background: var(--dark);
    color: var(--text);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 1000;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    pointer-events: none;
}

.logout-btn:hover::after {
    opacity: 1;
    visibility: visible;
}

body.sidebar-expanded .logout-btn span {
    opacity: 1;
}

body.sidebar-expanded .logout-btn::after {
    display: none;
}

/* Show user profile section when user is logged in */
body.user-logged-in .user-profile-section {
    display: block;
}

/* Hide sidebar footer when user is logged in */
body.user-logged-in .sidebar-footer {
    display: none;
}

/* Mobile adjustments for user profile */
@media (max-width: 1024px) {
    .user-profile-section {
        display: block;
    }
    
    .logout-btn span {
        opacity: 1;
    }
    
    .logout-btn::after {
        display: none;
    }
}

/* Improve mobile search experience */
@media (max-width: 1024px) {
  .mobile-search-container:focus-within {
    background-color: var(--dark);
  }
  
  /* Prevent body scrolling when search results are visible */
  body.search-results-visible {
    overflow: hidden;
  }
  
  /* Better touch targets for mobile */
  .search-result-item {
    padding: 12px 10px;
    min-height: 50px;
  }
}

/* Responsive Styles - MOBILE ONLY */
@media (max-width: 1024px) {
  body {
    padding-left: 0;
  }
  body.sidebar-expanded {
    padding-left: 0;
    overflow: hidden; /* Prevent scrolling when mobile menu is open */
  }

  #sidebar {
    width: var(--sidebar-width-expanded);
    transform: translateX(-100%);
    transition: transform var(--sidebar-transition-speed) ease;
    pointer-events: auto !important;
  }
  
  #sidebar:hover {
    transform: translateX(-100%) !important;
  }
  
  body.sidebar-expanded #sidebar {
    transform: translateX(0);
  }

  /* Show full logo on mobile when expanded */
  body.sidebar-expanded .logo-text {
    opacity: 1;
  }

  /* Show mobile header ONLY on mobile */
  #mobile-header {
    display: flex;
  }
  
  /* Show overlay when menu is open */
  body.sidebar-expanded #sidebar-overlay {
    display: block;
  }

  /* Always show text and icons inside sidebar on mobile */
  #sidebar .logo-text,
  #sidebar .search-container input,
  #sidebar .sidebar-nav a span,
  #sidebar .sidebar-footer .icon-button span {
    opacity: 1;
  }
  
  /* Hide tooltips on mobile */
  .sidebar-nav a::after,
  .sidebar-footer .icon-button::after {
    display: none;
  }
  
  /* Hide the desktop toggle, we use the mobile one now */
  #sidebar-toggle {
    display: none;
  }
  
  /* Hide sidebar search on mobile */
  #sidebarSearchContainer {
    display: none;
  }
  
  /* Add padding to content to avoid overlap with mobile header */
  main.container {
    padding-top: 80px;
  }
}

/* Desktop styles - Ensure mobile header is hidden on desktop */
@media (min-width: 1025px) {
  #mobile-header {
    display: none !important;
  }
  
  /* Hide mobile search on desktop */
  .mobile-search-container {
    display: none !important;
  }
  
  /* Show sidebar search on desktop */
  #sidebarSearchContainer {
    display: flex !important;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  .mobile-logo {
    font-size: 1.2rem;
  }
  
  .mobile-logo-container {
    gap: 5px;
  }
  
  .mobile-search-container {
    margin: 0 5px;
  }
  
  .mobile-search-container input {
    font-size: 0.8rem;
  }
}