/**
 * 移动端Header样式修复
 * 修复移动端顶部header组件和选项卡的样式问题
 */

/* 移动端Header基础样式 */
@media (max-width: 991px) {
  .header .topbar .inner {
    align-items: stretch;
    padding: 15px 0;
  }

  .header .topbar .logo {
    padding: 15px 0;
    text-align: center;
    order: 1;
  }

  .header .topbar .logo>a {
    height: 50px;
    width: 120px;
    margin: 0 auto;
  }

  .header .topbar .header_action {
    order: 2;
    margin-top: 15px;
  }

  .header .topbar .header_action ul {
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
  }

  .header .topbar .header_action>ul>li {
    margin: 0 10px;
  }

  .header .topbar .header_action ul>li>a {
    font-size: 18px;
  }

  .header .topbar .header_action ul>li.cart .cart_text {
    display: none;
  }

  .header .topbar .header_action ul>li.user a span {
    display: none;
  }

  .header .topbar .header_action ul>li.user a img {
    width: 35px;
    height: 35px;
    margin-right: 0;
  }
}

/* 移动端导航栏样式 */
@media (max-width: 991px) {
  .main_navigation {
    position: relative;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  }

  .main_navigation .nav_inner {
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    min-height: 60px;
  }

  .main_navigation .main-menu {
    display: none !important;
  }

  .main_navigation .hamburger {
    display: flex !important;
    width: 50px;
    height: 50px;
    background-color: var(--thm-color-one);
    border-radius: 5px;
    margin: 0;
  }

  .main_navigation .hamburger .hamburger_btn {
    width: 24px;
    height: 18px;
  }

  .main_navigation .hamburger .hamburger_btn span {
    width: 24px;
    height: 2px;
    margin-bottom: 4px;
    background-color: var(--thm-white);
  }

  .main_navigation .hamburger .hamburger_btn span:last-child {
    margin-bottom: 0;
  }

  /* 汉堡菜单激活状态 */
  .main_navigation .hamburger.active .hamburger_btn span:first-child {
    transform: rotate(45deg) translate(5px, 5px);
  }

  .main_navigation .hamburger.active .hamburger_btn span:nth-child(2) {
    opacity: 0;
  }

  .main_navigation .hamburger.active .hamburger_btn span:last-child {
    transform: rotate(-45deg) translate(7px, -6px);
  }
}

/* 移动端菜单面板样式 */
.mobile-menu-panel {
  position: fixed;
  top: 0;
  right: -100%;
  width: 300px;
  height: 100vh;
  background: #fff;
  z-index: 9999;
  transition: right 0.3s ease;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
  overflow-y: auto;
}

.mobile-menu-panel.active {
  right: 0;
}

