/**
 * Admin Sidebar Styles
 * Shared CSS for consistent sidebar across all admin pages
 */

/* Hide menu items by default until JS filters them - prevents flash */
.sidebar:not(.filtered) .menu-item[data-page]:not([data-page="home"]) {
  display: none;
}

/* Sidebar Layout - Fixed dimensions */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  height: 100vh;
  width: 260px;
  background: #fff;
  border-right: 1px solid #e5e5e5;
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
  z-index: 100;
}

.sidebar.collapsed {
  width: 72px;
}

/* Sidebar Header */
.sidebar-header {
  display: flex;
  align-items: center;
  padding: 20px 16px;
  border-bottom: 1px solid #e5e5e5;
  gap: 12px;
  position: relative;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.sidebar-title {
  font-weight: 600;
  font-size: 16px;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
}

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

.sidebar-toggle {
  position: absolute;
  right: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #666;
  transition: all 0.2s;
  z-index: 1001;
}

.sidebar-toggle:hover {
  background: #f5f5f5;
  border-color: #C4A77D;
  color: #C4A77D;
}

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

/* Sidebar Menu */
.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

/* Menu Item */
.menu-item {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  gap: 12px;
  text-decoration: none;
  color: #555;
  border-radius: 8px;
  margin-bottom: 4px;
  transition: all 0.2s;
  position: relative;
}

.menu-item:hover {
  background: #f5f5f5;
  color: #333;
}

.menu-item.active {
  background: #FFF8F0;
  color: #C4A77D;
}

.menu-item.active .menu-icon {
  stroke: #C4A77D;
}

.menu-item.active .super-badge {
  background: #C4A77D;
  color: #fff;
}

/* Menu Icon */
.menu-icon {
  width: 22px;
  height: 22px;
  min-width: 22px;
  flex-shrink: 0;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

/* Menu Text */
.menu-text {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  flex: 1;
}

.sidebar.collapsed .menu-text {
  display: none;
}

.sidebar.collapsed .menu-item {
  justify-content: center;
  padding: 12px;
}

/* Super Badge - positioned without affecting layout */
.super-badge, .super-admin-badge {
  position: absolute;
  right: 10px;
  background: #C4A77D;
  color: #fff;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.sidebar.collapsed .super-badge {
  display: none;
}

[dir="rtl"] .super-badge, [dir="rtl"] .super-admin-badge {
  right: auto;
  left: 10px;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid #e5e5e5;
}

.footer-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  height: 44px;
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  gap: 12px;
  color: #666;
  transition: all 0.2s;
}

.footer-btn:hover {
  background: #f5f5f5;
}

.sidebar.collapsed .footer-btn {
  justify-content: center;
  padding: 12px;
}

.sidebar.collapsed .footer-btn .menu-text {
  display: none;
}

/* Main content offset */
.main-wrapper {
  margin-left: 260px;
  min-height: 100vh;
  transition: margin-left 0.3s ease;
}

.sidebar.collapsed ~ .main-wrapper {
  margin-left: 72px;
}

/* Mobile Styles */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
  }

  .sidebar.collapsed {
    width: 280px;
  }

  .main-wrapper {
    margin-left: 0;
  }

  .sidebar.collapsed ~ .main-wrapper {
    margin-left: 0;
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
  }

  .sidebar.mobile-open ~ .sidebar-overlay {
    display: block;
  }
}

/* RTL Support */
[dir="rtl"] .sidebar {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid #e5e5e5;
}

[dir="rtl"] .sidebar-toggle {
  margin-left: 0;
  margin-right: auto;
}

[dir="rtl"] .sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(0deg);
}

[dir="rtl"] .sidebar-toggle svg {
  transform: rotate(180deg);
}

[dir="rtl"] .main-wrapper {
  margin-left: 0;
  margin-right: 260px;
}

[dir="rtl"] .sidebar.collapsed ~ .main-wrapper {
  margin-right: 72px;
}

@media (max-width: 768px) {
  [dir="rtl"] .sidebar {
    transform: translateX(100%);
  }

  [dir="rtl"] .sidebar.mobile-open {
    transform: translateX(0);
  }

  [dir="rtl"] .main-wrapper {
    margin-right: 0;
  }
}
