/* ============================================================
   Projekti dokumendid (#page-docs)
   Left: the project and what to do with it, kept in view while the
   form scrolls. Right: the document details as grouped lists, as in
   Minu konto. Phones: project, details, then files and actions.
   ============================================================ */
#page-docs .dashboard-container { max-width: 1180px; }
#page-docs .topbar .back-link { left: 0; }
#page-docs .user-icon-btn { right: 0; }
#page-docs h2 { text-transform: none; letter-spacing: -0.01em; }
#page-docs label { text-transform: none; letter-spacing: 0; opacity: 1; }
#page-docs.is-loading .docs { opacity: 0.6; pointer-events: none; }

.docs {
  display: grid; grid-template-columns: 320px minmax(0, 1fr);
  gap: 24px; align-items: start; margin-top: 24px;
  transition: opacity 200ms ease;
}
.docs-side { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.docs-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; padding: 18px; }
.docs-h2 { margin: 0; color: var(--text); font-size: 15px; font-weight: 600; line-height: 1.3; }
.docs-hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.docs-hint.is-warning { color: var(--warn-text, #ffb340); }

/* Fields: the Admin field (36px, faint fill); inside a list row, borderless */
#page-docs .docs-input {
  width: 100%; height: 36px; margin: 0; padding: 0 12px; box-sizing: border-box;
  border: 1px solid transparent !important; border-radius: 10px; box-shadow: none !important;
  background-color: var(--adm-fill) !important; color: var(--text) !important;
  font: 400 14px var(--font-sans);
  transition: background-color 150ms ease, border-color 150ms ease;
}
#page-docs .docs-input:hover { background-color: var(--adm-fill-hover) !important; }
#page-docs .docs-input:focus { outline: none; border-color: var(--adm-ring) !important; background-color: var(--adm-fill-hover) !important; }
#page-docs .docs-input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#page-docs .docs-input::placeholder { color: var(--muted); opacity: 0.7; }
#page-docs .docs-input[aria-invalid] { border-color: var(--adm-red) !important; }
#page-docs .docs-select {
  padding-right: 32px; cursor: pointer; -webkit-appearance: none; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%239fb0c1' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: right 13px center !important;
}
.docs-select option { background: rgb(var(--pop-rgb)); color: var(--text); }

/* The on/off setting is a switch, as in Minu konto */
.docs-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; color: var(--text); font-size: 14px; cursor: pointer; }

