/**
 * Responsive Components CSS
 * 移动端/平板端共享组件样式
 * 适用于屏幕宽度 < 992px
 */

/* ========================================
   CSS Variables
   ======================================== */
:root {
  --mobile-breakpoint: 768px;
  --tablet-breakpoint: 992px;
  --header-height: 68px;
  --slide-panel-width: 280px;
  --primary-color: #ff5c5c;
  --text-color: #333;
  --border-color: #eee;
  --mask-color: rgba(0, 0, 0, 0.4);
  --transition-speed: 0.3s;
}

/* ========================================
   Mobile Header Bar Layout
   移动端/平板端顶部导航栏布局
   ======================================== */
@media (max-width: 991px) {
  /* 隐藏桌面端菜单 */
  .header_menu {
    display: none !important;
  }
  
  /* 隐藏桌面端登录区域 */
  .login_text.pc {
    display: none !important;
  }
  
  /* 隐藏桌面端搜索框 */
  .searchform {
    display: none !important;
  }
  
  /* 重新布局header_inner */
  .header_inner {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between;
    padding: 0 10px;
    height: var(--header-height);
    overflow: visible !important; /* 关键：覆盖main.css的overflow:hidden */
  }
  
  /* Logo调整 - 确保显示和垂直居中 */
  .logo,
  h1.logo {
    float: none !important;
    margin: 0 !important;
    flex-shrink: 0;
    display: flex !important;
    align-items: center;
    height: var(--header-height);
    overflow: visible !important;
  }
  
  .logo a {
    display: flex !important;
    align-items: center;
    height: 100%;
  }
  
  .logo img,
  .logo .logo-pc {
    display: block !important;
    height: 32px;
    width: auto;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 !important; /* 覆盖style.css的margin-bottom: 100px */
  }
  
  /* 隐藏logo中的文字 */
  .logo span {
    display: none !important;
  }
  
  /* 显示移动端组件 */
  .mobile-category-dropdown,
  .mobile-search-toggle,
  .mobile-menu-toggle {
    display: flex !important;
  }
  
  /* 右侧按钮组 */
  .mobile-header-right {
    display: flex;
    align-items: center;
    gap: 5px;
  }
}

/* ========================================
   Category Dropdown Component
   分类下拉菜单组件
   ======================================== */
.mobile-category-dropdown {
  display: none;
  position: relative;
  margin-left: 10px;
}

.category-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--text-color);
  cursor: pointer;
  padding: 8px 10px;
  border-radius: 4px;
  transition: background-color var(--transition-speed);
}

.category-toggle:hover {
  background-color: #f5f5f5;
}

.category-toggle .current-category {
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.category-toggle .iconfont {
  font-size: 12px;
  transition: transform var(--transition-speed);
  margin-right: 0;
}

.category-toggle[aria-expanded="true"] .iconfont {
  transform: rotate(180deg);
}

/* 下拉菜单列表 */
.category-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  min-width: 150px;
  padding: 8px 0;
  display: none;
  z-index: 100;
  list-style: none;
  margin: 0;
}

.category-menu.show {
  display: block;
}

.category-menu li {
  margin: 0;
  padding: 0;
}

.category-menu li a {
  display: block;
  padding: 12px 20px;
  color: var(--text-color);
  font-size: 14px;
  transition: all var(--transition-speed);
}

.category-menu li a:hover {
  background: #f5f5f5;
  color: var(--primary-color);
}

.category-menu li.active a {
  color: var(--primary-color);
  font-weight: 500;
}

/* ========================================
   Mobile Search Toggle
   移动端搜索图标
   ======================================== */
.mobile-search-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 4px;
  transition: background-color var(--transition-speed);
}

.mobile-search-toggle:hover {
  background-color: #f5f5f5;
}

.mobile-search-toggle .iconfont {
  font-size: 20px;
  color: var(--text-color);
  margin-right: 0;
}

/* ========================================
   Hamburger Menu Toggle
   汉堡菜单图标
   ======================================== */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 4px;
  transition: background-color var(--transition-speed);
}

.mobile-menu-toggle:hover {
  background-color: #f5f5f5;
}

.mobile-menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-color);
  transition: all var(--transition-speed);
  border-radius: 1px;
}

/* 激活状态 - X形 */
.mobile-menu-toggle.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active span:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}


/* ========================================
   User Slide Panel
   右侧滑出用户面板
   ======================================== */
.user-panel-mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--mask-color);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-speed);
}

.user-panel-mask.show {
  opacity: 1;
  visibility: visible;
}

.user-slide-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--slide-panel-width);
  max-width: 80%;
  height: 100%;
  background: #fff;
  z-index: 999;
  transform: translateX(100%);
  transition: transform var(--transition-speed) ease-out;
  overflow-y: auto;
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
}

.user-slide-panel.show {
  transform: translateX(0);
}

/* 面板头部 */
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 68px;
  padding: 10px;
  border-bottom: 1px solid var(--border-color);
  font-size: 16px;
  font-weight: 500;
  color: var(--text-color);
}

.panel-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all var(--transition-speed);
}

.panel-close:hover {
  background-color: #f5f5f5;
  color: var(--text-color);
}

/* 未登录状态 */
.panel-guest {
  padding: 30px 20px;
  text-align: center;
}

