/* Word column sizing */
#results-tbody td:nth-child(2) {
  font-size: 1.1rem;
}

/* RTL language: direction + Arabic font in word column */
#results-table.lang-arabic #results-tbody td:nth-child(2) {
  direction: rtl;
  font-family: "Scheherazade New", serif;
}

/* Sidebar resize handle — invisible, only cursor changes */
#sidebar-resize-handle {
  width: 6px;
  flex-shrink: 0;
  cursor: col-resize;
}

/* Sidebar session items */
.session-item {
  cursor: pointer;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 4px;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.15s;
}
.session-item:hover {
  background: #e9ecef;
}
.session-item.active {
  background: #0d6efd22;
  font-weight: 600;
}
.session-item .btn-delete,
.session-item .btn-rename {
  opacity: 0;
  transition: opacity 0.15s;
  padding: 0 4px;
  font-size: 0.75rem;
}

/* In-progress analysis placeholder */
.pending-session {
  cursor: pointer;
}
.pending-session .pending-name {
  opacity: 0.55;
  font-style: italic;
}
.pending-session .spinner-border {
  width: 0.85rem;
  height: 0.85rem;
  border-width: 0.15em;
}
.session-item:hover .btn-delete,
.session-item:hover .btn-rename {
  opacity: 1;
}


/* Profile avatar toggle — echo the btn-outline-light login button on the dark navbar */
.profile-toggle img,
.profile-toggle i {
  border-radius: 50%;
}
.profile-toggle i {
  border: 1px solid #f8f9fa;   /* outlined circle for the fallback icon */
  display: inline-flex;
  width: 32px;
  height: 32px;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  color: #f8f9fa;
}

/* Profile dropdown: Logout item — red text, rounded, highlight = menu bg but darker */
.dropdown-item-logout {
  color: #dc3545;
  width: auto;
  margin: 0 0.5rem;
  border-radius: 0.375rem;
  /* match the sign-in button's smooth hover transition */
  transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out;
}
.dropdown-item-logout:hover,
.dropdown-item-logout:focus {
  background-color: #dee2e6;   /* dropdown background (#fff) but darker */
  color: #dc3545;
}

/* Flash messages */
.flash-alert {
  animation: fadeout 0.5s ease 3s forwards;
}
@keyframes fadeout {
  to { opacity: 0; pointer-events: none; }
}

/* Spinner overlay */
#analyze-spinner {
  vertical-align: middle;
}

/* Drag-and-drop upload zone */
.drop-zone {
  border: 2px solid #6c757d;
  border-radius: 12px;
  padding: 3rem 4rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-width: 320px;
}
.drop-zone:hover,
.drop-zone.drag-over {
  border-color: #0d6efd;
  background: #f0f4ff;
}
.drop-zone.disabled {
  pointer-events: none;
  opacity: 0.5;
}
.drop-zone-icon {
  font-size: 3rem;
  color: #adb5bd;
  transition: color 0.15s;
}
.drop-zone:hover .drop-zone-icon,
.drop-zone.drag-over .drop-zone-icon {
  color: #0d6efd;
}

/* Results table + subtitle panels row */
.results-panels-row { display: flex; gap: 0.5rem; align-items: stretch; }
.results-panels-row .results-table-wrapper { flex: 0 0 35%; min-width: 180px; }

/* Viewports row fills remaining height inside the column */
.subtitle-viewports-row { flex: 1 1 0; min-height: 0; }

/* Force the two viewport columns to share width equally regardless of content,
   so the Subtitles title bar can't be widened by a long selected lemma. */
.subtitle-viewports-row > * { flex: 1 1 0; min-width: 0; min-height: 0; }

/* Title bar: clip overflowing content instead of letting it spill outside the column */
.subtitle-viewports-row > * > .bg-dark { overflow: hidden; }

/* Selected-lemma readout: allow shrinking and ellipsis when column is narrow */
#selected-lemma-display {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Scrollable results table */
.results-table-wrapper {
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid #dee2e6;
  border-radius: 4px;
}

/* Subtitle viewports */
.subtitle-viewport {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  padding: 0.5rem;
  font-size: 0.85rem;
  min-width: 0;
}

.subtitle-entry {
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.6rem;
  border-left: 3px solid transparent;
}

.subtitle-entry.active {
  background-color: #fff8e1;
  border-left-color: #ffc107;
}

.sub-number, .sub-time {
  font-size: 0.72rem;
  color: #6c757d;
  font-family: monospace;
}

.sub-text {
  margin-top: 0.15rem;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
}

#subtitle-viewport-processed .sub-text {
  font-size: 1rem;
}

.lang-arabic .sub-text {
  font-family: "Scheherazade New", serif;
}

.sub-word {
  cursor: pointer;
  border-radius: 2px;
}

#subtitle-viewport-processed .sub-word:hover {
  text-decoration: underline;
}

#subtitle-viewport-native .subtitle-entry {
  cursor: pointer;
}

