/* EXCEL EDITOR (edit mode) — shared by Documents and MyFiles */
.docs-edit-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.docs-add-row {
  padding: 4px 10px;
  border: 1px solid #0f70d0;
  background: white;
  color: #0f70d0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}
.docs-add-row:hover {
  background: #e8f0fb;
}
.docs-add-col {
  padding: 4px 10px;
  border: 1px solid #0f70d0;
  background: white;
  color: #0f70d0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}
.docs-add-col:hover {
  background: #e8f0fb;
}
.docs-save-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  box-sizing: border-box;
  padding: 0;
  border: 1px solid #0f70d0;
  background: #0f70d0;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
}
.docs-save-btn:hover {
  background: #0b5aaa;
}
.docs-save-btn svg {
  display: block;
}
.docs-save-status {
  font-size: 0.8rem;
  color: #888;
  white-space: nowrap;
}
.docs-filter-group {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.docs-cols-toggle {
  padding: 4px 10px;
  border: 1px solid #0f70d0;
  background: white;
  color: #0f70d0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  white-space: nowrap;
}
.docs-cols-toggle:hover {
  background: #e8f0fb;
}
.docs-cols-toggle.active {
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
  background: #eef5fc;
  transform: translateY(1px);
}
.docs-cols-toggle.active:hover {
  background: #d5e2f2;
}
.docs-cols-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  width: 100%;
  padding: 8px;
  margin-top: 6px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #f9f9f9;
  font-size: 0.8rem;
}
.docs-col-block {
  display: flex;
  flex-direction: column;
}
.docs-col-label {
  cursor: default;
}
.docs-col-settings-toggle {
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0 2px;
  color: #0f70d0;
}
.docs-col-settings {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
}
.docs-col-type,
.docs-col-align {
  border: 1px solid #0f70d0;
  border-radius: 4px;
  padding: 2px 4px;
  font-size: 0.75rem;
}
.docs-col-negred {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  white-space: nowrap;
}
.docs-col-row {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

/* Generic edit-mode toggle button (Excel editor) */
.edit-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  box-sizing: border-box;
  border: 1px solid #0f70d0;
  border-radius: 4px;
  background: white;
  color: #0f70d0;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.edit-toggle-btn:hover {
  background: #e8f0fb;
}
.edit-toggle-btn.active {
  background: #0f70d0;
  color: white;
}
.edit-toggle-btn svg {
  display: block;
}

/* Editable Excel table */
.xlsx-edit-table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
}
.xlsx-edit-table th,
.xlsx-edit-table td {
  box-shadow: inset -1px -1px 0 #ddd;
  padding: 2px 4px;
}
.xlsx-edit-table td.cell-checkbox {
  text-align: center;
}
.xlsx-edit-table input[type="checkbox"]:disabled,
.vocab-field input[type="checkbox"]:disabled {
  accent-color: #222;
  opacity: 1;
  cursor: default;
}
.xlsx-edit-table tr:nth-child(even) {
  background: #f5f5f5;
}
.xlsx-edit-table tbody tr.active {
  background: #d0e4f7;
}
.col-resize-handle {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
}
.col-resize-handle:hover {
  background: rgba(15, 112, 208, 0.35);
}
.docs-cell-input {
  width: 100%;
  min-width: 60px;
  box-sizing: border-box;
  border: 1px solid transparent;
  background: transparent;
  font-size: 0.8rem;
  padding: 4px 6px;
  font-family: inherit;
}
.docs-cell-input:focus {
  border-color: #0f70d0;
  background: white;
  outline: none;
}
.docs-delete-row {
  border: none;
  background: none;
  color: #c0392b;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 2px 6px;
}
.docs-delete-row:hover {
  color: #a93226;
}
.docs-col-header {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.docs-col-name {
  cursor: pointer;
  border-bottom: 1px dashed transparent;
}
.docs-col-name:hover {
  border-bottom-color: #0f70d0;
}
.docs-col-sort {
  cursor: pointer;
  user-select: none;
  color: #0f70d0;
  font-size: 0.7rem;
}
.docs-col-sort:hover {
  opacity: 0.7;
}
.docs-delete-col {
  border: none;
  background: none;
  color: #c0392b;
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0 2px;
  line-height: 1;
}
.docs-delete-col:hover {
  color: #a93226;
}

/* DETAIL CARD — shared by the Excel editor (Documents/MyFiles) and Vocabulary */
.docs-detail {
  position: relative;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 26px 12px 12px 12px;
  margin-top: 12px;
  background: #f9f9f9;
}
.docs-detail .vocab-label {
  flex: 0 0 var(--vocab-label-width);
  max-width: var(--vocab-label-width);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-right: 1px solid #ddd;
  padding-right: 8px;
  position: relative;
}
.docs-detail.collapsed {
  box-sizing: border-box;
  min-height: 24px;
  padding: 0;
}
.docs-detail.collapsed .docs-detail-content {
  display: none;
}
.docs-detail-input {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.85rem;
  flex: 1;
  min-width: 0;
}

/* Generic detail-nav (prev/next) — shared by docs-detail and vocab-detail */
.docs-detail-nav,
.vocab-detail-nav {
  position: absolute;
  top: 3px;
  left: 3px;
  display: flex;
  gap: 3px;
}
.docs-detail-prev,
.docs-detail-next,
.vocab-detail-prev,
.vocab-detail-next {
  box-sizing: border-box;
  width: 20px;
  height: 16px;
  padding: 0;
  margin: 0;
  border: 1px solid #0f70d0;
  background: white;
  color: #0f70d0;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 14px;
}
.docs-detail-prev:hover:not(:disabled),
.docs-detail-next:hover:not(:disabled),
.vocab-detail-prev:hover:not(:disabled),
.vocab-detail-next:hover:not(:disabled) {
  background: #e8f0fb;
}
.docs-detail-prev:disabled,
.docs-detail-next:disabled,
.vocab-detail-prev:disabled,
.vocab-detail-next:disabled {
  opacity: 0.35;
  cursor: default;
}

.docs-detail:not(.collapsed) .docs-detail-content {
  max-height: 40vh;
  overflow-y: auto;
}

.docs-detail .vocab-card {
  --vocab-label-width: 25%; /* overrides the 20% set below when scoped under .docs-detail */
  display: flex;
  flex-direction: column;
}

.docs-detail .vocab-field {
  align-items: center;
  padding: 4px 8px;
  border-bottom: 1px solid #ddd;
}

/* Generic label-resize handle — shared by docs-detail and vocab-detail cards */
.vocab-label-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
}
.vocab-label-resize-handle:hover {
  background: rgba(15, 112, 208, 0.35);
}

