﻿/**
 * Mobile Responsive Styles
 * 移动端响应式样式优化
 * 
 * 断点定义:
 * - 1024px: 平板横屏及以下
 * - 768px: 平板竖屏及以下  
 * - 640px: 大屏手机
 * - 480px: 标准手机
 * - 375px: 小屏手机
 */

/* ============================================
   移动端基础优化
   ============================================ */

/* 添加更好的触摸体验 */
@media (max-width: 1024px) {
  * {
    -webkit-tap-highlight-color: transparent;
  }

  /* 增大可点击区域 */
  button,
  a,
  .btn,
  input[type="button"],
  input[type="submit"] {
    min-height: 44px;
    min-width: 44px;
  }

  /* 防止文字选中影响交互 */
  .ts-nav,
  .panel__cta,
  .ios-profile-actions {
    -webkit-user-select: none;
    user-select: none;
  }
}

/* ============================================
   平板适配 (768px - 1024px)
   ============================================ */

@media (max-width: 1024px) and (min-width: 769px) {
  .section {
    padding: 48px 20px;
  }

  .ts-nav {
    padding: 0 20px;
  }

  .panel__title {
    font-size: clamp(32px, 5vw, 42px);
  }

  /* 弹窗优化 */
  .modal-content {
    max-width: 90%;
  }

  /* FRP弹窗适配 */
  #frp-modal .modal-content {
    max-width: 480px;
  }
}

/* ============================================
   平板竖屏及以下 (max-width: 768px)
   ============================================ */

@media (max-width: 768px) {

  /* 导航栏优化 */
  .ts-nav {
    height: 56px;
    padding: 0 16px;
    grid-template-columns: auto 1fr auto;
  }

  .ts-nav__logo {
    font-size: 15px;
    letter-spacing: 1.5px;
  }

  .ts-nav__btn {
    padding: 8px 12px;
    font-size: 13px;
  }

  /* 主面板优化 */
  .panel__content {
    padding: 16px;
  }

  .panel__title {
    font-size: 28px !important;
    line-height: 1.2;
    margin-bottom: 8px;
  }

  .panel__subtitle {
    font-size: 15px !important;
    line-height: 1.4;
  }

  /* 按钮组优化 */
  .panel__cta {
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    padding: 0 16px;
    padding-bottom: 120px;
  }

  .panel__cta .btn {
    width: 100%;
  }

  /* 状态栏优化 */
  .ts-status {
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
    max-width: calc(100% - 32px);
    bottom: 16px;
  }

  .ts-status__item {
    font-size: 13px;
    width: 100%;
    justify-content: space-between;
  }

  /* 卡片优化 */
  .ios-profile-card,
  .ios-bind-card {
    margin: 16px auto 0;
    padding: 20px 16px;
    padding-bottom: 100px;
    border-radius: 20px;
    max-width: calc(100% - 24px);
  }

  .ios-profile-header {
    gap: 12px;
    padding-bottom: 20px;
    margin-bottom: 20px;
  }

  .ios-avatar {
    width: 72px;
    height: 72px;
  }

  .ios-nickname {
    font-size: 22px;
    letter-spacing: -0.5px;
  }

  /* 输入框优化 */
  .ios-input {
    padding: 14px 16px;
    font-size: 16px;
    /* 防止iOS自动缩放 */
    border-radius: 12px;
  }

  /* 按钮优化 */
  .ios-btn {
    padding: 14px 20px;
    font-size: 15px;
    border-radius: 12px;
  }

  .ios-profile-actions {
    gap: 12px;
  }

  /* 弹窗优化 */
  .modal-overlay {
    padding: 12px;
    align-items: flex-end;
  }

  .modal-content {
    max-width: 100%;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    margin-bottom: 0;
    animation: modalSlideUpMobile 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes modalSlideUpMobile {
    from {
      transform: translateY(100%);
      opacity: 0;
    }

    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  .modal-header {
    padding: 20px 20px;
    position: sticky;
    top: 0;
    background: inherit;
    z-index: 10;
  }

  .modal-title {
    font-size: 18px;
  }

  .modal-body {
    padding: 16px 20px 24px;
    max-height: calc(85vh - 80px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* FRP弹窗特殊优化 */
  #frp-modal .modal-content {
    max-height: 90vh;
  }

  #frp-modal .modal-body {
    max-height: calc(90vh - 80px);
  }

  /* SakuraFrp视图优化 */
  #frp-sakura-view .sakura-section {
    padding: 12px;
    border-radius: 10px;
    margin-bottom: 16px;
  }

  #sakura-nodes-container {
    max-height: 200px !important;
  }

  /* 成功弹窗优化 */
  #frp-success-modal .modal-content {
    max-width: 100%;
    border-radius: 20px 20px 0 0;
  }

  #success-ip-display {
    font-size: 18px !important;
    padding: 16px !important;
    word-break: break-all;
  }

  /* 申请修改ID弹窗优化 */
  #change-id-modal .modal-content {
    max-width: 100%;
  }
}