.mobile-menu-header {
  background: var(--thm-color-one);
  color: white;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.mobile-menu-close {
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 5px;
  border-radius: 50%;
  transition: background-color 0.2s ease;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mobile-menu-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.mobile-menu-content {
  padding: 0;
}

.mobile-menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

.mobile-menu-item {
  border-bottom: 1px solid #f0f0f0;
}

.mobile-menu-item:last-child {
  border-bottom: none;
}

.mobile-menu-item a {
  display: block;
  padding: 18px 20px;
  color: #333;
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.mobile-menu-item a:hover {
  background: #f8f9fa;
  color: var(--thm-color-one);
  padding-left: 25px;
}

.mobile-menu-item a:active {
  background: #e9ecef;
}

/* 遮罩层样式 */
.mobile-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.mobile-menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* 小屏幕适配 */
@media (max-width: 768px) {
  .mobile-menu-panel {
    width: 280px;
  }

  .mobile-menu-header {
    padding: 15px;
  }

  .mobile-menu-item a {
    padding: 15px 20px;
    font-size: 15px;
  }

  .header .topbar .header_action>ul>li {
    margin: 0 8px;
  }

  .header .topbar .header_action ul>li>a {
    font-size: 16px;
  }
}

@media (max-width: 576px) {
  .mobile-menu-panel {
    width: 100%;
    right: -100%;
  }

  .mobile-menu-panel.active {
    right: 0;
  }

  .mobile-menu-header {
    padding: 12px 15px;
  }

  .mobile-menu-item a {
    padding: 12px 15px;
    font-size: 14px;
  }

  .header .topbar .inner {
    padding: 10px 0;
  }

  .header .topbar .logo>a {
    height: 40px;
  }

  .header .topbar .header_action ul {
    gap: 10px;
  }

  .header .topbar .header_action>ul>li {
    margin: 0 5px;
  }

  .main_navigation .nav_inner {
    padding: 0 10px;
    min-height: 50px;
  }

  .main_navigation .hamburger {
    width: 45px;
    height: 45px;
  }
}

/* 动画效果 */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
  }

  to {
    transform: translateX(0);
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(100%);
  }
}

.mobile-menu-panel.active {
  animation: slideInRight 0.3s ease forwards;
}

.mobile-menu-panel:not(.active) {
  animation: slideOutRight 0.3s ease forwards;
}

/* 确保在所有页面都能正常显示 */
body.mobile-menu-open {
  overflow: hidden;
}

/* 修复hide_cat类的显示问题 */
.hide_cat .main_navigation {
  display: block !important;
}

.hide_cat .main_navigation .nav_inner {
  display: flex !important;
}

/* 确保移动端菜单按钮可见 */
@media (max-width: 991px) {
  .hamburger {
    display: flex !important;
  }

  .main-menu {
    display: none !important;
  }
}

@media (min-width: 992px) {
  .hamburger {
    display: none !important;
  }

  .main-menu {
    display: flex !important;
  }
}

/* 修复用户菜单在移动端的显示 */
@media (max-width: 991px) {
  .header .topbar .header_action ul>li .sub-menu {
    position: fixed;
    top: 11%;
    left: 45%;
    max-width: 300px;
    z-index: 1000;
  }

  .header .topbar .header_action ul>li:hover>.sub-menu {
    opacity: 1;
    visibility: visible;
  }
}

/* 移动端Header优化样式 */

/* 移动端视口优化 */
@media (max-width: 768px) {

  /* Header组件移动端优化 */
  .header {
    position: sticky;
    top: 0;
    z-index: 1000;
  }

  /* Logo移动端优化 */
  .logo img {
    max-height: 40px;
    width: auto;
    object-fit: contain;
  }

  /* 购物车和心愿单图标移动端优化 */
  .header_action ul li {
    margin: 0 5px;
  }

  .header_action ul li a {
    padding: 8px;
    font-size: 14px;
  }

  .cart_text {
    display: none;
    /* 移动端隐藏文字，只显示图标和数量 */
  }

  .cart_value,
  .wishlist-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
  }

  /* 用户菜单移动端优化 */
  .user-menu-toggle {
    padding: 8px !important;
  }

  .user-menu-toggle img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
  }

  #user-name {
    display: none;
    /* 移动端隐藏用户名 */
  }

  /* 用户下拉菜单移动端优化 */
  .sub-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    z-index: 1001;
  }

  .sub-menu li {
    border-bottom: 1px solid #f0f0f0;
  }

  .sub-menu li:last-child {
    border-bottom: none;
  }

  .sub-menu li a {
    padding: 12px 16px;
    display: block;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s ease;
  }

  .sub-menu li a:hover {
    background-color: #f8f9fa;
  }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
  .header_action ul li {
    margin: 0 2px;
  }

  .header_action ul li a {
    padding: 6px;
    font-size: 12px;
  }

  .logo img {
    max-height: 35px;
  }

  .cart_value,
  .wishlist-count {
    width: 16px;
    height: 16px;
    font-size: 9px;
  }
}

/* 平板设备优化 */
@media (min-width: 769px) and (max-width: 1024px) {
  .header_action ul li {
    margin: 0 8px;
  }

  .cart_text {
    font-size: 12px;
  }

  .cart_text .amount {
    font-size: 11px;
  }
}

/* 确保图片不会变形 */
img {
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

/* 响应式表格 */
@media (max-width: 768px) {
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .cart_table table,
  .wishlist-content table {
    min-width: 600px;
    /* 确保表格内容完整显示 */
  }
}

/* 响应式按钮 */
@media (max-width: 768px) {
  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }

  .btn-lg {
    padding: 12px 20px;
    font-size: 16px;
  }

  .btn-sm {
    padding: 8px 12px;
    font-size: 12px;
  }
}

/* 响应式表单 */
@media (max-width: 768px) {
  .form-control {
    font-size: 16px;
    /* 防止iOS缩放 */
    padding: 12px 16px;
  }

  .form-group {
    margin-bottom: 20px;
  }
}

/* 响应式卡片 */
@media (max-width: 768px) {
  .card {
    margin-bottom: 20px;
  }

  .card-body {
    padding: 20px 16px;
  }

  .card-header {
    padding: 16px;
  }
}

/* 响应式间距 */
@media (max-width: 768px) {
  .section-padding {
    padding: 40px 0;
  }

  .mb-xl-30 {
    margin-bottom: 20px !important;
  }

  .mt-4 {
    margin-top: 20px !important;
  }

  .py-5 {
    padding: 30px 0 !important;
  }
}

/* 响应式网格 */
@media (max-width: 768px) {

  .col-md-6,
  .col-lg-6 {
    margin-bottom: 20px;
  }

  .row>[class*="col-"] {
    margin-bottom: 20px;
  }
}

/* 确保文本不会溢出 */
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 长文本自动换行 */
.text-wrap {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* 移动端触摸优化 */
@media (max-width: 768px) {

  button,
  a,
  input,
  select,
  textarea {
    min-height: 44px;
    /* 确保触摸目标足够大 */
  }

  .wishlist-link {
    min-height: auto !important;
  }

  #remember {
    min-height: auto !important;
  }

  .btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}