/* ═══════════════════════════════════════════════════════════════════
   SỔ TAY FSRS — Upload Modal Stylesheet v1.0
   Overlay + 3-step wizard: file picker → preview table → saving
   ═══════════════════════════════════════════════════════════════════ */

/* --- Overlay --- */
.sotay-upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--sotay-dur) var(--sotay-easing);
}
.sotay-upload-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* --- Modal --- */
.sotay-upload-modal {
  width: 94vw;
  max-width: 680px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--sotay-panel);
  border: 1px solid var(--sotay-border-hi);
  border-radius: var(--sotay-radius-lg);
  box-shadow: var(--sotay-shadow), 0 0 60px rgba(200, 169, 110, 0.08);
  transform: translateY(20px) scale(0.97);
  transition: transform var(--sotay-dur-slow) var(--sotay-easing);
}
.sotay-upload-overlay.is-open .sotay-upload-modal {
  transform: translateY(0) scale(1);
}

/* Header */
.sotay-upload-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--sotay-border);
}
.sotay-upload-modal__header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--sotay-gold);
  display: flex;
  align-items: center;
  gap: 8px;
}
.sotay-upload-modal__header h2 i {
  color: var(--sotay-accent-2);
}
.sotay-upload-close {
  background: none;
  border: none;
  color: var(--sotay-text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background var(--sotay-dur-fast), color var(--sotay-dur-fast);
}
.sotay-upload-close:hover {
  background: rgba(255,255,255,0.07);
  color: var(--sotay-text);
}

/* Body */
.sotay-upload-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* --- Tab toggle --- */
.sotay-upload-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
  border: 1px solid var(--sotay-border);
  border-radius: var(--sotay-radius-sm);
  overflow: hidden;
}
.sotay-upload-tab {
  flex: 1;
  padding: 8px 0;
  background: transparent;
  border: none;
  color: var(--sotay-text-dim);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--sotay-dur-fast);
  font-family: inherit;
}
.sotay-upload-tab + .sotay-upload-tab {
  border-left: 1px solid var(--sotay-border);
}
.sotay-upload-tab:hover {
  background: rgba(255,255,255,0.04);
}
.sotay-upload-tab.is-active {
  background: rgba(200, 169, 110, 0.12);
  color: var(--sotay-gold);
}

/* --- Textarea (paste mode) --- */
.sotay-upload-textarea {
  width: 100%;
  min-height: 140px;
  max-height: 280px;
  padding: 12px;
  background: var(--sotay-card);
  border: 1px solid var(--sotay-border);
  border-radius: var(--sotay-radius-sm);
  color: var(--sotay-text);
  font-size: 0.92rem;
  font-family: 'Noto Serif SC', 'Inter', sans-serif;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color var(--sotay-dur-fast);
}
.sotay-upload-textarea:focus {
  border-color: var(--sotay-gold);
}
.sotay-upload-textarea::placeholder {
  color: var(--sotay-text-mute);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
}

/* Footer */
.sotay-upload-modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--sotay-border);
}

/* --- Dropzone --- */
.sotay-upload-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 40px 20px;
  border: 2px dashed var(--sotay-border-hi);
  border-radius: var(--sotay-radius-md);
  background: rgba(200, 169, 110, 0.03);
  cursor: pointer;
  transition: border-color var(--sotay-dur), background var(--sotay-dur);
  text-align: center;
}
.sotay-upload-dropzone:hover,
.sotay-upload-dropzone.is-dragover {
  border-color: var(--sotay-gold);
  background: rgba(200, 169, 110, 0.08);
}
.sotay-upload-dropzone i {
  font-size: 2.4rem;
  color: var(--sotay-text-dim);
}
.sotay-upload-dropzone p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--sotay-text);
}
.sotay-upload-hint {
  font-size: 0.8rem;
  color: var(--sotay-text-mute);
}