.panel-guest .btn-login,
.panel-guest .btn-register {
  display: block;
  width: 100%;
  padding: 12px 20px;
  margin-bottom: 10px;
  border-radius: 4px;
  font-size: 14px;
  text-align: center;
  transition: all var(--transition-speed);
}

.panel-guest .btn-login {
  background: var(--primary-color);
  color: #fff;
}

.panel-guest .btn-login:hover {
  background: #e54545;
  color: #fff;
}

.panel-guest .btn-register {
  background: #f5f5f5;
  color: var(--text-color);
}

.panel-guest .btn-register:hover {
  background: #eee;
}

/* 已登录状态 - 用户信息 */
.panel-user-info {
  display: flex;
  align-items: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--primary-color), #ff7b7b);
}

.panel-user-info .avatar {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  margin-right: 15px;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.panel-user-info .user-detail {
  flex: 1;
  color: #fff;
}

.panel-user-info .nickname {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 5px;
}

.panel-user-info .user-id {
  font-size: 12px;
  opacity: 0.8;
}

.panel-user-info .vip-badge {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  font-size: 12px;
  margin-top: 5px;
}

/* 用户菜单列表 */
.panel-user-menu {
  list-style: none;
  margin: 0;
  padding: 10px 0;
}

.panel-user-menu li {
  margin: 0;
  padding: 0;
}

.panel-user-menu li a {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  color: var(--text-color);
  font-size: 14px;
  transition: all var(--transition-speed);
}

.panel-user-menu li a:hover {
  background: #f5f5f5;
  color: var(--primary-color);
}

.panel-user-menu li a .iconfont {
  font-size: 18px;
  margin-right: 12px;
  color: #999;
}

.panel-user-menu li a:hover .iconfont {
  color: var(--primary-color);
}

.panel-user-menu li.logout a {
  color: #999;
  border-top: 1px solid var(--border-color);
  margin-top: 10px;
  padding-top: 20px;
}

/* ========================================
   Pagination Simplification
   分页组件简化（移动端+平板端）
   只显示：上一页、下一页
   ======================================== */
@media (max-width: 991px) {
  /* 调整分页容器 */
  .pagination {
    padding: 15px 10px;
  }
  
  .pagination ul {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
  }
  
  /* 默认隐藏所有分页项 */
  .pagination ul li {
    display: none !important;
  }
  
  /* 显示上一页 */
  .pagination ul li.prev-page {
    display: inline-block !important;
  }
  
  /* 第一页时隐藏上一页按钮 */
  .pagination ul li.prev-page.disabled {
    display: none !important;
  }
  
  /* 显示下一页 */
  .pagination ul li.next-page {
    display: inline-block !important;
  }
  
  .pagination ul li a,
  .pagination ul li span {
    display: inline-block;
    padding: 10px 20px;
    font-size: 14px;
    border-radius: 4px;
    background: #f5f5f5;
    color: var(--text-color);
    transition: all var(--transition-speed);
  }
  
  .pagination ul li a:hover {
    background: var(--primary-color);
    color: #fff;
  }
}

/* ========================================
   Mobile Search Overlay
   移动端搜索 - 在顶部菜单栏显示，不使用全屏蒙层
   ======================================== */
.mobile-search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 68px; /* 只占用顶部导航栏高度 */
  background: #fff;
  z-index: 1000;
  display: none;
  flex-direction: row;
  align-items: center;
  padding: 0 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.mobile-search-overlay.show {
  display: flex;
}

.mobile-search-overlay .search-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 100%;
}

.mobile-search-overlay .search-input {
  flex: 1;
  height: 44px;
  padding: 0 15px;
  border: 1px solid var(--border-color);
  border-radius: 22px;
  font-size: 14px;
  outline: none;
}

.mobile-search-overlay .search-input:focus {
  border-color: var(--primary-color);
}

.mobile-search-overlay .search-cancel {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 14px;
  cursor: pointer;
  padding: 10px;
  flex-shrink: 0;
}

/* ========================================
   Body Lock (prevent scroll when panel open)
   ======================================== */
body.panel-open {
  overflow: hidden;
}

/* ========================================
   Index Page Adjustments
   首页布局调整
   ======================================== */
@media (max-width: 991px) {
  .cat_demo2_UI {
    margin-top: 0 !important;
  }
  
  /* ========================================
     Related Posts (相关推荐)
     文章页底部相关推荐 - 2列布局 + 固定宽高比
     ======================================== */
  .postitems ul {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -5px !important;
  }

  .postitems li {
    width: 50% !important;
    padding: 5px !important;
    margin: 0 !important;
    box-sizing: border-box;
  }

  /* 图片容器 - 保持284:160比例 (56.34%) 与首页一致 */
  .postitems li .thumbnail {
    position: relative;
    width: 100%;
    height: 0 !important;
    padding-bottom: 56.34% !important;
    overflow: hidden;
    display: block;
  }

  .postitems li .thumbnail img,
  .postitems li .thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100% !important;
    object-fit: cover;
    margin: 0 !important;
  }

  .postitems li h2 {
    font-size: 12px;
    line-height: 1.4;
    margin: 5px 0 0;
    padding: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  /* 文章标签 - 左对齐，文字垂直居中 */
  .article-tags {
    text-align: left;
  }

  .article-tags a {
    display: inline-flex;
    align-items: center;
    height: auto;
    min-height: 0;
    padding: 4px 8px;
    line-height: 1.2;
  }
}
