/**
 * Quick Tools - PWA Styles
 * PWA 相关样式，包括安装提示、Toast、移动端优化等
 */

/* ============================================
   PWA 安装提示样式
   ============================================ */

/* Android 安装提示 */
.pwa-install-prompt {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
  width: calc(100% - 32px);
  max-width: 400px;
}

.pwa-install-prompt.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.pwa-prompt-content {
  display: flex;
  align-items: center;
  background: #ffffff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  gap: 12px;
}

[data-theme="dark"] .pwa-prompt-content {
  background: #1e1e1e;
}

.pwa-prompt-icon {
  font-size: 32px;
  flex-shrink: 0;
}

.pwa-prompt-text {
  flex: 1;
  min-width: 0;
}

.pwa-prompt-title {
  font-size: 16px;
  font-weight: 600;
  color: #2c3e50;
  margin-bottom: 4px;
}

[data-theme="dark"] .pwa-prompt-title {
  color: #e0e0e0;
}

.pwa-prompt-desc {
  font-size: 13px;
  color: #7f8c8d;
}

[data-theme="dark"] .pwa-prompt-desc {
  color: #a0a0a0;
}

.pwa-prompt-btn {
  background: #2DBAA3;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s;
}

.pwa-prompt-btn:hover {
  background: #25a08c;
}

.pwa-prompt-close {
  background: none;
  border: none;
  color: #7f8c8d;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}

/* iOS 安装引导 */
.pwa-install-guide {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.pwa-guide-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.65);
}

.pwa-guide-content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 320px;
}

.pwa-guide-box {
  background: #ffffff;
  border-radius: 20px;
  padding: 28px 24px 20px;
  text-align: center;
  position: relative;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.pwa-guide-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border: none;
  background: #f0f0f0;
  border-radius: 50%;
  font-size: 14px;
  color: #7f8c8d;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pwa-guide-title {
  font-size: 20px;
  font-weight: 700;
  color: #2c3e50;
  margin-bottom: 24px;
  margin-top: 4px;
}

.pwa-guide-steps {
  text-align: left;
  margin-bottom: 24px;
}

.pwa-guide-step {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 15px;
  color: #2c3e50;
  line-height: 1.5;
}

.step-num {
  width: 28px;
  height: 28px;
  background: #2DBAA3;
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

.share-icon {
  font-size: 20px;
  margin-left: 4px;
}

.pwa-guide-btn {
  background: #2DBAA3;
  color: white;
  border: none;
  padding: 14px 32px;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s;
}

.pwa-guide-btn:active {
  background: #25a08c;
}

/* 向下的箭头指示 - 指向底部工具栏 */
.pwa-guide-arrow-wrapper {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.pwa-guide-arrow-down {
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 12px solid #2DBAA3;
  animation: bounceDown 1.5s infinite;
}

@keyframes bounceDown {
  0%, 100% { transform: translateY(0); opacity: 0.6; }
  50% { transform: translateY(6px); opacity: 1; }
}

/* ============================================
   Toast 提示样式
   ============================================ */

.pwa-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 14px;
  z-index: 10001;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.pwa-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ============================================
   移动端优化样式
   ============================================ */

/* 触摸反馈 */
@media (hover: none) {
  .btn:active,
  .tool-card:active,
  .action-item:active {
    transform: scale(0.96);
    opacity: 0.8;
  }
}

/* 移动端底部安全区域 */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .pwa-install-prompt {
    bottom: calc(20px + env(safe-area-inset-bottom));
  }
  
  footer {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
}

/* 禁止文本选择（提升 App 体验） */
@media (display-mode: standalone) {
  body {
    user-select: none;
    -webkit-user-select: none;
  }
  
  /* 但允许输入框选择 */
  input,
  textarea {
    user-select: text;
    -webkit-user-select: text;
  }
}

/* ============================================
   分享按钮样式
   ============================================ */

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #2DBAA3;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.share-btn:hover {
  background: #25a08c;
}

.share-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* ============================================
   离线提示样式
   ============================================ */

.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #ff9800;
  color: white;
  text-align: center;
  padding: 8px;
  font-size: 13px;
  z-index: 9999;
  transform: translateY(-100%);
  transition: transform 0.3s ease;
}

.offline-banner.show {
  transform: translateY(0);
}

/* ============================================
   移动端布局优化
   ============================================ */

@media (max-width: 768px) {
  /* 增大触摸目标 */
  .btn,
  .btn-small {
    min-height: 44px;
    min-width: 44px;
  }
  
  /* 优化字体大小 */
  body {
    font-size: 16px; /* 防止 iOS 缩放 */
  }
  
  /* 优化编辑器在移动端的显示 */
  .editor-container {
    grid-template-columns: 1fr;
    height: auto;
  }
  
  .panel {
    min-height: 300px;
  }
  
  /* 工具栏换行 */
  .toolbar {
    gap: 8px;
  }
  
  .toolbar .btn {
    font-size: 12px;
    padding: 6px 12px;
  }
}

/* ============================================
   深色模式适配
   ============================================ */

[data-theme="dark"] .pwa-guide-box {
  background: #1e1e1e;
}

[data-theme="dark"] .pwa-guide-title,
[data-theme="dark"] .pwa-guide-step {
  color: #e0e0e0;
}

/* ============================================
   动画效果
   ============================================ */

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

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

.pwa-install-prompt {
  animation: slideUp 0.3s ease;
}

.pwa-guide-overlay {
  animation: fadeIn 0.3s ease;
}
