/* ========================================================
   CSS POPUP GỢI Ý TÌM KIẾM (HEADER SEARCH SUGGEST)
   Tách riêng hoàn toàn, không sửa đổi main.css
======================================================== */

@media (min-width: 992px) {
  .search-container {
    position: relative !important;
  }
}

@media (max-width: 991.98px) {
  .header .search-container {
    display: none !important;
  }
}

/* Khung popup nổi */
.header-suggest-popup {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  width: 480px;
  max-width: calc(100vw - 24px);
  background: #ffffff;
  border-radius: 18px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 20px 45px -8px rgba(15, 23, 42, 0.16), 0 8px 16px -4px rgba(15, 23, 42, 0.06);
  z-index: 9999;
  display: none;
  padding: 16px 14px 14px 14px;
  box-sizing: border-box;
  text-align: left;
}

.header-suggest-popup.show {
  display: block;
  animation: suggestPopIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes suggestPopIn {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Mũi tên tam giác chỉ lên input (giống ảnh mẫu) */
.header-suggest-popup::before {
  content: "";
  position: absolute;
  top: -7px;
  left: 36px;
  width: 13px;
  height: 13px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  border-left: 1px solid #e2e8f0;
  transform: rotate(45deg);
  z-index: 10000;
}

/* Header của popup */
.header-suggest-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 12px 6px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 8px;
}

.header-suggest-head-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.header-suggest-head-title .suggest-flame-icon {
  font-size: 15px;
}

.header-suggest-head-link {
  font-size: 13px;
  font-weight: 600;
  color: #0284c7;
  text-decoration: none;
  transition: color 0.15s ease;
}

.header-suggest-head-link:hover {
  color: #0369a1;
  text-decoration: underline;
}

/* Thân danh sách cuộn mượt */
.header-suggest-body {
  max-height: 420px;
  overflow-y: auto;
  padding-right: 4px;
}

.header-suggest-body::-webkit-scrollbar {
  width: 5px;
}
.header-suggest-body::-webkit-scrollbar-track {
  background: transparent;
}
.header-suggest-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}
.header-suggest-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Nhãn nhóm danh mục */
.header-suggest-group {
  margin-bottom: 12px;
}
.header-suggest-group:last-child {
  margin-bottom: 4px;
}

.header-suggest-group-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 8px 4px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Từng dòng item gợi ý theo mẫu */
.header-suggest-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  margin-bottom: 3px;
  border-radius: 12px;
  text-decoration: none !important;
  transition: all 0.18s ease;
  background: transparent;
}

.header-suggest-item:hover {
  background: #f8fafc;
  transform: translateX(2px);
}

.header-suggest-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

/* Badge vuông bo góc bên trái (giống huy hiệu 5G DATA trong ảnh mẫu) */
.suggest-badge {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
  transition: transform 0.18s ease;
}

.header-suggest-item:hover .suggest-badge {
  transform: scale(1.04);
}

.suggest-badge .badge-icon {
  font-size: 16px;
  line-height: 1.1;
}

.suggest-badge .badge-text {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  margin-top: 1px;
}

/* Badge Kingdom: Xanh ngọc / Xanh dương */
.suggest-badge-kd {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  border: 1px solid #38bdf8;
}

/* Badge Flashcard: Cam / Vàng ấm */
.suggest-badge-fc {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  border: 1px solid #fbbf24;
}

/* Badge Quiz: Tím / Hồng tươi */
.suggest-badge-qz {
  background: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);
  color: #ffffff;
  border: 1px solid #c084fc;
}

/* Nội dung text */
.header-suggest-item-info {
  flex: 1;
  min-width: 0;
}

.header-suggest-item-title {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.3;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s ease;
}

.header-suggest-item:hover .header-suggest-item-title {
  color: #0284c7;
}

/* Dòng sub nổi bật (giống số tiền màu đỏ nổi bật trong ảnh mẫu) */
.header-suggest-item-sub {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-suggest-item-sub.sub-kd {
  color: #0284c7;
}

.header-suggest-item-sub.sub-fc {
  color: #d97706;
}

.header-suggest-item-sub.sub-qz {
  color: #7c3aed;
}

/* Mũi tên chevron bên phải */
.header-suggest-item-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  padding-left: 8px;
  transition: transform 0.18s ease, color 0.18s ease;
}

