/**
 * Sidebar Styles - Pixel Perfect Implementation
 * Based on Base44 specifications
 */

/* ==================== CONTAINER ==================== */
.sidebar-container {
  width: 100%;
  height: calc(100vh - 64px - 56px);
  /* Full height minus header and mobile button */
  background: white;
  position: fixed;
  top: 64px;
  /* Below header */
  left: 0;
  bottom: 56px;
  /* Above mobile nav button */
  z-index: 1000;
  transform: translateX(-100%);
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  direction: ltr;
}

.sidebar-container--open {
  transform: translateX(0);
  pointer-events: auto;
  /* Enable clicks when open */
}

/* Desktop */
@media (min-width: 1024px) {
  .sidebar-container {
    width: 256px;
    /* 16rem */
    position: sticky;
    top: 64px;
    transform: translateX(0);
    border-right: 1px solid #f3f4f6;
    height: calc(100vh - 64px);
    overflow: hidden;
    pointer-events: auto;
    /* Always enable clicks on desktop */
  }
}

.sidebar {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ==================== NAVIGATION ==================== */
.sidebar-nav {
  padding: 16px;
  /* p-4 */
  padding-right: 8px;
  /* space for scrollbar */
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  min-height: 0;
}

.sidebar-menu {
  list-style: none;
  margin: 0;
  padding: 0;
  padding-right: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  /* space-y-1 */
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Tighter gap on desktop */
@media (min-width: 1024px) {
  .sidebar-menu {
    gap: 1px;
  }
}

.sidebar-item {
  position: relative;
}

/* ==================== BUTTONS (Lobby & Root Folders) ==================== */
.sidebar-button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  /* py-2.5 px-3 */
  border-radius: 8px;
  /* rounded-lg */
  font-family: 'Roboto', sans-serif;
  font-size: 16px !important;
  /* text-base on mobile */
  color: #4b5563;
  /* gray-600 */
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
  text-align: left;
  direction: ltr;
}

/* Tighter padding on desktop */
@media (min-width: 1024px) {
  .sidebar-button {
    padding-top: 4px !important;
    padding-bottom: 4px !important;
  }
}

/* Desktop font size */
@media (min-width: 1024px) {
  .sidebar-button {
    font-size: 16px !important;
    /* KEEP SAME SIZE */
  }
}

.sidebar-button:hover {
  background-color: #f9fafb;
  /* gray-50 */
  color: #111827;
  /* gray-900 */
}

.sidebar-button--active {
  background-color: rgba(2, 38, 53, 0.2);
  color: #022635;
  font-weight: 500;
  /* font-medium */
}

/* ==================== BUTTON CONTENT ==================== */
.sidebar-button__content {
  display: flex;
  align-items: center;
  gap: 12px;
  /* gap-3 */
  flex: 1;
  min-width: 0;
}

/* ==================== ICONS ==================== */
.sidebar-icon {
  width: 20px;
  /* w-5 */
  height: 20px;
  /* h-5 */
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* ==================== TEXT ==================== */
.sidebar-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 500;
  /* font-medium */
}

/* ==================== CHEVRON ==================== */
.sidebar-chevron {
  padding: 4px;
  /* p-1 */
  margin-left: auto;
  flex-shrink: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-chevron:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.sidebar-chevron svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  transition: transform 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Desktop chevron size */
@media (min-width: 1024px) {
  .sidebar-chevron svg {
    width: 16px;
    height: 16px;
  }
}

/* Rotate chevron when expanded */
.sidebar-item--expanded .sidebar-chevron svg {
  transform: rotate(180deg);
}

/* ==================== SUBFOLDERS ==================== */
.sidebar-submenu {
  list-style: none;
  margin: 0;
  padding: 0;
  margin-right: 32px;
  /* ml-8 in RTL */
  margin-top: 2px;
  /* mt-1 */
  overflow: hidden;
  height: 0;
  opacity: 0;
  transition: height 200ms cubic-bezier(0.4, 0, 0.2, 1),
    opacity 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-subitem {
  margin-top: 2px;
  /* space-y-1 */
}

.sidebar-subitem:first-child {
  margin-top: 0;
}

/* ==================== SUBFOLDER BUTTONS ==================== */
.sidebar-subbutton {
  width: 100%;
  display: block;
  padding: 6px 12px 6px 32px;
  /* py-2 px-3, extra left padding for indent */
  border-radius: 8px;
  /* rounded-lg */
  font-family: 'Roboto', sans-serif;
  font-size: 16px !important;
  /* text-base on mobile */
  color: #6b7280;
  /* gray-500 */
  text-decoration: none;
  text-align: left;
  direction: ltr;
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Desktop font size */
@media (min-width: 1024px) {
  .sidebar-subbutton {
    font-size: 16px !important;
    /* KEEP SAME SIZE */
  }
}

.sidebar-subbutton:hover {
  background-color: #f9fafb;
  /* gray-50 */
  color: #374151;
  /* gray-700 */
}

.sidebar-subbutton--active {
  background-color: rgba(2, 38, 53, 0.2);
  color: #022635;
  font-weight: 500;
  /* font-medium */
}

/* ==================== CONTACT SUPPORT ==================== */
.sidebar-support {
  padding-top: 8px;
  /* pt-4 */
  border-top: 1px solid #f3f4f6;
  /* gray-100 */
  margin-top: 8px;
  /* mt-4 */
  flex-shrink: 0;
}

.sidebar-support__button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  /* gap-3 */
  padding: 8px 12px;
  /* py-2.5 px-3 */
  border-radius: 8px;
  /* rounded-lg */
  font-family: 'Roboto', sans-serif;
  font-size: 16px !important;
  /* text-base on mobile */
  font-weight: 500;
  /* font-medium */
  color: #4b5563;
  /* gray-600 */
  text-decoration: none;
  transition: all 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Desktop font size */
@media (min-width: 1024px) {
  .sidebar-support__button {
    font-size: 16px !important;
    /* KEEP SAME SIZE */
  }
}

.sidebar-support__button:hover {
  background-color: #f9fafb;
  /* gray-50 */
  color: #111827;
  /* gray-900 */
}

/* ==================== MOBILE NAV BUTTON ==================== */
.mobile-nav-button {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 56px;
  z-index: 99999;
  background: #E31E24;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mobile-nav-button:active {
  background: #C81E24;
}

.mobile-nav-icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  pointer-events: none;
}

.mobile-nav-text {
  pointer-events: none;
}

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

/* ==================== MOBILE OVERLAY ==================== */
.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 40;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1),
    visibility 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-overlay--visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

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

/* ==================== SCROLLBAR ==================== */
.sidebar-menu::-webkit-scrollbar,
.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-menu::-webkit-scrollbar-track,
.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-menu::-webkit-scrollbar-thumb,
.sidebar-nav::-webkit-scrollbar-thumb {
  background: #e5e7eb;
  border-radius: 3px;
}

.sidebar-menu::-webkit-scrollbar-thumb:hover,
.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: #d1d5db;
}

/* ==================== FORCE EQUAL FONT SIZES FOR ALL SIDEBAR ITEMS ==================== */
.sidebar-button,
.sidebar-subbutton,
.sidebar-support__button,
.sidebar-text {
  font-size: 16px !important;
}

@media (min-width: 1024px) {

  .sidebar-button,
  .sidebar-subbutton,
  .sidebar-support__button,
  .sidebar-text {
    font-size: 12px !important;
  }
}

/* ==================== ALIGN ALL MENU TEXT TO SAME LINE ==================== */
.sidebar-icon {
  width: 24px !important;
  min-width: 24px !important;
  max-width: 24px !important;
  height: 20px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
}

.sidebar-icon svg,
.sidebar-icon img {
  max-width: 20px !important;
  max-height: 20px !important;
  width: auto !important;
  height: auto !important;
}

.sidebar-icon-img {
  max-width: 20px !important;
  max-height: 20px !important;
  width: auto !important;
  height: auto !important;
}

/* ==================== SUB-ITEMS INDENTATION ==================== */
.sidebar-submenu {
  padding-right: 0 !important;
  margin-right: 0 !important;
}

.sidebar-subbutton {
  padding-right: 12px !important;
  padding-left: 48px !important;
  margin-right: 0 !important;
}

/* Ensure parent items align perfectly */
.sidebar-button {
  padding-right: 12px !important;
  padding-left: 12px !important;
}

/* ==================== FORCE EQUAL TEXT SIZE & SPACING ==================== */
.sidebar-button {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  width: 100% !important;
}

.sidebar-button__content {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
  flex: 1 !important;
  min-width: 0 !important;
}

.sidebar-text {
  flex: 1 !important;
  font-size: 16px !important;
  font-weight: 500 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.sidebar-chevron {
  flex-shrink: 0 !important;
  margin-left: 0 !important;
  width: 20px !important;
  height: 20px !important;
}

/* ==================== LARGER ARROW ICON ==================== */
.sidebar-chevron {
  width: 40px !important;
  height: 40px !important;
}

.sidebar-chevron svg {
  width: 24px !important;
  height: 24px !important;
}

/* ==================== ADJUST ARROW SIZE ==================== */
.sidebar-chevron {
  width: 30px !important;
  height: 30px !important;
}

.sidebar-chevron svg {
  width: 20px !important;
  height: 20px !important;
}