/* ============================================
   大屏手机 (max-width: 640px)
   ============================================ */

@media (max-width: 640px) {

  /* 导航栏进一步压缩 */
  .ts-nav {
    height: 52px;
  }

  .ts-nav__logo {
    font-size: 14px;
  }

  /* 标题缩小 */
  .panel__title {
    font-size: 24px !important;
  }

  .panel__subtitle {
    font-size: 14px !important;
  }

  /* 卡片进一步优化 */
  .ios-profile-card,
  .ios-bind-card {
    padding: 16px 14px;
    padding-bottom: 90px;
    border-radius: 18px;
  }

  .ios-avatar {
    width: 64px;
    height: 64px;
  }

  .ios-nickname {
    font-size: 20px;
  }

  /* 按钮操作区域 */
  .ios-profile-actions {
    gap: 10px;
  }

  .ios-btn {
    padding: 13px 16px;
    font-size: 14px;
  }

  /* IP显示优化 */
  #profile-ip {
    font-size: 14px !important;
    padding: 6px 10px !important;
  }

  /* 弹窗进一步优化 */
  .modal-header {
    padding: 16px;
  }

  .modal-body {
    padding: 14px 16px 20px;
  }

  /* QQ登录按钮 */
  #btn-qq-login {
    height: 48px !important;
    font-size: 16px !important;
    border-radius: 14px !important;
  }

  /* 免责声明弹窗优化 */
  .disclaimer-modal__content {
    padding: 16px 14px;
    max-height: 85vh;
  }

  .disclaimer-modal__title {
    font-size: 18px;
    margin-bottom: 14px;
  }

  .disclaimer-modal__text {
    max-height: 55vh;
    font-size: 12px;
    line-height: 1.6;
  }

  .disclaimer-modal__text p {
    font-size: 12px;
    margin-bottom: 8px;
  }

  /* 公告弹窗优化 */
  .news-modal__content {
    padding: 16px 14px;
  }

  .news-modal__title {
    font-size: 18px;
  }

  .news-modal__text {
    max-height: 55vh;
    font-size: 12px;
  }
}

/* ============================================
   标准手机 (max-width: 480px)
   ============================================ */

@media (max-width: 480px) {

  /* 边距进一步减少 */
  .section {
    padding: 32px 12px;
  }

  .ts-nav {
    height: 48px;
    padding: 0 12px;
  }

  .ts-nav__logo {
    font-size: 13px;
    letter-spacing: 1px;
  }

  /* 标题 */
  .panel__title {
    font-size: 22px !important;
  }

  .panel__subtitle {
    font-size: 13px !important;
  }

  /* 卡片 */
  .ios-profile-card,
  .ios-bind-card {
    padding: 14px 12px;
    padding-bottom: 80px;
    margin: 12px auto 0;
    max-width: calc(100% - 16px);
    border-radius: 16px;
  }

  .ios-profile-header {
    gap: 10px;
    padding-bottom: 16px;
    margin-bottom: 16px;
  }

  .ios-avatar {
    width: 56px;
    height: 56px;
    border-width: 3px;
  }

  .ios-nickname {
    font-size: 18px;
  }

  /* 输入和按钮 */
  .ios-input {
    padding: 12px 14px;
    font-size: 16px;
    border-radius: 10px;
  }

  .ios-btn {
    padding: 12px 14px;
    font-size: 14px;
    border-radius: 10px;
  }

  .ios-profile-actions {
    gap: 8px;
  }

  /* 绑定卡片标题 */
  .ios-bind-title {
    font-size: 20px;
    margin-bottom: 8px;
  }

  .ios-bind-desc {
    font-size: 14px;
  }

  /* 弹窗 */
  .modal-content {
    border-radius: 16px 16px 0 0;
  }

  .modal-header {
    padding: 14px;
  }

  .modal-title {
    font-size: 16px;
  }

  .modal-close {
    width: 28px;
    height: 28px;
    font-size: 18px;
  }

  .modal-body {
    padding: 12px 14px 16px;
  }

  /* FRP配置优化 */
  #frp-config-input {
    height: 140px !important;
    font-size: 12px !important;
  }

  /* SakuraFrp优化 */
  #frp-sakura-view .sakura-section {
    padding: 10px;
    margin-bottom: 12px;
  }

  #sakura-token-input,
  #sakura-port-input {
    font-size: 15px;
  }

  .toggle-switch {
    width: 46px !important;
    height: 28px !important;
  }

  .toggle-switch .toggle-slider:before {
    height: 24px !important;
    width: 24px !important;
  }

  #sakura-nodes-container {
    max-height: 180px !important;
    padding: 6px !important;
  }

  /* 成功弹窗 */
  #success-ip-display {
    font-size: 16px !important;
    padding: 14px !important;
  }

  /* 底部固定元素 */

  /* Toast提示优化 */
  .ios-toast {
    top: 60px;
    max-width: calc(100% - 24px);
    padding: 10px 14px;
    font-size: 13px;
    border-radius: 12px;
  }
}

