/* ============================================================================
   DICTIONARY EDITOR
   ============================================================================ */

.de-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  overflow: hidden;
}

/* ---- Toolbar ---- */

.de-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.de-search {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  padding: 8px 12px 8px 34px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  outline: none;
  background: #f8fafc url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 10px center no-repeat;
}

.de-search:focus {
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  background-color: #fff;
}

.de-stats {
  font-size: 13px;
  color: #94a3b8;
  margin-left: auto;
}

.de-toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  background: #fff;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.de-toolbar-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.de-toolbar-btn.primary {
  background: var(--color-primary, #2563eb);
  color: #fff;
  border-color: var(--color-primary, #2563eb);
}

.de-toolbar-btn.primary:hover {
  filter: brightness(1.1);
}

/* ---- Table ---- */

.de-table-wrap {
  flex: 1;
  overflow: auto;
}

.de-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}

.de-table thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.de-table th {
  position: relative;
  background: #f8fafc;
  border-bottom: 2px solid var(--border-color, #e2e8f0);
  padding: 10px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
  vertical-align: middle;
  overflow: hidden;
}

/* Column resize handle */

.de-col-resize {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  background: transparent;
  z-index: 2;
  transition: background 150ms;
}

.de-col-resize:hover,
.de-col-resize.active {
  background: var(--color-primary, #2563eb);
}

.de-col-key {
  width: 160px;
}

.de-col-lang {
  width: 140px;
}

.de-col-lang.base-lang {
  background: #eff6ff !important;
}

/* Language column header */

.de-lang-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.de-lang-header-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
}

.de-base-badge {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary, #2563eb);
  background: var(--color-primary-bg, #eff6ff);
  padding: 1px 5px;
  border-radius: 4px;
}

.de-lang-missing-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: var(--color-warning, #f59e0b);
  border-radius: 99px;
  line-height: 1;
}

.de-header-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.1s;
  margin-left: auto;
}

.de-header-btn:hover {
  background: #e2e8f0;
  color: #475569;
}

/* ---- Table body ---- */

.de-table td {
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  padding: 0;
  vertical-align: middle;
  height: 40px;
  overflow: hidden;
}

/* Group header row */

.de-group-row {
  cursor: pointer;
  user-select: none;
}

.de-group-row td {
  background: #f1f5f9;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.de-group-row:hover td {
  background: #e8ecf1;
}

.de-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.de-group-chevron {
  transition: transform 0.15s;
  color: #94a3b8;
}

.de-group-chevron.collapsed {
  transform: rotate(-90deg);
}

.de-group-count {
  font-size: 12px;
  font-weight: 400;
  color: #94a3b8;
}

/* Key cell */

.de-key-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-size: 13px;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  color: #64748b;
}

.de-key-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.de-key-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.1s;
  opacity: 0;
  flex-shrink: 0;
}

.de-key-cell:hover .de-key-delete {
  opacity: 1;
}

.de-key-delete:hover {
  background: #fef2f2;
  color: var(--color-error, #ef4444);
}

/* Language cells */

.de-td-lang {
  overflow: hidden;
}

.de-td-lang.base-lang-cell {
  background: #fafcff;
}

.de-cell {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  min-height: 30px;
  cursor: text;
  border-radius: 3px;
  margin: 2px 3px;
  transition: background 0.1s;
}

.de-cell:hover {
  background: #f1f5f9;
}

.de-cell-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1e293b;
  font-size: 14px;
}

.de-cell-empty {
  flex: 1;
  color: #cbd5e1;
  font-style: italic;
  font-size: 13px;
}

.de-cell-translate-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: all 0.1s;
  opacity: 0;
  flex-shrink: 0;
}

.de-cell:hover .de-cell-translate-btn,
.de-cell-translate-btn.translating {
  opacity: 1;
}

.de-cell-translate-btn:hover {
  background: var(--color-primary-bg, #eff6ff);
  color: var(--color-primary, #2563eb);
}

.de-cell-translate-btn.translating {
  animation: de-spin 1s linear infinite;
  color: var(--color-primary, #2563eb);
}

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

/* Cell input */

.de-cell-input {
  width: 100%;
  padding: 4px 8px;
  margin: 2px 3px;
  font-size: 14px;
  font-family: inherit;
  border: 2px solid var(--color-primary, #2563eb);
  border-radius: 5px;
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  box-sizing: border-box;
}

/* ---- Modal overlay (add key / add language) ---- */

.de-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.35);
}

.de-modal {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  padding: 28px;
  width: 420px;
  max-width: 90vw;
}

.de-modal h3 {
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 600;
  color: #1e293b;
}

.de-form-field {
  margin-bottom: 16px;
}

.de-form-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  margin-bottom: 5px;
}

.de-form-field input,
.de-form-field select {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  outline: none;
  box-sizing: border-box;
}

.de-form-field input:focus,
.de-form-field select:focus {
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.de-form-row {
  display: flex;
  gap: 12px;
}

.de-form-row .de-form-field {
  flex: 1;
}

.de-form-hint {
  font-size: 12px;
  color: #94a3b8;
  margin-top: 4px;
}

.de-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
}

.de-modal-actions button {
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid var(--border-color, #e2e8f0);
  background: #fff;
  color: #475569;
  transition: all 0.15s;
}

.de-modal-actions button:hover {
  background: #f1f5f9;
}

.de-modal-actions button.primary {
  background: var(--color-primary, #2563eb);
  color: #fff;
  border-color: var(--color-primary, #2563eb);
}

.de-modal-actions button.primary:hover {
  filter: brightness(1.1);
}

/* ---- Empty state ---- */

.de-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: #94a3b8;
  gap: 8px;
}

.de-empty p {
  font-size: 14px;
}

/* ---- Language selector in Add Language modal ---- */

.de-lang-select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  outline: none;
  box-sizing: border-box;
  cursor: pointer;
  background: #fff;
}

.de-lang-select:focus {
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.de-lang-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
}

.de-lang-preview-flag {
  font-size: 36px;
  line-height: 1;
}

.de-lang-preview-name {
  font-size: 16px;
  font-weight: 600;
  color: #1e293b;
}

.de-lang-preview-meta {
  font-size: 13px;
  color: #94a3b8;
  margin-top: 2px;
}

.de-modal-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