.docs-detail .vocab-field:nth-child(even) {
  background: #f5f5f5;
}
.docs-detail .vocab-field:last-child {
  border-bottom: none;
}

.docs-detail .vocab-value,
.docs-detail .docs-detail-input {
  font-size: 0.85rem;
}

/* Generic collapse/expand button — shared by docs-detail and vocab-detail */
.detail-toggle {
  box-sizing: border-box;
  position: absolute;
  top: 3px;
  right: 3px;
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  border: 1px solid #0f70d0;
  background: white;
  color: #0f70d0;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.6rem;
  line-height: 14px;
  display: block;
  text-align: center;
}
.detail-toggle:hover {
  background: #e8f0fb;
}

/* PDF VIEWER — shared by Documents and MyFiles */
.pdf-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 10px;
}
.pdf-controls-left {
  justify-self: start;
}
.pdf-controls-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.pdf-controls-right {
  justify-self: end;
}
.pdf-controls button {
  padding: 4px 12px;
  border: 1px solid #0f70d0;
  background: white;
  color: #0f70d0;
  border-radius: 4px;
  cursor: pointer;
}
.pdf-controls button:hover {
  background: #0f70d0;
  color: white;
}

.pdf-page-canvas {
  /* max-width: 100%; */ /* If this restriction exists no possibility to zoom with a view greater than the canvas */
  border: 1px solid #eee;
  display: block;
  margin: 0 auto; /* centers when the canvas fits; collapses to flush-left (no negative margin) when zoomed past wrapper width, avoiding flexbox's "unsafe centering" scroll-clipping bug */
}
.pdf-canvas-wrapper {
  overflow: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  padding: 8px 0;
}

