/* ===== Sidebar - Professional Desktop App Style ===== */

/* Layout Wrapper */
.app-wrapper {
  display: flex;
  min-height: 100vh;
  direction: rtl;
}

/* Sidebar Base */

.sidebar {
  width: 240px;
  background: linear-gradient(180deg, #1e1e2e 0%, #27293d 100%);
  color: white;
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: visible;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1050;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

html, body {
  overflow-x: hidden;
}

/* Mobile topbar layout */
.topbar-mobile {
  position: relative;
  width: 100%;
  height: 56px;
}

.topbar-mobile-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  justify-content: flex-start;
  flex-wrap: nowrap;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
}

.topbar-mobile-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.topbar-mobile-logo img {
  max-height: 34px;
  max-width: 150px;
  object-fit: contain;
}

.topbar-mobile-logo-text {
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #fff;
}

.topbar-desktop {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-direction: row-reverse;
}

.topbar-desktop .topbar-title {
  text-align: right;
}

.topbar-desktop .topbar-actions {
  justify-content: flex-start;
}

.topbar-avatar-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.2);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.topbar-avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.topbar-avatar-btn .material-icons {
  font-size: 30px;
}

.topbar-dropdown {
  background: rgba(30, 30, 46, 0.98);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.topbar-dropdown .list-group-item {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.06);
}

.topbar-dropdown .list-group-item.unread {
  background: rgba(102, 126, 234, 0.10);
}

.topbar-dropdown .text-muted {
  color: rgba(255, 255, 255, 0.65) !important;
}

.sidebar.collapsed {
  width: 64px;
}

