/* Text Viewer Components */
.text-viewer {
  font-family: 'Courier New', Courier, monospace;
  line-height: 2;
  letter-spacing: 1px;
  font-size: 1rem;
}

.letter {
  cursor: pointer;
  transition: all 0.2s;
  display: inline-block;
}

.letter:hover {
  background: rgba(52, 152, 219, 0.2);
  transform: scale(1.1);
}

.letter.highlighted {
  background: var(--highlight-color);
  color: white;
  font-weight: bold;
  padding: 2px 4px;
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Matrix Components */
.matrix-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--bg-color);
  border-radius: 4px;
}

.matrix-controls label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.matrix-controls input {
  width: 80px;
  padding: 0.4rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

#auto-width-btn {
  padding: 0.5rem 1rem;
  background: var(--secondary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.3s;
}

#auto-width-btn:hover {
  background: #2980b9;
}

.matrix-viewer {
  font-family: 'Courier New', Courier, monospace;
  overflow: auto;
  flex: 1;
  padding: 1rem;
  background: #fafafa;
  border-radius: 4px;
}

.matrix-grid {
  display: inline-grid;
  gap: 1px;
  background: var(--border-color);
  padding: 1px;
}

.matrix-cell {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  cursor: default;
}

.matrix-cell:hover {
  background: rgba(52, 152, 219, 0.1);
  transform: scale(1.05);
}

.matrix-cell.highlighted {
  background: var(--highlight-color);
  color: white;
  font-weight: bold;
  box-shadow: 0 0 5px rgba(243, 156, 18, 0.5);
  z-index: 1;
}

/* Dual Pane Components */
.dual-pane-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  height: 100%;
  overflow: hidden;
}

.pane {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  height: 100%;
  min-height: 0;
}

.pane-header {
  background: var(--primary-color);
  color: white;
  padding: 1rem;
  text-align: center;
  font-weight: 600;
  flex-shrink: 0;
}

.pane-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.pane-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
  font-family: 'Courier New', Courier, monospace;
  line-height: 2;
  background: white;
  min-height: 0;
}

.pane.rtl .pane-content {
  direction: rtl;
  text-align: right;
}

.verse-group {
  margin-bottom: 1rem;
  padding: 0.5rem;
  border-radius: 4px;
  transition: background 0.2s;
}

.verse-group:hover {
  background: rgba(52, 152, 219, 0.05);
}

.word {
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all 0.2s;
  display: inline-block;
}

.word:hover {
  background: rgba(52, 152, 219, 0.3);
  transform: translateY(-1px);
}

.word.highlighted {
  background: var(--highlight-color);
  color: white;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.primary-word {
  border-bottom: 1px dotted var(--border-color);
}

.secondary-word {
  border-bottom: 1px dotted transparent;
}

/* Result Items */
.result-item {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
  transition: all 0.3s;
  background: white;
}

.result-item:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  border-color: var(--secondary-color);
  transform: translateX(2px);
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--bg-color);
}

.result-term {
  font-weight: bold;
  font-size: 1.1rem;
  color: var(--secondary-color);
  font-family: 'Courier New', monospace;
}

.result-skip {
  background: var(--bg-color);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
}

.result-details {
  font-size: 0.9rem;
  color: #666;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-family: 'Courier New', monospace;
  margin-bottom: 0.75rem;
}

.result-details span {
  padding: 0.2rem 0;
}

.view-btn {
  margin-top: 0.5rem;
  padding: 0.6rem;
  background: var(--secondary-color);
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  width: 100%;
  font-weight: 500;
  transition: all 0.3s;
}

.view-btn:hover {
  background: #2980b9;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* Cluster Result Display */
.cluster-item {
  border-left: 4px solid var(--accent-color);
  padding-left: 1rem;
}

.cluster-item .result-term {
  color: var(--accent-color);
}

.related-terms {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-color);
  border-radius: 4px;
  font-size: 0.85rem;
}

.related-terms .related-term {
  display: inline-block;
  margin: 0.2rem;
  padding: 0.2rem 0.5rem;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 3px;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: #999;
  text-align: center;
}

.empty-state-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.3;
}