#pdfZoomOut {
  margin-left: 12px;
}
#pdfZoomInput {
  width: 4ch;
  text-align: center;
  border: 1px solid #0f70d0;
  border-radius: 4px;
  padding: 2px 4px;
}
#pdfPageInput {
  width: 2.5ch;  /* 2 digits + a little space */
  text-align: center;
  border: 1px solid #0f70d0;
  border-radius: 4px;
  padding: 2px 4px;
}
.zoom-input-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
#pdfZoomOut,
#pdfZoomIn {
  font-size: 0.85rem;
}
/* Reused by familyTree.js's own zoom controls (#ft-zoom-input) */
.zoom-group {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.25rem;
}

/* IMAGE / VIDEO VIEWER — shared by Documents and MyFiles */
.docs-image-wrapper {
  overflow: auto;
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
}
.docs-image-wrapper img {
  margin: auto;
}
.docs-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  cursor: zoom-in;
}
.docs-image.zoomed {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}
.docs-video-wrapper {
  overflow: auto;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.docs-video-wrapper video {
  max-width: 100%;
  max-height: 100%;
}

/* DOWNLOAD BUTTON — generic, reused everywhere (Documents, Tools, MyFiles, Vocabulary, Travels/lightbox) */
.icon-download-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  box-sizing: border-box;
  border: 1px solid #0f70d0;
  border-radius: 4px;
  background: white;
  color: #0f70d0;
  text-decoration: none;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-download-btn:hover {
  background: #e8f0fb;
}
.icon-download-btn svg {
  display: block;
}
.icon-download-btn-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

/* EXCEL VIEWER (generic, read-only sheet_to_html) — Documents/Tools/MyFiles/Vocabulary */
.xlsx-sheets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.xlsx-toolbar {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: start;
  gap: 8px;
  margin-bottom: 10px;
}
.xlsx-toolbar .icon-download-btn {
  margin-top: 1px;
}
.xlsx-toolbar .xlsx-sheets {
  margin-bottom: 0;
}
.sheet-btn {
  padding: 4px 10px;
  border: 1px solid #0f70d0;
  background: white;
  color: #0f70d0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}
.sheet-btn.active {
  background: #0f70d0;
  color: white;
}
.xlsx-table-wrapper {
  position: relative;
}
.xlsx-edit-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fafafa;
}
.xlsx-table-wrapper table {
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.8rem;
}
.xlsx-table-wrapper td,
.xlsx-table-wrapper th {
  box-shadow: inset -1px -1px 0 #ddd;
  padding: 4px 8px;
  white-space: nowrap;
}
.xlsx-table-wrapper tr:first-child th,
.xlsx-table-wrapper tr:first-child td {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fafafa;
}

.xlsx-table-wrapper tr:nth-child(even) {
  background: #f5f5f5;
}

.xlsx-edit-table tbody tr:first-child th,
.xlsx-edit-table tbody tr:first-child td {
  position: static;
  background: transparent;
}

/* CODE VIEWER — shared by Tools and MyFiles */
.code-viewer-wrapper {
  overflow: auto;
  flex: 1;
}

/* Responsive midden width of windows */
/* ================================== */
@media (max-width: 1024px) {
  .pdf-controls {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .pdf-controls-left {
    justify-self: center;
  }
  .pdf-controls-center {
    justify-self: center;
  }
}

/* Responsive smartphone */
/* ===================== */
@media (max-width: 768px) {
  /* PDF continuous viewer must keep its own scroll boundary,
   independent of .docs-viewer/.myfiles-viewer */
  .pdf-canvas-wrapper {
    max-height: 80vh;
    overflow-y: auto;
    flex: none;
  }

  .code-viewer-wrapper {
    max-height: 80vh;
    overflow-y: auto;
    overflow-x: auto; /* keep horizontal scroll for long code lines */
    flex: none;
  }

  .docs-edit-toolbar {
    flex-wrap: wrap;
  }
  .docs-filter-group {
    min-width: 100%;
    order: 1;
    flex-wrap: wrap;
  }

  .docs-cell-check {
    display: block;
    margin: 0 auto;
  }

  .col-resize-handle {
    display: none;
  }
}