/* Hide text when collapsed */
.sidebar.collapsed .sidebar-menu-text,
.sidebar.collapsed .sidebar-user-card .badge {
  opacity: 0;
  width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-submenu {
  display: none !important;
}

.sidebar.collapsed .sidebar-user-card {
  padding: 0.5rem !important;
  justify-content: center;
}

.sidebar.collapsed .sidebar-user-card .d-flex {
  justify-content: center;
}

.sidebar.collapsed .sidebar-user-name {
  display: none;
}

/* Toggle Button */
.sidebar-toggle-btn {
  position: absolute;
  left: -18px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: 3px solid #1e1e2e;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
  z-index: 1051;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-toggle-btn:hover {
  transform: translateY(-50%) scale(1.12);
  box-shadow: 0 6px 18px rgba(102, 126, 234, 0.6);
  background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.sidebar-toggle-btn:active {
  transform: translateY(-50%) scale(0.95);
}

.sidebar-toggle-btn .material-icons {
  font-size: 20px;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed .sidebar-toggle-btn .material-icons {
  transform: rotate(180deg);
}

/* Sidebar Header */
.sidebar-header {
  padding: 1.5rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.15);
  text-align: center;
}

.sidebar-header img {
  transition: max-width 0.25s ease, max-height 0.25s ease, transform 0.25s ease;
}

.sidebar.collapsed .sidebar-header img {
  max-width: 42px !important;
  max-height: 42px !important;
}

.sidebar-header h3 {
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar.collapsed .sidebar-header h3 {
  opacity: 0;
  height: 0;
  overflow: hidden;
}

/* User card removed from sidebar layout */

/* Sidebar Menu */
.sidebar-menu {
  list-style: none;
  padding: 0.5rem 0;
  margin: 0;
}

.sidebar-menu-item {
  margin: 0;
  position: relative;
}

.sidebar-menu-link {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-right: 3px solid transparent;
  gap: 14px;
  position: relative;
  overflow: hidden;
  margin: 2px 8px;
  border-radius: 10px;
}

.sidebar-menu-link::before {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 0;
  background: rgba(102, 126, 234, 0.15);
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: -1;
  border-radius: 10px;
}

.sidebar-menu-link:hover::before {
  width: 100%;
}

.sidebar-menu-link:hover {
  color: #fff;
  padding-right: 24px;
  transform: translateX(-4px);
  background: rgba(102, 126, 234, 0.08);
}

.sidebar-menu-link:hover .material-icons {
  transform: scale(1.15) rotate(5deg);
  color: #667eea;
}

.sidebar-menu-link.active {
  background: linear-gradient(90deg, rgba(102, 126, 234, 0.25) 0%, rgba(118, 75, 162, 0.15) 100%);
  color: #fff;
  border-right-color: #667eea;
  box-shadow: inset -3px 0 0 #667eea, 0 2px 8px rgba(102, 126, 234, 0.2);
  font-weight: 600;
}

.sidebar-menu-link.active .material-icons {
  color: #667eea;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.sidebar-menu-link .material-icons {
  font-size: 24px;
  flex-shrink: 0;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-menu-text {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Submenu */
.sidebar-submenu {
  list-style: none;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.25);
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 0 0 10px 10px;
}

.sidebar-submenu.show {
  max-height: 600px;
  padding: 8px 0;
}

.sidebar-submenu .sidebar-menu-link {
  padding: 11px 20px 11px 55px;
  font-size: 14px;
  margin: 2px 8px;
}

.sidebar-submenu .sidebar-menu-link:hover {
  padding-right: 24px;
}

.sidebar-submenu .sidebar-menu-link .material-icons {
  font-size: 20px;
}

/* Logout */
.sidebar-logout {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-logout .sidebar-menu-link {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.08);
  justify-content: center;
  border-right: none;
  font-weight: 600;
}

.sidebar-logout .sidebar-menu-link:hover {
  background: rgba(255, 107, 107, 0.18);
  transform: translateX(0) scale(1.02);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.sidebar-logout .sidebar-menu-link .material-icons {
  color: #ff6b6b;
}

/* Main Content */
.main-content {
  flex: 1;
  margin-right: 64px;
  transition: margin-right 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  background: #f8f9fa;
  min-height: 100vh;
}

.sidebar:not(.collapsed) ~ .main-content {
  margin-right: 240px;
}

[data-bs-theme="dark"] .main-content {
  background: #1a1d2e;
}

/* Topbar */
.topbar {
  background: white;
  padding: 1.2rem 1.8rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1040;
  border-bottom: 1px solid #e9ecef;
}

[data-bs-theme="dark"] .topbar {
  background: #252836;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

.topbar-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #2d3748;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

[data-bs-theme="dark"] .topbar-title {
  color: #fff;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
  color: #667eea;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  position: relative;
}

[data-bs-theme="dark"] .topbar-icon {
  background: #1e2139;
  color: #667eea;
}

.topbar-icon:hover {
  background: #667eea;
  color: white;
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.topbar-icon:active {
  transform: translateY(0) scale(0.95);
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: #667eea;
  color: white;
  border: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
  transition: all 0.3s ease;
}

.mobile-menu-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

/* Place the menu button on the right inside the mobile topbar */
.topbar-mobile .mobile-menu-toggle {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

/* Mobile Styles */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(100%);
    right: -240px;
    width: 240px;
    box-shadow: none;
  }
  
  .sidebar.show {
    transform: translateX(0);
    right: 0;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.4);
  }
  
  .sidebar.collapsed {
    width: 240px;
    transform: translateX(100%);
  }
  
  .sidebar.show.collapsed {
    transform: translateX(0);
  }
  
  .sidebar-toggle-btn {
    display: none !important;
  }
  
  .main-content {
    margin-right: 0 !important;
  }

  /* Leave room for the mobile bottom bar */
  .main-content {
    padding-bottom: 120px;
  }
  
  .mobile-menu-toggle {
    display: flex;
  }
  
  .topbar {
    padding: 1rem 1.2rem;
    display: block;
  }
  
  .topbar-title {
    font-size: 1.3rem;
  }
}

/* Mobile bottom navigation (mobile only) */
.mobile-bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: calc(100% - 24px);
  max-width: 540px;
  box-sizing: border-box;
  height: 72px;
  padding: 12px 14px;
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 0px, transparent 0 40px, rgba(30, 30, 46, 0.92) 41px),
    rgba(30, 30, 46, 0.92);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 1040;
  display: grid;
  grid-template-columns: 1fr 1fr auto 1fr 1fr;
  align-items: center;
  gap: 10px;
}

.mobile-bottom-item {
  text-decoration: none;
  color: rgba(255, 255, 255, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 2px;
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
  padding-top: 0;
  padding-bottom: 6px;
}

.mobile-bottom-item .material-icons {
  margin-top: -2px;
}

.mobile-bottom-item > span:last-child {
  display: block;
  margin-top: 2px;
}

.mobile-bottom-item .material-icons {
  font-size: 24px;
}

.mobile-bottom-item.active {
  color: #fff;
}

.mobile-bottom-add {
  width: 68px;
  height: 68px;
  margin: 0 auto;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 10px 26px rgba(102, 126, 234, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.10);
  transform: translateY(-18px);
}

.mobile-bottom-add .material-icons {
  font-size: 30px;
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1049;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Scrollbar Styling */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(102, 126, 234, 0.4);
  border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(102, 126, 234, 0.6);
}

/* Smooth Animations */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Badge Notifications */
.sidebar-menu-link .badge {
  position: absolute;
  left: 12px;
  top: 8px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  background: #ff6b6b;
  color: white;
  box-shadow: 0 2px 6px rgba(255, 107, 107, 0.4);
}

.sidebar.collapsed .sidebar-menu-link .badge {
  left: 50%;
  transform: translateX(-50%);
  top: 6px;
}

/* Sidebar Badge */
.sidebar-badge {
  position: absolute;
  left: 12px;
  top: 8px;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  background: #ff6b6b;
  color: white;
  box-shadow: 0 2px 6px rgba(255, 107, 107, 0.4);
}

.sidebar.collapsed .sidebar-badge {
  left: 50%;
  transform: translateX(-50%);
  top: 6px;
}

/* Sidebar Footer */
.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer .sidebar-menu-link {
  color: #ff6b6b !important;
  background: rgba(255, 107, 107, 0.08);
  justify-content: center;
  border-right: none;
  font-weight: 600;
}

.sidebar-footer .sidebar-menu-link:hover {
  background: rgba(255, 107, 107, 0.18);
  transform: translateX(0) scale(1.02);
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

.sidebar-footer .sidebar-menu-link .material-icons {
  color: #ff6b6b;
}
