.main-header {
  background-color: var(--card-bg);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 1rem 0;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  min-width: 0;
  flex-shrink: 1;
}

.logo i {
  color: var(--primary);
}

.logo h1 {
  font-size: 1.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.site-logo-img {
  width: 100px;
  height: 100px;
  aspect-ratio: 1/1;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  object-position: center;
  background-color: white;
  /* Ensure visibility in dark mode */
  border: 3px solid var(--primary);
  box-shadow: 0 0 15px rgba(var(--shadow-color), 0.3);
  padding: 5px;
  margin: 0;
  display: block;
}

.mobile-only {
  display: none !important;
}

#add-item-btn,
#add-category-btn,
#settings-btn,
#logout-btn {
  display: none;
}

.lang-switcher {
  display: flex;
  justify-content: center !important;
  align-items: center !important;
  gap: 0.25rem;
  background: transparent;
  direction: ltr;
}

.lang-btn {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn:hover {
  color: var(--text-main);
  background: transparent;
}

.lang-btn.active {
  background: transparent;
  color: var(--primary);
  border-color: transparent;
  border-bottom-color: var(--primary);
  box-shadow: none;
}

body.logged-in #add-item-btn,
body.logged-in #add-category-btn,
body.logged-in #settings-btn,
body.logged-in #logout-btn {
  display: inline-flex;
}

#theme-toggle,
.lang-dropdown {
  display: inline-flex;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

@media (max-width: 1024px) {
  .btn-text {
    display: none;
  }

  .btn-primary {
    padding: 0.55rem;
    gap: 0;
    min-width: 40px;
    justify-content: center;
    border-radius: 50%;
    width: 40px;
    height: 40px;
  }

  .header-actions {
    gap: 0.5rem;
  }

  .logo h1 {
    font-size: 1.1rem;
  }

  .site-logo-img {
    width: 70px;
    height: 70px;
  }
}

@media (max-width: 850px) {

  #item-counter .counter-label {
    display: none;
  }

  .item-counter {
    padding: 0.4rem 0.6rem;
    gap: 0.3rem;
  }
}

@media (max-width: 640px) {
  .header-content {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    min-height: auto;
    width: 100%;
  }

  .logo {
    gap: 0.5rem;
    flex: 1;
    min-width: 150px;
    display: flex;
    align-items: center;
    max-width: none;
    flex-shrink: 0;
  }

  .site-logo-img {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
  }

  .header-actions {
    gap: 0.5rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-top: 5px;
  }

  #add-item-btn,
  #add-category-btn,
  #settings-btn,
  #logout-btn {
    display: none !important;
  }

  #theme-toggle,
  .lang-dropdown {
    display: inline-flex !important;
  }

  .lang-text,
  .btn-lang-selector i:last-child {
    display: none !important;
  }

  .btn-lang-selector {
    padding: 0.5rem;
    width: 40px;
    height: 40px;
    justify-content: center;
    border-radius: 50%;
  }

  .header-actions {
    gap: 0.4rem;
  }

  .mobile-only {
    display: flex !important;
    background: var(--primary) !important;
    color: white !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    justify-content: center !important;
    align-items: center !important;
    padding: 0 !important;
    box-shadow: 0 4px 10px rgba(var(--shadow-color), 0.3) !important;
  }
}

/* Mobile Menu Styles */
.mobile-menu {
  position: absolute;
  top: calc(100% - 15px);
  right: 1rem;
  width: 260px;
  max-height: calc(90vh - 100px);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.3);
  z-index: 1000;
  overflow-y: auto;
  scrollbar-width: none;
  transform-origin: top right;
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  opacity: 1;
  transform: translateY(10px) scale(1);
}

.mobile-menu::-webkit-scrollbar {
  display: none;
}

body.dark-mode .mobile-menu {
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5);
}

.mobile-menu.hidden {
  opacity: 0;
  transform: translateY(0) scale(0.9);
  pointer-events: none;
}

.mobile-admin-actions {
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
}

.mobile-menu-item {
  display: flex !important;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 600;
  transition: background 0.2s;
  background: transparent;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
}

[dir="rtl"] .mobile-menu-item {
  text-align: right;
}

.mobile-menu-item:hover {
  background: rgba(var(--shadow-color), 0.1);
  color: var(--primary-dark);
}

.mobile-menu-item i {
  width: 24px;
  font-size: 1.1rem;
  color: var(--primary);
}

.mobile-menu-item.logout {
  color: #ef4444;
}

.mobile-menu-item.logout i {
  color: #ef4444;
}

.mobile-menu-item-group {
  display: none !important;
}

.mobile-menu-label {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.mobile-lang-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.mobile-lang-btn {
  background: rgba(var(--shadow-color), 0.05);
  border: 1px solid rgba(var(--shadow-color), 0.1);
  padding: 8px;
  border-radius: 10px;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-en);
}

.mobile-lang-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

[dir="rtl"] .mobile-menu {
  right: auto;
  left: 1rem;
  transform-origin: top left;
}

body.is-customer #mobile-more-btn {
  display: none !important;
}

body.is-customer #mobile-menu {
  display: none !important;
}