/* The upload form: fields, file pickers, the file list, progress and errors. Split out of style.css (issue #159). */

.create-panel {
  position: relative;
  overflow: hidden;
}

.upload-row {
  display: flex;
  gap: 0.85rem;
  align-items: flex-end;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
}

.field > span {
  color: var(--muted-strong);
  font-size: 0.76rem;
  font-weight: 650;
}

.project-name-field { flex: 1 1 260px; }

/* The project form's required fields, the name and the PDFs: the number,
   kohde and address are optional, and the form's intro says so. */
.required-mark { color: var(--danger); font-weight: 700; }

/* The name and the project's number, kohde and address on one line above
   the files (issue #178). */
.project-details { display: flex; flex-wrap: wrap; gap: 0.85rem; flex: 1 1 100%; }

.project-detail-field { flex: 1 1 160px; }

.file-field { flex: 1.35 1 340px; }

.test-file-field { max-width: 600px; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.file-picker {
  min-height: 3.05rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.48rem 0.75rem;
  background: rgba(7, 11, 18, 0.62);
  border: 1px dashed #354761;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.file-picker:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.file-picker:active { transform: translateY(1px); }

.file-picker-icon {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 8px;
  background: var(--accent-soft);
  color: #b9c9ff;
  font-size: 1.35rem;
  font-weight: 300;
  line-height: 1;
}

.file-picker-copy { min-width: 0; display: flex; flex-direction: column; }

.file-picker-copy strong { color: var(--text); font-size: 0.86rem; font-weight: 650; }

.file-picker-copy small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

input[type="text"], input[type="password"] {
  width: 100%;
  min-width: 0;
  min-height: 3.05rem;
  background: rgba(7, 11, 18, 0.62);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.68rem 0.85rem;
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]::placeholder, input[type="password"]::placeholder { color: #657287; }

input[type="text"]:focus, input[type="password"]:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* Upload/analysis progress bar, driven by the UI's poll loop. */
.progress-bar {
  height: 8px;
  background: var(--border-soft);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.85rem;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #e66730, #ff9b6d);
  width: 0%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.status-line { color: var(--muted); font-size: 0.84rem; margin-top: 0.5rem; }

/* Icon + text, no container: the earlier tinted-box treatment washed out
   against both surfaces (worst in light mode, where a red wash over the
   warm cream panel just read as muddy). Color comes from tokens so each
   theme gets a readable red -- the original hardcoded #ff9ca4 was tuned
   for dark surfaces and measured ~2:1 against the light theme's panel,
   far under the 4.5:1 WCAG AA floor for body text.
   The glyph is a CSS mask rather than markup so showError() can keep
   assigning textContent: switching it to innerHTML for the sake of an
   inline <svg> would put backend-supplied error strings into an HTML
   sink for no reason. currentColor means the icon tracks the token
   automatically, and it carries the alert meaning without relying on
   color alone. JS shows these with display:flex (see showError). */
.error-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--danger-strong);
  font-size: 0.88rem;
  font-weight: 600;
  margin-top: 0.8rem;
}

.error-line::before {
  content: "";
  flex: none;
  width: 15px;
  height: 15px;
  background: currentColor;
  -webkit-mask: var(--error-glyph) center / contain no-repeat;
  mask: var(--error-glyph) center / contain no-repeat;
}

/* Issue #28: the upload matches an existing project. A warning, not an
   error -- nothing failed, the user has a choice to make -- so the tone
   sits in the edge only and the text keeps the normal colours. */
.duplicate-notice {
  margin-top: 0.9rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm);
  background: var(--panel-raised);
}

.duplicate-title { margin: 0; font-weight: 650; }

.duplicate-list { list-style: none; margin: 0.75rem 0 0; padding: 0; display: grid; gap: 0.55rem; }

.duplicate-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; flex-wrap: wrap; }

.duplicate-row-text { display: grid; gap: 0.15rem; min-width: 0; }

.duplicate-row-meta { color: var(--muted); font-size: 0.8rem; }

.duplicate-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-top: 0.85rem; }

@media (max-width: 620px) {
  .upload-row { align-items: stretch; flex-direction: column; }
  .field, .primary-button { width: 100%; max-width: none; }
}

.field > span {
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
}

input[type="text"]::placeholder,
input[type="password"]::placeholder,
input[type="search"]::placeholder,
.point-menu-input::placeholder { color: var(--muted); }

input[type="text"]:hover,
input[type="password"]:hover,
input[type="search"]:hover,
.point-menu .point-menu-input:hover { border-color: var(--muted); }