/* ============================================
   小屏手机 (max-width: 375px)
   ============================================ */

@media (max-width: 375px) {
  .ts-nav {
    height: 44px;
    padding: 0 10px;
  }

  .ts-nav__logo {
    font-size: 12px;
  }

  .panel__title {
    font-size: 20px !important;
  }

  .panel__subtitle {
    font-size: 12px !important;
  }

  /* 卡片 */
  .ios-profile-card,
  .ios-bind-card {
    padding: 12px 10px;
    padding-bottom: 70px;
    border-radius: 14px;
  }

  .ios-avatar {
    width: 48px;
    height: 48px;
    border-width: 2px;
  }

  .ios-nickname {
    font-size: 16px;
  }

  .ios-btn {
    padding: 10px 12px;
    font-size: 13px;
    border-radius: 8px;
  }

  /* 绑定卡片 */
  .ios-bind-title {
    font-size: 18px;
  }

  .ios-bind-desc {
    font-size: 13px;
  }

  /* 弹窗 */
  .modal-header {
    padding: 12px;
  }

  .modal-title {
    font-size: 15px;
  }

  .modal-body {
    padding: 10px 12px 14px;
  }

  /* 免责声明 */
  .disclaimer-modal__content {
    padding: 14px 10px;
  }

  .disclaimer-modal__title {
    font-size: 16px;
  }

  .disclaimer-modal__text {
    font-size: 11px;
  }

  .disclaimer-modal__text p {
    font-size: 11px;
  }
}

/* ============================================
   横屏模式优化
   ============================================ */

@media (max-height: 500px) and (orientation: landscape) {
  .panel {
    min-height: auto;
    padding: 20px 0;
  }

  .panel__content {
    padding-top: 20px !important;
  }

  .panel__cta {
    padding-bottom: 60px;
  }

  .ts-status {
    bottom: 10px;
    padding: 6px 10px;
    gap: 8px;
  }

  .ts-status__item {
    font-size: 11px;
  }

  /* 卡片横屏优化 */
  .ios-profile-card,
  .ios-bind-card {
    padding-bottom: 60px;
    max-width: 500px;
  }

  /* 弹窗横屏优化 */
  .modal-overlay {
    align-items: center;
  }

  .modal-content {
    max-height: 90vh;
    border-radius: 16px;
  }

  .modal-body {
    max-height: calc(90vh - 60px);
  }
}

/* ============================================
   安全区域适配 (刘海屏/圆角屏)
   ============================================ */

@supports (padding: env(safe-area-inset-top)) {
  .ts-nav {
    padding-top: env(safe-area-inset-top);
    height: calc(56px + env(safe-area-inset-top));
  }

  .panel__content {
    padding-top: calc(56px + env(safe-area-inset-top));
  }

  .modal-content {
    padding-bottom: env(safe-area-inset-bottom);
  }

  @media (max-width: 768px) {
    .modal-overlay {
      padding-bottom: env(safe-area-inset-bottom);
    }

    .panel__cta {
      padding-bottom: calc(120px + env(safe-area-inset-bottom));
    }

    .ios-profile-card,
    .ios-bind-card {
      padding-bottom: calc(100px + env(safe-area-inset-bottom));
    }
  }
}

