/* Modal dialogs + rich text editor.
   Self-contained so it works on both stylesheets. */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,.34);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
  opacity: 0; transition: opacity .18s ease;
}
.modal-backdrop.in { opacity: 1; }

.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 440px;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
  transform: translateY(12px) scale(.98);
  transition: transform .2s cubic-bezier(.2,.8,.3,1);
  max-height: 88vh; display: flex; flex-direction: column;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  color: #1d1d1f;
}
.modal-wide { max-width: 760px; }
.modal-backdrop.in .modal { transform: translateY(0) scale(1); }

.modal-head { padding: 20px 24px 0; }
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.modal-body { padding: 16px 24px 4px; overflow-y: auto; }
.modal-text { margin: 0; font-size: 14.5px; line-height: 1.55; color: #3a3a3c; }

.modal-label {
  display: block; font-size: 12.5px; font-weight: 600;
  margin: 14px 0 5px; color: #1d1d1f;
}
.modal-body > .modal-label:first-child { margin-top: 0; }
.modal-input {
  width: 100%; padding: 9px 11px; font-size: 14px; font-family: inherit;
  border: 1px solid #d2d2d7; border-radius: 9px; background: #fff; color: #1d1d1f;
  box-sizing: border-box;
}
.modal-input:focus {
  outline: none; border-color: #0071e3; box-shadow: 0 0 0 3px rgba(0,113,227,.14);
}
textarea.modal-input { resize: vertical; min-height: 76px; }
select.modal-input[multiple] { padding: 5px; }
.modal-hint { font-size: 12px; color: #86868b; margin: 5px 0 0; line-height: 1.45; }
.modal-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; margin: 14px 0 2px; cursor: pointer;
}
.modal-check input { width: auto; margin: 0; }

.modal-actions {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 16px 24px 20px; border-top: 1px solid #f0f0f2; margin-top: 12px;
}
.modal-actions .btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 17px; border: 0; border-radius: 9px; cursor: pointer;
  font-size: 14px; font-weight: 500; font-family: inherit;
  background: #0071e3; color: #fff;
}
.modal-actions .btn:hover { opacity: .88; }
.modal-actions .btn.secondary { background: #e8e8ed; color: #1d1d1f; }
.modal-actions .btn.danger { background: #c0332b; color: #fff; }

/* ---- Rich text editor ---- */
.rt-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  padding: 7px 8px; border: 1px solid #d2d2d7; border-bottom: 0;
  border-radius: 10px 10px 0 0; background: #fbfbfd;
}
.rt-btn {
  min-width: 30px; height: 28px; padding: 0 7px;
  border: 1px solid transparent; border-radius: 7px; background: transparent;
  font-size: 13.5px; cursor: pointer; color: #1d1d1f; font-family: inherit;
  display: inline-flex; align-items: center; justify-content: center;
}
.rt-btn:hover { background: #ececf0; }
.rt-btn:active { background: #dfdfe4; }
.rt-select {
  height: 28px; padding: 0 6px; font-size: 12.5px; font-family: inherit;
  border: 1px solid #d2d2d7; border-radius: 7px; background: #fff; color: #1d1d1f;
  max-width: 130px;
}
.rt-sep { width: 1px; height: 18px; background: #d2d2d7; margin: 0 3px; }

.rt-editor {
  border: 1px solid #d2d2d7; border-radius: 0 0 10px 10px;
  padding: 16px 18px; min-height: 260px; max-height: 46vh; overflow-y: auto;
  font-size: 14.5px; line-height: 1.65; background: #fff; color: #1d1d1f;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.rt-editor:focus { outline: none; border-color: #0071e3; box-shadow: 0 0 0 3px rgba(0,113,227,.14); }
.rt-editor p { margin: 0 0 10px; }
.rt-editor ul, .rt-editor ol { margin: 0 0 10px; padding-left: 24px; }

/* Rendered letter content elsewhere in the app */
.letter-html {
  background: #fbfbfd; border: 1px solid #e8e8ed; border-radius: 10px;
  padding: 15px 17px; margin: 0 0 12px; font-size: 13.5px; line-height: 1.6;
  overflow-wrap: break-word;
}
.letter-html p { margin: 0 0 9px; }
.letter-html ul, .letter-html ol { margin: 0 0 9px; padding-left: 22px; }

@media (max-width: 560px) {
  .modal { max-width: 100%; }
  .rt-select { max-width: 96px; }
}

/* ---- File preview ---- */
.preview-frame {
  width: 100%; height: 60vh; border: 1px solid #d2d2d7; border-radius: 10px; background: #fff;
}
.preview-image-wrap {
  display: flex; align-items: center; justify-content: center;
  max-height: 60vh; overflow: auto; background: #f3f3f5; border-radius: 10px; padding: 12px;
}
.preview-image { max-width: 100%; max-height: 56vh; border-radius: 6px; }
@media (max-width: 560px) { .preview-frame { height: 44vh; } }

/* ---- Action chooser ---- */
.choice-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.choice-item {
  width: 100%; text-align: left; padding: 11px 14px; border-radius: 10px;
  border: 1px solid #d2d2d7; background: #fff; font-size: 14px; cursor: pointer;
  box-shadow: none; color: inherit; font-weight: 500;
}
.choice-item:hover { background: #f2f5f4; transform: none; filter: none; }
.choice-item.danger { color: #b3261e; }
.choice-item.danger:hover { background: #fdeceb; }
[data-theme="dark"] .choice-item { background: #1c2b27; border-color: #2e423c; }
[data-theme="dark"] .choice-item:hover { background: #24352f; }

/* ---- Submission confirmation ---- */
.confirm-block .k { font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: #6b7772; display: block; margin-bottom: 2px; }
.confirm-ref { background: #f2f5f4; border-radius: 10px; padding: 12px 14px; margin: 12px 0; }
.confirm-ref strong { font-size: 19px; letter-spacing: .5px; }
.confirm-steps { margin: 6px 0 12px; padding-left: 20px; }
.confirm-steps li { margin-bottom: 5px; font-size: 14px; }
[data-theme="dark"] .confirm-ref { background: #1c2b27; }
[data-theme="dark"] .confirm-block .k { color: #93a49e; }