.file-picker {
  position: relative;
  min-height: 3.05rem;
  border-color: var(--control-border);
  background: var(--control-bg);
}

.file-picker:hover {
  border-color: var(--muted);
  background: var(--control-hover);
}

.file-picker-icon {
  border-radius: var(--radius);
  color: var(--text);
  background: var(--neutral-fill);
  font-weight: 350;
}

.progress-bar {
  position: relative;
  height: 9px;
  background: var(--neutral-fill);
  border: 0;
}

.progress-fill {
  position: relative;
  background: var(--accent);
}

.progress-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  animation: jis-progress 1.5s linear infinite;
}

@media (max-width: 700px) {
  /* Desktop uses flex-basis to balance the name and file controls in one
     row. Once the form stacks vertically that basis becomes height, so it
     must be cleared or the file picker is pushed hundreds of pixels down. */
  .upload-row { align-items: stretch; flex-direction: column; }
  .upload-row .field { flex: none; }
  .upload-row .field,
  .upload-row .primary-button { width: 100%; max-width: none; }
}

/* Creating a project from a folder (issue #131): the two pickers side by
   side, the field lit while something is dragged over the form, and the list
   of found PDFs to prune before sending. Last in the file so it wins over
   the themed .file-picker rules above. */
.file-picker-row { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.file-picker-row .file-picker { flex: 1 1 150px; min-width: 0; }

.file-field.dragging .file-picker { border-color: var(--accent); background: var(--accent-soft); }

.project-file-list {
  position: relative;
  z-index: 1;
  margin-top: 0.85rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  background: var(--panel-raised);
}

.project-file-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35rem 0.9rem; font-size: 0.85rem; }

.project-file-problem { margin: 0.5rem 0 0; color: var(--danger-strong); font-size: 0.84rem; font-weight: 650; }

.project-file-rows { list-style: none; margin: 0.55rem 0 0; padding: 0; max-height: 15rem; overflow-y: auto; display: grid; gap: 0.1rem; }

.project-file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
  font-size: 0.82rem;
}

.project-file-row:hover { background: var(--accent-soft); }

.project-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.project-file-size { color: var(--muted); font-variant-numeric: tabular-nums; }

.project-file-row.too-big .project-file-size { color: var(--danger-strong); font-weight: 700; }

/* A tender package's PDFs folder by folder, each file ticked or not
   (issue #273). */
.zip-folders { margin-top: 0.55rem; display: grid; gap: 0.3rem; max-height: 24rem; overflow-y: auto; }
.zip-folder { border: 1px solid var(--border); border-radius: 6px; background: var(--panel); }
.zip-folder > summary { display: flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0.5rem; cursor: pointer; font-size: 0.82rem; }
.zip-folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.zip-folder-count { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.zip-folder .project-file-rows { margin: 0 0 0.3rem; padding: 0 0.5rem 0 1.6rem; max-height: none; }
.zip-folder .project-file-row { grid-template-columns: minmax(0, 1fr) auto; }
.zip-file-label { display: flex; align-items: center; gap: 0.45rem; min-width: 0; cursor: pointer; }

/* The new-project form folds away while a project is open (issue #274):
   only its title strip stays, with a button on the strip to open it. The
   progress bar, the error line and the duplicate notice are outside
   #create-panel-body, so a running upload still shows. */
.create-panel-toggle {
  margin-left: auto;
  align-self: center;
  padding: 0.28rem 0.7rem;
  font-size: 0.82rem;
  color: var(--panel-head-text);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: none;
}
.create-panel-toggle:hover:not(:disabled) { color: var(--panel-head-text); background: var(--bar-hover); border-color: rgba(255, 255, 255, 0.55); }
.create-panel-toggle[hidden] { display: none; }
/* As .panel-head + .section-copy did before the copy moved into the body. */
#create-panel-body > .section-copy:first-child { margin: 0 0 1rem; }
.create-panel.collapsed #create-panel-body { display: none; }
.create-panel.collapsed > .panel-head { margin-bottom: calc(-1 * var(--panel-pad)); border-radius: var(--radius); }
/* A running upload's bar and status line still show under the folded strip.
   The strip's negative margin pulled them up against it, so the bar read as
   part of the strip. Padding gives the pull back -- a margin would only
   collapse into it and the bar's own margin -- so the bar keeps its gap. */
.create-panel.collapsed > #project-progress-wrap { padding-top: var(--panel-pad); }