/* --- Tên chủ đề --- */
.sotay-upload-name-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.sotay-upload-name-row label {
  font-size: 0.88rem;
  color: var(--sotay-text-dim);
  white-space: nowrap;
}
.sotay-upload-name-row input {
  flex: 1;
  padding: 8px 12px;
  background: var(--sotay-card);
  border: 1px solid var(--sotay-border);
  border-radius: var(--sotay-radius-sm);
  color: var(--sotay-text);
  font-size: 0.92rem;
  outline: none;
  transition: border-color var(--sotay-dur-fast);
}
.sotay-upload-name-row input:focus {
  border-color: var(--sotay-gold);
}

/* --- Info banner (step 2) --- */
.sotay-upload-info {
  margin-bottom: 12px;
}
.sotay-upload-info p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--sotay-text);
}
.sotay-upload-info strong {
  color: var(--sotay-gold);
}

/* --- Actions top row --- */
.sotay-upload-actions-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.sotay-upload-count {
  margin-left: auto;
  font-size: 0.82rem;
  color: var(--sotay-text-dim);
}

/* --- Preview table --- */
.sotay-upload-table-wrap {
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--sotay-border);
  border-radius: var(--sotay-radius-sm);
}
.sotay-upload-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.sotay-upload-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}
.sotay-upload-table th {
  background: var(--sotay-card);
  color: var(--sotay-text-dim);
  font-weight: 500;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--sotay-border);
  white-space: nowrap;
}
.sotay-upload-table td {
  padding: 7px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}
