/* Anonymous request portal. Layout, card and typography come from pages/account.css
   (.account-row / .account-box / .btn), so this file only adds the form controls,
   pickers and tree dialogs that the portal needs. */

.request-content {
  width: 100%;
  max-width: 560px;
}

.request-content-narrow {
  max-width: 460px;
}

.request-company {
  margin-top: 20px;
  font-family: var(--font-heading);
  font-size: 20px;
  color: var(--muted);
  text-align: center;
}

.request-client-logo {
  display: block;
  max-width: 100%;
  max-height: 100px;
  margin: 0 auto;
}

.request-doc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.request-doc-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
}

.request-doc-name {
  font-size: 16px;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.request-box {
  padding: 35px 30px;
}

.request-title {
  margin: 0 0 25px;
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-secondary);
}

.request-asset-header {
  margin: 0 0 20px;
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-secondary);
}

.request-field {
  margin-bottom: 20px;
}

.request-field-title {
  margin-bottom: 0;
}

.request-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.request-required {
  margin-left: 2px;
  color: var(--accent);
  font-weight: 700;
}

.request-hint {
  display: block;
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.request-static-value {
  font-size: 14px;
  font-weight: 500;
}

/* Boxed controls: same tokens as the rest of the app, accent focus ring. */
.request-portal .form-control,
.request-tree-dialog .form-control {
  display: block;
  width: 100%;
  height: 40px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  box-shadow: none;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.request-portal textarea.form-control {
  height: auto;
  min-height: 96px;
  resize: vertical;
}

.request-portal .form-control::placeholder,
.request-tree-dialog .form-control::placeholder {
  color: var(--placeholder);
}

.request-portal .form-control:hover,
.request-tree-dialog .form-control:hover {
  border-color: var(--border-strong);
}

.request-portal .form-control:focus,
.request-tree-dialog .form-control:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.request-portal select.form-control {
  padding-right: 34px;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236f7781' d='M1.4 0 6 4.6 10.6 0 12 1.4 6 7.4 0 1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

/* Tree pickers read as a select: value inline, caret on the right, clear next to it. */
.request-picker {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.request-picker-control {
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  min-height: 40px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 20px;
  text-align: left;
  color: var(--placeholder);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.request-picker-control:hover {
  border-color: var(--border-strong);
}

.request-picker-control:focus-visible {
  outline: 0;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.request-picker-control.is-selected {
  color: var(--text);
  font-weight: 500;
}

.request-picker-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.request-picker-caret {
  flex: 0 0 auto;
  width: 12px;
  height: 8px;
  fill: var(--muted);
}

.request-picker-clear {
  flex: 0 0 auto;
  width: 40px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  cursor: pointer;
  transition:
    color 0.15s ease,
    border-color 0.15s ease;
}

.request-picker-clear:hover,
.request-picker-clear:focus-visible {
  color: var(--error);
  border-color: var(--error-border);
}

.request-alert-danger {
  margin-top: 8px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--error);
  background-color: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: var(--radius-control);
}

/* Reuses the register form checkbox (.simple-check / .checkmark from account.css). */
.request-check {
  margin-bottom: 0;
  font-size: 13px;
  line-height: 1.5;
}

.request-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.request-photo {
  position: relative;
  flex: 1 1 100%;
}

.request-photo img {
  display: block;
  width: 100%;
  height: 250px;
  object-fit: cover;
  border-radius: var(--radius-control);
}

.request-photo-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 20px;
  line-height: 1;
  color: #fff;
  background: rgb(50 51 57 / 72%);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.request-photo-remove:hover,
.request-photo-remove:focus-visible {
  background: var(--error);
}

.request-upload-trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  color: var(--text-secondary);
  background-color: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-control);
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease;
}

.request-upload-trigger:hover,
.request-upload-trigger:focus-within {
  color: var(--accent-hover);
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.request-upload-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.request-upload-trigger input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.request-submit-group {
  margin-top: 30px;
}

.request-message-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.request-captcha-widget {
  display: flex;
  justify-content: center;
  margin-top: 20px;
}

/* Tree dialogs — native <dialog>, styled like the app modals. */
.request-tree-dialog {
  width: min(560px, calc(100% - 24px));
  max-height: min(640px, calc(100vh - 32px));
  padding: 0;
  overflow: hidden;
  color: var(--text);
  font-family: var(--font-base);
  font-size: var(--font-size-base);
  background: var(--surface);
  border: 0;
  border-radius: var(--radius-modal);
  box-shadow: var(--modal-shadow);
}

.request-tree-dialog[open] {
  display: flex;
  flex-direction: column;
}

.request-tree-dialog::backdrop {
  background: rgb(50 51 57 / 55%);
}

.request-dialog-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 20px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border-light);
}

.request-dialog-title {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
}

.request-dialog-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: var(--radius-control);
  cursor: pointer;
}

.request-dialog-close:hover,
.request-dialog-close:focus-visible {
  color: var(--text);
  background: rgb(0 0 0 / 6%);
}

.request-dialog-body {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  padding: 16px 20px 20px;
}

.request-search {
  position: relative;
  flex: 0 0 auto;
}

.request-search-icon {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 16px;
  height: 16px;
  fill: var(--muted);
  pointer-events: none;
}

.request-tree-dialog .request-tree-search {
  padding-left: 36px;
}

.request-tree-dialog .request-tree-search::-webkit-search-cancel-button {
  cursor: pointer;
}

.request-tree {
  flex: 1 1 auto;
  min-height: 180px;
  margin: 0 -6px;
  padding: 0 6px;
  overflow: auto;
}

/* jsTree default theme repainted with the app palette. */
.request-tree .jstree-anchor {
  font-family: var(--font-base);
  font-size: 14px;
  color: var(--text);
}

.request-tree .jstree-wholerow-hovered {
  background: rgb(0 0 0 / 4%);
  border-radius: var(--radius-control);
  box-shadow: none;
}

.request-tree .jstree-wholerow-clicked,
.request-tree .jstree-wholerow-clicked.jstree-wholerow-hovered {
  background: var(--accent-soft);
  border-radius: var(--radius-control);
  box-shadow: none;
}

.request-tree .jstree-anchor.jstree-clicked,
.request-tree .jstree-anchor.jstree-hovered {
  background: transparent;
  border-radius: var(--radius-control);
  box-shadow: none;
}

.request-tree .jstree-anchor.jstree-clicked {
  font-weight: 500;
  color: var(--accent-hover);
}

.request-tree .jstree-search {
  font-style: normal;
  font-weight: 600;
  color: var(--accent);
}

/* Loading state */
.request-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 70vh;
  padding: 40px 20px;
  text-align: center;
}