.empty-state-text {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.empty-state-subtext {
  font-size: 0.9rem;
  color: #bbb;
}

/* Progress Bar */
.progress-container {
  width: 100%;
  height: 4px;
  background: var(--bg-color);
  border-radius: 2px;
  overflow: hidden;
  margin: 1rem 0;
}

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

/* Tooltip */
.tooltip {
  position: relative;
  display: inline-block;
}

.tooltip .tooltiptext {
  visibility: hidden;
  background-color: var(--primary-color);
  color: white;
  text-align: center;
  padding: 0.5rem;
  border-radius: 4px;
  position: absolute;
  z-index: 1000;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.85rem;
  white-space: nowrap;
}

.tooltip:hover .tooltiptext {
  visibility: visible;
  opacity: 1;
}

/* Responsive Components */
@media (max-width: 992px) {
  .dual-pane-container {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  
  .matrix-cell {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }
}

@media (max-width: 768px) {
  .text-viewer {
    font-size: 0.9rem;
    line-height: 1.8;
  }
  
  .pane-content {
    padding: 1rem;
    font-size: 0.9rem;
  }
  
  .result-item {
    padding: 0.75rem;
  }
  
  .matrix-controls {
    flex-direction: column;
    align-items: stretch;
  }
  
  .matrix-controls label {
    justify-content: space-between;
  }
}

/* ============================================================
   GEMATRIA COMPONENTS
   ============================================================ */

/* Section header */
#gematria-section h3 {
  margin-bottom: 1rem;
  color: var(--primary-color);
  font-size: 1.1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--bg-color);
}

/* Live value display box */
.gematria-value-display {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, var(--primary-color), #3d5a73);
  color: white;
  border-radius: 8px;
  text-align: center;
}

.gematria-value-number {
  display: block;
  font-size: 2.2rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  cursor: pointer;
  transition: transform 0.15s;
}

.gematria-value-number:hover {
  transform: scale(1.1);
}

.gematria-value-number::after {
  content: " →";
  font-size: 0.9rem;
  opacity: 0.6;
}

.gematria-value-label {
  display: block;
  font-size: 0.75rem;
  opacity: 0.75;
  margin-bottom: 0.5rem;
}

/* Letter breakdown chips */
.gematria-breakdown {
  font-size: 0.8rem;
  margin-top: 0.5rem;
  opacity: 0.9;
  line-height: 1.8;
  word-break: break-all;
}

.gem-letter-chip {
  display: inline-block;
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
  padding: 1px 4px;
  margin: 1px;
  font-family: 'Courier New', monospace;
}

.gematria-digital-root {
  font-size: 0.78rem;
  opacity: 0.7;
  margin-top: 0.4rem;
}

/* Search row */
.gematria-search-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.gematria-search-row input {
  flex: 1;
  padding: 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.95rem;
}

.gematria-search-btn {
  width: auto !important;
  padding: 0.6rem 1rem !important;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Radio labels */
.gematria-mode-row {
  display: flex;
  gap: 1rem;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  font-weight: normal;
  font-size: 0.9rem;
}

/* ---- Results ---- */
.gematria-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0;
  border-top: 2px solid var(--border-color);
  margin-top: 1rem;
  font-weight: 600;
  color: var(--primary-color);
}

.result-count-badge {
  background: var(--secondary-color);
  color: white;
  font-size: 0.8rem;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
}

.gematria-results-list {
  max-height: 400px;
  overflow-y: auto;
}

.gematria-result-item {
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
  background: white;
  transition: box-shadow 0.2s;
}

.gematria-result-item:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,0.12);
}

.gematria-result-word {
  font-size: 1.1rem;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  color: var(--primary-color);
  margin-bottom: 0.3rem;
}

.gematria-result-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
}

.gematria-badge {
  background: var(--accent-color);
  color: white;
  font-weight: bold;
  font-size: 0.85rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-family: 'Courier New', monospace;
}

.gematria-verse-ref {
  font-size: 0.82rem;
  color: var(--secondary-color);
  font-weight: 500;
}

.gematria-pos {
  font-size: 0.78rem;
  color: #999;
}

.gematria-verse-preview {
  font-size: 0.82rem;
  color: #666;
  line-height: 1.5;
  border-left: 3px solid var(--bg-color);
  padding-left: 0.5rem;
  margin-top: 0.25rem;
}

mark.gematria-word-highlight {
  background: var(--highlight-color);
  color: var(--primary-color);
  padding: 0 2px;
  border-radius: 2px;
}

/* Multi-language comparison chips */
.gem-multilang {
  margin-top: 0.4rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.gem-lang-chip {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 3px;
  font-size: 0.75rem;
  padding: 0.1rem 0.4rem;
  font-family: 'Courier New', monospace;
  cursor: default;
}

.gem-lang-chip:hover {
  background: var(--secondary-color);
  color: white;
  border-color: var(--secondary-color);
}

/* Gematria view button */
.gematria-view-btn {
  margin-top: 0.4rem;
  font-size: 0.82rem;
  padding: 0.35rem 0.7rem;
}

/* All-systems comparison block */
.gem-all-systems {
  font-size: 0.85rem;
  line-height: 2;
}

.gem-lang-group {
  margin: 0.25rem 0;
}

/* ============================================================
   HELP BUTTON (header)
   ============================================================ */

.help-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 1rem;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 5px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
  white-space: nowrap;
  margin-left: 0.6rem;
}