/* ============================================
   深色模式移动端优化
   ============================================ */

@media (max-width: 768px) {

  [data-theme="dark"] .ios-profile-card,
  [data-theme="dark"] .ios-bind-card {
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  }

  [data-theme="dark"] .modal-content {
    border-color: rgba(255, 255, 255, 0.1);
  }

  [data-theme="dark"] .ios-input {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.1);
  }

  [data-theme="dark"] .ios-toast {
    background: rgba(40, 40, 42, 0.95);
  }
}

/* ============================================
   触摸反馈优化
   ============================================ */

@media (hover: none) and (pointer: coarse) {
  .ios-btn:active {
    transform: scale(0.97);
    opacity: 0.9;
  }

  .btn:active {
    transform: translateY(0) scale(0.98);
  }

  /* 移除hover效果，使用active效果 */
  .ios-btn:hover {
    transform: none;
    box-shadow: inherit;
  }

  .btn:hover {
    transform: none;
  }

  /* 卡片触摸效果 */
  .ios-profile-card:active {
    transform: scale(0.99);
  }

  .ios-profile-card:hover {
    transform: none;
    box-shadow: inherit;
  }
}

/* ============================================
   滚动优化
   ============================================ */

@media (max-width: 768px) {

  .modal-body,
  .disclaimer-modal__text,
  .news-modal__text,
  #sakura-nodes-container {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* 隐藏滚动条但保持功能 */
  .modal-body::-webkit-scrollbar,
  .disclaimer-modal__text::-webkit-scrollbar,
  .news-modal__text::-webkit-scrollbar {
    width: 4px;
  }

  .modal-body::-webkit-scrollbar-track,
  .disclaimer-modal__text::-webkit-scrollbar-track,
  .news-modal__text::-webkit-scrollbar-track {
    background: transparent;
  }

  .modal-body::-webkit-scrollbar-thumb,
  .disclaimer-modal__text::-webkit-scrollbar-thumb,
  .news-modal__text::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 2px;
  }

  [data-theme="dark"] .modal-body::-webkit-scrollbar-thumb,
  [data-theme="dark"] .disclaimer-modal__text::-webkit-scrollbar-thumb,
  [data-theme="dark"] .news-modal__text::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
  }
}

/* ============================================
   加载状态优化
   ============================================ */

@media (max-width: 768px) {

  #loading,
  #requests-loading {
    min-height: 150px !important;
  }

  .loading-spinner {
    width: 28px;
    height: 28px;
  }
}

/* ============================================
   管理后台移动端优化
   ============================================ */

@media (max-width: 768px) {
  .admin-container {
    padding: 16px 12px;
    padding-bottom: 100px;
  }

  .admin-header {
    margin-bottom: 16px;
  }

  .admin-title {
    font-size: 22px !important;
  }

  .admin-tabs {
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 12px;
  }

  .admin-tabs__left {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .admin-tabs__left::-webkit-scrollbar {
    display: none;
  }

  .admin-tab {
    padding: 10px 14px;
    font-size: 13px;
    white-space: nowrap;
  }

  .btn-refresh {
    position: fixed;
    bottom: 20px;
    right: 16px;
    z-index: 100;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .btn-refresh .refresh-text {
    display: none;
  }

  /* 卡片式布局优化 */
  .admin-card {
    padding: 14px;
    margin-bottom: 10px;
  }

  .admin-card__header .user-avatar {
    width: 44px !important;
    height: 44px !important;
  }

  .admin-card__nickname {
    font-size: 14px;
  }

  .admin-card__actions {
    width: 100%;
    min-width: unset;
    flex-direction: row;
    margin-top: 12px;
  }

  .admin-card__actions .btn {
    flex: 1;
    padding: 10px;
    font-size: 12px;
  }

  .admin-card__content {
    flex-direction: column;
  }

  .admin-card__left {
    margin-right: 0;
  }
}

/* ============================================
   打印样式优化
   ============================================ */

@media print {

  .ts-nav,
  .ts-status,
  .panel__cta {
    display: none !important;
  }

  .modal-overlay,
  .news-modal,
  .disclaimer-modal {
    display: none !important;
  }

  body {
    background: white !important;
  }

  .panel {
    min-height: auto !important;
  }
}