/* Header */
.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-dark);
  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;
  border-radius: 50%;
  object-fit: contain;
  border: 3px solid var(--primary);
  /* Adding a ring like the photo */
  box-shadow: 0 0 15px rgba(var(--shadow-color), 0.3);
}

/* Visibility Logic */
.mobile-only {
  display: none !important;
}

#add-item-btn,
#add-category-btn,
#settings-btn,
#logout-btn {
  display: 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 */
.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Mobile Adjustments */
@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) {
  .logo h1 {
    display: none;
  }

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

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

@media (max-width: 640px) {
  .header-content {
    flex-wrap: nowrap;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    min-height: 110px;
    /* Increased to fix logo hiding */
    width: 100%;
  }

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

  .logo h1 {
    display: none !important;
    /* Hide name on mobile to make room for big logo and buttons */
  }

  .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;
    /* Hide "English" text and arrow icon on mobile */
  }

  .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: 100%;
  right: 1.5rem;
  width: 240px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(15px) saturate(160%);
  -webkit-backdrop-filter: blur(15px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  overflow: hidden;
  transform-origin: top right;
  transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
  opacity: 1;
  transform: translateY(10px);
}

body.dark-mode .mobile-menu {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(255, 255, 255, 0.1);
}

.mobile-menu.hidden {
  opacity: 0;
  transform: translateY(0) scale(0.95);
  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(139, 69, 19, 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;
  /* Hide redundant language/theme in menu */
}

.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);
}