/* Folders: what kind, which one (or "Valimata"), and "Vali" */
.docs-folders { display: flex; flex-direction: column; border-radius: 12px; background: var(--adm-surface); border: 1px solid var(--adm-card-line); overflow: hidden; }
.docs-folder { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 8px 8px 12px; }
.docs-folder + .docs-folder { border-top: 1px solid var(--adm-sep); }
.docs-folder > .material-icons-outlined { flex: none; font-size: 20px; color: var(--accent); }
.docs-folder-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; font-size: 14px; }
.docs-folder-text small { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs-pick { flex: none; height: 32px; }
#page-docs .adm-btn:disabled { opacity: 0.45; cursor: default; filter: none; transform: none; }

/* Actions: Save and the main action side by side, the main one last */
.docs-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }
.docs-actions .adm-btn { height: 40px; }
.docs-status { min-height: 1.4em; margin: 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.docs-status:empty { display: none; }
.docs-status[data-kind="error"] { color: var(--adm-red-text); }
.docs-status[data-kind="success"] { color: var(--adm-green-text); }
.docs-status[data-kind="pending"] { color: var(--muted); font-weight: 500; }

/* Details: one grouped list per group; label left, value right */
.docs-main { display: flex; flex-direction: column; gap: 24px; min-width: 0; }
.docs-section { min-width: 0; }
.docs-row { gap: 12px; min-height: 52px; padding: 8px 8px 8px 16px; }
.docs-row .acc-row-label { width: 180px; font-size: 14px; color: var(--muted); }
#page-docs .docs-row .docs-row-input { flex: 1; min-width: 0; background-color: transparent !important; }
#page-docs .docs-row .docs-row-input:hover { background-color: var(--adm-fill) !important; }
#page-docs .docs-row .docs-row-input:focus { background-color: var(--adm-fill) !important; }

/* Phones: one column; project first, then the details, then files and actions */
@media (max-width: 900px) {
  .docs { grid-template-columns: 1fr; gap: 16px; margin-top: 16px; }
  .docs-side { display: contents; }
  .docs-project { order: 1; }
  .docs-main { order: 2; }
  .docs-files { order: 3; }
}
@media (max-width: 760px) {
  #page-docs .dashboard-container { width: 100%; padding: 16px 16px 40px; }
  #page-docs .topbar { padding-inline: 52px; min-height: 44px; }
  #page-docs .topbar .brand { gap: 10px; }
  #page-docs .logo-wrap { width: 34px; height: 34px; }
  #page-docs .brand-name { font-size: 20px; white-space: nowrap; }
  #page-docs .topbar .back-link { padding: 10px; }
  #page-docs .topbar .back-link span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* Label above the value when the row is too narrow for both */
  .docs-row { flex-direction: column; align-items: stretch; gap: 4px; padding: 10px 12px; }
  .docs-row .acc-row-label { width: auto; font-size: 13px; }
  /* 16px keeps iOS from zooming into a field; 44px is a comfortable tap */
  #page-docs .docs-input { height: 44px; font-size: 16px; }
  #page-docs .docs-row .docs-row-input { padding-inline: 8px; }
  .docs-actions .adm-btn { height: 44px; }
}
@media (prefers-reduced-motion: reduce) { .docs, #page-docs .docs-input { transition: none; } }
@media (prefers-reduced-transparency: reduce) { #page-docs .glass { background: rgb(var(--sheet-rgb)); } }
@media (prefers-contrast: more) {
  #page-docs :is(.glass, .docs-folders) { border-color: rgb(var(--fg-rgb) / 0.5); }
  #page-docs :is(.docs-hint, .docs-folder-text small, .docs-row .acc-row-label) { color: var(--text); }
}
/* No inherited section margin: the gaps come from the layout alone */
#page-docs section { margin: 0; }
#page-docs .docs-row .acc-row-label { font-weight: 500; }

/* The sidebar's top edge lines up with the first list, below its group title:
   the title's line (21px) plus its gap (8px) */
.docs { --docs-head: 29px; }
.docs-section > .acc-h3 { height: 21px; line-height: 21px; margin-bottom: 8px; }
@media (min-width: 901px) { .docs-side { margin-top: var(--docs-head); } }

/* Fields in the lists have a visible outline, as in Minu konto */
#page-docs .docs-row .docs-row-input { border: 1px solid var(--adm-card-line) !important; }
#page-docs .docs-row .docs-row-input:hover { border-color: color-mix(in srgb, var(--text) 22%, transparent) !important; }
#page-docs .docs-row .docs-row-input:focus { border-color: var(--adm-ring) !important; }
#page-docs .docs-row .docs-row-input[aria-invalid] { border-color: var(--adm-red) !important; }
@media (prefers-contrast: more) { #page-docs .docs-row .docs-row-input { border-color: rgb(var(--fg-rgb) / 0.5) !important; } }

/* The project list opens as the site's menu (as in Projektid and Redeli
   täituvus): a blurred panel that grows from the field, a teal check on the
   chosen row, and the chevron turning while it is open */
@supports (appearance: base-select) {
  #page-docs .docs-select {
    appearance: base-select; -webkit-appearance: base-select;
    display: inline-flex; align-items: center; padding-right: 10px; background-image: none !important;
  }
  #page-docs .docs-select::picker-icon {
    content: ""; flex: none; width: 14px; height: 14px; margin-left: auto;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239fb0c1' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") center / 14px no-repeat;
    transition: rotate 250ms var(--adm-spring);
  }
  #page-docs.light .docs-select::picker-icon { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23546475' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); }
  #page-docs .docs-select:open::picker-icon { rotate: 180deg; }
  #page-docs .docs-select::picker(select) {
    appearance: base-select;
    min-width: anchor-size(width); max-height: min(420px, 60vh);
    margin-top: 6px; padding: 5px; box-sizing: border-box;
    border: 1px solid rgb(var(--fg-rgb) / 0.1); border-radius: 14px;
    background: rgb(var(--pop-rgb) / 0.9);
    -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35); color: var(--text);
    opacity: 1; transform: none; transform-origin: top center;
    transition: opacity 160ms ease-out, transform 320ms var(--adm-spring), overlay 160ms allow-discrete, display 160ms allow-discrete;
  }
  @starting-style { #page-docs .docs-select:open::picker(select) { opacity: 0; transform: scale(0.94); } }
  #page-docs.light .docs-select::picker(select) { box-shadow: 0 24px 60px rgba(17, 24, 39, 0.18); }
  #page-docs .docs-select option {
    display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 10px; box-sizing: border-box;
    border-radius: 9px; background: transparent; color: var(--text); font: 14px var(--font-sans); cursor: pointer;
  }
  #page-docs .docs-select option:hover, #page-docs .docs-select option:focus-visible { outline: none; background: rgb(var(--fg-rgb) / 0.1); }
  #page-docs .docs-select option:checked { font-weight: 600; }
  #page-docs .docs-select option::checkmark { order: 1; margin-left: auto; color: var(--accent); }
  @media (prefers-reduced-motion: reduce) { #page-docs .docs-select::picker(select), #page-docs .docs-select::picker-icon { transition: opacity 120ms ease; } }
  @media (prefers-reduced-transparency: reduce) { #page-docs .docs-select::picker(select) { background: rgb(var(--pop-rgb)); -webkit-backdrop-filter: none; backdrop-filter: none; } }
}

/* ============================================================
   Suggestion lists (project-documents-suggest.js): the site's menu,
   under the field; a small chevron says a field has suggestions
   ============================================================ */
#page-docs .docs-row .docs-row-input.is-combo {
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%239fb0c1' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important; background-position: right 12px center !important;
}
.docs-suggest {
  position: fixed; inset: auto; margin: 0; padding: 5px; box-sizing: border-box; overflow-y: auto;
  border: 1px solid rgb(var(--fg-rgb) / 0.1); border-radius: 14px;
  background: rgb(var(--pop-rgb) / 0.92); color: var(--text);
  -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  opacity: 1; transform: none; transform-origin: top center;
  transition: opacity 160ms ease-out, transform 320ms var(--adm-spring), overlay 160ms allow-discrete, display 160ms allow-discrete;
}
.docs-suggest[data-side="top"] { transform-origin: bottom center; }
@starting-style { .docs-suggest:popover-open { opacity: 0; transform: scale(0.96); } }
.light .docs-suggest { box-shadow: 0 24px 60px rgba(17, 24, 39, 0.18); }
.docs-suggest-opt {
  display: flex; flex-direction: column; justify-content: center; gap: 1px; min-height: 38px; padding: 6px 10px; box-sizing: border-box;
  border-radius: 9px; font-size: 14px; cursor: pointer;
}
.docs-suggest-opt small { color: var(--muted); font-size: 12px; }
.docs-suggest-opt :is(span, small) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.docs-suggest-opt:hover, .docs-suggest-opt[aria-selected="true"] { background: rgb(var(--fg-rgb) / 0.1); }
/* "Võta tagasi" after fields were filled in automatically */
.docs-undo {
  margin-left: 4px; padding: 2px 8px; border: 0; border-radius: 8px; background: transparent;
  color: var(--accent); font: 600 13px var(--font-sans); cursor: pointer;
}
.docs-undo:hover { background: rgb(var(--fg-rgb) / 0.06); }
.docs-undo:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .docs-suggest { transition: opacity 120ms ease; } }
@media (prefers-reduced-transparency: reduce) { .docs-suggest { background: rgb(var(--pop-rgb)); -webkit-backdrop-filter: none; backdrop-filter: none; } }

