/* Mizalign — Arabic-French Sentence Alignment Tool */

:root {
  --color-bg: #f8f9fb;
  --color-surface: #ffffff;
  --color-surface-2: #f3f4f6;
  --color-border: #e2e5ea;
  --color-border-light: #eef0f3;
  --color-text: #1a1d23;
  --color-text-muted: #6b7280;
  --color-text-faint: #9ca3af;
  --color-primary: #1B2B5C;
  --color-primary-hover: #0d1f3a;
  --color-primary-light: #e8f0fe;
  --color-accent: #2980b9;
  --color-success: #059669;
  --color-success-light: #d1fae5;
  --color-warning: #d97706;
  --color-warning-light: #fff3cd;
  --color-error: #dc2626;
  --color-error-light: #fee2e2;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --transition: 180ms ease;
}

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

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: #ffffff;
  color: #1B2B5C;
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
  border-bottom: 3px solid #C9A060;
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.logo {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-img {
  /* V17 W21: logo bumped from 180px -> 240px. */
  height: 240px;
  width: auto;
  display: block;
}

@media (max-width: 1100px) {
  .logo-img { height: 200px; }
}

@media (max-width: 720px) {
  .logo-img { height: 150px; }
}

/* V17 W22: permanently visible build stamp in the page header. Replaces the
   faded bottom-right corner watermark as the primary build indicator.
   The watermark is still added by app.js as a secondary signal. */
.header-build-stamp {
  position: absolute;
  top: 12px;
  right: 16px;
  font: 600 12.5px/1.2 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: #1B2B5C;
  background: rgba(201, 160, 96, 0.18);
  border: 1px solid #C9A060;
  border-radius: 4px;
  padding: 4px 8px;
  letter-spacing: 0.2px;
  user-select: text;
  pointer-events: auto;
  white-space: nowrap;
}

.header-build-stamp:empty {
  display: none;
}

@media (max-width: 720px) {
  .header-build-stamp {
    top: 8px;
    right: 8px;
    font-size: 11px;
    padding: 3px 6px;
  }
}

.logo-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-name { display: none; }

.slogan { display: none; }

/* Main */
.app-main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  width: 100%;
}

.section {
  margin-bottom: 24px;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text);
}

.step-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

/* Upload Grid */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.upload-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.upload-label {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.lang-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.rtl-tag {
  background: #e8f0fe;
  color: #1B2B5C;
  font-family: 'Traditional Arabic', 'Arabic Typesetting', serif;
  font-size: 13px;
}

.ltr-tag {
  background: #dbeafe;
  color: #1e40af;
}

.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

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

.drop-zone svg {
  color: var(--color-text-faint);
}

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

.browse-link {
  color: var(--color-accent);
  font-weight: 500;
  text-decoration: underline;
  cursor: pointer;
}

.file-info {
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--color-success-light);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-success);
  display: none;
}

.file-info.visible {
  display: flex;
}

.file-info svg {
  flex-shrink: 0;
}

.file-info span {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.remove-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 0 4px;
  line-height: 1;
}

.remove-btn:hover {
  color: var(--color-error);
}

/* Buttons */
.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

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

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

.secondary-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

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

/* Progress */
.progress-container {
  text-align: center;
  padding: 40px 20px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
}

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

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

#progress-text {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 16px;
}

.progress-bar {
  width: 300px;
  height: 6px;
  background: var(--color-surface-2);
  border-radius: 3px;
  margin: 0 auto;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

/* Stats */
.stats-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
}

.stat {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  flex: 1;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--color-primary);
}

.stat-warning .stat-value {
  color: var(--color-warning);
}

.stat-sentence .stat-value {
  color: var(--color-success);
}

.stat-para .stat-value {
  color: var(--color-accent);
}

.stat-label {
  display: block;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Warnings */
#warnings-container {
  margin-bottom: 16px;
}

.warning-box {
  background: var(--color-warning-light);
  border: 1px solid #fbbf24;
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 8px;
  font-size: 13px;
  color: #92400e;
  display: flex;
  align-items: center;
  gap: 8px;
}

.warning-box::before {
  content: "⚠";
  font-size: 16px;
}

.technical-info-container {
  margin-top: 14px;
}

.technical-details {
  border-top: 1px solid var(--color-border-light);
  color: var(--color-text-muted);
  font-size: 12px;
  padding-top: 12px;
}

.technical-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--color-text-muted);
}

