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

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: rgba(37, 99, 235, 0.1);
  --success: #10b981;
  --success-light: rgba(16, 185, 129, 0.1);
  --warning: #f59e0b;
  --warning-light: rgba(245, 158, 11, 0.1);
  --error: #ef4444;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;
  --border-color: #e2e8f0;
  --border-input: #cbd5e1;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 52px;
  --radius-card: 12px;
  --radius-input: 6px;
  --radius-button: 8px;
}

[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: rgba(59, 130, 246, 0.15);
  --success: #34d399;
  --success-light: rgba(52, 211, 153, 0.15);
  --warning: #fbbf24;
  --warning-light: rgba(251, 191, 36, 0.15);
  --error: #f87171;
  --bg-page: #0f172a;
  --bg-card: #1e293b;
  --bg-elevated: #334155;
  --border-color: #334155;
  --border-input: #475569;
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Smooth theme transitions for all themed elements */
.app,
.drop-zone,
.match-summary,
.images-table,
.table-header,
.table-row,
.row-alttext-input,
.btn,
.language-selector,
.theme-toggle,
.processing-content,
.row-thumbnail {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.3s ease;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--spacing-xl) var(--spacing-lg);
}

header {
  margin-bottom: var(--spacing-lg);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.header-content {
  flex: 1;
}

h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--primary);
  margin-bottom: var(--spacing-sm);
}

.header-controls {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.language-selector {
  display: flex;
  gap: 4px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-button);
  padding: 4px;
  transition: all 0.2s ease;
}

.language-btn {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: calc(var(--radius-button) - 2px);
  transition: all 0.2s ease;
  font-family: 'Inter', sans-serif;
}

.language-btn:hover {
  color: var(--text-primary);
  background: var(--bg-page);
}

.language-btn.active {
  background: var(--primary);
  color: white;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border-color);
  background: var(--bg-elevated);
  border-radius: var(--radius-button);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  color: var(--text-secondary);
}

.theme-toggle:hover {
  background: var(--bg-page);
  color: var(--text-primary);
  transform: scale(1.05);
}

.theme-toggle:active {
  transform: scale(0.95);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.3s ease;
}

.theme-toggle:hover svg {
  transform: rotate(15deg);
}

.theme-toggle:active svg {
  transform: rotate(-15deg) scale(0.9);
}

/* Focus states with smooth transitions */
.theme-toggle,
.language-btn,
.btn {
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: all 0.2s ease;
}

.theme-toggle:focus-visible {
  outline-color: var(--primary);
}

.language-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.btn:focus-visible {
  outline-color: var(--primary);
}

.row-alttext-input:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 16px;
  transition: color 0.3s ease;
}

/* Enhanced dark mode adjustments */
[data-theme="dark"] .drop-zone:hover,
[data-theme="dark"] .drop-zone.dragging {
  background: var(--primary-light);
  border-color: var(--primary);
}

[data-theme="dark"] .btn-primary {
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

[data-theme="dark"] .btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

[data-theme="dark"] h1 {
  color: var(--primary);
  text-shadow: 0 0 20px rgba(59, 130, 246, 0.15);
}

/* Custom scrollbar styling */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-page);
}

::-webkit-scrollbar-thumb {
  background: var(--border-input);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

[data-theme="dark"] ::-webkit-scrollbar-track {
  background: var(--bg-card);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--border-color);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--border-input);
}

.upload-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
}

.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-card);
  padding: var(--spacing-lg);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-card);
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.drop-zone:hover, .drop-zone.dragging {
  border-color: var(--primary);
  background: var(--primary-light);
}

.drop-zone.has-content {
  border-style: solid;
  border-color: var(--success);
  background: var(--success-light);
}

.drop-zone-icon {
  width: 40px;
  height: 40px;
  margin-bottom: var(--spacing-sm);
  color: var(--text-secondary);
}

.drop-zone.has-content .drop-zone-icon {
  color: var(--success);
}

.drop-zone-title {
  font-weight: 500;
  margin-bottom: 4px;
}

.drop-zone-text {
  color: var(--text-secondary);
  font-size: 14px;
}

.drop-zone-text strong {
  color: var(--primary);
}

.drop-zone-hint {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: var(--spacing-sm);
}

.drop-zone-status {
  margin-top: var(--spacing-sm);
  font-size: 14px;
  font-weight: 500;
}

