/* Reset một số mặc định */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: sans-serif;
}

.main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.2rem;
  background: #6133bd;
  color: white;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.main-header-left {
  display: flex;
  gap: 10px;
  align-items: center;
}

.menu-icon {
  font-size: 1.5rem;
  cursor: pointer;
}

.logo {
  font-size: 1.25rem;
  font-weight: bold;
  cursor: pointer;
}

/* Search bar */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  background: white;
  border-radius: 8px;
  padding: 4px 8px;
  margin: 10px;
  flex-grow: 1;
  max-width: 400px;
  height: 36px;
}

.search-bar input {
  border: none;
  outline: none;
  padding: 5px 10px;
  flex-grow: 1;
  font-size: 14px;
}

.search-bar button {
  border: none;
  background: none;
  cursor: pointer;
  color: #6133bd;
  font-size: 16px;
}

.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background-color: white;
  border: 1px solid #ddd;
  /* border-top: none; */
  z-index: 10;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  display: none;
  border-radius: 10px;
  padding: 10px;
  margin-top: 5px;
}

#searchResultsDropdown ul li{
  padding: 10px;
  cursor: pointer;
} 

#searchResultsDropdown ul li:hover{
  background: #d7d7d7;
} 

/* --- Styles cho nút Đăng nhập --- */
.btn-login {
  display: inline-block;
  /* Để các thuộc tính padding/margin hoạt động như block nhưng vẫn nằm trên một dòng */
  padding: 10px 20px;
  /* Khoảng cách bên trong nút */
  background-color: #007bff;
  /* Màu nền xanh dương */
  color: white;
  /* Màu chữ trắng */
  text-decoration: none;
  /* Bỏ gạch chân mặc định của thẻ <a> */
  border-radius: 5px;
  /* Bo tròn các góc */
  font-weight: bold;
  /* Chữ in đậm */
  font-size: 16px;
  /* Kích thước chữ */
  transition: background-color 0.3s ease, transform 0.2s ease;
  /* Hiệu ứng chuyển động mượt mà khi hover */
  border: none;
  /* Bỏ viền mặc định */
  cursor: pointer;
  /* Hiển thị con trỏ dạng ngón tay */
}

/* Hiệu ứng khi di chuột qua (hover) */
.btn-login:hover {
  background-color: #0056b3;
  /* Màu xanh đậm hơn khi hover */
  transform: translateY(-2px);
  /* Nút nhích lên một chút */
}

/* Hiệu ứng khi click vào (active) */
.btn-login:active {
  background-color: #004085;
  /* Màu xanh đậm nhất khi click */
  transform: translateY(0);
  /* Trở về vị trí ban đầu */
}

/* --- User Profile Dropdown Styles --- */
.header-user-profile-dropdown {
  /* Container chính cho dropdown */
  position: relative;
  display: flex;
  align-items: center;
  height: 100%;
}

.header-user-profile-dropdown .avatar-container {
  /* Phần tử kích hoạt dropdown */
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 8px;
  transition: background-color 0.2s ease;
}

.header-user-profile-dropdown .avatar-container:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.header-user-profile-dropdown .avatar-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #fff;
}

.header-user-profile-dropdown .user-name {
  color: #fff;
  font-weight: 600;
}

/* Dropdown Menu Itself */
.header-user-profile-dropdown .dropdown-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background-color: #6133bd;
  /* Nền tối cho menu */
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  min-width: 220px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease;
}

/* Hiển thị dropdown khi container có class 'active' */
.header-user-profile-dropdown.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Dropdown Menu Items */
.header-user-profile-dropdown .dropdown-item {
  display: flex;
  align-items: center;
  padding: 12px 15px;
  color: #eee;
  text-decoration: none;
  font-size: 15px;
  transition: background-color 0.2s ease, color 0.2s ease;
  white-space: nowrap;
  /* Đảm bảo text không bị xuống dòng */
}

.header-user-profile-dropdown .dropdown-item:hover {
  background-color: #555;
  color: #fff;
}

.header-user-profile-dropdown .dropdown-item.logout {
  color: #ef5350;
  /* Màu đỏ cho nút đăng xuất */
}

.header-user-profile-dropdown .dropdown-item.logout:hover {
  background-color: #c62828;
  color: #fff;
}

.header-user-profile-dropdown .dropdown-divider {
  height: 1px;
  background-color: #616161;
  margin: 8px 0;
}


/* --- Theme Toggle Switch Styles (trong dropdown) --- */
.header-user-profile-dropdown .theme-toggle-container {
  justify-content: space-between;
  cursor: default;
}

.header-user-profile-dropdown .switch {
  /* Bao bọc input và slider */
  position: relative;
  display: inline-block;
  width: 45px;
  height: 25px;
}

.header-user-profile-dropdown .switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.header-user-profile-dropdown .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #9e9e9e;
  /* Màu xám khi tắt */
  transition: .4s;
  border-radius: 25px;
}

.header-user-profile-dropdown .slider:before {
  position: absolute;
  content: "";
  height: 17px;
  width: 17px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

.header-user-profile-dropdown input:checked+.slider {
  background-color: #42a5f5;
  /* Màu xanh khi bật */
}

.header-user-profile-dropdown input:focus+.slider {
  box-shadow: 0 0 1px #42a5f5;
}

.header-user-profile-dropdown input:checked+.slider:before {
  transform: translateX(20px);
}

.avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

/* Responsive: iPad trở xuống */
@media (max-width: 768px) {
  .main-header {
    /* Keep items on one row, but allow wrapping */
    flex-direction: row;
    /* Ensure row direction */
    flex-wrap: wrap;
    /* Allow items to wrap */
    justify-content: space-between;
    /* Space out left and right items */
    align-items: center;
    /* Vertically align items */
    height: auto;
    gap: 10px;
    /* Adjust gap as needed */
    padding: 10px;
  }

  .main-header-left {
    /* No specific changes needed here as main-header handles spacing */
    /* width: auto; /* Allow content to dictate width */
  }

  .search-bar {
    order: 1;
    /* Pushes the search bar to the next line */
    width: 100%;
    /* Makes search bar take full width */
    margin: 10px 0;
    /* Add vertical margin, remove horizontal */
    flex-basis: 100%;
    /* Ensures it takes up full row and wraps */
    max-width: unset;
    /* Remove max-width on smaller screens */
  }

  .avatar {
    /* No specific changes needed here, `justify-content` on main-header handles positioning */
  }
}