.technical-details h4 {
  color: var(--color-text);
  font-size: 12px;
  margin: 12px 0 6px;
}

.technical-details ul {
  margin: 0;
  padding-left: 18px;
  max-height: 260px;
  overflow: auto;
}

.technical-details li {
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

/* Filter */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.filter-btn {
  padding: 6px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--color-text-muted);
}

.filter-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

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

/* Alignment Table */
.alignment-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 16px;
  max-height: 600px;
  overflow-y: auto;
}

.alignment-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.alignment-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}

.alignment-table th {
  background: var(--color-primary);
  color: white;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
}

.alignment-table th.col-arabic {
  text-align: right;
  direction: rtl;
}

.col-idx { width: 48px; text-align: center; }
.col-arabic { width: 38%; }
.col-french { width: 38%; }
.col-mode { width: 100px; }
.col-conf { width: 80px; }

.alignment-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border-light);
  font-size: 13px;
  vertical-align: top;
  line-height: 1.5;
}

.alignment-table tr:hover td {
  background: var(--color-primary-light);
}

.alignment-table .cell-arabic {
  direction: rtl;
  text-align: right;
  font-family: 'Traditional Arabic', 'Arabic Typesetting', 'Noto Naskh Arabic', serif;
  font-size: 15px;
  line-height: 1.8;
}

.alignment-table .cell-french {
  direction: ltr;
  text-align: left;
}

.alignment-table .cell-idx {
  text-align: center;
  color: var(--color-text-faint);
  font-size: 12px;
}

.alignment-table .cell-type {
  text-align: center;
}

.type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.type-heading { background: #e8f0fe; color: #1B2B5C; }
.type-body { background: #f3f4f6; color: #6b7280; }
.type-table_cell { background: #fef3c7; color: #92400e; }
.type-list_item { background: #ede9fe; color: #6d28d9; }
.type-footnote { background: #fce7f3; color: #be185d; }

.mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.mode-sentence { background: #d1fae5; color: #059669; }
.mode-paragraph { background: #e0e7ff; color: #4338ca; }

.conf-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.conf-high { background: var(--color-success-light); color: var(--color-success); }
.conf-medium { background: #fef3c7; color: #92400e; }
.conf-low { background: var(--color-error-light); color: var(--color-error); }

.row-flagged td {
  background: #fffbeb;
}

.flag-text {
  display: block;
  font-size: 11px;
  color: var(--color-warning);
  margin-top: 4px;
  font-style: italic;
}

/* Section header row in table */
.section-header-row td {
  background: var(--color-primary) !important;
  color: white !important;
  font-weight: 600;
  text-align: center;
  font-size: 13px;
  padding: 8px 12px;
}

/* Export bar */
.export-bar {
  display: flex;
  justify-content: center;
  padding: 8px 0;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 16px 24px;
  color: var(--color-text-faint);
  font-size: 12px;
  border-top: 1px solid var(--color-border-light);
  margin-top: auto;
}

/* Responsive */
@media (max-width: 768px) {
  .upload-grid {
    grid-template-columns: 1fr;
  }
  .header-inner {
    flex-direction: column;
    gap: 4px;
  }
  .stats-bar {
    flex-direction: column;
  }
  .col-mode, .col-conf {
    display: none;
  }
  .col-arabic, .col-french {
    width: 45%;
  }
}

/* ============================================================ */
/* EDITOR MODE                                                  */
/* ============================================================ */

.filter-bar-spacer {
  flex: 1;
}
.editor-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.editor-toggle-btn:hover:not(:disabled) {
  background: var(--color-bg);
  border-color: var(--color-primary);
  color: var(--color-primary);
}
.editor-toggle-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Modal overlay */
.editor-modal {
  position: fixed;
  inset: 0;
  background: #f9fafb;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.editor-modal[hidden] { display: none; }

.editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: #1e293b;
  color: white;
  border-bottom: 1px solid #334155;
  flex-shrink: 0;
}
.editor-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
}
.editor-edit-count {
  font-size: 12px;
  font-weight: 500;
  color: #94a3b8;
  background: #334155;
  padding: 3px 10px;
  border-radius: 12px;
  margin-left: 8px;
}
.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
.editor-divider {
  width: 1px;
  height: 22px;
  background: #475569;
  margin: 0 4px;
}
.editor-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #334155;
  color: white;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
}
.editor-btn-active {
  background: #2563eb;
  border-color: #2563eb;
}
.editor-btn-active:hover:not(:disabled) {
  background: #1d4ed8;
}
#editor-link-selection-btn,
#editor-link-one-to-one-btn,
#editor-disconnect-selection-btn {
  min-height: 36px;
  padding: 8px 13px;
  font-weight: 800;
}
#editor-link-selection-btn,
#editor-link-one-to-one-btn {
  background: #0f766e;
  border-color: #0f766e;
}
#editor-link-selection-btn:hover:not(:disabled),
#editor-link-one-to-one-btn:hover:not(:disabled) {
  background: #0d9488;
}
#editor-disconnect-selection-btn {
  background: #b45309;
  border-color: #b45309;
}
#editor-disconnect-selection-btn:hover:not(:disabled) {
  background: #92400e;
}
.editor-btn:hover:not(:disabled) {
  background: #475569;
}
.editor-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.editor-btn-primary {
  background: #16a34a;
  border-color: #16a34a;
}
.editor-btn-primary:hover {
  background: #15803d;
}
.editor-btn-warn {
  background: #b91c1c;
  border-color: #b91c1c;
}
.editor-btn-warn:hover {
  background: #991b1b;
}
.editor-autosave-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid #14532d;
  border-radius: 999px;
  background: #dcfce7;
  color: #166534;
  font-size: 12px;
  font-weight: 800;
}
.editor-autosave-status.is-saving {
  border-color: #92400e;
  background: #fef3c7;
  color: #92400e;
}
.editor-autosave-status.is-error {
  border-color: #991b1b;
  background: #fee2e2;
  color: #991b1b;
}

