/* ==================== 移动端侧边栏导航样式 ==================== */

/* 只在移动设备上显示 */
@media screen and (max-width: 768px) {
  
  /* ========== 隐藏原有的导航中心区域 ========== */
  .navbar-center {
    display: none !important;
  }
  
  /* ========== 汉堡菜单按钮 ========== */
  .hamburger-button {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 44px;
    height: 44px;
    padding: 8px;
    background: transparent;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.3s ease;
    z-index: 10001;
    position: relative;
  }
  
  .hamburger-button:hover {
    background-color: rgba(255, 255, 255, 0.15);
  }
  
  .hamburger-button:active {
    transform: scale(0.95);
  }
  
  .hamburger-line {
    display: block;
    width: 24px;
    height: 2.5px;
    background-color: #fff;
    border-radius: 2px;
    transition: all 0.35s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
  }
  
  .hamburger-line:nth-child(1) {
    transform: translateY(-3px);
  }
  
  .hamburger-line:nth-child(3) {
    transform: translateY(3px);
  }
  
  /* 汉堡按钮激活状态（变成X） */
  .hamburger-button.is-active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(5px, 6px);
  }
  
  .hamburger-button.is-active .hamburger-line:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
  }
  
  .hamburger-button.is-active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -6px);
  }
  
  /* ========== 侧边栏遮罩层 ========== */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9998;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
  }
  
  .sidebar-overlay.open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
  }
  
  /* ========== 遮罩背景 ========== */
  .sidebar-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
    opacity: 0;
  }
  
  .sidebar-overlay.open .sidebar-backdrop {
    opacity: 1;
  }
  
  /* ========== 侧边栏面板 ========== */
  .sidebar-panel {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px; /* 侧边栏宽度 */
    max-width: 85vw;
    background: linear-gradient(180deg, #dc2626 0%, #b91c1c 50%, #991b1b 100%);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    transform: translateX(-100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .sidebar-overlay.open .sidebar-panel {
    transform: translateX(0);
  }
  
  /* ========== 侧边栏头部 ========== */
  .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
  }
  
  .sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
  }
  
  .sidebar-brand .brand-icon {
    font-size: 28px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  }
  
  .sidebar-brand .brand-text {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  }
  
  /* 关闭按钮 */
  .sidebar-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.25s ease;
  }
  
  .sidebar-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(90deg);
  }
  
  .sidebar-close:active {
    transform: rotate(90deg) scale(0.95);
  }
  
  /* ========== 导航菜单区域 ========== */
  .sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
  }
  
  /* ========== 菜单项 ========== */
  .sidebar-menu-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    text-decoration: none;
    color: rgba(255, 255, 255, 0.9);
    font-size: 15px;
    font-weight: 500;
    transition: all 0.25s ease;
    position: relative;
    border-left: 3px solid transparent;
    margin: 2px 12px;
    border-radius: 0 8px 8px 0;
  }
  
  .sidebar-menu-item:hover {
    background-color: rgba(255, 255, 255, 0.12);
    color: #fff;
    border-left-color: rgba(255, 255, 255, 0.5);
    transform: translateX(4px);
  }
  
  .sidebar-menu-item:active {
    transform: scale(0.98) translateX(4px);
  }
  
  /* 当前活动菜单项 */
  .sidebar-menu-item.active {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-left-color: #fcd34d;
    font-weight: 600;
  }
  
  .sidebar-menu-item.active::after {
    content: '';
    position: absolute;
    right: 16px;
    width: 6px;
    height: 6px;
    background-color: #fcd34d;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(252, 211, 77, 0.6);
  }
  
  /* 菜单图标 */
  .menu-icon {
    font-size: 20px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
  }
  
  /* 菜单文字 */
  .menu-text {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  /* ========== 用户信息区域 ========== */
  .sidebar-user {
    padding: 20px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    background-color: rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
  }
  
  .user-login-prompt {
    text-align: center;
    padding: 10px 0;
  }
  
  .user-login-prompt p {
    color: rgba(255, 255, 255, 0.7);
    margin: 0 0 12px 0;
    font-size: 14px;
  }
  
  .login-btn {
    display: inline-block;
    padding: 10px 32px;
    background: linear-gradient(135deg, #fcd34d, #f59e0b);
    color: #991b1b;
    text-decoration: none;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
  }
  
  .login-btn:hover,
  .login-btn:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.5);
  }
  
  /* ========== 导航栏布局调整 ========== */
  .navbar-container {
    position: relative !important;
  }
  
  .navbar-right {
    order: 2 !important; /* 用户信息在汉堡按钮左边 */
  }
  
  .hamburger-button {
    order: 3 !important; /* 汉堡按钮在最右边 */
  }
}

