/* ==========================================================================
   EPUB AI Translator - Production Modern Solid UI Stylesheet
   Rules: 100% Solid Colors, Zero Gradients, Zero Glassmorphism Slop, WCAG AA
   ========================================================================== */

:root {
  /* Light Theme Surface Tokens */
  --surface-0: #f8fafc;
  --surface-1: #ffffff;
  --surface-2: #f1f5f9;
  --surface-3: #e2e8f0;
  
  --border-color: #cbd5e1;
  --border-light: #e2e8f0;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --brand-primary: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-active: #1e40af;
  --brand-subtle: #dbeafe;

  --status-success: #15803d;
  --status-success-bg: #dcfce7;
  --status-warning: #b45309;
  --status-warning-bg: #fef3c7;
  --status-danger: #b91c1c;
  --status-danger-bg: #fee2e2;
  --status-info: #0369a1;
  --status-info-bg: #e0f2fe;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
}

[data-theme="dark"] {
  /* Dark Theme Surface Tokens */
  --surface-0: #0b0f19;
  --surface-1: #111827;
  --surface-2: #1f2937;
  --surface-3: #374151;

  --border-color: #374151;
  --border-light: #1f2937;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-inverse: #0b0f19;

  --brand-primary: #3b82f6;
  --brand-hover: #60a5fa;
  --brand-active: #2563eb;
  --brand-subtle: #1e3a8a;

  --status-success: #4ade80;
  --status-success-bg: #064e3b;
  --status-warning: #fbbf24;
  --status-warning-bg: #78350f;
  --status-danger: #f87171;
  --status-danger-bg: #7f1d1d;
  --status-info: #38bdf8;
  --status-info-bg: #0c4a6e;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--surface-0);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

p {
  color: var(--text-secondary);
}

/* Navbar */
.app-header {
  background-color: var(--surface-1);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background-color: var(--brand-primary);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.badge-version {
  font-size: 0.75rem;
  background-color: var(--surface-2);
  color: var(--text-muted);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-light);
  font-weight: 500;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Main Container */
.app-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
}

/* Tabs */
.view-nav, .sub-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.15s ease-out;
}

.tab-btn:hover {
  color: var(--text-primary);
  background-color: var(--surface-2);
}

.tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color 0.15s ease-out, border-color 0.15s ease-out;
  border: 1px solid transparent;
  line-height: 1.2;
}

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

.btn-primary {
  background-color: var(--brand-primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--brand-hover);
}

.btn-secondary {
  background-color: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--surface-3);
}

.btn-outline {
  background-color: transparent;
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

.btn-outline:hover:not(:disabled) {
  background-color: var(--brand-subtle);
}

.btn-danger {
  background-color: var(--status-danger);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background-color: #991b1b;
}

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

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Dropzone & Upload */
.upload-card {
  background-color: var(--surface-1);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  margin-bottom: 2rem;
}

.upload-card:hover, .upload-card.dragover {
  border-color: var(--brand-primary);
  background-color: var(--surface-2);
}

.upload-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  color: var(--brand-primary);
}

.upload-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}

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

/* Cards & Panels */
.panel {
  background-color: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 600;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--surface-1);
}

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

th {
  background-color: var(--surface-2);
  color: var(--text-secondary);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tr:hover td {
  background-color: var(--surface-2);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-ready {
  background-color: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.badge-translating {
  background-color: var(--status-info-bg);
  color: var(--status-info);
}

.badge-completed {
  background-color: var(--status-success-bg);
  color: var(--status-success);
}

.badge-paused {
  background-color: var(--status-warning-bg);
  color: var(--status-warning);
}

.badge-failed {
  background-color: var(--status-danger-bg);
  color: var(--status-danger);
}

/* Progress bar */
.progress-bar-bg {
  width: 100%;
  height: 8px;
  background-color: var(--surface-3);
  border-radius: 4px;
  overflow: hidden;
}

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

/* Pagination */
.pagination-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.85rem 0.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.form-control {
  width: 100%;
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--surface-1);
  color: var(--text-primary);
  transition: border-color 0.15s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 1px var(--brand-primary);
}

.form-help {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Modal Dialog */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-dialog {
  background-color: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
}

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

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background-color: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 280px;
  max-width: 420px;
  box-shadow: var(--shadow-md);
  font-size: 0.88rem;
  animation: slideIn 0.2s ease;
}

.toast.toast-success {
  border-left: 4px solid var(--status-success);
}

.toast.toast-error {
  border-left: 4px solid var(--status-danger);
}

.toast.toast-info {
  border-left: 4px solid var(--status-info);
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Bilingual Reader Layout */
.reader-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}

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

.reader-column {
  background-color: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  max-height: 70vh;
  overflow-y: auto;
}

.reader-column-header {
  font-size: 0.95rem;
  font-weight: 600;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.paragraph-item {
  padding: 0.75rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  background-color: var(--surface-0);
  transition: border-color 0.15s ease;
}

.paragraph-item:hover {
  border-color: var(--brand-primary);
}

.paragraph-id {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.paragraph-text {
  font-size: 0.92rem;
  line-height: 1.6;
}

/* Studio Details Header Card */
.studio-hero {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  background-color: var(--surface-1);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.studio-cover {
  width: 90px;
  height: 130px;
  object-fit: cover;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: var(--surface-2);
}

.studio-info {
  flex: 1;
  min-width: 250px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  color: var(--border-color);
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

/* Live Terminal / Log Box */
.terminal-box {
  background-color: #0b0f19;
  color: #10b981;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  height: 220px;
  overflow-y: auto;
  line-height: 1.5;
  border: 1px solid #1f2937;
}

.terminal-line {
  margin-bottom: 0.25rem;
}
