/**
 * 全站响应式：PC + WAP 共用（与现有侧栏/顶栏结构配合）
 *
 * @package AI_Tools_Navigator
 */

:root {
  --mobile-tabbar-h: 62px;
  --header-sticky-z: 100;
  --sidebar-z: 200;
  --overlay-z: 150;
}

/* ========== 侧栏：与 JS 使用的 .active 一致（兼容 style.css 的 .open） ========== */
@media (max-width: 1023px) {
  /* WAP：隐藏页脚（关于我们 / 联系方式 / 版权等），PC（≥1024px）照常显示 */
  .site-footer {
    display: none !important;
  }

  /* 手机版隐藏顶部蓝色快捷通栏（ChatGPT / Midjourney 等） */
  .top-bar {
    display: none !important;
  }

  .page-wrapper .sidebar-nav {
    width: min(288px, 88vw);
    box-shadow: 4px 0 24px rgba(15, 23, 42, 0.12);
  }

  .page-wrapper .sidebar-nav.active,
  .page-wrapper .sidebar-nav.open {
    transform: translateX(0);
  }

  .sidebar-overlay,
  #sidebarOverlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: var(--overlay-z);
    -webkit-tap-highlight-color: transparent;
  }

  .sidebar-overlay.active,
  #sidebarOverlay.active {
    display: block;
  }

  /* 含底部 Tab 的主区留白 */
  .main-content--tabbar {
    padding-bottom: calc(var(--mobile-tabbar-h) + env(safe-area-inset-bottom, 0px) + 20px);
  }

  /* 底栏：更高、字更大、当前页更明显 */
  .mobile-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: var(--header-sticky-z);
    background: rgba(255, 255, 255, 0.97);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(226, 232, 240, 0.98);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -6px 24px rgba(15, 23, 42, 0.08);
  }

  .mobile-nav-inner {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    min-height: var(--mobile-tabbar-h);
    max-width: 100%;
    padding: 6px 6px 8px;
    box-sizing: border-box;
  }

  /* 工具网格：WAP 固定两列，避免中等宽度被设为 3 列导致只看清一个 */
  .tools-grid-5 {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    width: 100%;
    box-sizing: border-box;
  }

  .tools-section {
    max-width: 100%;
    overflow: visible;
  }

  /* 广告区不被侧向裁切；主内容区不裁切横向子元素 */
  .ad-banners-section {
    max-width: 100%;
    overflow: visible;
    box-sizing: border-box;
  }

  .page-wrapper .content-area {
    overflow-x: visible;
    max-width: 100%;
    box-sizing: border-box;
  }

  .page-wrapper .main-content {
    overflow-x: visible;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* 工具归档列表：手机固定两列且格子可收缩 */
  .tools-grid-archive {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    padding: 4px 2px;
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.15;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    border-radius: 12px;
    max-width: 25%;
  }

  .mobile-nav-item:active {
    background: rgba(99, 102, 241, 0.08);
  }

  .mobile-nav-item.active {
    color: #4338ca;
    background: rgba(99, 102, 241, 0.1);
  }

  .mobile-nav-item--btn {
    appearance: none;
    -webkit-appearance: none;
  }

  .mobile-nav-icon {
    font-size: 24px;
    line-height: 1;
  }

  .mobile-nav-text {
    font-size: 11px;
    letter-spacing: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  /* 顶栏内汉堡：覆盖模板里 display:none */
  .page-wrapper .main-header .hamburger-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
  }

  /* 手机版：Logo + 站点标题在顶栏水平居中（左右保留汉堡与搜索占位） */
  .page-wrapper .main-header .main-header-inner {
    position: relative;
    justify-content: space-between;
  }

  .page-wrapper .main-header .header-logo {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100% - 104px);
    pointer-events: none;
    justify-content: center;
  }

  .page-wrapper .main-header .header-logo a,
  .page-wrapper .main-header .header-logo .logo-icon,
  .page-wrapper .main-header .header-logo .logo-text {
    pointer-events: auto;
  }

  .page-wrapper .main-header .header-search {
    position: relative;
    z-index: 120;
    flex-shrink: 0;
    width: 44px;
    margin-left: 0;
    display: flex;
    justify-content: flex-end;
  }

  .page-wrapper .main-header .search-toggle {
    position: relative;
    z-index: 121;
    cursor: pointer;
  }

  .page-wrapper .main-header .header-nav {
    display: none !important;
  }

  .page-wrapper .main-content {
    margin-left: 0 !important;
  }

  .page-wrapper .sidebar-nav {
    transform: translateX(-100%);
  }

  .page-wrapper .sidebar-nav.active,
  .page-wrapper .sidebar-nav.open {
    transform: translateX(0);
  }

  /* 回到顶部避开底栏 */
  .back-to-top {
    bottom: calc(var(--mobile-tabbar-h) + env(safe-area-inset-bottom, 0px) + 16px) !important;
    right: 12px !important;
  }

  /* 筛选标签横向滑动 */
  .filter-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 8px !important;
    padding-bottom: 4px;
  }

  .filter-tabs::-webkit-scrollbar {
    display: none;
  }

  .filter-tab {
    flex-shrink: 0;
  }

  /* Logo 文字：居中区域内完整显示（过长再省略） */
  .page-wrapper .main-header .header-logo .logo-text {
    max-width: min(52vw, 14em);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
  }
}