/* A note under a group title ("Minu osa") */
.docs-group-note { margin: -2px 0 8px 4px; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
@media (prefers-contrast: more) { .docs-group-note { color: var(--text); } }

/* ============================================================
   Changes from others: a button at the right of the changed row opens a
   small preview (your value, the new one, who and when) with the choice
   ============================================================ */
.docs-change-btn {
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; margin: 0;
  border: 0; border-radius: 9px; background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent); cursor: pointer;
  transition: background-color 150ms ease, transform 200ms var(--adm-spring);
}
.docs-change-btn[hidden] { display: none; }
.docs-change-btn .material-icons-outlined { font-size: 18px; }
.docs-change-btn:hover { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.docs-change-btn:active { transform: scale(0.92); transition-duration: 0ms; }
.docs-change-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.docs-change {
  position: fixed; inset: auto; margin: 0; box-sizing: border-box; width: min(320px, calc(100vw - 24px));
  padding: 14px 16px; border: 1px solid var(--adm-card-line); border-radius: 14px;
  background: var(--adm-pop); color: var(--text);
  -webkit-backdrop-filter: blur(24px) saturate(160%); backdrop-filter: blur(24px) saturate(160%);
  box-shadow: 0 16px 40px var(--shadow);
  opacity: 1; transform: none;
  transition: opacity 160ms ease-out, transform 320ms var(--adm-spring), overlay 160ms allow-discrete, display 160ms allow-discrete;
}
@starting-style { .docs-change:popover-open { opacity: 0; transform: scale(0.94); } }
.docs-change.is-busy { opacity: 0.6; pointer-events: none; }
.docs-change-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.docs-change-who { margin: 2px 0 10px; color: var(--muted); font-size: 12.5px; }
.docs-change-values { display: flex; flex-direction: column; gap: 6px; margin: 0 0 14px; }
.docs-change-values > div { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 8px; align-items: baseline; }
.docs-change-values dt { color: var(--muted); font-size: 12px; font-weight: 600; }
.docs-change-values dd { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.docs-change-values > div:first-child dd { color: var(--muted); text-decoration: line-through; text-decoration-color: rgb(var(--fg-rgb) / 0.35); }
.docs-change-values > div:last-child dd { font-weight: 600; }
.docs-change-actions { display: flex; justify-content: flex-end; gap: 8px; }
.docs-change-actions .adm-btn { height: 32px; }
/* The changed row: its label carries a small teal dot as well */
.docs-row.has-proposal .acc-row-label::after {
  content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; vertical-align: 2px;
  border-radius: 50%; background: var(--accent);
}
@media (max-width: 760px) {
  /* Label and button on one line, the field below */
  .docs-row { position: relative; }
  .docs-row .docs-change-btn { position: absolute; top: 6px; right: 8px; width: 36px; height: 36px; }
  .docs-change-actions .adm-btn { height: 40px; }
}
@media (prefers-reduced-motion: reduce) { .docs-change, .docs-change-btn { transition: opacity 120ms ease; } .docs-change-btn:active { transform: none; } }
@media (prefers-reduced-transparency: reduce) { .docs-change { background: rgb(var(--pop-rgb)); -webkit-backdrop-filter: none; backdrop-filter: none; } }
@media (prefers-contrast: more) { .docs-change { border-color: rgb(var(--fg-rgb) / 0.5); } .docs-change-who, .docs-change-values dt { color: var(--text); } }
/* A hidden button still keeps its place on wide screens, so every field in a
   list has the same width; on phones it floats, so it takes no room at all */
@media (min-width: 761px) { .docs-change-btn[hidden] { display: grid; visibility: hidden; } }
/* A long project name in the closed list stays on one line */
#page-docs .docs-select { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#page-docs .docs-select option { white-space: normal; }

/* Actions: Salvesta and Uuenda side by side, the main action full width below */
.docs-actions { grid-template-columns: 1fr 1fr; }
.docs-actions .docs-actions-main { grid-column: 1 / -1; }