#subtitle-viewport-native .subtitle-entry:hover .sub-text {
  text-decoration: underline;
}

.sub-word.active-word {
  background-color: #ffe066;
}

#results-tbody td:nth-child(2) {
  cursor: pointer;
}

#results-tbody td:nth-child(2):hover {
  text-decoration: underline;
}

#results-tbody tr.selected-row {
  --bs-table-bg: #fff8e1;
  --bs-table-hover-bg: #fff8e1;
  border-left: 3px solid #ffc107;
}

.subtitle-lemma-display {
  font-family: "Scheherazade New", serif;
  font-size: 1.05rem;
  min-width: 4ch;
}

.min-width-0 { min-width: 0; }

#results-table {
  table-layout: fixed;
}

#results-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

#results-table thead th {
  position: relative;
  overflow: visible;
  white-space: nowrap;
  user-select: none;
}

/* Earlier columns stack above later ones so their handles render on top */
#results-table thead th:nth-child(1) { z-index: 3; }
#results-table thead th:nth-child(2) { z-index: 2; }
#results-table thead th:nth-child(3) { z-index: 1; }

/* Action column: fixed, non-resizable, just wide enough for the button */
#results-table thead th:last-child {
  width: 50px;
}

#results-table tbody td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

#results-table tbody td:last-child {
  overflow: visible;
}

.col-resize-handle {
  position: absolute;
  right: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  /* Visible 2px stripe centered on the column border */
  background: linear-gradient(to right, transparent 2px, rgba(255,255,255,0.4) 2px, rgba(255,255,255,0.4) 4px, transparent 4px);
}

.col-resize-handle:hover,
.col-resize-handle.resizing {
  background: rgba(255, 255, 255, 0.25);
}

/* Word analysis tooltip */
.word-tooltip {
  position: fixed;
  z-index: 1080;
  width: 260px;
  background: #fff;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  font-size: 0.82rem;
  overflow: hidden;
}

.word-tooltip-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #343a40;
  color: #fff;
  padding: 6px 10px;
}

.word-tooltip-title {
  font-family: "Scheherazade New", serif;
  font-size: 1rem;
  flex: 1;
  text-align: right;
}

.word-tooltip-close {
  background: none;
  border: none;
  color: #adb5bd;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0 0 8px;
}
.word-tooltip-close:hover { color: #fff; }

.word-tooltip-body {
  padding: 8px 10px;
  max-height: 320px;
  overflow-y: auto;
}

.word-tooltip-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #6c757d;
  letter-spacing: 0.04em;
  margin: 8px 0 2px;
}
.word-tooltip-section-label:first-child { margin-top: 0; }

.word-tooltip-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 8px;
  row-gap: 1px;
  margin: 0;
}

.word-tooltip-dl dt {
  color: #6c757d;
  font-weight: 400;
  white-space: nowrap;
}

.word-tooltip-dl dd {
  margin: 0;
  word-break: break-word;
}

/* ---------- Responsive: mobile (< 768px) ---------- */
@media (max-width: 767.98px) {
  /* The manual resize handle is meaningless when the sidebar is an offcanvas drawer */
  #sidebar-resize-handle { display: none; }

  /* Bootstrap's offcanvas-md uses var(--bs-offcanvas-width) below the breakpoint */
  #sidebar.offcanvas-md { --bs-offcanvas-width: 280px; }

  /* The desktop layout pins everything inside a fixed-height app shell.
     On a phone the stacked panels can't all fit, so let the main column
     scroll as a page instead of clipping the bottom panels. */
  #main-content { overflow-y: auto !important; }
  #results-section { flex-shrink: 0; }

  /* Stack results table above the subtitle viewers */
  .results-panels-row { flex-direction: column; }
  .results-panels-row .results-table-wrapper {
    flex: 0 0 auto;
    height: 45vh;
    min-height: 200px;
    width: 100%;
  }

  /* Stack the two subtitle viewers vertically too; each gets a fixed,
     non-shrinking height so its own scrollbar works and nothing collapses */
  .subtitle-viewports-row { flex-direction: column; flex: 0 0 auto; }
  .subtitle-viewports-row > * { flex: 0 0 auto; }
  .subtitle-viewport { flex: 0 0 auto; height: 45vh; }

  /* Column-resize handles are unusable on touch — hide them */
  .col-resize-handle { display: none; }

  #main-content { padding: 1rem !important; }

  .drop-zone {
    min-width: 0;
    padding: 2rem 1.5rem;
    width: 100%;
    max-width: 360px;
  }
}

/* Sidebar layout: flex column at all widths; fixed dimensions only at md+ */
#sidebar { display: flex; flex-direction: column; }
@media (min-width: 768px) {
  #sidebar {
    width: 240px;
    min-width: 160px;
    flex-shrink: 0;
    overflow-y: auto;
  }
}

/* ---------- Responsive: icons-only toolbar (< 576px) ---------- */
@media (max-width: 575.98px) {
  .btn-label { display: none; }
}
