/**
 * 锦玥图像引擎 - 移动端优化CSS v3.0（清理版）
 * 系统性移动端适配方案，无重复规则
 * 设计原则：触摸友好、内容优先、流畅交互
 */

/* ============================================
   1. 全局移动端优化
   ============================================ */

* {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

html {
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

body {
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   2. Header导航栏（始终显示）
   ============================================ */

.header {
  display: block;
  position: relative;
  z-index: 100000;
  min-height: 60px;
  padding: 10px 16px;
  background: rgba(15, 15, 35, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.logo-icon img {
  height: 32px;
  width: auto;
  display: block;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ============================================
   3. 语言切换器（始终显示图标按钮）
   ============================================ */

.lang-switcher {
  display: inline-block;
  position: relative;
  z-index: 100001;
}

.lang-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  color: white;
  cursor: pointer;
}

.lang-icon {
  font-size: 18px;
  display: block;
}

.lang-current,
.lang-arrow {
  display: none;
}

/* 语言下拉菜单：默认隐藏，点击后底部弹出 */
.lang-dropdown {
  display: none;
  position: fixed;
  top: auto;
  bottom: 0;
  left: 0;
  right: 0;
  min-width: 100%;
  max-height: 70vh;
  overflow-y: auto;
  border-radius: 20px 20px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  z-index: 99999;
  background: rgba(20, 20, 45, 0.99);
  box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
}

.lang-dropdown.show {
  display: block;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 14px 16px;
  border-radius: 12px;
  color: white;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.2s;
}

.lang-option:hover,
.lang-option:active {
  background: rgba(255, 255, 255, 0.1);
}

.lang-option.active {
  background: rgba(102, 126, 234, 0.3);
  border: 1px solid rgba(102, 126, 234, 0.5);
}

.lang-flag {
  font-size: 24px;
  flex-shrink: 0;
}

/* ============================================
   4. 汉堡菜单按钮（始终显示）
   ============================================ */

.mobile-menu-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  cursor: pointer;
  z-index: 100001;
}

.mobile-menu-toggle span {
  display: block;
  width: 20px;
  height: 2px;
  background: white;
  border-radius: 2px;
}

/* ============================================
   5. 移动端菜单（默认隐藏，点击后全屏显示）
   ============================================ */

.mobile-menu {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 15, 35, 0.99);
  z-index: 99998;
  overflow-y: auto;
  padding-top: 70px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.mobile-menu.show {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.mobile-menu-content {
  padding: 16px;
  max-width: 100%;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 14px 16px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 16px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 4px;
  transition: background 0.2s;
}

.mobile-nav-link:hover,
.mobile-nav-link:active,
.mobile-nav-link.active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.mobile-nav-link.mobile-register {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  justify-content: center;
  font-weight: 600;
  margin-top: 12px;
  min-height: 56px;
}

.mobile-menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 12px 0;
}

/* ============================================
   6. 桌面端导航在移动端隐藏
   ============================================ */

@media (max-width: 1024px) {
  .nav {
    display: none;
  }

  .header-actions .btn-ghost {
    display: none;
  }

  .header-actions .btn-primary {
    display: none;
  }
}

/* ============================================
   7. Hero区域移动端优化
   ============================================ */

@media (max-width: 1024px) {
  .hero {
    padding: 40px 0;
  }

  .hero-title {
    font-size: 36px;
    line-height: 1.2;
  }

  .hero-subtitle {
    font-size: 15px;
    line-height: 1.7;
  }

  .hero-badge {
    font-size: 13px;
    padding: 8px 16px;
  }
}

@media (max-width: 768px) {
  .hero {
    padding: 30px 0;
    text-align: center;
  }

  .hero-title {
    font-size: 28px;
    line-height: 1.3;
    margin-bottom: 16px;
  }

  .hero-subtitle {
    font-size: 14px;
    line-height: 1.8;
    margin-bottom: 24px;
  }

  .hero-badge {
    font-size: 12px;
    padding: 6px 14px;
    margin-bottom: 20px;
  }

  .hero-actions {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 32px;
  }

  .hero-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 52px;
    font-size: 16px;
  }

  .hero-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .hero-stat {
    padding: 20px 16px;
  }

  .hero-stat-value {
    font-size: 28px;
    margin-bottom: 4px;
  }

  .hero-stat-label {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 24px;
  }

  .hero-subtitle {
    font-size: 13px;
  }

  .hero-stat-value {
    font-size: 24px;
  }
}

/* ============================================
   8. 工具卡片移动端布局
   ============================================ */

@media (max-width: 1024px) {
  .tools-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
}

@media (max-width: 768px) {
  .tools-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .tool-card {
    padding: 20px 16px;
    min-height: 160px;
  }

  .tool-icon {
    font-size: 32px;
    margin-bottom: 12px;
  }

  .tool-title {
    font-size: 14px;
    margin-bottom: 8px;
    line-height: 1.4;
  }

  .tool-desc {
    font-size: 12px;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .tool-arrow {
    font-size: 12px;
    margin-top: 12px;
  }

  .tool-badge {
    font-size: 10px;
    padding: 2px 6px;
  }
}

@media (max-width: 480px) {
  .tools-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .tool-card {
    padding: 18px 16px;
    min-height: auto;
    display: flex;
    align-items: center;
    gap: 16px;
  }

  .tool-icon {
    font-size: 36px;
    margin-bottom: 0;
    flex-shrink: 0;
  }

  .tool-content {
    flex: 1;
  }

  .tool-title {
    font-size: 15px;
    margin-bottom: 4px;
  }

  .tool-desc {
    font-size: 12px;
    -webkit-line-clamp: 2;
  }

  .tool-arrow {
    display: none;
  }
}

/* ============================================
   9. 特性卡片移动端优化
   ============================================ */

@media (max-width: 1024px) {
  .features-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
}

@media (max-width: 768px) {
  .features-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .feature-card {
    padding: 24px 20px;
  }

  .feature-icon {
    font-size: 36px;
    margin-bottom: 16px;
  }

  .feature-title {
    font-size: 18px;
    margin-bottom: 10px;
  }

  .feature-desc {
    font-size: 14px;
    line-height: 1.7;
  }
}

/* ============================================
   10. 页脚移动端优化
   ============================================ */

@media (max-width: 1024px) {
  .footer-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 32px;
  }
}

@media (max-width: 768px) {
  .footer {
    padding: 40px 0 24px;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 28px;
    text-align: center;
  }

  .footer-brand {
    text-align: center;
  }

  .footer-brand img {
    margin: 0 auto 16px;
  }

  .footer-brand p {
    font-size: 13px;
    line-height: 1.7;
  }

  .footer-title {
    font-size: 16px;
    margin-bottom: 16px;
  }

  .footer-links li {
    margin-bottom: 10px;
  }

  .footer-links a {
    font-size: 14px;
    padding: 8px 0;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }

  .footer-bottom {
    flex-direction: column;
    text-align: center;
    gap: 8px;
    padding-top: 24px;
    margin-top: 32px;
    font-size: 12px;
  }
}

/* ============================================
   11. 通用区块移动端优化
   ============================================ */

@media (max-width: 768px) {
  .section {
    padding: 40px 0;
  }

  .section-header {
    margin-bottom: 28px;
    text-align: center;
  }

  .section-title {
    font-size: 24px;
    margin-bottom: 8px;
  }

  .section-subtitle {
    font-size: 14px;
    line-height: 1.6;
  }

  .container {
    padding: 0 16px;
  }

  .glass-card {
    border-radius: 16px;
  }

  .btn {
    min-height: 48px;
    font-size: 15px;
    padding: 12px 24px;
  }

  .btn-lg {
    min-height: 54px;
    font-size: 16px;
    padding: 14px 28px;
  }
}

@media (max-width: 480px) {
  .section {
    padding: 32px 0;
  }

  .section-title {
    font-size: 20px;
  }

  .container {
    padding: 0 12px;
  }
}

/* ============================================
   12. 工具页面通用移动端优化
   ============================================ */

@media (max-width: 768px) {
  .editor-container,
  .tool-container,
  .workspace {
    padding: 16px;
    border-radius: 12px;
  }

  .toolbar,
  .controls {
    flex-wrap: wrap;
    gap: 8px;
  }

  .toolbar button,
  .controls button,
  .control-group button {
    min-height: 44px;
    min-width: 44px;
    font-size: 14px;
    padding: 8px 12px;
  }

  input[type="range"] {
    height: 40px;
  }

  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  select,
  textarea {
    min-height: 48px;
    font-size: 16px;
    padding: 12px 16px;
  }

  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

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

  .tab {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 14px;
    white-space: nowrap;
  }

  .upload-area,
  .drop-zone {
    min-height: 120px;
    padding: 24px 16px;
  }

  .preview-container,
  .canvas-wrapper {
    max-height: 50vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .action-buttons {
    flex-direction: column;
    gap: 10px;
  }

  .action-buttons .btn {
    width: 100%;
  }
}

/* ============================================
   13. 触摸友好优化
   ============================================ */

@media (hover: none) and (pointer: coarse) {
  .tool-card:active,
  .feature-card:active,
  .btn:active,
  .nav-link:active,
  .mobile-nav-link:active,
  .lang-option:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }

  .tool-card:hover,
  .feature-card:hover {
    transform: none;
  }
}

/* ============================================
   14. iPhone安全区域适配
   ============================================ */

@supports (padding: max(0px)) {
  .header {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .footer {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
}

/* ============================================
   15. 性能优化
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 768px) {
  .glass-card {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
  }

  .bg-layer {
    background-attachment: scroll;
  }
}

/* ============================================
   16. 主内容层级
   ============================================ */

.main {
  position: relative;
  z-index: 1;
}

/* ============================================
   17. 工具页面通用移动端适配（深度优化）
   ============================================ */

@media (max-width: 768px) {
  /* 页面标题 */
  .page-title {
    font-size: 22px;
    margin-bottom: 16px;
    text-align: center;
  }

  /* 主内容区 */
  .main {
    padding: 16px 0;
  }

  .container {
    padding: 0 12px;
  }

  /* 面板 */
  .panel {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
  }

  .panel-title {
    font-size: 16px;
    margin-bottom: 12px;
    padding-bottom: 8px;
  }

  /* 选项组 */
  .option-group {
    margin-bottom: 16px;
  }

  .option-label {
    font-size: 14px;
    margin-bottom: 8px;
    display: block;
  }

  /* 滑块 */
  .slider {
    width: 100%;
    height: 40px;
    margin: 8px 0;
  }

  .slider-group {
    margin-bottom: 16px;
  }

  .slider-label {
    font-size: 14px;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .slider-value {
    font-size: 14px;
    font-weight: 600;
    color: #667eea;
    min-width: 50px;
    text-align: right;
  }

  /* 表单 */
  .form-group {
    margin-bottom: 16px;
  }

  .form-group label {
    font-size: 14px;
    margin-bottom: 6px;
    display: block;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    width: 100%;
    min-height: 48px;
    font-size: 16px;
    padding: 12px 16px;
    border-radius: 10px;
  }

  /* 按钮通用 */
  .btn,
  .upload-btn,
  .preset-btn,
  .action-btn {
    min-height: 48px;
    font-size: 15px;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
  }

  .btn:active,
  .upload-btn:active,
  .preset-btn:active,
  .action-btn:active {
    transform: scale(0.98);
  }

  .btn-primary,
  .action-btn.primary {
    width: 100%;
    justify-content: center;
  }

  .btn-secondary,
  .action-btn.secondary {
    width: 100%;
    justify-content: center;
  }

  .btn-danger,
  .action-btn.danger {
    width: 100%;
    justify-content: center;
  }

  /* 按钮组 */
  .btn-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
  }

  .btn-group .btn,
  .btn-group .action-btn {
    width: 100%;
  }

  /* Canvas区域 */
  .canvas-area {
    width: 100%;
    margin-bottom: 16px;
  }

  .canvas-wrapper {
    width: 100%;
    max-height: 50vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
  }

  .canvas-wrapper canvas {
    max-width: 100%;
    height: auto;
  }

  .canvas-header {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
  }

  .canvas-info {
    font-size: 12px;
    flex-wrap: wrap;
  }

  /* Canvas标签页 */
  .canvas-tabs,
  .toolbar-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }

  .canvas-tabs::-webkit-scrollbar,
  .toolbar-tabs::-webkit-scrollbar {
    display: none;
  }

  .canvas-tab,
  .toolbar-tab {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 14px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* 工具栏 */
  .toolbar {
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
  }

  .toolbar-content {
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .toolbar-header {
    width: 100%;
    margin-bottom: 8px;
  }

  .toolbar button,
  .toolbar .btn,
  .toolbar .action-btn {
    min-height: 44px;
    min-width: 44px;
    font-size: 14px;
    padding: 8px 12px;
  }

  /* 控制面板 */
  .control-panel,
  .action-panel {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
  }

  .action-title {
    font-size: 16px;
    margin-bottom: 12px;
  }

  /* 上传区域 */
  .drop-zone,
  .upload-area {
    min-height: 140px;
    padding: 24px 16px;
    border-radius: 12px;
    border-width: 2px;
  }

  .drop-zone h3,
  .upload-area h3 {
    font-size: 16px;
    margin-bottom: 8px;
  }

  .drop-zone p,
  .upload-area p {
    font-size: 13px;
    line-height: 1.6;
  }

  /* 颜色选择器 */
  .color-picker {
    width: 100%;
    min-height: 48px;
  }

  /* 滤镜网格 */
  .filter-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* 历史记录 */
  .history-list {
    max-height: 200px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 文本输入 */
  .text-input {
    width: 100%;
    min-height: 48px;
    font-size: 16px;
    padding: 12px 16px;
    border-radius: 10px;
  }

  /* 相关工具 */
  .related-tools {
    margin-top: 32px;
    padding-top: 24px;
  }

  .related-tools h3 {
    font-size: 18px;
    margin-bottom: 16px;
    text-align: center;
  }

  .related-tools-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .related-tool {
    padding: 16px 12px;
    border-radius: 12px;
    text-align: center;
  }

  .related-tool .tool-icon {
    font-size: 28px;
    margin-bottom: 8px;
  }

  .related-tool .tool-title {
    font-size: 13px;
    line-height: 1.4;
  }

  /* 广告位 */
  .ad-slot {
    margin: 16px 0;
    padding: 12px;
    border-radius: 10px;
  }

  .ad-tool-bottom {
    margin-top: 24px;
  }

  /* 空状态 */
  .empty-state {
    padding: 40px 20px;
    text-align: center;
  }

  .empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
  }

  .empty-text {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
  }

  .empty-hint {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
  }

  /* 批量处理 */
  .batch-list {
    max-height: 300px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .batch-progress {
    width: 100%;
    height: 8px;
    border-radius: 4px;
  }

  /* 比较滑块 */
  .cmp-slider {
    width: 100%;
  }

  .cmp-handle {
    width: 40px;
    height: 40px;
  }

  /* 预设按钮网格 */
  .preset-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .preset-btn {
    min-height: 44px;
    font-size: 13px;
    padding: 8px;
  }
}

@media (max-width: 480px) {
  /* 小屏进一步优化 */
  .page-title {
    font-size: 20px;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }

  .related-tools-grid {
    grid-template-columns: 1fr;
  }

  .preset-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .panel {
    padding: 12px;
  }

  .canvas-wrapper {
    max-height: 45vh;
  }
}
