/* Documents sub-tab on a partner firm's page (public/staff-documents.js):
   managing Firm Documents and General Documents with minimized-by-default
   dropdown accordions, 2-column layout, preview, version replacement,
   download, deletion, and text-free plus upload triggers.

   Colours come from the site's own palette in styles.css (--blue,
   --blue-pale, --blue-wash, --ink, --muted, --line): the folders and the
   documents are GROW blue, nothing else. The rows are a three column grid
   when the list has room (a laptop), and stack into one card per document
   when it has not (a phone, or Phone view), judged by the width of the
   list itself rather than of the window. */

.doc-panel {
  margin-top: 10px;
}

.doc-header-row {
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.doc-main-title {
  margin: 0 0 6px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
}

.doc-main-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

/* Centered Accordions Layout */
.doc-accordions-center {
  container-type: inline-size;
  container-name: docs;
  max-width: 1200px;
  margin: 20px auto 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.doc-accordion-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(9, 106, 211, 0.05);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.doc-accordion-card:hover,
.doc-accordion-card.is-open {
  border-color: #b9d4ef;
}

.doc-accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s;
}

.doc-accordion-header:hover,
.doc-accordion-card.is-open .doc-accordion-header {
  background: var(--blue-wash);
}

.doc-accordion-header:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: -2px;
}

.doc-accordion-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.doc-folder-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--blue-pale);
  color: var(--blue);
}

.doc-folder-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
  min-width: 0;
}

.doc-count-pill {
  flex: 0 0 auto;
  min-width: 24px;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1;
  text-align: center;
  padding: 5px 8px;
  border-radius: 999px;
  background: var(--blue-pale);
  color: var(--blue-dark);
}

.doc-accordion-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 6px;
}

/* Plus icon button (no visible text) */
.doc-plus-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--blue);
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.doc-plus-btn:hover {
  background: var(--blue-pale);
  border-color: var(--blue);
  color: var(--blue-dark);
}

.doc-toggle-arrow-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, background-color 0.15s;
}

.doc-toggle-arrow-btn:hover {
  color: var(--blue-dark);
  background: var(--blue-pale);
}

.doc-chevron-svg {
  transition: transform 0.2s ease;
}

.doc-chevron-svg.open {
  transform: rotate(180deg);
}

/* Accordion body and 2-column list */
.doc-accordion-body {
  border-top: 1px solid var(--line);
  background: #fff;
}

.doc-accordion-body.hidden {
  display: none;
}

/* The heading row and every document row share one grid, so the columns
   line up: saved name, email name, then a fixed width for the buttons. */
.doc-columns-head,
.doc-file-row {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) 400px;
  column-gap: 24px;
  align-items: center;
  padding-left: 20px;
  padding-right: 20px;
}

.doc-columns-head {
  padding-top: 10px;
  padding-bottom: 10px;
  background: #fafcff;
  border-bottom: 1px solid var(--line);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.doc-head-actions {
  text-align: right;
}

.doc-files-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.doc-file-row {
  padding-top: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background-color 0.12s;
}

.doc-file-row:last-child {
  border-bottom: 0;
}

.doc-file-row:hover {
  background: var(--blue-wash);
}

/* Left side: System saved filename */
.doc-col-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

.doc-file-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--blue-wash);
  border: 1px solid var(--blue-pale);
  color: var(--blue);
  flex-shrink: 0;
}

.doc-system-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

/* The whole saved name is shown, wrapping where it must, rather than cut
   off: two files can differ only in their last words. */
.doc-system-filename code {
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--ink);
  background: none;
  padding: 0;
  overflow-wrap: anywhere;
}

.doc-file-size {
  color: var(--muted);
  font-size: 0.78rem;
}

/* Right side: Name when attached in email */
.doc-col-right {
  min-width: 0;
}

.doc-email-name {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* The column names beside each value, shown only once the rows stack and
   the heading row is hidden. */
.doc-col-label {
  display: none;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 2px;
}

/* Actions */
.doc-col-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: nowrap;
}

.doc-col-actions .btn {
  white-space: nowrap;
  padding: 7px 12px;
  font-size: 0.85rem;
}

.doc-col-actions .doc-preview-btn {
  padding: 7px 16px;
}

.doc-download-btn,
.doc-replace-btn {
  color: var(--blue);
}

.doc-empty-state {
  padding: 32px 20px;
  text-align: center;
}

.doc-empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* A medium width list: the buttons move under the two names. */
@container docs (max-width: 900px) {
  .doc-columns-head,
  .doc-file-row {
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    row-gap: 12px;
  }
  .doc-head-actions {
    display: none;
  }
  .doc-col-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-left: 46px;
  }
}

/* A phone width list: one card per document, labels beside the values,
   and the four buttons in a tidy two by two grid. */
@container docs (max-width: 600px) {
  .doc-accordion-header {
    gap: 8px;
    padding: 14px 10px 14px 14px;
  }
  .doc-accordion-title {
    gap: 9px;
  }
  .doc-accordion-actions {
    gap: 2px;
  }
  .doc-toggle-arrow-btn {
    width: 30px;
  }
  .doc-folder-badge {
    width: 32px;
    height: 32px;
  }
  .doc-folder-name {
    font-size: 1rem;
  }
  .doc-columns-head {
    display: none;
  }
  .doc-file-row {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 14px;
    padding: 16px;
  }
  .doc-col-label {
    display: block;
  }
  .doc-col-right {
    padding-left: 46px;
  }
  .doc-col-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding-left: 0;
  }
  .doc-col-actions .btn,
  .doc-col-actions .doc-preview-btn {
    width: 100%;
    padding: 9px 10px;
  }
  .doc-col-actions .btn-ghost,
  .doc-col-actions .btn-danger-ghost {
    border: 1px solid var(--line);
  }
  .doc-col-actions .btn-danger-ghost {
    border-color: #f2c9c5;
  }
}

/* Modals */
.doc-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 16px;
}

.doc-modal-dialog {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.doc-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--blue-wash);
}

.doc-modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink);
}

.doc-modal-close {
  background: transparent;
  border: 0;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.doc-modal-close:hover {
  color: var(--ink);
  background: var(--blue-pale);
}

.doc-modal-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.doc-modal-radio-group {
  display: flex;
  gap: 16px;
  margin-top: 4px;
}

.doc-modal-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}

.doc-modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

/* Preview Modal */
.doc-preview-dialog {
  max-width: 860px;
  height: 80vh;
  display: flex;
  flex-direction: column;
}

.doc-preview-sub {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.doc-preview-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.doc-preview-frame-wrap {
  flex: 1 1 auto;
  background: var(--blue-wash);
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.doc-preview-iframe {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  border: 0;
}

.doc-preview-hint,
.doc-preview-loading,
.doc-preview-error {
  margin: 0;
  padding: 10px 16px;
  flex: 0 0 auto;
}