.sotay-upload-table tr:hover td {
  background: rgba(255,255,255,0.03);
}
.sotay-upload-table input[type="checkbox"] {
  accent-color: var(--sotay-gold);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Cột hanzi */
.sotay-up-hanzi {
  font-family: 'Noto Serif SC', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--sotay-gold-soft);
}
.sotay-up-pinyin {
  color: var(--sotay-text-dim);
  font-size: 0.85rem;
}
.sotay-up-meaning {
  color: var(--sotay-text);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sotay-up-meaning-cell {
  cursor: pointer;
  transition: background var(--sotay-dur-fast);
}
.sotay-up-meaning-cell:hover {
  background: rgba(200, 169, 110, 0.08);
}
.sotay-up-inline-input {
  width: 100%;
  padding: 3px 6px;
  background: var(--sotay-card);
  border: 1px solid var(--sotay-gold);
  border-radius: 4px;
  color: var(--sotay-text);
  font-size: 0.85rem;
  outline: none;
}

/* HSK badge */
.sotay-up-hsk {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(200, 169, 110, 0.15);
  color: var(--sotay-gold);
}

/* --- Saving spinner (step 3) --- */
.sotay-upload-saving {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 40px 20px;
}
.sotay-upload-saving p {
  margin: 0;
  color: var(--sotay-text-dim);
}

/* --- Buttons (reuse existing sotay-btn + add sm variant) --- */
.sotay-btn--sm {
  padding: 4px 12px;
  font-size: 0.82rem;
}

/* --- Mobile --- */
@media (max-width: 600px) {
  .sotay-upload-modal {
    width: 98vw;
    max-height: 94vh;
    border-radius: var(--sotay-radius-md);
  }
  .sotay-upload-dropzone {
    padding: 28px 14px;
  }
  .sotay-upload-table-wrap {
    max-height: 280px;
  }
  .sotay-up-meaning {
    max-width: 120px;
  }
}

/* ═══════════════════════════════════════════════════════════════════
   S52 — LIGHT MODE: Upload modal "Nhập từ vựng"
   Palette muted/earthy mở rộng từ 4 màu Founder:
     #c7312f brick red · #4087a6 petrol · #f3b6b6 blush · #5e6266 slate
     + #d4a574 honey · #9ab87a sage · #e8c4b8 peach · #3a3d3f charcoal · #fdf6f3 cream
   Scope dưới html[data-theme="light"] — dark mode KHÔNG đổi.
   ═══════════════════════════════════════════════════════════════════ */

/* Backdrop nhẹ hơn, ấm hơn */
html[data-theme="light"] .sotay-upload-overlay {
  background: rgba(58,61,63,0.35);
  backdrop-filter: blur(3px);
}

/* Modal — nền kem ấm, viền slate đậm, không 3D shadow */
html[data-theme="light"] .sotay-upload-modal {
  background: #fdf6f3;
  border: 2px solid #5e6266;
  box-shadow: 0 8px 28px rgba(58,61,63,0.18);
}

/* Header — title brick red, icon honey */
html[data-theme="light"] .sotay-upload-modal__header {
  border-bottom: 1px solid #e8c4b8;
  background: linear-gradient(180deg, #fbeae5 0%, #fdf6f3 100%);
}
html[data-theme="light"] .sotay-upload-modal__header h2 {
  color: #c7312f;
  font-weight: 800;
  font-size: 1.2rem;
}
html[data-theme="light"] .sotay-upload-modal__header h2 i {
  color: #d4a574;
}
html[data-theme="light"] .sotay-upload-close {
  color: #5e6266;
  font-weight: 700;
}
html[data-theme="light"] .sotay-upload-close:hover {
  background: rgba(199,49,47,0.10);
  color: #c7312f;
}

/* Body — không đổi */
html[data-theme="light"] .sotay-upload-modal__body {
  background: #fdf6f3;
}

/* Tabs — peach pill cho active, slate cho inactive */
html[data-theme="light"] .sotay-upload-tabs {
  border: 1px solid #5e6266;
  background: #ffffff;
  border-radius: 10px;
}
html[data-theme="light"] .sotay-upload-tab {
  color: #5e6266;
  font-weight: 700;
  font-size: 0.92rem;
}
html[data-theme="light"] .sotay-upload-tab + .sotay-upload-tab {
  border-left-color: #5e6266;
}
html[data-theme="light"] .sotay-upload-tab:hover {
  background: rgba(232,196,184,0.40);
  color: #c7312f;
}
html[data-theme="light"] .sotay-upload-tab.is-active {
  background: linear-gradient(135deg, #e8c4b8 0%, #f3b6b6 100%);
  color: #c7312f;
  font-weight: 800;
}

/* Textarea — fix legacy `body.dark-mode textarea { #222 !important }` */
html[data-theme="light"] .sotay-upload-textarea {
  background: #ffffff !important;
  border: 1.5px solid #5e6266 !important;
  color: #3a3d3f !important;
  font-weight: 500;
}
html[data-theme="light"] .sotay-upload-textarea:focus {
  border-color: #c7312f !important;
  box-shadow: 0 0 0 3px rgba(199,49,47,0.12);
}
html[data-theme="light"] .sotay-upload-textarea::placeholder {
  color: #8b8d8f;
  font-style: italic;
}

/* Dropzone — petrol dashed + peach bg */
html[data-theme="light"] .sotay-upload-dropzone {
  background: rgba(232,196,184,0.18);
  border: 2px dashed #4087a6;
}
html[data-theme="light"] .sotay-upload-dropzone:hover,
html[data-theme="light"] .sotay-upload-dropzone.is-dragover {
  background: rgba(232,196,184,0.36);
  border-color: #c7312f;
}
html[data-theme="light"] .sotay-upload-dropzone i {
  color: #4087a6;
}
html[data-theme="light"] .sotay-upload-dropzone p {
  color: #3a3d3f;
  font-weight: 700;
}
html[data-theme="light"] .sotay-upload-hint {
  color: #5e6266;
  font-weight: 600;
}

/* Tên chủ đề input — fix legacy override */
html[data-theme="light"] .sotay-upload-name-row label {
  color: #3a3d3f;
  font-weight: 700;
  font-size: 0.95rem;
}
html[data-theme="light"] .sotay-upload-name-row input {
  background: #ffffff !important;
  border: 1.5px solid #5e6266 !important;
  color: #3a3d3f !important;
  font-weight: 600;
}
html[data-theme="light"] .sotay-upload-name-row input:focus {
  border-color: #4087a6 !important;
  box-shadow: 0 0 0 3px rgba(64,135,166,0.12);
}

/* Info banner — strong = brick red */
html[data-theme="light"] .sotay-upload-info p {
  color: #3a3d3f;
  font-weight: 600;
}
html[data-theme="light"] .sotay-upload-info strong {
  color: #c7312f;
  font-weight: 800;
}

/* Actions top row — count text */
html[data-theme="light"] .sotay-upload-count {
  color: #5e6266;
  font-weight: 700;
}

/* Footer */
html[data-theme="light"] .sotay-upload-modal__footer {
  border-top: 1px solid #e8c4b8;
  background: linear-gradient(0deg, #fbeae5 0%, #fdf6f3 100%);
}

/* Preview table */
html[data-theme="light"] .sotay-upload-table-wrap {
  border: 1.5px solid #5e6266;
  background: #ffffff;
}
html[data-theme="light"] .sotay-upload-table th {
  background: #fbeae5;
  color: #c7312f;
  border-bottom: 2px solid #5e6266;
  font-weight: 800;
}
html[data-theme="light"] .sotay-upload-table td {
  border-bottom-color: #f3e0d8;
  color: #3a3d3f;
}
html[data-theme="light"] .sotay-upload-table tr:hover td {
  background: rgba(232,196,184,0.22);
}
html[data-theme="light"] .sotay-upload-table input[type="checkbox"] {
  accent-color: #c7312f;
}

/* Hanzi column — honey caramel */
html[data-theme="light"] .sotay-up-hanzi {
  color: #b8842f;
  font-weight: 700;
}
html[data-theme="light"] .sotay-up-pinyin {
  color: #4087a6;
  font-weight: 600;
}
html[data-theme="light"] .sotay-up-meaning {
  color: #3a3d3f;
  font-weight: 500;
}
html[data-theme="light"] .sotay-up-meaning-cell:hover {
  background: rgba(154,184,122,0.18);
}
html[data-theme="light"] .sotay-up-inline-input {
  background: #ffffff !important;
  border: 1.5px solid #c7312f !important;
  color: #3a3d3f !important;
}

/* HSK badge — peach pill */
html[data-theme="light"] .sotay-up-hsk {
  background: linear-gradient(135deg, #e8c4b8 0%, #f3b6b6 100%);
  color: #c7312f;
  font-weight: 800;
  border: 1px solid #c7312f;
}

/* Saving spinner */
html[data-theme="light"] .sotay-upload-saving p {
  color: #5e6266;
  font-weight: 600;
}

/* Footer buttons — scope trong upload modal để không leak ra global */
/* Hủy button (.sotay-btn default) — outline slate */
html[data-theme="light"] .sotay-upload-modal__footer .sotay-btn {
  background: #ffffff;
  border: 1.5px solid #5e6266;
  color: #3a3d3f;
  font-weight: 700;
  box-shadow: none;
}
html[data-theme="light"] .sotay-upload-modal__footer .sotay-btn:hover {
  background: rgba(94,98,102,0.08);
  border-color: #3a3d3f;
}
/* Phân tích button (.sotay-btn--primary) — brick red gradient flat */
html[data-theme="light"] .sotay-upload-modal__footer .sotay-btn--primary {
  background: linear-gradient(135deg, #c7312f 0%, #a82929 100%);
  border: none;
  color: #ffffff;
  font-weight: 800;
  box-shadow: 0 2px 6px rgba(199,49,47,0.25);
}
html[data-theme="light"] .sotay-upload-modal__footer .sotay-btn--primary:hover {
  background: linear-gradient(135deg, #d63b39 0%, #b73030 100%);
  box-shadow: 0 4px 10px rgba(199,49,47,0.35);
  filter: brightness(1.04);
}
html[data-theme="light"] .sotay-upload-modal__footer .sotay-btn--primary:disabled {
  background: #c4bedd;
  color: #ffffff;
  cursor: not-allowed;
  box-shadow: none;
  opacity: 0.65;
}
html[data-theme="light"] .sotay-upload-modal__footer .sotay-btn--sm {
  padding: 6px 14px;
  font-size: 0.88rem;
}