.header-suggest-item:hover .header-suggest-item-arrow {
  color: #0284c7;
  transform: translateX(3px);
}

/* ========================================================
   RESPONSIVE CHO MOBILE & TABLET (< 992px)
   ======================================================== */
@media (max-width: 991.98px) {
  /* Header container & flex layout */
  .header {
    position: relative !important;
    padding: 8px 12px !important;
  }

  .header .container-home {
    padding-left: 2px !important;
    padding-right: 2px !important;
  }

  .header-memu-top {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 8px !important;
  }

  /* Nhóm bên trái: Hamburger + Logo */
  .header-left-group {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    flex-shrink: 0 !important;
  }

  .header-left-group .mobile-nav-container {
    margin-left: 0 !important;
    width: 32px !important;
    height: 32px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
  }

  .header-logo-link {
    display: flex !important;
    align-items: center !important;
    text-decoration: none !important;
    flex-shrink: 0 !important;
  }

  /* Bảo vệ Logo không bị bẹp méo hình trên Mobile */
  .header-logo {
    height: 38px !important;
    width: auto !important;
    max-width: 135px !important;
    object-fit: contain !important;
    display: block !important;
  }

  /* Nhóm bên phải: Avatar/Login + Nút Kính lúp */
  .header-right-group {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    flex-shrink: 0 !important;
  }

  .header-right-group .user-login-btn {
    margin: 0 !important;
    padding: 0 !important;
    min-width: unset !important;
  }

  .header-right-group .user-info .user-avatar,
  .header-right-group .user-info .user-avatar img,
  .header-right-group .avatar {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    object-fit: cover !important;
    display: block !important;
    margin: 0 !important;
  }

  .header-right-group .user-name {
    display: none !important;
  }

  /* Nút kính lúp tròn đẹp, cách đều */
  .btn-search-mobile-toggle {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #334155 !important;
    cursor: pointer !important;
    padding: 0 !important;
    transition: all 0.2s ease !important;
    flex-shrink: 0 !important;
  }

  .btn-search-mobile-toggle:active,
  .btn-search-mobile-toggle.active {
    background: #e2e8f0 !important;
    color: #0284c7 !important;
    border-color: #0284c7 !important;
    transform: scale(0.95);
  }

  .btn-search-mobile-toggle svg {
    width: 18px !important;
    height: 18px !important;
  }

  /* Ẩn các icon search mobile cũ tránh xung đột */
  .header-memu-top > svg.icon-search-mobile {
    display: none !important;
  }
}

/* ========================================================
   KHỐI SEARCH DROPDOWN XỔ XUỐNG TRÊN MOBILE
   ======================================================== */
.mobile-search-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  width: 100%;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 20px 35px -5px rgba(15, 23, 42, 0.2), 0 8px 16px -4px rgba(15, 23, 42, 0.08);
  z-index: 10010;
  padding: 12px 14px 16px 14px;
  box-sizing: border-box;
}

.mobile-search-dropdown.show {
  display: block;
  animation: mobileSearchSlideDown 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes mobileSearchSlideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.mobile-search-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 10005;
}

.mobile-search-backdrop.show {
  display: block;
}

/* Thanh input tìm kiếm trên Mobile */
.mobile-search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.mobile-search-input-box {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  background: #f1f5f9;
  border: 1.5px solid #cbd5e1;
  border-radius: 50px;
  padding: 0 14px;
  height: 42px;
  transition: all 0.2s ease;
}

.mobile-search-input-box:focus-within {
  border-color: #0284c7;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.mobile-search-input-box .mobile-search-icon {
  flex-shrink: 0;
  color: #64748b;
}

.mobile-search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: #0f172a;
  margin-left: 8px;
  min-width: 0;
}

.mobile-search-clear {
  border: none;
  background: #cbd5e1;
  color: #475569;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.mobile-search-clear.show {
  display: flex !important;
}

.mobile-search-clear:hover {
  background: #94a3b8;
  color: #ffffff;
}

.mobile-search-close-btn {
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
  padding: 8px 4px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.mobile-search-close-btn:hover {
  color: #0f172a;
}

/* Phần body danh sách gợi ý trong mobile search dropdown */
.mobile-suggest-content .header-suggest-body {
  max-height: 52vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