@media (min-width: 1024px) {
  .mobile-bottom-nav {
    display: none !important;
  }

  .main-content--tabbar {
    padding-bottom: 0;
  }
}

/* ========== 首页 + 内页：四宫格广告角标在手机上可见（覆盖 front-page 内联 display:none） ========== */
@media (max-width: 1023px) {
  .ad-banners-section .ad-banner-item {
    position: relative;
  }

  .ad-banners-section .ad-banner-item .ad-badge {
    display: block !important;
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.28);
    border-radius: var(--radius-sm, 4px);
    font-size: 9px;
    line-height: 1.2;
    color: #fff;
  }
}

@media (min-width: 1024px) {
  .ad-banners-section .ad-banner-item {
    position: relative;
  }

  .ad-banners-section .ad-banner-item .ad-badge {
    display: block !important;
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm, 4px);
    font-size: 9px;
    line-height: 1.2;
    color: #fff;
  }
}

/* ========== 内页推广条（与首页区块同源，不依赖 front-page 内联样式） ========== */
.ad-strip-wrap.ad-banners-section {
  margin-bottom: 16px;
  width: 100%;
  max-width: 100%;
  overflow: visible;
}

.ad-strip-wrap .ad-two-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.ad-strip-wrap .ad-card-large {
  display: block;
  border-radius: var(--radius-lg, 10px);
  padding: 14px 12px 16px;
  color: #fff;
  position: relative;
  overflow: visible;
  min-width: 0;
  box-sizing: border-box;
}

.ad-strip-wrap .ad-card-large:active {
  opacity: 0.96;
}

.ad-strip-wrap .ad-badge-sm {
  flex-shrink: 0;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.28);
  border-radius: var(--radius-sm, 4px);
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
}

.ad-strip-wrap .ad-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  width: 100%;
}

.ad-strip-wrap .ad-card-header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.ad-strip-wrap .ad-card-brand {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.25;
  word-break: break-word;
}

.ad-strip-wrap .ad-card-region {
  font-size: 11px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  white-space: nowrap;
}

.ad-strip-wrap .ad-card-offer {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  line-height: 1.4;
  word-break: break-word;
}

.ad-strip-wrap .ad-card-features {
  font-size: 13px;
  opacity: 0.95;
  line-height: 1.45;
  word-break: break-word;
}

