/* Subs Translator - Dark theme */
:root {
  --bg: #0f1419;
  --card-bg: #1a1f29;
  --border: #2a3038;
  --text: #e4e6eb;
  --text-dim: #8b929b;
  --accent: #5b9dff;
  --accent-hover: #4a8ae8;
  --success: #4ade80;
  --error: #f87171;
  --warn: #fbbf24;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  padding: 2rem 1rem 1rem;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
header h1 { font-size: 2rem; font-weight: 700; }
header .tag { color: var(--text-dim); margin-top: 0.5rem; }

main {
  flex: 1;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}
.card h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  color: var(--accent);
}

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 2rem;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}
.dropzone.dragging {
  border-color: var(--accent);
  background: rgba(91, 157, 255, 0.05);
}
.dropzone-content .icon { font-size: 3rem; margin-bottom: 0.5rem; }
.dropzone-content p { margin: 0.25rem 0; }
.dropzone-content .hint { color: var(--text-dim); font-size: 0.85rem; }

.file-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 6px;
}
.file-info strong { flex: 1; }
.file-info span { color: var(--text-dim); font-size: 0.9rem; }

/* Buttons */
button { cursor: pointer; font-family: inherit; }
.primary-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  margin-top: 1rem;
  font-size: 1rem;
}
.primary-btn:hover:not(:disabled) { background: var(--accent-hover); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
}
.secondary-btn:hover { border-color: var(--accent); }

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  padding: 0;
}

.icon-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
}
.icon-btn:hover { color: var(--error); }

/* Progress */
.progress-info { margin-bottom: 1rem; }
.progress-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
.progress-row #progress-percent { color: var(--accent); font-weight: 600; }
.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  width: 0%;
  transition: width 0.3s;
}

.log {
  background: var(--bg);
  border-radius: 6px;
  padding: 1rem;
  max-height: 200px;
  overflow-y: auto;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.log .log-line { margin: 0.2rem 0; }
.log .log-error { color: var(--error); }
.log .log-success { color: var(--success); }

/* Result */
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1.5rem;
}
.result-actions input {
  flex: 1;
  min-width: 200px;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
}
.result-actions input:focus {
  outline: none;
  border-color: var(--accent);
}

.preview h3 {
  font-size: 1rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}
.preview-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 600px;
  overflow-y: auto;
}
.preview-block {
  background: var(--bg);
  border-radius: 6px;
  padding: 0.75rem;
  border-left: 3px solid var(--accent);
}
.preview-block .ts {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--accent);
  margin-bottom: 0.25rem;
}
.preview-block .text { white-space: pre-wrap; font-size: 0.95rem; }

/* Dual column preview (EN | EL side-by-side) */
.dual-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.preview-col {
  background: var(--bg);
  border-radius: 8px;
  padding: 0.75rem;
  min-width: 0;  /* allow text wrap */
}
.col-header {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}
.live-preview {
  margin-top: 1.5rem;
}
.live-preview h3 {
  font-size: 1rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}
.live-preview .preview-list {
  max-height: 500px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Translate animation for newly added blocks */
.preview-block.new {
  animation: fadeIn 0.4s ease-out;
  border-left-color: var(--success);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Pending (not yet translated) */
.preview-block.pending {
  opacity: 0.4;
}
.preview-block.pending .text {
  color: var(--text-dim);
  font-style: italic;
}
.preview-block.pending .ts {
  color: var(--text-dim);
}

/* Translated (EN side, fully visible since we know the content) */
.preview-block.translated {
  opacity: 0.85;
  border-left-color: var(--success);
}

/* Responsive: stack on small screens */
@media (max-width: 768px) {
  .dual-col {
    grid-template-columns: 1fr;
  }
}

/* Utilities */
.hidden { display: none !important; }

footer {
  text-align: center;
  padding: 1rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

/* History sidebar */
.history-sidebar {
  position: fixed;
  right: 1rem;
  top: 6rem;
  width: 280px;
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
  padding: 1rem;
  z-index: 10;
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.history-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}
.history-item:hover {
  border-color: var(--accent);
  background: rgba(91, 157, 255, 0.05);
}
.history-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}
.history-item-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.history-item-badge {
  background: var(--accent);
  color: var(--bg);
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
}

/* Main content adjustment for sidebar */
@media (min-width: 1100px) {
  main {
    margin-right: 300px;
  }
}
@media (max-width: 1099px) {
  .history-sidebar {
    position: relative;
    right: auto;
    top: auto;
    width: 100%;
    max-height: 300px;
    margin-bottom: 1rem;
  }
}

/* Restore banner */
.restore-banner {
  background: linear-gradient(135deg, var(--accent) 0%, #4a8ae8 100%);
  color: var(--bg);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}

/* Queue list */
.queue-list {
  margin: 1rem 0;
  padding: 0.75rem;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}
#queue-items {
  list-style: none;
  padding: 0;
  margin: 0;
}
#queue-items li {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.5rem;
  background: var(--card);
  border-radius: 6px;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
}
#queue-items li.processing {
  border-left: 3px solid var(--accent);
  background: rgba(99, 102, 241, 0.1);
}
#queue-items li.done {
  border-left: 3px solid #22c55e;
  opacity: 0.6;
}
#queue-items li.error {
  border-left: 3px solid #ef4444;
}
#queue-items li .file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#queue-items li .status {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-left: 0.5rem;
}
#queue-items li .remove-btn {
  margin-left: 0.5rem;
  color: var(--text-dim);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 0 0.3rem;
}
#queue-items li .remove-btn:hover {
  color: var(--danger, #ef4444);
}

/* Auto-save indicator */
.auto-save-badge {
  display: inline-block;
  background: #22c55e;
  color: white;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  margin-left: 0.5rem;
}
