:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --success: #22c55e;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
}

.app-container {
  max-width: 1024px;
  margin: 0 auto;
  padding: 0 1rem;
}

header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
  padding: 0 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
  border-radius: 0 0 1rem 1rem;
  margin-bottom: 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary);
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

nav {
  display: flex;
  gap: 0.25rem;
  background: #f1f5f9;
  padding: 0.25rem;
  border-radius: 0.5rem;
}

nav button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.375rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  border-radius: 0.375rem;
  transition: all 0.2s;
  font-size: 0.875rem;
}

nav button.active {
  background: var(--card-bg);
  color: var(--primary);
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.api-key-container {
  flex: 1;
  display: flex;
  justify-content: center;
  margin: 0 1rem;
}

.api-input {
  width: 100%;
  max-width: 300px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  outline: none;
  background: #f8fafc;
  transition: all 0.2s;
}

.api-input:focus {
  border-color: var(--primary);
  background: white;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

section {
  display: none;
  animation: fadeIn 0.3s ease;
}

section.active {
  display: block;
}

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

/* Text Translator */
.translator-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.controls {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.controls > * {
  padding: 0.75rem;
}

select {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  color: var(--text-main);
}

select:hover {
  color: var(--primary);
}

.swap-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: #f8fafc;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 1.5rem;
}

.text-area-container {
  display: grid;
  grid-template-columns: 1fr;
  height: 400px;
}

@media (min-width: 768px) {
  .text-area-container {
    grid-template-columns: 1fr 1fr;
  }
}

.input-wrapper, .output-wrapper {
  position: relative;
  height: 100%;
}

.input-wrapper {
  border-bottom: 1px solid var(--border);
}

@media (min-width: 768px) {
  .input-wrapper {
    border-bottom: none;
    border-right: 1px solid var(--border);
  }
}

.output-wrapper {
  background: #f8fafc;
}

textarea {
  width: 100%;
  height: 100%;
  padding: 1.5rem;
  border: none;
  resize: none;
  outline: none;
  font-size: 1.125rem;
  background: transparent;
  color: var(--text-main);
}

.clear-btn, .copy-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  padding: 0.5rem;
  border-radius: 9999px;
  transition: all 0.2s;
}

.clear-btn:hover, .copy-btn:hover {
  background: rgba(0,0,0,0.05);
  color: var(--text-main);
}

.actions {
  padding: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

#translate-text-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.625rem 1.5rem;
  border-radius: 0.5rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

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

/* Loader */
.loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-col: column;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.8);
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  z-index: 5;
}

.spin {
  animation: spin 1s linear infinite;
  color: var(--primary);
  width: 2rem;
  height: 2rem;
}

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

/* Document Translator */
.language-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card-bg);
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  margin-bottom: 1.5rem;
}

.language-bar select {
  padding: 0.5rem;
  background: #f8fafc;
  border-radius: 0.5rem;
}

.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: 1rem;
  padding: 3rem;
  text-align: center;
  cursor: pointer;
  background: var(--card-bg);
  transition: all 0.2s;
}

.drop-zone:hover, .drop-zone.drag-active {
  border-color: var(--primary);
  background: #eff6ff;
}

.icon-circle {
  width: 4rem;
  height: 4rem;
  background: #f1f5f9;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  color: #94a3b8;
}

.drop-zone:hover .icon-circle {
  background: #dbeafe;
  color: var(--primary);
}

.main-text {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 0.25rem;
}

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

.file-list {
  margin-top: 1.5rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 1rem;
  overflow: hidden;
}

.file-list-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.file-list-header h3 {
  font-size: 0.95rem;
  color: var(--text-main);
}

.text-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-weight: 500;
  cursor: pointer;
  font-size: 0.875rem;
}

.file-item {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
}

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

.file-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: #eff6ff;
  color: var(--primary);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-info {
  flex: 1;
}

.file-name {
  font-weight: 500;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.file-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.75rem;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.action-btn {
  padding: 0.5rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 0.375rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.action-btn.delete:hover {
  background: #fef2f2;
  color: var(--danger);
}

.translate-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.375rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  cursor: pointer;
}

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

/* Progress Bar */
.progress-container {
  width: 100px;
  text-align: right;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--primary);
  display: block;
  margin-bottom: 0.25rem;
}

.progress-bar-bg {
  width: 100%;
  height: 6px;
  background: #f1f5f9;
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal.hidden, .hidden {
  display: none !important;
}

.modal-content {
  background: white;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  border-radius: 1rem;
  display: flex;
  flex-col: column;
  flex-direction: column;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  background: #f8fafc;
}

pre {
  white-space: pre-wrap;
  font-family: monospace;
  font-size: 0.875rem;
  color: var(--text-main);
}