.ad-strip-wrap .ad-card-gradient-green {
  background: linear-gradient(135deg, #10b981, #059669);
}

.ad-strip-wrap .ad-card-gradient-orange {
  background: linear-gradient(135deg, #f97316, #ea580c);
}

.ad-strip-wrap .ad-card-gradient-purple {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.ad-strip-wrap .ad-card-gradient-blue {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.ad-strip-wrap .ad-banner-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}

.ad-strip-wrap .ad-banner-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 8px;
  border-radius: var(--radius-md, 6px);
  color: #fff;
  text-align: center;
  min-height: 78px;
  box-sizing: border-box;
  min-width: 0;
  word-break: break-word;
  text-decoration: none;
}

.ad-strip-wrap .ad-banner-item:active {
  opacity: 0.92;
}

.ad-strip-wrap .ad-banner-item-brand {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
  line-height: 1.25;
  max-width: 100%;
}

.ad-strip-wrap .ad-banner-item-desc {
  font-size: 12px;
  opacity: 0.95;
  line-height: 1.35;
  max-width: 100%;
}

.ad-strip-wrap .ad-banner-dark-blue {
  background: linear-gradient(135deg, #1e40af, #1e3a8a);
}

.ad-strip-wrap .ad-banner-light-blue {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.ad-strip-wrap .ad-banner-orange {
  background: linear-gradient(135deg, #f97316, #ea580c);
}

.ad-strip-wrap .ad-banner-deep-blue {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
}

@media (min-width: 1024px) {
  .ad-strip-wrap .ad-two-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .ad-strip-wrap .ad-card-large {
    padding: 20px;
    min-height: 100px;
  }

  .ad-strip-wrap .ad-banner-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }

  .ad-strip-wrap .ad-banner-item {
    min-height: 80px;
    padding: 14px;
  }
}

@media (max-width: 480px) {
  .ad-strip-wrap .ad-banner-item {
    min-height: 72px;
    padding: 10px 6px;
  }

  .ad-strip-wrap .ad-banner-item-brand {
    font-size: 14px;
  }

  .ad-strip-wrap .ad-banner-item-desc {
    font-size: 11px;
  }
}

/* 工具详情页：右侧推广位在平板/手机完整展示 */
@media (max-width: 1023px) {
  .tool-header-section {
    grid-template-columns: 1fr !important;
  }

  .tool-header-section .tool-ad-box {
    display: block !important;
    min-height: 100px;
  }

  .tool-header-section .tool-ad-box .ad-rectangle {
    min-height: 88px;
  }
}

/* ========== 顶栏放大镜：全站搜索抽屉（类似 IDC 站手机版展开搜索） ========== */
.screen-reader-text {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.header-search-drawer {
  position: fixed;
  inset: 0;
  z-index: 400;
  pointer-events: none;
}

.header-search-drawer.is-open {
  pointer-events: auto;
}

.header-search-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  opacity: 0;
  transition: opacity 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.header-search-drawer.is-open .header-search-drawer__backdrop {
  opacity: 1;
}

.header-search-drawer__panel {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: #fff;
  box-shadow: 0 4px 24px rgba(15, 23, 42, 0.15);
  border-bottom: 1px solid var(--border-color, #e5e7eb);
  transform: translateY(-100%);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}

.header-search-drawer.is-open .header-search-drawer__panel {
  transform: translateY(0);
}

.header-search-drawer__form {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.header-search-drawer__input {
  flex: 1;
  min-width: 0;
  padding: 10px 14px;
  font-size: 16px;
  line-height: 1.4;
  border: 1px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  background: var(--bg-secondary, #f9fafb);
  color: var(--text-primary, #1f2937);
  -webkit-appearance: none;
  appearance: none;
}

.header-search-drawer__input:focus {
  outline: none;
  border-color: var(--primary-color, #6366f1);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.header-search-drawer__submit {
  flex-shrink: 0;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--primary-color, #6366f1), var(--primary-hover, #4f46e5));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.header-search-drawer__submit:active {
  opacity: 0.92;
}

.header-search-drawer__close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  color: var(--text-secondary, #6b7280);
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.header-search-drawer__close:active {
  background: var(--bg-tertiary, #f3f4f6);
}

body.header-search-drawer-open {
  overflow: hidden;
}

@media (min-width: 1024px) {
  .header-search-drawer__panel {
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    max-width: 720px;
    margin: 0 auto;
    border-radius: 0 0 12px 12px;
  }
}

/* ========== PC：全站主顶栏与首页一致（Logo | 居中导航 | 搜索 + 下拉） ========== */
@media (min-width: 1024px) {
  .page-wrapper .main-content .main-header .hamburger-btn {
    display: none !important;
  }

  .page-wrapper .main-content .main-header .main-header-inner {
    display: grid !important;
    grid-template-columns: auto 1fr auto !important;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    position: relative !important;
    justify-content: stretch !important;
  }

  .page-wrapper .main-content .main-header .header-logo {
    position: relative !important;
    left: auto !important;
    transform: none !important;
    justify-self: start;
    max-width: none !important;
    pointer-events: auto !important;
    flex-shrink: 0;
  }

  .page-wrapper .main-content .main-header .header-search {
    margin-left: 0 !important;
    justify-self: end;
    flex-shrink: 0;
  }

  .page-wrapper .main-content .main-header .header-nav {
    display: flex !important;
    align-items: center;
    justify-content: center;
    justify-self: stretch;
    width: 100%;
    min-width: 0;
    gap: 4px;
    flex-wrap: wrap;
  }

  .page-wrapper .main-content .main-header .header-nav-link {
    padding: 8px 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-md);
  }

  .page-wrapper .main-content .main-header .header-nav-link:hover,
  .page-wrapper .main-content .main-header .header-nav-link.active {
    background: var(--bg-tertiary);
    color: var(--primary-color);
  }

  .page-wrapper .main-content .main-header .nav-icon {
    font-size: 14px;
  }

  .page-wrapper .main-content .main-header .nav-dropdown {
    position: relative;
  }

  .page-wrapper .main-content .main-header .dropdown-arrow {
    font-size: 10px;
    margin-left: 4px;
  }

  .page-wrapper .main-content .main-header .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 160px;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: all 0.2s;
    z-index: 150;
    padding: 8px 0;
    margin-top: 4px;
  }

  .page-wrapper .main-content .main-header .nav-dropdown:hover .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .page-wrapper .main-content .main-header .dropdown-item {
    display: block;
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 14px;
  }

  .page-wrapper .main-content .main-header .dropdown-item:hover {
    background: var(--bg-tertiary);
    color: var(--primary-color);
  }
}
