/* ===================================================================
   Mobile Responsive Optimization
   Optimized mobile navigation and responsive design for better UX
   =================================================================== */

/* Bottom navigation is hidden by default (desktop & large screens) */
.bottom-nav {
  display: none;
}

/* Base mobile layout adjustments */
@media (max-width: 992px) {
  /* ===== Header Container ===== */
  header {
    display: block !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    z-index: 1000010 !important;
    background: rgba(20, 20, 20, 0.98) !important;
    backdrop-filter: blur(10px) !important;
    pointer-events: auto !important;
    padding: 12px 15px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3) !important;
  }

  /* Header flex layout */
  header .de-flex {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 15px !important;
  }

  /* Keep header positioning context for absolute centering */
  header .container {
    position: relative !important;
  }

  header .de-flex-col {
    display: flex !important;
    align-items: center !important;
  }

  /* Last column (contains hamburger menu) */
  header .de-flex-col:last-child {
    gap: 12px !important;
  }

  /* ===== Logo Styling ===== */
  #logo {
    flex-shrink: 0 !important;
  }

  #logo img.logo {
    max-width: 140px !important;
    height: auto !important;
    display: block !important;
    margin: 0 auto !important;
  }

  /* Hide duplicate logo on mobile */
  #logo .logo-2 {
    display: none !important;
  }

  /* ===== Center Logo (H5 header) ===== */
  /* Hide the horizontal menu on mobile; bottom-nav is used instead */
  header .header-col-mid {
    display: none !important;
  }

  /* Center the logo horizontally & vertically */
  header .de-flex-col:first-child {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    z-index: 1000012 !important;
  }

  /* Keep right-side tools (e.g., language switcher) on the right */
  header .de-flex-col:last-child {
    position: absolute !important;
    right: 15px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 1000012 !important;
  }

  /* ===== Hamburger Menu (hidden in H5 bottom-nav layout) ===== */
  #menu-btn {
    display: none !important;
  }

  /* ===== Mobile Navigation Menu ===== */
  #mainmenu {
    position: absolute !important;
    top: 100% !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000011 !important;
    display: none !important;
    background: rgba(20, 20, 20, 0.98) !important;
    backdrop-filter: blur(10px) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
    max-height: calc(100vh - 70px) !important;
    overflow-y: auto !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Show menu when header has menu-open class */
  header.menu-open #mainmenu {
    display: block !important;
  }

  /* Menu items - 修复移动端菜单显示问题 */
  #mainmenu li {
    float: none !important;
    display: block !important;
    width: 100% !important;
    list-style: none !important;
  }

  #mainmenu > li {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #mainmenu > li:last-child {
    border-bottom: none !important;
  }

  #mainmenu > li > a {
    display: block !important;
    padding: 16px 20px !important;
    color: #ffffff !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
    text-align: left !important;
    /* 添加 CJK 字体回退以确保中文正常显示 */
    font-family: "Jost", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif !important;
    text-transform: none !important;
  }

  #mainmenu > li > a:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    padding-left: 25px !important;
  }

  /* Submenu styling - 修复子菜单显示 */
  #mainmenu ul {
    position: static !important;
    display: block !important;
    height: auto !important;
    overflow: visible !important;
    background: rgba(0, 0, 0, 0.3) !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }
  
  #mainmenu > li > ul {
    background: rgba(0, 0, 0, 0.3) !important;
    padding: 8px 0 !important;
  }

  #mainmenu > li > ul li {
    border: none !important;
    float: none !important;
    display: block !important;
    width: 100% !important;
  }

  #mainmenu > li > ul li a {
    display: block !important;
    padding: 12px 20px 12px 35px !important;
    color: rgba(255, 255, 255, 0.9) !important;
    font-size: 15px !important;
    text-decoration: none !important;
    transition: all 0.3s ease !important;
    text-align: left !important;
    /* 添加 CJK 字体回退以确保中文正常显示 */
    font-family: "Jost", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif !important;
    text-transform: none !important;
  }

  #mainmenu > li > ul li a:hover {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
    padding-left: 40px !important;
  }

  /* ===== Content Spacing ===== */
  /* Add padding to body to account for fixed header & bottom nav */
  body {
    padding-top: 68px !important;
    padding-bottom: 70px !important;
  }

  /* ===== Bottom Tab Navigation (simple bar, consistent with theme) ===== */
  .bottom-nav {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    height: 56px !important;
    background: rgba(17, 17, 17, 0.98) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-around !important;
    padding: 0 8px !important;
    z-index: 1000010 !important;
  }

  .bottom-nav-item {
    flex: 1 1 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
    color: rgba(255, 255, 255, 0.75) !important;
    font-size: 11px !important;
    font-weight: 500 !important;
    text-transform: none !important;
    font-family: "Jost", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif !important;
  }

  .bottom-nav-item .bottom-nav-icon {
    font-size: 18px !important;
    line-height: 1 !important;
    margin-bottom: 2px !important;
  }

  .bottom-nav-item .bottom-nav-label {
    line-height: 1.2 !important;
  }

  .bottom-nav-item.active {
    color: #ffffff !important;
  }

  .bottom-nav-item.active .bottom-nav-icon {
    color: #4caf50 !important;
  }

  /* ===== Revolution Slider (mobile text layout & readability) ===== */
  #section-slider .tp-caption h1,
  #section-slider .tp-caption h3,
  #section-slider .tp-caption p {
    text-shadow: 0 6px 18px rgba(0, 0, 0, 0.55) !important;
  }

  #section-slider .tp-caption h1 {
    font-size: 28px !important;
    line-height: 1.15 !important;
    letter-spacing: 0 !important;
  }

  #section-slider .tp-caption h3.id-color {
    color: #4caf50 !important;
    font-size: 16px !important;
    line-height: 1.2 !important;
  }

  #section-slider .tp-caption p.lead {
    font-size: 14px !important;
    line-height: 1.45 !important;
    color: rgba(255, 255, 255, 0.92) !important;
    background: rgba(0, 0, 0, 0.32) !important;
    padding: 10px 12px !important;
    border-radius: 12px !important;
    max-width: 92vw !important;
  }

  /* ===== Language Switcher (if present) ===== */
  .language-switcher {
    position: relative !important;
    z-index: 1000012 !important;
    margin-right: 8px !important;
  }

  .lang-toggle {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 10px 14px !important;
    background: rgba(255, 255, 255, 0.15) !important;
    border: 2px solid rgba(255, 255, 255, 0.4) !important;
    border-radius: 8px !important;
    color: #ffffff !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    white-space: nowrap !important;
  }

  .lang-toggle:hover {
    background: rgba(255, 255, 255, 0.25) !important;
    border-color: rgba(255, 255, 255, 0.6) !important;
  }

  .lang-menu {
    position: absolute !important;
    top: calc(100% + 8px) !important;
    right: 0 !important;
    z-index: 1000013 !important;
    display: none !important;
    background: #ffffff !important;
    border-radius: 8px !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3) !important;
    min-width: 150px !important;
    overflow: hidden !important;
  }

  .lang-menu.show {
    display: block !important;
  }

  .lang-menu a {
    display: block !important;
    padding: 12px 16px !important;
    color: #333333 !important;
    text-decoration: none !important;
    font-size: 14px !important;
    transition: background 0.2s ease !important;
    border-bottom: 1px solid #f0f0f0 !important;
  }

  .lang-menu a:last-child {
    border-bottom: none !important;
  }

  .lang-menu a:hover {
    background: #f5f5f5 !important;
  }

  .lang-menu a.active {
    background: #e8e8e8 !important;
    font-weight: 600 !important;
    color: #000000 !important;
  }
}