.editor-help {
  padding: 8px 24px;
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  font-size: 12px;
  color: #78350f;
  flex-shrink: 0;
}
.editor-shortcuts {
  margin-left: 16px;
  color: #92400e;
}
.editor-help kbd {
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 3px;
  padding: 1px 6px;
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 11px;
}

.editor-body {
  flex: 1;
  overflow: auto;
  padding: 16px 24px;
}

.editor-table {
  width: 100%;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.editor-table .col-actions {
  width: 56px;
  text-align: center;
}
.editor-table .col-link,
.editor-table .cell-link {
  width: 74px;
  text-align: center;
  vertical-align: middle;
}
.editor-table tr {
  transition: background 0.1s;
}
.editor-table tr:hover {
  background: #f8fafc;
}
.editor-table tr.editor-row-selected {
  background: #dbeafe !important;
}

/* Editable cells */
.editor-table .cell-arabic,
.editor-table .cell-french {
  padding: 0 !important;
}
.editor-cell-edit {
  width: 100%;
  min-height: 38px;
  padding: 10px 12px;
  border: 2px solid transparent;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  background: transparent;
  resize: none;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  box-sizing: border-box;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}
.editor-cell-edit:hover {
  background: #f1f5f9;
}
.editor-cell-edit:focus {
  background: white;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.cell-arabic .editor-cell-edit {
  direction: rtl;
  text-align: right;
  font-family: 'Amiri', 'Traditional Arabic', serif;
}
.cell-french .editor-cell-edit {
  direction: ltr;
  text-align: left;
}

/* Orphan visual indicators */
.editor-table tr.editor-row-orphan-ar td.cell-french {
  background: repeating-linear-gradient(45deg, #fef2f2, #fef2f2 10px, #fee2e2 10px, #fee2e2 11px);
}
.editor-table tr.editor-row-orphan-fr td.cell-arabic {
  background: repeating-linear-gradient(45deg, #fef2f2, #fef2f2 10px, #fee2e2 10px, #fee2e2 11px);
}
.editor-table tr.editor-row-manual {
  border-left: 3px solid #16a34a;
}
.editor-table tr.editor-row-priority {
  box-shadow: inset 4px 0 0 #f59e0b;
}
.editor-table tr.editor-row-link-selected {
  outline: 2px solid #2563eb;
  outline-offset: -2px;
}
.editor-priority-marker {
  display: block;
  width: fit-content;
  margin: 4px auto 0;
  padding: 2px 5px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

/* Visual segment boxes and link controls */
.editor-segment-box {
  position: relative;
  min-height: 46px;
  margin: 5px;
  border: 2px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  transition: border-color 0.12s, box-shadow 0.12s, background 0.12s;
}
.editor-segment-box:not(.editor-segment-empty) {
  cursor: grab;
}
.editor-segment-box:not(.editor-segment-empty):hover {
  border-color: #64748b;
  box-shadow: 0 2px 10px rgba(15,23,42,0.08);
}
.editor-segment-box.editor-segment-selected {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
}
.editor-segment-box.editor-segment-dragover {
  border-color: #0f766e;
  background: #ecfdf5;
  box-shadow: 0 0 0 4px rgba(15,118,110,0.18);
}
.editor-segment-box.editor-segment-empty {
  border-style: dashed;
  background: transparent;
  min-height: 42px;
}
.editor-drag-handle {
  position: absolute;
  top: 4px;
  inset-inline-start: 6px;
  z-index: 1;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: grab;
  user-select: none;
}
.editor-segment-box .editor-cell-edit {
  border: none;
  background: transparent;
  padding-inline-start: 22px;
}
.editor-segment-box .editor-cell-edit:hover {
  background: transparent;
}
.editor-segment-box .editor-cell-edit:focus {
  border: none;
  box-shadow: none;
  background: white;
}
.editor-link-btn {
  width: 48px;
  height: 32px;
  border-radius: 999px;
  border: 2px solid #cbd5e1;
  background: white;
  color: #475569;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.12s;
}
.editor-link-btn.editor-link-linked {
  border-color: #0f766e;
  background: #ccfbf1;
  color: #0f766e;
}
.editor-link-btn.editor-link-linked:hover,
.editor-link-btn.editor-link-selected {
  border-color: #2563eb;
  background: #dbeafe;
  color: #1d4ed8;
}
.editor-link-btn.editor-link-open {
  border-style: dashed;
  color: #94a3b8;
  cursor: default;
}
.editor-empty-state {
  padding: 28px;
  text-align: center;
  color: #64748b;
  font-weight: 700;
}

/* Row action menu */
.editor-row-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.editor-row-actions-trigger {
  background: transparent;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 14px;
  color: #6b7280;
  transition: all 0.1s;
}
.editor-row-actions-trigger:hover {
  background: #f3f4f6;
  color: #1f2937;
  border-color: #9ca3af;
}
.editor-row-actions-menu {
  position: absolute;
  top: 100%;
  right: 0;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 180px;
  z-index: 10;
  padding: 4px;
  margin-top: 4px;
}
.editor-row-actions-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 8px 12px;
  font-size: 13px;
  color: #1f2937;
  cursor: pointer;
  border-radius: 4px;
  font-family: inherit;
}
.editor-row-actions-menu button:hover {
  background: #f3f4f6;
}
.editor-row-actions-menu button:disabled {
  color: #9ca3af;
  cursor: not-allowed;
}
.editor-row-actions-menu button:disabled:hover {
  background: transparent;
}
.editor-row-actions-menu .editor-menu-divider {
  height: 1px;
  background: #e5e7eb;
  margin: 4px 0;
}
.editor-row-actions-menu .menu-shortcut {
  margin-left: auto;
  color: #9ca3af;
  font-size: 11px;
}

/* Pair-orphans selection UI */
.editor-table tr.editor-pair-candidate {
  outline: 2px dashed #f59e0b;
  outline-offset: -2px;
}

/* Pairing toast */
.editor-pairing-banner {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  z-index: 1100;
}
.editor-pairing-banner button {
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
}
.editor-pairing-banner button.cancel {
  background: transparent;
  border: 1px solid #475569;
}

/* Confidence badge: manual */
.conf-manual {
  background: #dbeafe;
  color: #1e40af;
}

/* ============================================================ */
/* LANGUAGE PAIR SELECTOR                                       */
/* ============================================================ */

.language-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.lang-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  min-height: 40px;
  cursor: default;
  transition: all var(--transition);
}

.target-pill {
  padding-right: 14px; /* extra room for the dropdown chevron */
  cursor: pointer;
}

.target-pill:hover {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-md);
}

.lang-pill-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(255, 255, 255, 0.7);
}

.lang-pill-name {
  font-size: 14px;
  font-weight: 600;
  color: white;
}

.lang-arrow {
  font-size: 18px;
  color: var(--color-text-muted, #9ca3af);
  font-weight: 500;
}

.target-lang-select {
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: white;
  cursor: pointer;
  outline: none;
  padding: 0 4px;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0 center;
  padding-right: 22px;
}

.target-lang-select option {
  /* native dropdown styling — reset to readable defaults */
  background: white;
  color: var(--color-text);
  font-weight: 500;
}

.target-lang-select:focus {
  outline: none;
}

@media (max-width: 600px) {
  .language-selector {
    flex-direction: column;
    align-items: stretch;
  }
  .lang-arrow {
    text-align: center;
    transform: rotate(90deg);
  }
  .lang-pill {
    width: 100%;
    justify-content: center;
  }
}

/* ===== V17 W19/W20 — multi-file upload + batch table ===== */

.upload-multi {
  margin-bottom: 18px;
}

.drop-zone-multi {
  /* Bigger drop target than the single-card zones */
  min-height: 180px;
  padding: 32px 24px;
  border: 2px dashed #C9A060;
  background: #FFFEF8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease;
  text-align: center;
}

.drop-zone-multi:hover,
.drop-zone-multi.drag-over {
  background: #FFF7E6;
  border-color: #8A6A33;
}

.drop-zone-multi p {
  margin: 0;
  color: #1B2B5C;
  font-size: 15px;
}

.drop-zone-multi .drop-zone-sub {
  color: #666;
  font-size: 12.5px;
}

.drop-zone-multi code {
  background: #f5efe2;
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 12px;
  color: #5a4500;
}

.multi-toggle {
  text-align: right;
  margin-top: 8px;
}

.link-btn {
  background: none;
  border: none;
  color: #1B2B5C;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-btn:hover {
  color: #C9A060;
}

/* Summary table shown BEFORE the user clicks Align */
.batch-summary {
  margin: 18px 0;
  padding: 14px 16px;
  background: #FAFAF6;
  border: 1px solid #DBD5C2;
  border-radius: 6px;
}

.batch-summary-title {
  margin: 0 0 10px 0;
  font-size: 15px;
  color: #1B2B5C;
}

.batch-summary-table,
.batch-progress-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.batch-summary-table th,
.batch-summary-table td,
.batch-progress-table th,
.batch-progress-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #EEE8D8;
  vertical-align: middle;
}

.batch-summary-table th,
.batch-progress-table th {
  background: #F5EFE2;
  font-weight: 600;
  color: #5a4500;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.batch-summary-table tr.error td,
.batch-progress-table tr.error td {
  background: #FEF2F2;
}

.batch-warnings {
  margin-top: 10px;
  padding: 8px 12px;
  background: #FFF8E1;
  border-left: 3px solid #C9A060;
  color: #5A4500;
  font-size: 13px;
  border-radius: 3px;
}

.batch-warnings ul {
  margin: 4px 0 0 18px;
  padding: 0;
}

.batch-status {
  font-weight: 600;
  font-size: 12.5px;
}

.batch-status.ready   { color: #2F855A; }
.batch-status.queued  { color: #6B7280; }
.batch-status.running { color: #C9A060; }
.batch-status.done    { color: #2F855A; }
.batch-status.failed  { color: #B91C1C; }

.batch-progress-note {
  font-size: 13px;
  color: #555;
  margin: 0 0 14px 0;
}

.batch-progress-table .download-cell {
  white-space: nowrap;
}

.batch-progress-table .download-link {
  display: inline-block;
  margin-right: 6px;
  padding: 4px 10px;
  background: #1B2B5C;
  color: #fff;
  text-decoration: none;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
  border: 0;          /* V17.1: also styled as <button>, kill UA defaults */
  cursor: pointer;
  font-family: inherit;
  line-height: 1.4;
}

.batch-progress-table .download-link:hover {
  background: #2A3E7A;
}

.batch-progress-table .download-link.tmx,
.batch-progress-table .download-link.xliff {
  background: transparent;
  color: #1B2B5C;
  border: 1px solid #1B2B5C;
}

.batch-progress-table .download-link.tmx:hover,
.batch-progress-table .download-link.xliff:hover {
  background: #F5EFE2;
}

.batch-progress-table .file-cell {
  font-family: ui-monospace, "SF Mono", Monaco, Consolas, monospace;
  font-size: 12.5px;
}

.batch-progress-table .row-elapsed {
  font-size: 11.5px;
  color: #888;
  margin-left: 6px;
}

/* ============================================================
   V19 — Alignment viewer modal + batch toolbar + bundle button
   ============================================================ */

.miz-batch-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0 14px;
}
.miz-batch-toolbar[hidden] { display: none; }
.miz-batch-toolbar-note {
  font-size: 13px;
  color: #5a5a5a;
}

/* Bundle / "All (.zip)" buttons inherit .download-link styling, but get
   a distinctive accent so users see the new option. */
.download-link.bundle {
  background: #243250;
  color: #fff;
  border-color: #1b2541;
}
.download-link.bundle:hover { background: #1b2541; }
.download-link.bundle[disabled],
.download-link.bundle[disabled]:hover {
  background: #6b7793;
  cursor: progress;
}
.download-link.view {
  background: #fff;
  color: #243250;
  border: 1px solid #c9c6bc;
}
.download-link.view:hover {
  background: #f1eee5;
}

/* View column in the batch table */
.view-cell {
  white-space: nowrap;
}

/* ----- Viewer modal ----- */
.miz-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20000;
  padding: 24px;
}
.miz-viewer-overlay[hidden] { display: none; }

.miz-viewer-modal {
  background: #fff;
  border-radius: 6px;
  width: min(1200px, 100%);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

.miz-viewer-header {
  padding: 14px 18px;
  border-bottom: 1px solid #e7e3d6;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.miz-viewer-header h3 {
  margin: 0;
  font-size: 16px;
  color: #243250;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.miz-viewer-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.miz-viewer-tools input[type="search"] {
  border: 1px solid #c9c6bc;
  border-radius: 4px;
  padding: 5px 9px;
  font: 13px system-ui, -apple-system, sans-serif;
  min-width: 200px;
}
.miz-viewer-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #444;
  user-select: none;
}

.miz-viewer-meta {
  padding: 8px 18px;
  background: #faf8f1;
  border-bottom: 1px solid #ece7d4;
  font-size: 13px;
  color: #444;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.miz-viewer-warnings {
  color: #a3722a;
  cursor: help;
}

.miz-viewer-body {
  overflow: auto;
  flex: 1;
  padding: 0;
  background: #fff;
}

.miz-viewer-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
.miz-viewer-table thead th {
  position: sticky;
  top: 0;
  background: #f3efe2;
  border-bottom: 1px solid #d9d3bc;
  text-align: left;
  padding: 8px 10px;
  font-weight: 600;
  color: #243250;
  z-index: 1;
}
.miz-viewer-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid #f0ecdc;
  vertical-align: top;
  word-wrap: break-word;
  line-height: 1.45;
}
.miz-viewer-table tr.orphan {
  background: #fff7e0;
}
.miz-viewer-table tr.orphan td.col-src:empty::after,
.miz-viewer-table tr.orphan td.col-tgt:empty::after {
  content: "—";
  color: #c4a25c;
}
.miz-viewer-table .col-idx  { width: 60px;  color: #888; font-variant-numeric: tabular-nums; }
.miz-viewer-table .col-conf { width: 70px; }
.miz-viewer-table .col-src  { width: 38%; }
.miz-viewer-table .col-tgt  { width: 38%; }
.miz-viewer-table .col-flag { width: 14%; color: #666; font-size: 12px; }

.miz-viewer-table .col-conf.conf-high   { color: #2a7a2a; font-weight: 600; }
.miz-viewer-table .col-conf.conf-medium { color: #b07a00; font-weight: 600; }
.miz-viewer-table .col-conf.conf-low    { color: #a13a3a; font-weight: 600; }

.miz-viewer-table .col-src {
  direction: rtl;
  font-family: "Tahoma", "Segoe UI", "Arial", sans-serif;
}

.miz-viewer-empty {
  padding: 24px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

/* V19 — Improve alignment button (opens the editor in a new tab) */
.improve-cell { white-space: nowrap; }
.download-link.improve {
  background: #fff8e1;
  color: #5a4500;
  border: 1px solid #d8b85a;
}
.download-link.improve:hover {
  background: #f3e3a8;
  color: #3a2c00;
}

/* V19 — batch-table footer with bulk-download per-format buttons + New Alignment */
#batch-progress-foot[hidden] { display: none; }
.batch-progress-table tfoot td {
  background: #faf8f1;
  border-top: 2px solid #d9d3bc;
  padding: 12px 14px;
  vertical-align: middle;
}
.batch-progress-table tfoot .foot-actions {
  text-align: left;
}
.batch-progress-table tfoot .foot-downloads {
  text-align: left;
  white-space: nowrap;
}
.batch-progress-table tfoot .foot-downloads .download-link {
  margin-right: 4px;
}
#miz-new-alignment-btn {
  font-size: 13px;
  padding: 6px 14px;
}
.download-link.html {
  background: #fff;
  color: #243250;
  border: 1px solid #c9c6bc;
}
.download-link.html:hover { background: #f1eee5; }
