:root {
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.07), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
  --text-main: #0f172a;
  --text-muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-border: #bfdbfe;
  --success: #10b981;
  --success-hover: #059669;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --danger-light: #fef2f2;
  --radius: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 980px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--card-border);
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--primary-border);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
}

.logo-text h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.logo-text p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: #f1f5f9;
  border: 1px solid var(--card-border);
  color: #334155;
  padding: 0.4rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 500;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--success);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.8; }
}

/* Cards */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1.75rem;
  box-shadow: var(--card-shadow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.card-header h2, .card-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  font-weight: 600;
}

.badge-info {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.badge-lang {
  background: #f3e8ff;
  color: #7e22ce;
  border: 1px solid #d8b4fe;
}

/* Language Selector */
.lang-selector-card {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1.25rem;
  background: #f8fafc;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.lang-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.lang-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.lang-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-top: 1rem;
}

.lang-arrow svg {
  width: 20px;
  height: 20px;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  color: var(--text-main);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: all 0.2s;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Dropzone */
.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius);
  padding: 2.75rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fafbfc;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-icon {
  width: 44px;
  height: 44px;
  color: var(--primary);
  margin-bottom: 0.75rem;
}

.dropzone-main-text {
  font-size: 1rem;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.dropzone-main-text span {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.dropzone-sub-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.selected-file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f1f5f9;
  padding: 0.85rem 1.25rem;
  border-radius: 8px;
  margin-top: 1.25rem;
  border: 1px solid var(--card-border);
}

.file-meta {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  overflow: hidden;
}

.file-icon-svg {
  width: 22px;
  height: 22px;
  color: var(--primary);
  flex-shrink: 0;
}

.file-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 320px;
  color: var(--text-main);
}

.file-size {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.25rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.18s ease;
}

.btn svg {
  width: 17px;
  height: 17px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}

.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover {
  background: var(--success-hover);
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.25);
}

.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--card-border);
}
.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fecaca;
}
.btn-danger:hover {
  background: var(--danger);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
}
.btn-ghost:hover {
  background: var(--primary-light);
}

.btn-outline-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid #fca5a5;
}
.btn-outline-danger:hover {
  background: var(--danger-light);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.35rem 0.75rem;
}

.btn-icon-action {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.btn-icon-action svg {
  width: 16px;
  height: 16px;
}

.btn-icon-download {
  color: var(--primary);
}
.btn-icon-download:hover {
  color: var(--primary-hover);
  background: var(--primary-light);
}

.btn-icon-delete {
  color: var(--text-muted);
}
.btn-icon-delete:hover {
  color: var(--danger);
  background: var(--danger-light);
}

/* Progress Section */
.job-id-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.job-status-badge {
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: capitalize;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.status-processing {
  background: var(--warning-light);
  color: #b45309;
  border: 1px solid #fde68a;
}

.status-completed {
  background: var(--success-light);
  color: #047857;
  border: 1px solid #a7f3d0;
}

.status-pending {
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
}

.status-failed {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fecaca;
}

.progress-details {
  margin: 1.5rem 0;
}

.progress-numbers {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.6rem;
  color: var(--text-main);
}

.progress-bar-track {
  height: 10px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #10b981);
  transition: width 0.3s ease;
}

.job-actions {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

/* Preview Table */
.preview-section {
  border-top: 1px solid var(--card-border);
  padding-top: 1.25rem;
}

.preview-header {
  margin-bottom: 0.85rem;
}

.preview-header h3 {
  font-size: 1rem;
  color: var(--text-main);
}

.preview-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.preview-table-container {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  background: #ffffff;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  text-align: left;
}

.preview-table th {
  background: #f8fafc;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--card-border);
  color: #475569;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

.preview-table td {
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: top;
}

.preview-table tr:hover {
  background: #f8fafc;
}

.timing-cell {
  color: #64748b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
}

.source-cell {
  color: #334155;
}

.target-cell {
  color: #0369a1;
  font-weight: 500;
}

/* History List */
.history-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.15s;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item:hover {
  background: #f8fafc;
}

.history-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.history-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.history-title svg {
  width: 16px;
  height: 16px;
  color: var(--primary);
}

.history-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.history-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.p-4 { padding: 1.5rem; }
.hidden { display: none !important; }

.app-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 1rem 0;
}

/* Responsive Design (Mobile & Tablet) */
@media (max-width: 768px) {
  .app-container {
    padding: 1.25rem 0.85rem;
    gap: 1.25rem;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
  }

  .header-badge {
    align-self: flex-start;
  }

  .card {
    padding: 1.25rem 1rem;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  /* Stack Language Selectors on Mobile */
  .lang-selector-card {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding: 1rem;
  }

  .lang-arrow {
    margin-top: 0;
    transform: rotate(90deg);
    padding: 0.25rem 0;
  }

  .selected-file-info {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
  }

  .file-name {
    max-width: 200px;
  }

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

  .job-actions {
    flex-direction: column;
  }

  .job-actions .btn {
    width: 100%;
  }

  .history-actions {
    width: 100%;
    justify-content: space-between;
  }

  .history-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .history-right {
    width: 100%;
    justify-content: space-between;
  }

  /* Table scrollable smoothly on mobile */
  .preview-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .preview-table th, .preview-table td {
    padding: 0.55rem 0.65rem;
    font-size: 0.8rem;
  }
}
