/*
 * Adtlas DAI Management System - Sidebar Styles
 * 
 * This file contains the sidebar-specific styles for the Adtlas application.
 * It includes sidebar layout, navigation, responsive behavior, and animations.
 */

/* ============================================================================
   SIDEBAR LAYOUT
   ============================================================================ */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: var(--white);
  z-index: 1000;
  transition: all var(--transition-base);
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

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

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

.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);
}

/* Collapsed Sidebar */
.sidebar.collapsed {
  width: 70px;
}

.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .nav-link-text,
.sidebar.collapsed .nav-section-title {
  opacity: 0;
  visibility: hidden;
}

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

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

.sidebar.collapsed .nav-item.has-submenu .nav-link::after {
  display: none;
}

.sidebar.collapsed .nav-submenu {
  display: none !important;
}

/* ============================================================================
   SIDEBAR HEADER
   ============================================================================ */

.sidebar-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--white);
  font-size: var(--font-size-xl);
  font-weight: 700;
  transition: all var(--transition-base);
}

.sidebar-brand:hover {
  color: var(--white);
  text-decoration: none;
  transform: scale(1.02);
}

.sidebar-brand-icon {
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: var(--spacing-md);
  font-size: var(--font-size-lg);
  transition: all var(--transition-base);
}

.sidebar-brand-text {
  transition: all var(--transition-base);
  white-space: nowrap;
}

.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: -15px;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  background: var(--white);
  color: var(--primary-color);
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--box-shadow);
  z-index: 1001;
}

.sidebar-toggle:hover {
  background: var(--light);
  transform: translateY(-50%) scale(1.1);
}

.sidebar-toggle i {
  font-size: 0.875rem;
  transition: transform var(--transition-base);
}

.sidebar.collapsed .sidebar-toggle i {
  transform: rotate(180deg);
}

/* ============================================================================
   SIDEBAR NAVIGATION
   ============================================================================ */

.sidebar-nav {
  padding: var(--spacing-lg) 0;
}

.nav-section {
  margin-bottom: var(--spacing-xl);
}

.nav-section-title {
  padding: 0 var(--spacing-lg) var(--spacing-sm);
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.7);
  transition: all var(--transition-base);
}

.nav-item {
  margin-bottom: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 0.75rem var(--spacing-lg);
  color: rgba(255, 255, 255, 0.9);
  text-decoration: none;
  transition: all var(--transition-base);
  position: relative;
  border-radius: 0;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  text-decoration: none;
  transform: translateX(5px);
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
  font-weight: 600;
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--white);
  border-radius: 0 2px 2px 0;
}

.nav-link i {
  width: 20px;
  margin-right: var(--spacing-md);
  text-align: center;
  font-size: 1rem;
  transition: all var(--transition-base);
}

.nav-link-text {
  flex: 1;
  transition: all var(--transition-base);
  white-space: nowrap;
}

.nav-link-badge {
  background: rgba(255, 255, 255, 0.2);
  color: var(--white);
  font-size: var(--font-size-xs);
  padding: 0.25rem 0.5rem;
  border-radius: 50px;
  margin-left: auto;
}

/* ============================================================================
   SUBMENU NAVIGATION
   ============================================================================ */

.nav-item.has-submenu .nav-link::after {
  content: '\f107';
  font-family: 'Font Awesome 5 Free';
  font-weight: 900;
  margin-left: auto;
  transition: transform var(--transition-base);
}

.nav-item.has-submenu.open .nav-link::after {
  transform: rotate(180deg);
}

.nav-submenu {
  background: rgba(0, 0, 0, 0.1);
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-base);
}

.nav-item.has-submenu.open .nav-submenu {
  max-height: 300px;
}

.nav-submenu .nav-link {
  padding-left: 3.5rem;
  font-size: var(--font-size-sm);
  color: rgba(255, 255, 255, 0.8);
}

.nav-submenu .nav-link:hover {
  color: var(--white);
  background: rgba(255, 255, 255, 0.05);
}

.nav-submenu .nav-link.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
}

.nav-submenu .nav-link i {
  width: 16px;
  font-size: 0.875rem;
  margin-right: var(--spacing-sm);
}

/* ============================================================================
   SIDEBAR FOOTER
   ============================================================================ */

.sidebar-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: var(--spacing-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.1);
}

.sidebar-user {
  display: flex;
  align-items: center;
  color: var(--white);
  text-decoration: none;
  transition: all var(--transition-base);
}

.sidebar-user:hover {
  color: var(--white);
  text-decoration: none;
  transform: translateY(-2px);
}

.sidebar-user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin-right: var(--spacing-md);
  border: 2px solid rgba(255, 255, 255, 0.3);
  transition: all var(--transition-base);
}

.sidebar-user:hover .sidebar-user-avatar {
  border-color: var(--white);
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
  transition: all var(--transition-base);
}

.sidebar-user-name {
  font-weight: 600;
  font-size: var(--font-size-sm);
  margin-bottom: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: var(--font-size-xs);
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================================
   CONTENT WRAPPER ADJUSTMENTS
   ============================================================================ */

.content-wrapper {
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-base);
  min-height: 100vh;
  background: var(--light);
}

