/**
 * AI 翻译专家 - 自定义样式
 */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #06b6d4;
  --bg-gradient-start: #f0f4ff;
  --bg-gradient-end: #e0e7ff;
  --card-bg: rgba(255, 255, 255, 0.85);
  --card-border: rgba(255, 255, 255, 0.6);
  --text-main: #1e293b;
  --text-muted: #64748b;
  --shadow: 0 20px 60px -10px rgba(99, 102, 241, 0.18);
  --radius: 20px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
  color: var(--text-main);
  overflow-x: hidden;
}

/* 背景装饰 */
.bg-decoration {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
}

.bg-decoration::before,
.bg-decoration::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.45;
}

.bg-decoration::before {
  width: 500px;
  height: 500px;
  background: linear-gradient(135deg, #818cf8, #c084fc);
  top: -120px;
  right: -120px;
}

.bg-decoration::after {
  width: 400px;
  height: 400px;
  background: linear-gradient(135deg, #22d3ee, #6366f1);
  bottom: -80px;
  left: -80px;
}

/* 容器 */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 20px;
}

/* 头部 */
header {
  text-align: center;
  margin-bottom: 36px;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.logo-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 28px;
  box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.4);
}

h1 {
  font-size: 2.4rem;
  font-weight: 800;
  margin: 0;
  background: linear-gradient(135deg, var(--primary-dark), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-top: 8px;
}

.settings-btn {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  color: var(--text-main);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.25s ease;
  z-index: 50;
}

.settings-btn:hover {
  transform: rotate(30deg);
  color: var(--primary);
}

/* 主卡片 */
.main-card {
  background: var(--card-bg);
  backdrop-filter: blur(20px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

/* 语言选择栏 */
.lang-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.lang-select {
  appearance: none;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 12px 40px 12px 16px;
  font-size: 1rem;
  color: var(--text-main);
  cursor: pointer;
  min-width: 180px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.lang-select:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.swap-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: var(--primary);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.swap-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: rotate(180deg);
}

/* 翻译区域 */
.translate-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 28px;
}

.panel {
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 320px;
  transition: box-shadow 0.2s;
}

.panel:focus-within {
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  border-color: var(--primary-light);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  background: #f8fafc;
}

.panel-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn:hover {
  background: #e2e8f0;
  color: var(--primary);
}

.panel-body {
  flex: 1;
  position: relative;
}

.text-input,
.text-output {
  width: 100%;
  height: 100%;
  min-height: 260px;
  border: none;
  outline: none;
  padding: 16px;
  font-size: 1.1rem;
  line-height: 1.7;
  color: var(--text-main);
  resize: none;
  font-family: inherit;
}

.text-output {
  background: #fff;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.text-input::placeholder {
  color: #94a3b8;
}

.char-count {
  position: absolute;
  bottom: 12px;
  right: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.9);
  padding: 2px 8px;
  border-radius: 20px;
}

/* 底部按钮 */
.action-bar {
  display: flex;
  justify-content: center;
}

.translate-btn {
  padding: 14px 48px;
  border-radius: 50px;
  border: none;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  box-shadow: 0 12px 30px -8px rgba(99, 102, 241, 0.45);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.translate-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 16px 40px -8px rgba(99, 102, 241, 0.55);
}

.translate-btn:active:not(:disabled) {
  transform: translateY(0);
}

.translate-btn:disabled {
  opacity: 0.75;
  cursor: not-allowed;
}

/* 历史记录 */
.history-section {
  margin-top: 32px;
}

.history-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.history-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.history-item:hover {
  border-color: var(--primary-light);
  box-shadow: 0 6px 20px -5px rgba(99, 102, 241, 0.12);
  transform: translateY(-2px);
}

.history-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.history-source {
  font-size: 0.95rem;
  color: var(--text-main);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-empty {
  color: var(--text-muted);
  font-size: 0.95rem;
  padding: 12px 0;
}

/* 加载遮罩 */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e2e8f0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Toast */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  z-index: 200;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

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

.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }
.toast-warning { background: #f59e0b; }
.toast-info { background: #3b82f6; }

/* 设置弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 150;
}

.modal.hidden {
  display: none;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius);
  width: 90%;
  max-width: 520px;
  box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 24px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-main);
}

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid #f1f5f9;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.btn-secondary,
.btn-primary {
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-secondary {
  background: #f1f5f9;
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
}

.btn-primary:hover {
  opacity: 0.92;
}

/* 页脚 */
footer {
  text-align: center;
  padding: 30px 0 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* 响应式 */
@media (max-width: 768px) {
  .container {
    padding: 24px 16px;
  }

  h1 {
    font-size: 1.8rem;
  }

  .translate-area {
    grid-template-columns: 1fr;
  }

  .panel {
    min-height: 240px;
  }

  .lang-bar {
    gap: 10px;
  }

  .lang-select {
    min-width: 140px;
    flex: 1;
  }

  .main-card {
    padding: 18px;
  }

  .translate-btn {
    width: 100%;
    justify-content: center;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}