/* ===== Extra Small Devices (iPhone SE, small phones) ===== */
@media (max-width: 375px) {
  header {
    padding: 10px 12px !important;
  }

  /* Adjust right-side tool alignment on very small screens */
  header .de-flex-col:last-child {
    right: 12px !important;
  }

  #logo img.logo {
    max-width: 120px !important;
  }

  #mainmenu > li > a {
    padding: 14px 15px !important;
    font-size: 15px !important;
  }

  body {
    padding-top: 62px !important;
    padding-bottom: 70px !important;
  }
}

/* ===== Smooth scrolling for mobile ===== */
@media (max-width: 992px) {
  html {
    scroll-behavior: smooth !important;
  }

  #mainmenu {
    -webkit-overflow-scrolling: touch !important;
  }
}

/* ===== Prevent body scroll when menu is open ===== */
@media (max-width: 992px) {
  body.menu-open {
    overflow: hidden !important;
  }
}

/* ===== Owl Carousel Pagination (Dots) Fix ===== */
@media (max-width: 992px) {
  /* 确保分页点可见和可点击 */
  .owl-dots {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    margin-top: 15px !important;
    padding: 10px 0 !important;
    pointer-events: auto !important;
    z-index: 100 !important;
    position: relative !important;
  }

  .owl-dots .owl-dot {
    display: inline-block !important;
    margin: 0 5px !important;
    padding: 5px !important;
    pointer-events: auto !important;
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
  }

  .owl-dots .owl-dot span {
    display: block !important;
    width: 12px !important;
    height: 12px !important;
    background: rgba(255, 255, 255, 0.4) !important;
    border-radius: 50% !important;
    transition: all 0.3s ease !important;
  }

  .owl-dots .owl-dot.active span,
  .owl-dots .owl-dot:hover span {
    background: #fff !important;
    transform: scale(1.2) !important;
  }

  /* Owl Navigation Arrows */
  .owl-nav {
    display: flex !important;
    justify-content: center !important;
    gap: 15px !important;
    margin-top: 10px !important;
  }

  .owl-nav .owl-prev,
  .owl-nav .owl-next {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 40px !important;
    height: 40px !important;
    background: rgba(255, 255, 255, 0.2) !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    transition: all 0.3s ease !important;
  }

  .owl-nav .owl-prev:hover,
  .owl-nav .owl-next:hover {
    background: rgba(255, 255, 255, 0.4) !important;
  }
}