/* ==================== 平板设备适配（768px - 1024px）==================== */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  /* 在平板上也可以显示侧边栏，但可选 */
  .hamburger-button {
    display: none !important; /* 平板默认隐藏，可改为flex显示 */
  }
  
  .sidebar-overlay {
    display: none !important;
  }
}

/* ==================== 大屏幕隐藏侧边栏 ==================== */
@media screen and (min-width: 769px) {
  .hamburger-button {
    display: none !important;
  }
  
  .sidebar-overlay {
    display: none !important;
  }
  
  /* 恢复桌面端的导航中心显示 */
  .navbar-center {
    display: flex !important;
  }
}

/* ==================== 安全区域适配（iPhone X系列）==================== */
@supports (padding: max(0px)) {
  @media screen and (max-width: 768px) {
    .sidebar-panel {
      padding-bottom: env(safe-area-inset-bottom);
    }
    
    .sidebar-header {
      padding-top: calc(20px + env(safe-area-inset-top));
    }
    
    .hamburger-button {
      margin-bottom: env(safe-area-inset-bottom);
    }
  }
}

/* ==================== 动画增强效果 ==================== */
@media screen and (max-width: 768px) {
  /* 菜单项入场动画 */
  .sidebar-overlay.open .sidebar-menu-item {
    animation: slideInRight 0.4s ease backwards;
  }
  
  .sidebar-overlay.open .sidebar-menu-item:nth-child(1) { animation-delay: 0.05s; }
  .sidebar-overlay.open .sidebar-menu-item:nth-child(2) { animation-delay: 0.1s; }
  .sidebar-overlay.open .sidebar-menu-item:nth-child(3) { animation-delay: 0.15s; }
  .sidebar-overlay.open .sidebar-menu-item:nth-child(4) { animation-delay: 0.2s; }
  .sidebar-overlay.open .sidebar-menu-item:nth-child(5) { animation-delay: 0.25s; }
  .sidebar-overlay.open .sidebar-menu-item:nth-child(6) { animation-delay: 0.3s; }
  .sidebar-overlay.open .sidebar-menu-item:nth-child(7) { animation-delay: 0.35s; }
  .sidebar-overlay.open .sidebar-menu-item:nth-child(8) { animation-delay: 0.4s; }
  .sidebar-overlay.open .sidebar-menu-item:nth-child(9) { animation-delay: 0.45s; }
  .sidebar-overlay.open .sidebar-menu-item:nth-child(10) { animation-delay: 0.5s; }
  
  @keyframes slideInRight {
    from {
      opacity: 0;
      transform: translateX(-30px);
    }
    to {
      opacity: 1;
      transform: translateX(0);
    }
  }
  
  /* 触摸反馈效果 */
  .sidebar-menu-item {
    -webkit-tap-highlight-color: transparent;
  }
  
  /* 滚动条美化 */
  .sidebar-panel::-webkit-scrollbar {
    width: 4px;
  }
  
  .sidebar-panel::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .sidebar-panel::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
  }
  
  .sidebar-panel::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.5);
  }
  
  .sidebar-nav::-webkit-scrollbar {
    width: 4px;
  }
  
  .sidebar-nav::-webkit-scrollbar-track {
    background: transparent;
  }
  
  .sidebar-nav::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
  }
}
