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

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #f8fafc;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #059669;
  --error: #dc2626;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* === Container === */
.container {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

/* === Header === */
header {
  text-align: center;
  margin-bottom: 32px;
}

header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 15px;
}

/* === Card === */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
  border: 1px solid var(--border);
}

/* === Input === */
.input-group {
  margin-bottom: 20px;
}

.input-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

textarea {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  resize: vertical;
  transition: border-color 0.2s;
  line-height: 1.5;
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea::placeholder {
  color: #94a3b8;
}

/* === Button === */
#translate-btn {
  width: 100%;
  padding: 14px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#translate-btn:hover {
  background: var(--primary-hover);
}

#translate-btn:active {
  transform: scale(0.98);
}

#translate-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.hidden {
  display: none !important;
}

/* === Result === */
#result-area {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.result-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.detected-lang {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.translated-text {
  font-size: 18px;
  line-height: 1.7;
  padding: 14px 16px;
  background: #f0fdf4;
  border-radius: 8px;
  border: 1px solid #bbf7d0;
  color: var(--text);
  min-height: 50px;
  word-break: break-word;
}

.copy-btn {
  margin-top: 12px;
  padding: 8px 16px;
  font-size: 13px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.2s;
}

.copy-btn:hover {
  background: var(--border);
}

/* === Error === */
#error-area {
  margin-top: 16px;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
}

.error-message {
  color: var(--error);
  font-size: 14px;
}

/* === Footer === */
footer {
  text-align: center;
  margin-top: 24px;
  color: var(--text-muted);
  font-size: 13px;
}

footer a {
  color: var(--primary);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* === Responsive === */
@media (max-width: 480px) {
  .card {
    padding: 20px;
  }
  header h1 {
    font-size: 22px;
  }
  textarea {
    font-size: 15px;
  }
  .translated-text {
    font-size: 16px;
  }
}