.content-wrapper.sidebar-collapsed {
  margin-left: 70px;
}

/* ============================================================================
   RESPONSIVE BEHAVIOR
   ============================================================================ */

@media (max-width: 1200px) {
  .sidebar {
    width: 250px;
  }
  
  .content-wrapper {
    margin-left: 250px;
  }
}

@media (max-width: 992px) {
  .sidebar {
    width: 220px;
  }
  
  .content-wrapper {
    margin-left: 220px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }
  
  .sidebar.mobile {
    transform: translateX(-100%);
  }
  
  .sidebar.mobile:not(.collapsed) {
    transform: translateX(0);
  }
  
  .content-wrapper {
    margin-left: 0;
  }
  
  .content-wrapper.sidebar-collapsed {
    margin-left: 0;
  }
  
  .sidebar-toggle {
    display: none;
  }
}

@media (max-width: 576px) {
  .sidebar {
    width: 100vw;
  }
  
  .sidebar-header {
    padding: var(--spacing-md);
  }
  
  .nav-link {
    padding: 0.875rem var(--spacing-md);
  }
  
  .nav-section-title {
    padding: 0 var(--spacing-md) var(--spacing-sm);
  }
}

/* ============================================================================
   SIDEBAR OVERLAY (Mobile)
   ============================================================================ */

.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.sidebar:not(.collapsed) + .sidebar-overlay,
.sidebar.mobile:not(.collapsed) ~ .sidebar-overlay {
  opacity: 1;
  visibility: visible;
}

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

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

@keyframes slideOutLeft {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(-100%);
  }
}

.sidebar.slide-in {
  animation: slideInLeft 0.3s ease;
}

.sidebar.slide-out {
  animation: slideOutLeft 0.3s ease;
}

/* ============================================================================
   SIDEBAR THEMES
   ============================================================================ */

/* Dark Theme */
[data-theme="dark"] .sidebar {
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
}

[data-theme="dark"] .sidebar-toggle {
  background: #2d3748;
  color: var(--white);
}

[data-theme="dark"] .sidebar-toggle:hover {
  background: #4a5568;
}

/* Light Theme Variations */
.sidebar.theme-light {
  background: linear-gradient(180deg, #f8f9fa 0%, #e9ecef 100%);
  color: var(--dark);
  border-right: 1px solid var(--light-gray);
}

.sidebar.theme-light .nav-link {
  color: var(--gray);
}

.sidebar.theme-light .nav-link:hover {
  background: rgba(102, 126, 234, 0.1);
  color: var(--primary-color);
}

.sidebar.theme-light .nav-link.active {
  background: rgba(102, 126, 234, 0.1);
  color: var(--primary-color);
}

.sidebar.theme-light .nav-link.active::before {
  background: var(--primary-color);
}

.sidebar.theme-light .nav-section-title {
  color: var(--gray);
}

.sidebar.theme-light .sidebar-brand {
  color: var(--dark);
}

.sidebar.theme-light .sidebar-user {
  color: var(--dark);
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

.sidebar .nav-link:focus {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: -2px;
}

.sidebar-toggle:focus {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
  .sidebar,
  .content-wrapper,
  .nav-link,
  .sidebar-toggle,
  .nav-submenu {
    transition: none;
  }
  
  .sidebar.slide-in,
  .sidebar.slide-out {
    animation: none;
  }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
  .sidebar {
    display: none;
  }
  
  .content-wrapper {
    margin-left: 0 !important;
  }
}

/* ============================================================================
   HIGH CONTRAST MODE
   ============================================================================ */

@media (prefers-contrast: high) {
  .sidebar {
    background: #000000;
    border-right: 2px solid #ffffff;
  }
  
  .nav-link {
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  }
  
  .nav-link:hover,
  .nav-link.active {
    background: #ffffff;
    color: #000000;
  }
}

/* ============================================================================
   CUSTOM SCROLLBAR FOR FIREFOX
   ============================================================================ */

.sidebar {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) rgba(255, 255, 255, 0.1);
}

/* ============================================================================
   SIDEBAR SEARCH
   ============================================================================ */

.sidebar-search {
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-search-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius);
  color: var(--white);
  font-size: var(--font-size-sm);
  transition: all var(--transition-base);
}

.sidebar-search-input::placeholder {
  color: rgba(255, 255, 255, 0.6);
}

.sidebar-search-input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

.sidebar.collapsed .sidebar-search {
  display: none;
}

/* ============================================================================
   SIDEBAR NOTIFICATIONS
   ============================================================================ */

.sidebar-notifications {
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-notification {
  display: flex;
  align-items: center;
  padding: 0.5rem 0;
  color: rgba(255, 255, 255, 0.8);
  font-size: var(--font-size-sm);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-notification:last-child {
  border-bottom: none;
}

.sidebar-notification-icon {
  width: 20px;
  margin-right: var(--spacing-sm);
  text-align: center;
}

.sidebar-notification-text {
  flex: 1;
  line-height: 1.4;
}

.sidebar.collapsed .sidebar-notifications {
  display: none;
}