/* ===================== RESET & BASE ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(15,23,42,.07);
}

body {
  font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ===================== HEADER ===================== */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1100px; margin: 0 auto;
  display: flex; align-items: center; gap: 32px;
  padding: 0 24px; height: 60px;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  font-size: 18px; font-weight: 700; color: var(--primary);
  text-decoration: none; white-space: nowrap;
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav-link {
  padding: 6px 14px; border-radius: 8px; font-size: 14px;
  color: var(--text-muted); text-decoration: none; transition: all .2s;
}
.nav-link:hover, .nav-link.active { color: var(--primary); background: #eff6ff; }

/* ===================== HERO ===================== */
.hero {
  background: linear-gradient(135deg, #1e3a5f 0%, #1a56db 60%, #3b82f6 100%);
  padding: 44px 0 50px;
}
.hero-inner {
  max-width: 1100px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 40px;
}
.hero-text h1 { color: #fff; font-size: 32px; font-weight: 700; margin-bottom: 8px; }
.hero-text p { color: rgba(255,255,255,.7); font-size: 15px; }
.hero-stats { display: flex; gap: 32px; }
.stat-item { text-align: center; }
.stat-num { display: block; color: #fff; font-size: 26px; font-weight: 700; }
.stat-label { color: rgba(255,255,255,.65); font-size: 12px; }

/* ===================== MAIN ===================== */
.main-content {
  max-width: 1100px; margin: 0 auto; padding: 32px 24px 60px;
  display: flex; flex-direction: column; gap: 40px;
}

/* ===================== TRANSLATOR CARD ===================== */
.translator-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* Language Bar */
.lang-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}
.lang-select-wrap { flex: 1; display: flex; align-items: center; gap: 8px; }
.lang-detect-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; color: var(--text-muted); font-size: 13px; cursor: pointer;
  white-space: nowrap; transition: all .2s;
}
.lang-detect-btn:hover { border-color: var(--primary); color: var(--primary); }
.lang-detect-btn.active { background: #eff6ff; border-color: var(--primary); color: var(--primary); }

.lang-select {
  flex: 1; padding: 7px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; color: var(--text);
  background: #fff; cursor: pointer; outline: none; transition: border .2s;
  font-family: inherit;
}
.lang-select:focus { border-color: var(--primary); }

.swap-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--border); background: #fff;
  color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .25s; flex-shrink: 0;
}
.swap-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); transform: rotate(180deg); }

/* Text Panels */
.text-panels {
  display: grid; grid-template-columns: 1fr 1fr;
  min-height: 260px;
}
.panel { display: flex; flex-direction: column; }
.source-panel { border-right: 1px solid var(--border); }

.text-area {
  flex: 1; padding: 20px; font-size: 16px; line-height: 1.7;
  border: none; outline: none; resize: none; font-family: inherit;
  color: var(--text); background: transparent; min-height: 200px;
}
.text-area::placeholder { color: #cbd5e1; }

.result-area {
  flex: 1; padding: 20px; font-size: 16px; line-height: 1.7;
  color: var(--text); min-height: 200px; position: relative;
  word-break: break-word; white-space: pre-wrap;
}
.placeholder-text { color: #cbd5e1; font-size: 15px; }
.result-area.loading::after {
  content: '';
  position: absolute; top: 24px; left: 20px;
  width: 120px; height: 12px; border-radius: 6px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.result-area.error { color: var(--danger); }
.result-area.success { color: var(--text); }

.panel-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; border-top: 1px solid var(--border);
  background: #fafafa;
}
.char-count { font-size: 12px; color: var(--text-muted); }
.char-count.warn { color: var(--warning); }
.char-count.danger { color: var(--danger); }
.panel-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 30px; height: 30px; border-radius: 6px; border: none;
  background: transparent; color: var(--text-muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .2s;
}
.icon-btn:hover { background: #f1f5f9; color: var(--primary); }
.icon-btn.copied { color: var(--success); }
.detected-lang { font-size: 12px; color: var(--text-muted); font-style: italic; }

/* Translate Bar */
.translate-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-top: 1px solid var(--border); background: #f8fafc;
}
.api-info {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
}
.translate-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 28px; border-radius: 10px;
  background: var(--primary); color: #fff; border: none;
  font-size: 15px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all .2s; min-width: 120px; justify-content: center;
}
.translate-btn:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(59,130,246,.35); }
.translate-btn:disabled { opacity: .65; cursor: not-allowed; transform: none; }
.translate-btn.loading-btn svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== QUICK PHRASES ===================== */
.section-title { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 16px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.text-btn {
  font-size: 13px; color: var(--text-muted); background: none;
  border: none; cursor: pointer; padding: 4px 0; transition: color .2s;
}
.text-btn:hover { color: var(--danger); }

.phrase-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px;
}
.phrase-chip {
  padding: 10px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--card);
  font-size: 13px; color: var(--text); cursor: pointer; transition: all .2s;
  display: flex; flex-direction: column; gap: 3px;
}
.phrase-chip:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); box-shadow: var(--shadow); }
.phrase-en { font-size: 11px; color: var(--text-muted); }

/* ===================== HISTORY ===================== */
.history-list { display: flex; flex-direction: column; gap: 10px; }
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 48px; color: var(--text-muted);
  border: 2px dashed var(--border); border-radius: var(--radius);
}
.empty-state p { font-size: 14px; }
.history-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 20px;
  display: grid; grid-template-columns: 1fr 1fr auto;
  gap: 16px; align-items: start; transition: box-shadow .2s;
}
.history-item:hover { box-shadow: var(--shadow); }
.history-lang-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em; margin-bottom: 4px;
}
.history-text { font-size: 14px; color: var(--text); line-height: 1.5; }
.history-arrow { color: #94a3b8; font-size: 18px; align-self: center; }
.history-meta {
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.history-time { font-size: 11px; color: var(--text-muted); }
.history-del-btn {
  width: 26px; height: 26px; border-radius: 6px; border: none;
  background: transparent; color: #cbd5e1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all .2s;
}
.history-del-btn:hover { background: #fee2e2; color: var(--danger); }

/* ===================== ABOUT ===================== */
.about-cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.about-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px;
}
.about-icon { font-size: 28px; margin-bottom: 12px; }
.about-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.about-card p { font-size: 13px; color: var(--text-muted); line-height: 1.6; }

/* ===================== FOOTER ===================== */
.footer {
  border-top: 1px solid var(--border);
  background: var(--card);
}
.footer-inner {
  max-width: 1100px; margin: 0 auto; padding: 18px 24px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-muted);
}

/* ===================== TOAST ===================== */
.toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #1e293b; color: #fff; padding: 10px 20px;
  border-radius: 10px; font-size: 14px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: all .3s; z-index: 9999;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success-toast { background: #16a34a; }
.toast.error-toast { background: #dc2626; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 720px) {
  .hero-inner { flex-direction: column; gap: 20px; }
  .hero-text h1 { font-size: 24px; }
  .hero-stats { gap: 20px; }
  .text-panels { grid-template-columns: 1fr; }
  .source-panel { border-right: none; border-bottom: 1px solid var(--border); }
  .lang-bar { flex-wrap: wrap; }
  .translate-bar { flex-direction: column; gap: 12px; }
  .history-item { grid-template-columns: 1fr; }
  .footer-inner { flex-direction: column; gap: 8px; text-align: center; }
  .nav { display: none; }
}
