/**
 * Planix Sidebar - Responsive Styles
 * Include this CSS on all pages that have the sidebar component.
 */

/* ===== Base Sidebar Styles ===== */
#sidebar {
  position: relative;
  left: auto;
  top: auto;
  transform: none;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

/* ===== Desktop: Sticky Sidebar ===== */
@media (min-width: 901px) {
  #sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transform: none !important;
    box-shadow: none;
    width: 16rem !important;
    max-width: none !important;
    flex-shrink: 0;
  }
}

/* ===== Mobile/Tablet: Off-canvas Drawer ===== */
@media (max-width: 900px) {
  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 16rem;
    max-width: 80vw;
    height: 100vh;
    height: 100dvh;
    z-index: 50;
    transform: translateX(-100%);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    overflow-y: auto;
    overflow-x: hidden;
  }

  #sidebar.is-open {
    transform: translateX(0);
  }

  #sidebarToggle {
    display: flex !important;
    position: relative;
    z-index: 60;
  }

  body.sidebar-open {
    overflow: hidden;
    touch-action: none;
  }

  #sidebarBackdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 40;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
  }

  #sidebarBackdrop.is-visible {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ===== Sidebar Navigation ===== */
#sidebarNav {
  transition: opacity 0.2s ease;
}

/* ===== Sidebar Toggle Button ===== */
#sidebarToggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.15s ease;
}

#sidebarToggle:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #0f172a;
}

#sidebarToggle:focus-visible {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

/* Class-based styling for header-placed toggle button */
.sidebar-toggle-btn {
  display: none;
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .sidebar-toggle-btn {
    display: flex !important;
  }
}

/* Dark mode hover for header-placed toggle button */
.dark #sidebarToggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

/* ===== Profile Section ===== */
#sidebarProfileAvatar {
  transition: transform 0.2s ease;
}

#sidebarProfileAvatar:hover {
  transform: scale(1.05);
}

/* ===== Active Nav Link Indicator ===== */
#sidebarNav a[aria-current="page"] {
  position: relative;
}

#sidebarNav a[aria-current="page"]::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: #3b82f6;
  border-radius: 0 2px 2px 0;
}

/* ===== Reduced Motion Support ===== */
@media (prefers-reduced-motion: reduce) {
  #sidebar,
  #sidebarToggle,
  #sidebarNav a {
    transition: none !important;
  }
}

/* ===== High Contrast Mode Support ===== */
@media (forced-colors: active) {
  #sidebarToggle {
    border: 1px solid ButtonText;
  }
  
  #sidebarNav a {
    border: 1px solid transparent;
  }
  
  #sidebarNav a:hover,
  #sidebarNav a[aria-current="page"] {
    border: 1px solid Highlight;
  }
}

/* ===== Print Styles ===== */
@media print {
  #sidebar {
    position: static !important;
    transform: none !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }
  
  #sidebarToggle {
    display: none !important;
  }
}
