/* ══════════════════════════════════════════════════════════════
   dictionary-popup.css — shared double-click dictionary lookup UI
   Used by pages that load js/shared/dictionary-lookup.js (currently
   Writing + Vocab/dashboard). Reading/Listening keep their own
   pre-existing copies of these same class names in reading.css /
   listening.css — not unified here to avoid touching those pages.
═══════════════════════════════════════════════════════════════ */

.dict-popup {
  position: fixed;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  padding: 16px 18px 14px;
  width: 320px;
  /* Must outrank writing.css's .modal-overlay (z-index:1100) and the shared
     --z-modal token (1000, css/tokens.css) — the popup is opened while the
     review-modal (#review-modal-body) is on screen, so anything lower would
     render invisibly behind that modal's backdrop. */
  z-index: 1200;
  border: 1px solid #e5e7eb;
}
.dict-popup.hidden { display: none; }

.dict-header { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.dict-word { font-size: 20px; font-weight: 800; color: #1e3a8a; flex: 1; }
.dict-phonetic {
  font-size: 12px; color: #6b7280; margin-bottom: 10px;
  display: block; font-family: 'Courier New', monospace;
}
.dict-close {
  background: none; border: none; cursor: pointer; color: #9ca3af;
  font-size: 16px; line-height: 1; padding: 2px 4px; border-radius: 4px;
  transition: color .15s;
}
.dict-close:hover { color: #374151; }
.dict-speak {
  background: none; border: none; cursor: pointer; font-size: 15px;
  padding: 3px 6px; border-radius: 6px; color: #3d8bff; transition: background .15s;
}
.dict-speak:hover { background: #eff6ff; }
.dict-body { max-height: 300px; overflow-y: auto; padding-right: 2px; }
.dict-loading { text-align: center; padding: 20px 16px; color: #9ca3af; font-size: 13px; }

.dict-primary-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.dict-primary-meaning { font-size: 22px; font-weight: 800; color: #1e3a8a; line-height: 1.2; flex: 1; }
.dict-save-btn {
  flex-shrink: 0; padding: 6px 12px; background: #e53935; color: #fff;
  border: none; border-radius: 8px; font-size: 12px; font-weight: 700;
  cursor: pointer; transition: background .15s; white-space: nowrap;
}
.dict-save-btn:hover { background: #c62828; }

.dict-chips-label {
  font-size: 10px; font-weight: 700; color: #9ca3af;
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 5px;
}
.dict-chips-wrap { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.dict-meaning-chip {
  padding: 3px 10px; background: #f3f4f6; border: 1px solid #e5e7eb;
  border-radius: 20px; font-size: 12px; color: #374151; cursor: pointer;
  font-family: inherit; transition: all .13s;
}
.dict-meaning-chip:hover { background: #eff6ff; border-color: #3d8bff; color: #1d4ed8; }
.dict-meaning-chip.active { background: #dbeafe; border-color: #2563eb; color: #1e40af; font-weight: 600; }

.dict-ex-section { border-top: 1px solid #f3f4f6; padding-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.dict-ex-item { font-size: 12px; font-style: italic; color: #6b7280; line-height: 1.5; border-left: 3px solid #dbeafe; padding-left: 8px; }

/* ── Meaning / Collocations tabs ── */
.dict-tabs { display: flex; gap: 2px; margin-bottom: 10px; border-bottom: 1px solid #e5e7eb; }
.dict-tab {
  background: none; border: none; cursor: pointer; font-family: inherit;
  font-size: 12px; font-weight: 700; color: #9ca3af; padding: 6px 4px 8px;
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s;
}
.dict-tab:hover { color: #374151; }
.dict-tab.active { color: #e53935; border-bottom-color: #e53935; }
.dict-tab-panel + .dict-tab-panel { margin-top: 0; }

.dict-colloc-item { padding: 8px 0; border-top: 1px solid #f3f4f6; }
.dict-colloc-item:first-child { border-top: none; padding-top: 0; }
.dict-colloc-phrase { font-size: 14px; font-weight: 700; color: #1e3a8a; }
.dict-colloc-meaning { font-size: 12px; color: #374151; margin-top: 2px; }
.dict-colloc-example { font-size: 12px; font-style: italic; color: #6b7280; line-height: 1.5; margin-top: 3px; border-left: 3px solid #dbeafe; padding-left: 8px; }
.dict-colloc-empty { text-align: center; padding: 16px 8px; color: #9ca3af; font-size: 12px; }
.dict-colloc-retry {
  display: block; margin: 8px auto 0; background: none; border: 1px solid #d1d5db;
  border-radius: 8px; padding: 4px 12px; font-size: 12px; color: #374151; cursor: pointer;
}

[data-theme="dark"] .dict-popup            { background: var(--surface, #0d0d0d); border-color: var(--border2, #333333); box-shadow: 0 10px 36px rgba(0,0,0,.5); }
[data-theme="dark"] .dict-word             { color: #93c5fd; }
[data-theme="dark"] .dict-phonetic         { color: #9ca3af; }
[data-theme="dark"] .dict-close            { color: #6b7280; }
[data-theme="dark"] .dict-primary-meaning  { color: #e5e7eb; }
[data-theme="dark"] .dict-save-btn         { background: #b91c1c; }
[data-theme="dark"] .dict-save-btn:hover   { background: #991b1b; }
[data-theme="dark"] .dict-chips-label      { color: #6b7280; }
[data-theme="dark"] .dict-meaning-chip     { background: var(--border2, #333333); border-color: #4b5563; color: #d1d5db; }
[data-theme="dark"] .dict-meaning-chip:hover  { background: #1e3a5f; border-color: #3d8bff; color: #93c5fd; }
[data-theme="dark"] .dict-meaning-chip.active { background: #1e3a8a; border-color: #2563eb; color: #bfdbfe; }
[data-theme="dark"] .dict-ex-section       { border-top-color: var(--border2, #333333); }
[data-theme="dark"] .dict-ex-item          { color: #9ca3af; border-left-color: var(--border2, #333333); }
[data-theme="dark"] .dict-tabs             { border-bottom-color: var(--border2, #333333); }
[data-theme="dark"] .dict-tab              { color: #6b7280; }
[data-theme="dark"] .dict-tab:hover        { color: #d1d5db; }
[data-theme="dark"] .dict-tab.active       { color: #f87171; border-bottom-color: #f87171; }
[data-theme="dark"] .dict-colloc-item      { border-top-color: var(--border2, #333333); }
[data-theme="dark"] .dict-colloc-phrase    { color: #93c5fd; }
[data-theme="dark"] .dict-colloc-meaning   { color: #d1d5db; }
[data-theme="dark"] .dict-colloc-example   { color: #9ca3af; border-left-color: var(--border2, #333333); }
[data-theme="dark"] .dict-colloc-empty     { color: #6b7280; }
[data-theme="dark"] .dict-colloc-retry     { border-color: var(--border2, #333333); color: #d1d5db; }

/* ── Vocab book-picker modal (self-contained: not tied to any page's
      own .modal-overlay convention, so this file can be dropped into
      any page unchanged) ─────────────────────────────────────────── */
.dict-vocab-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center;
  /* Same reasoning as .dict-popup above: "Lưu từ" inside the dict-popup
     opens this modal next, and dict lookup is enabled inside writing.html's
     #review-modal-body, which lives inside a .modal-overlay (z-index:1100).
     At 950 this rendered invisibly behind that backdrop the moment a
     student tried to save a word from there (bug found via live testing,
     not just theoretical). */
  z-index: 1150; padding: 16px;
}
.dict-vocab-modal.hidden { display: none; }
.dict-vocab-box {
  background: #fff; border-radius: 14px; width: 100%; max-width: 380px;
  max-height: 80vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.dict-vocab-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid #e5e7eb; flex-shrink: 0;
}
.dict-vocab-header h3 { margin: 0; font-size: 16px; font-weight: 700; color: #111; }
.dict-vocab-close {
  background: none; border: none; cursor: pointer; color: #9ca3af;
  font-size: 16px; padding: 4px 6px; border-radius: 6px;
}
.dict-vocab-close:hover { background: #f3f4f6; color: #374151; }
.dict-vocab-body { padding: 8px 18px 18px; overflow-y: auto; }

[data-theme="dark"] .dict-vocab-box       { background: var(--surface, #0d0d0d); }
[data-theme="dark"] .dict-vocab-header    { border-bottom-color: var(--border2, #333333); }
[data-theme="dark"] .dict-vocab-header h3 { color: #f9fafb; }
[data-theme="dark"] .dict-vocab-close     { color: #6b7280; }
[data-theme="dark"] .dict-vocab-close:hover { background: var(--border2, #333333); color: #e5e7eb; }

.rd-vocab-loading { text-align: center; padding: 16px; color: #9ca3af; }
[data-theme="dark"] .rd-vocab-loading { color: #6b7280; }

.vb-pick-item { display: flex; align-items: center; gap: 12px; padding: 10px 8px; cursor: pointer; border-radius: 8px; transition: background .15s; }
.vb-pick-item:hover { background: #f3f4f6; }
.vb-pick-emoji { font-size: 22px; }
.vb-pick-info { flex: 1; }
.vb-pick-name { font-size: 14px; font-weight: 600; color: #1f2937; }
.vb-pick-count { font-size: 12px; color: #9ca3af; }
.vb-pick-arrow { font-size: 20px; color: #d1d5db; }
[data-theme="dark"] .vb-pick-item:hover { background: var(--border2, #333333); }
[data-theme="dark"] .vb-pick-name  { color: #f9fafb; }
[data-theme="dark"] .vb-pick-count { color: #6b7280; }
[data-theme="dark"] .vb-pick-arrow { color: #4b5563; }

.rd-vocab-new-section { border-top: 1px solid #e5e7eb; padding: 12px 0 0; margin-top: 8px; }
[data-theme="dark"] .rd-vocab-new-section { border-top-color: var(--border2, #333333); }
.rd-vocab-new-label { font-size: 12px; color: #9ca3af; margin-bottom: 8px; }
[data-theme="dark"] .rd-vocab-new-label { color: #6b7280; }
.rd-vocab-input {
  flex: 1; border: 1px solid #e5e7eb; border-radius: 8px; padding: 8px 12px;
  font-size: 14px; font-family: inherit; outline: none; background: #fff;
  color: #111; transition: border-color .15s;
}
.rd-vocab-input:focus { border-color: #3d8bff; }
[data-theme="dark"] .rd-vocab-input { background: var(--bg, #000000); border-color: var(--border2, #333333); color: #e5e7eb; }
.rd-vocab-create-btn {
  background: #3d8bff; color: #fff; border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; cursor: pointer; font-family: inherit; white-space: nowrap;
}
.rd-vocab-create-btn:hover { background: #1d4ed8; }
