/* ============================================================
   KREAM 统一 Header（主页/登录/后台共用）
   完全自包含：不依赖任何页面的全局 reset
   ============================================================ */

/* --- 统一字体 + 固定顶部 --- */
#kreamHeaderMount {
  font-family: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont,
    'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  -webkit-font-smoothing: antialiased;
  position: sticky;
  top: 0;
  z-index: 100;
  background: #fff;
}

/* --- 顶部小字链接栏 --- */
.kream-header-top {
  position: relative;
  z-index: 5;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.kream-header-top .top_inner {
  display: flex;
  align-items: center;
  height: 22px;
  padding: 6px 40px 0;
  max-width: 1280px;
  margin: 0 auto;
  justify-content: flex-end;
  box-sizing: content-box;
}

.kream-header-top .top_list {
  display: flex;
  align-items: center;
  list-style: none;
  gap: 24px;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.kream-header-top .top_list li {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.kream-header-top .top_link,
.kream-header-top .top_link:link,
.kream-header-top .top_link:visited,
.kream-header-top .top_link:hover,
.kream-header-top .top_link:active {
  font-size: 12px;
  letter-spacing: -0.06px;
  color: rgba(34,34,34,0.8);
  cursor: pointer;
  transition: color 0.15s;
  text-decoration: none !important;
  margin: 0;
  padding: 0;
}

.kream-header-top .top_link:hover {
  color: #222;
}

/* --- 主导航栏（Logo） --- */
.kream-header-main {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border-bottom: none;
}

.kream-header-main .main_inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 40px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: content-box;
}

.kream-header-main .header-logo {
  padding-left: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: opacity 0.2s;
  text-decoration: none;
  color: inherit;
  box-sizing: border-box;
  flex-shrink: 0;
}

.kream-header-main .header-logo:hover { opacity: 0.8; }
.kream-header-main .header-logo:active { opacity: 0.6; }
/* 右侧 VIP logo（略大于 KREAM 字高，与 KREAM 留小间距） */
.kream-header-main .header-logo .header-cnlogo {
  width: auto;
  height: 30px;
  max-height: 30px;
  margin-left: 6px;
  vertical-align: top;
}

/* --- 主导航 GNB（HOME / SHOP） --- */
.gnb_area {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.gnb_list {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
}

.gnb_item {
  margin: 0 0 0 24px;
  padding: 0;
}

.gnb_item .gnb_link,
.gnb_item .gnb_link:link,
.gnb_item .gnb_link:visited,
.gnb_item .gnb_link:hover,
.gnb_item .gnb_link:active {
  display: flex;
  font-size: 20px;
  letter-spacing: -0.3px;
  color: #222;
  text-decoration: none !important;
  position: relative;
  transition: opacity 0.15s;
}

.gnb_item .gnb_link.active {
  font-weight: 700;
}

.gnb_item .gnb_link:hover {
  opacity: 0.6;
}

/* --- TOOLS 下拉菜单 --- */
.gnb_item_tools {
  position: relative;
}
/* TOOLS 右侧下拉指示（小三角） */
.gnb_tools_chevron {
  display: inline-flex;
  align-items: center;
  margin-left: 2px;
  opacity: 0.7;
  vertical-align: middle;
}
.gnb_tools_chevron svg {
  display: block;
}
.gnb_dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  right: 0;
  min-width: 220px;
  background: #fff;
  border: 1px solid #ebebeb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  padding: 8px;
  z-index: 1000;
  animation: gnbDropFade .15s ease;
}
.gnb_dropdown.open { display: block; }
@keyframes gnbDropFade {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.gnb_dropdown_item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 8px;
  color: #222;
  text-decoration: none !important;
  transition: background .15s;
}
.gnb_dropdown_item:hover { background: #f5f5f5; }
.gnb_dropdown_item svg { flex-shrink: 0; color: #666; }
.gnb_dropdown_title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}
.gnb_dropdown_desc {
  display: block;
  font-size: 11px;
  color: #999;
  line-height: 1.3;
  margin-top: 2px;
}

/* --- 全局搜索按钮（放大镜） --- */
.gnb_search_btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: all 0.2s;
  color: #222;
  line-height: 1;
}
.gnb_search_btn:hover {
  background: #f0f0f0;
}
.gnb_search_btn:active {
  transform: scale(0.92);
}
.gnb_search_btn svg {
  display: block;
}

/* --- 全局搜索栏（覆盖层） --- */
.global-search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 200;
  background: #fff;
  box-shadow: 0 1px 8px rgba(0,0,0,0.04);
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s;
  pointer-events: none;
}
.global-search-overlay.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.global-search-bar {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 40px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.global-search-input {
  flex: 1;
  border: none;
  border-bottom: 2px solid #e8e8e8;
  font-size: 22px;
  font-weight: 600;
  font-family: inherit;
  padding: 12px 0;
  outline: none;
  background: transparent;
  color: #333;
  letter-spacing: -0.15px;
  transition: border-color 0.2s;
}
.global-search-input:focus {
  border-bottom-color: #aaa;
}
.global-search-input::placeholder {
  color: #ccc;
  font-weight: 400;
}
.global-search-close {
  background: none;
  border: none;
  font-size: 28px;
  color: rgba(34,34,34,0.25);
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  transition: color 0.15s;
  flex-shrink: 0;
}
.global-search-close:hover {
  color: #666;
}
/* 搜索栏打开时的背景遮罩 */
.global-search-backdrop {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(255,255,255,0.7);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  pointer-events: none;
}
.global-search-backdrop.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

/* --- 响应式 --- */
@media (max-width: 768px) {
  .kream-header-top .top_inner {
    padding: 6px 16px 0;
  }
  .kream-header-main .main_inner {
    padding: 0 16px;
    height: 52px;
  }
  .kream-header-main .header-logo {
    padding-left: 0;
    /* 缩小 Logo 以留出空间给右侧搜索图标 */
  }
  .kream-header-main .header-logo svg {
    width: 88px;
    height: auto;
    max-height: 20px;
  }
  .kream-header-main .header-logo img,
  .kream-header-main .header-logo .header-cnlogo {
    height: 20px !important;
    max-height: 20px;
    width: auto;
  }
  .gnb_item {
    margin-left: 10px;
  }
  .gnb_item .gnb_link {
    font-size: 14px;
    padding: 10px 2px;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .gnb_search_btn {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .gnb_area {
    flex-shrink: 0;
    min-width: 0;
  }
  .gnb_item_tools {
    position: static;
  }
  .gnb_dropdown {
    position: fixed;
    top: auto;
    left: 12px;
    right: 12px;
    bottom: auto;
    min-width: 0;
    width: auto;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,.18);
    z-index: 1100;
    animation: gnbDropMobile .2s ease;
  }
  @keyframes gnbDropMobile {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .gnb_dropdown_item {
    padding: 14px 16px;
  }
  .global-search-bar {
    padding: 20px 16px;
  }
  .global-search-input {
    font-size: 18px;
  }
}

/* 超小屏：进一步缩小 Logo，保证搜索图标一定可见 */
@media (max-width: 480px) {
  .kream-header-main .main_inner {
    padding: 0 12px;
  }
  .kream-header-main .header-logo svg {
    width: 68px;
    max-height: 16px;
  }
  .kream-header-main .header-logo img,
  .kream-header-main .header-logo .header-cnlogo {
    height: 16px !important;
    max-height: 16px;
    width: auto;
  }
  .gnb_item {
    margin-left: 6px;
  }
  .gnb_item .gnb_link {
    font-size: 12px;
    padding: 8px 2px;
  }
  .gnb_search_btn {
    min-width: 40px;
    min-height: 40px;
    padding: 2px;
  }
  .gnb_search_btn svg {
    width: 20px;
    height: 20px;
  }
}

/* 页面全屏时：header 与下方内容一致铺满，左右留白对齐 */
body.page-fullscreen .kream-header-top .top_inner,
body.page-fullscreen .kream-header-main .main_inner {
  max-width: none;
  width: 100%;
  padding-left: 24px;
  padding-right: 16px;
  box-sizing: border-box;
}

/* 首页/搜索等使用 .wrap 的页面：下方主内容区也全屏 */
body.page-fullscreen .wrap {
  max-width: none;
  width: 100%;
  padding-left: 24px;
  padding-right: 16px;
  box-sizing: border-box;
}

/* 首页全屏时：最近浏览、收藏区域也铺满宽度 */
body.page-fullscreen .recently-viewed-section,
body.page-fullscreen .saved-products-home-section {
  max-width: none;
  width: 100%;
}

/* 搜索页面全屏时：每行显示 7 个商品 */
body.page-fullscreen .section .products-grid {
  grid-template-columns: repeat(7, 1fr);
}

/* 我的页面 (/my) 使用 .container-my：下方主内容区也全屏（与 admin.css 保持一致，确保全站生效） */
body.page-fullscreen .container-my {
  max-width: none;
  width: 100%;
  padding-left: 24px;
  padding-right: 16px;
  box-sizing: border-box;
}

/* 全屏切换按钮（全站显示，由 kream-header.js 注入；偏好持久化到 localStorage） */
.btn-page-fullscreen {
  position: fixed;
  top: 100px;
  right: 16px;
  z-index: 900;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(34,34,34,0.12);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  color: #222;
  transition: background 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-page-fullscreen:hover {
  background: #f5f5f5;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.btn-page-fullscreen:active {
  background: #eee;
}
.btn-page-fullscreen svg {
  width: 20px;
  height: 20px;
}
.btn-page-fullscreen.exit-fullscreen svg.expand-icon { display: none; }
.btn-page-fullscreen.exit-fullscreen svg.shrink-icon { display: block; }
.btn-page-fullscreen svg.expand-icon { display: block; }
.btn-page-fullscreen svg.shrink-icon { display: none; }
@media (max-width: 768px) {
  .btn-page-fullscreen {
    display: none !important; /* 手机版不显示全屏按钮 */
  }
}