.request-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: request-spin 0.9s linear infinite;
}

@keyframes request-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .request-spinner {
    animation-duration: 2.5s;
  }
}

.request-loading-text {
  font-family: var(--font-heading);
  font-size: 18px;
  color: var(--text-secondary);
}

.request-loading-slow {
  font-size: 14px;
  color: var(--muted);
}

@media (max-width: 991px) {
  .request-box {
    padding: 0;
  }

  .request-portal .form-control,
  .request-tree-dialog .form-control,
  .request-picker-control {
    min-height: 44px;
    height: 44px;
  }

  .request-upload-trigger {
    min-height: 44px;
  }

  .request-portal textarea.form-control {
    height: auto;
  }

  .request-picker-clear {
    width: 44px;
  }

  .request-search-icon {
    top: 14px;
  }
}

/* jsTree's responsive theme paints grey embossed rows below 768px — flatten it. */
@media (max-width: 768px) {
  .request-tree.jstree-default-responsive .jstree-anchor {
    font-size: 14px;
    font-weight: 400;
    color: var(--text);
    text-shadow: none;
  }

  .request-tree.jstree-default-responsive .jstree-anchor.jstree-clicked {
    font-weight: 500;
    color: var(--accent-hover);
  }

  .request-tree.jstree-default-responsive .jstree-wholerow {
    background: transparent;
    border-top: 0;
    border-bottom: 1px solid var(--border-light);
  }

  .request-tree.jstree-default-responsive .jstree-wholerow-hovered {
    background: rgb(0 0 0 / 4%);
  }

  .request-tree.jstree-default-responsive .jstree-wholerow-clicked,
  .request-tree.jstree-default-responsive .jstree-wholerow-clicked.jstree-wholerow-hovered {
    background: var(--accent-soft);
  }

  .request-tree.jstree-default-responsive .jstree-children .jstree-last > .jstree-wholerow,
  .request-tree.jstree-default-responsive .jstree-children .jstree-open > .jstree-wholerow {
    box-shadow: none;
  }

  .request-tree.jstree-default-responsive .jstree-search {
    color: var(--accent);
  }
}

@media (max-width: 767px) {
  .request-tree-dialog {
    width: calc(100% - 16px);
    max-height: calc(100vh - 24px);
  }

  .request-dialog-body {
    padding: 14px 16px 16px;
  }

  .request-dialog-header {
    padding: 12px 16px;
  }
}

.request-section.is-hidden,
[hidden] {
  display: none !important;
}

.request-portal-embed .request-box {
  margin-top: 0;
}