.help-btn:hover {
  background: rgba(255,255,255,0.25);
  color: white;
  border-color: rgba(255,255,255,0.6);
}

/* ============================================================
   DUAL-PANE SIDE-BY-SIDE VIEW
   ============================================================ */

.dual-pane-wrapper {
  display: flex;
  gap: 0;
  height: 100%;
  overflow: hidden;
}

.dual-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--border-color);
}

.dual-pane:last-child {
  border-right: none;
}

.dual-pane-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background: var(--bg-color);
  border-bottom: 2px solid var(--border-color);
  flex-shrink: 0;
}

.pane-lang-label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--primary-color);
}

.pane-hint {
  font-size: 0.75rem;
  color: #999;
  font-style: italic;
}

.dual-pane-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  line-height: 1.9;
}

/* Verse blocks */
.verse-group {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  margin-bottom: 0.15rem;
  transition: background 0.15s, opacity 0.15s;
}

.verse-group[dir="rtl"] {
  flex-direction: row-reverse;
  text-align: right;
}

.verse-num {
  flex-shrink: 0;
  font-size: 0.72rem;
  color: #aaa;
  font-family: 'Courier New', monospace;
  min-width: 1.8rem;
  text-align: right;
  user-select: none;
}

.verse-text {
  flex: 1;
  font-size: 0.95rem;
}

.verse-missing {
  color: #ccc;
  font-style: italic;
}

/* Verse hover states — verse-level (safe, never word-misaligned) */
.verse-group.verse-highlighted {
  background: rgba(52, 152, 219, 0.12);
  border-left: 3px solid var(--secondary-color);
  padding-left: 0.6rem;
}

.verse-group.verse-highlighted .verse-num {
  color: var(--secondary-color);
  font-weight: 700;
}

.verse-group.verse-dimmed {
  opacity: 0.35;
}

/* Individual word spans */
.word {
  cursor: default;
  border-radius: 3px;
  padding: 1px 2px;
  transition: background 0.1s;
  display: inline;
}

.word:hover {
  background: rgba(52, 152, 219, 0.18);
}

.word-space {
  display: inline;
}

/* ============================================================
   GEMATRIA HOVER TOOLTIP
   ============================================================ */

.gem-hover-tooltip {
  position: absolute;
  z-index: 9999;
  background: #1a2332;
  color: #e8edf2;
  border: 1px solid rgba(52,152,219,0.5);
  border-radius: 8px;
  padding: 0.6rem 0.85rem 0.55rem;
  min-width: 160px;
  max-width: 280px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.35);
  font-size: 0.82rem;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-100%) translateY(-10px);
  transition: opacity 0.12s ease;
  line-height: 1.4;
}

.gem-hover-tooltip.gem-tooltip-visible {
  opacity: 1;
  pointer-events: auto;
}

/* The word being hovered */
.gem-tip-word {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 0.3rem;
  letter-spacing: 0.02em;
}

/* Primary value line */
.gem-tip-main {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
}

.gem-tip-value {
  font-size: 1.5rem;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  color: #f0c040;
  line-height: 1;
}

.gem-tip-system {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.gem-tip-root {
  font-size: 0.72rem;
  color: rgba(255,200,80,0.65);
  margin-left: auto;
}

/* Letter breakdown row */
.gem-tip-breakdown {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.65);
  margin-bottom: 0.3rem;
  line-height: 1.7;
  font-family: 'Courier New', monospace;
  word-break: break-all;
}

.gem-tip-chip {
  display: inline-block;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  padding: 0 3px;
  margin: 1px;
}

.gem-tip-chip sub {
  font-size: 0.65rem;
  color: #f0c040;
  vertical-align: sub;
}

.gem-tip-more {
  color: rgba(255,255,255,0.35);
}

/* Secondary systems */
.gem-tip-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0.25rem;
  padding-top: 0.25rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.gem-tip-sec-chip {
  background: rgba(52,152,219,0.2);
  border: 1px solid rgba(52,152,219,0.35);
  border-radius: 3px;
  font-size: 0.72rem;
  padding: 0.1rem 0.4rem;
  color: rgba(255,255,255,0.8);
  white-space: nowrap;
}

.gem-tip-sec-chip b {
  color: #f0c040;
}

/* Verse reference */
.gem-tip-verse {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.35);
  text-align: right;
  margin-top: 0.2rem;
  padding-top: 0.2rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* RTL word support inside tooltip */
.gem-tip-word[dir="rtl"] {
  direction: rtl;
  font-size: 1.2rem;
}