.drop-zone-status.success {
  color: var(--success);
}

.match-summary {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  padding: var(--spacing-lg);
  margin-bottom: var(--spacing-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.match-stats {
  display: flex;
  gap: var(--spacing-xl);
}

.stat-item {
  text-align: center;
}

.stat-value {
  font-size: 32px;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 4px;
}

.stat-value.matched { color: var(--success); }
.stat-value.unmatched { color: var(--warning); }
.stat-value.total { color: var(--primary); }

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.images-table {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-card);
  overflow: hidden;
  margin-bottom: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.table-header {
  display: grid;
  grid-template-columns: 80px 1fr 2fr 100px;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.table-row {
  display: grid;
  grid-template-columns: 80px 1fr 2fr 100px;
  gap: var(--spacing-md);
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  align-items: center;
}

.table-row:last-child {
  border-bottom: none;
}

.table-row:hover {
  background: var(--bg-elevated);
}

.row-thumbnail {
  width: 64px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-input);
  background: var(--bg-page);
  border: 1px solid var(--border-color);
}

.row-filename {
  font-size: 14px;
  font-weight: 500;
  word-break: break-all;
}

.row-alttext {
  font-size: 14px;
  color: var(--text-secondary);
}

.row-alttext.empty {
  color: var(--text-muted);
  font-style: italic;
}

.row-alttext-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-input);
  font-size: 14px;
  font-family: inherit;
  resize: none;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.row-alttext-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.row-alttext-input.over-limit {
  border-color: var(--error);
}

.row-alttext-input.over-limit:focus {
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.char-count {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
  text-align: right;
}

.char-count.over-limit {
  color: var(--error);
  font-weight: 600;
}

.row-status {
  text-align: center;
}

.status-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: var(--radius-input);
}

.status-badge.matched {
  background: var(--success-light);
  color: var(--success);
}

.status-badge.unmatched {
  background: var(--warning-light);
  color: var(--warning);
}

.status-badge.manual {
  background: var(--primary-light);
  color: var(--primary);
}

.status-badge.over-limit {
  background: rgba(239, 68, 68, 0.1);
  color: var(--error);
}

.info-text-error {
  color: var(--error);
  font-size: 13px;
  margin-top: 4px;
}

.alt-text-lang-selector {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-right: 8px;
}

.alt-text-lang-selector select {
  padding: 6px 10px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-input);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.alt-text-lang-selector select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: var(--spacing-lg);
  border-top: 1px solid var(--border-color);
}

.btn-group {
  display: flex;
  gap: var(--spacing-md);
}

.btn {
  padding: 12px 24px;
  border-radius: var(--radius-button);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  border-color: var(--border-input);
  color: var(--text-primary);
  background: var(--bg-page);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: var(--spacing-xl);
  color: var(--text-muted);
}

.excel-preview {
  margin-top: var(--spacing-sm);
  font-size: 12px;
  color: var(--text-muted);
  max-height: 60px;
  overflow: hidden;
}

.processing-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

[data-theme="dark"] .processing-overlay {
  background: rgba(0, 0, 0, 0.85);
}

.processing-content {
  background: var(--bg-card);
  border-radius: var(--radius-card);
  padding: var(--spacing-xl);
  text-align: center;
  min-width: 240px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-color);
  transition: all 0.2s ease;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto var(--spacing-md);
}

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

.toast {
  position: fixed;
  bottom: var(--spacing-lg);
  right: var(--spacing-lg);
  background: var(--success);
  color: white;
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-card);
  font-weight: 500;
  font-size: 14px;
  animation: slideIn 0.2s ease;
  z-index: 1001;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  box-shadow: var(--shadow-md);
}

.toast.warning {
  background: var(--warning);
}

.toast.error {
  background: var(--error);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.info-text {
  font-size: 13px;
  color: var(--text-muted);
}

.template-link {
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
}

.template-link:hover {
  color: var(--primary-hover);
}

@media (max-width: 900px) {
  .upload-section {
    grid-template-columns: 1fr;
  }

  .table-header, .table-row {
    grid-template-columns: 60px 1fr 100px;
  }

  .table-header > *:nth-child(3),
  .table-row > *:nth-child(3) {
    display: none;
  }

  .match-stats {
    gap: var(--spacing-lg);
  }

  header {
    flex-direction: column;
    gap: var(--spacing-md);
  }

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