/* Formularios e controles.
   Use `form-grid`, `field`, `field__label`, `field__control`, `file-input`, `check-row` e `inline-check` para compor entradas padronizadas. */

.form,
.form-stack {
  display: grid;
  gap: 12px;
}

.form-grid {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid__action {
  align-self: end;
  display: flex;
  justify-content: flex-end;
}

.form-grid__action .btn {
  width: auto;
}

.conditional-choice {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

[data-orcamento-panel][hidden] {
  display: none !important;
}

.image-carousel,
.image-upload-preview {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}

.image-carousel__viewport {
  aspect-ratio: 16 / 9;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  overflow: hidden;
  position: relative;
}

.image-carousel__slide {
  height: 100%;
  margin: 0;
  position: relative;
  width: 100%;
}

.image-carousel__slide.is-hidden {
  display: none;
}

.image-carousel__image,
.image-upload-preview__image {
  display: block;
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.image-carousel__caption {
  background: rgba(20, 32, 43, 0.78);
  bottom: 0;
  color: #fff;
  font-size: 12px;
  left: 0;
  line-height: 1.35;
  padding: 7px 9px;
  position: absolute;
  right: 0;
}

.image-carousel__controls {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

.image-carousel__counter {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  min-width: 48px;
  text-align: center;
}

.image-upload-preview {
  min-height: 160px;
}

.image-upload-preview[hidden] {
  display: none !important;
}

.image-upload-preview__image {
  max-height: 220px;
}

.field {
  align-content: start;
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field--full {
  grid-column: 1 / -1;
}

.field__label {
  color: var(--text-soft);
  display: block;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  min-height: 15px;
}

.field__label--with-help {
  align-items: center;
  display: inline-flex;
  gap: 6px;
}

.field-help {
  align-items: center;
  background: color-mix(in srgb, var(--brand) 12%, #fff);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, var(--border));
  border-radius: 999px;
  color: var(--brand-strong);
  cursor: help;
  display: inline-flex;
  font-size: 11px;
  font-weight: 800;
  height: 18px;
  justify-content: center;
  line-height: 1;
  position: relative;
  width: 18px;
}

.field-help::after {
  background: var(--text);
  border-radius: 8px;
  bottom: calc(100% + 8px);
  box-shadow: var(--shadow-md);
  color: #fff;
  content: attr(title);
  font-size: 12px;
  font-weight: 600;
  left: 50%;
  line-height: 1.35;
  max-width: 260px;
  min-width: 220px;
  opacity: 0;
  padding: 8px 10px;
  pointer-events: none;
  position: absolute;
  transform: translateX(-50%) translateY(4px);
  transition: opacity 140ms ease, transform 140ms ease;
  white-space: normal;
  z-index: 40;
}

.field-help:hover::after,
.field-help:focus-visible::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.field__control,
.file-input,
.emoji-picker__search,
.rt-editor__area {
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  box-sizing: border-box;
  color: var(--text);
  font: inherit;
  line-height: 1.35;
  min-height: 36px;
  padding: 7px 9px;
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease,
    color 140ms ease;
  width: 100%;
}

.field__control--compact {
  min-height: 34px;
  padding: 6px 9px;
}

.field__control::-ms-expand,
.file-input::-ms-expand,
.emoji-picker__search::-ms-expand,
.rt-editor__area::-ms-expand {
  display: none;
}

select.field__control,
select.file-input {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-soft) 50%),
    linear-gradient(135deg, var(--text-soft) 50%, transparent 50%),
    linear-gradient(var(--border-strong), var(--border-strong));
  background-position:
    calc(100% - 18px) calc(50% - 3px),
    calc(100% - 12px) calc(50% - 3px),
    calc(100% - 34px) 50%;
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px, 1px 18px;
  padding-right: 42px;
}

textarea.field__control,
textarea.rt-editor__area {
  line-height: 1.45;
  min-height: 104px;
  resize: vertical;
}

.field__control:focus,
.file-input:focus,
.emoji-picker__search:focus,
.rt-editor__area:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(11, 61, 46, 0.12);
  outline: none;
}

.field__control[readonly],
.field__control[disabled],
.file-input[readonly],
.file-input[disabled],
.emoji-picker__search[readonly],
.emoji-picker__search[disabled],
.rt-editor__area[readonly],
.rt-editor__area[disabled] {
  background-color: var(--surface);
  border-color: var(--border);
  box-shadow: none;
  color: var(--text);
  cursor: not-allowed;
  opacity: 1;
}

.field__control[readonly],
.file-input[readonly],
.emoji-picker__search[readonly],
.rt-editor__area[readonly] {
  pointer-events: none;
}

.field__control[disabled],
.file-input[disabled],
.emoji-picker__search[disabled],
.rt-editor__area[disabled] {
  -webkit-text-fill-color: var(--text);
}

.field__control[readonly]:focus,
.field__control[disabled]:focus,
.file-input[readonly]:focus,
.file-input[disabled]:focus,
.emoji-picker__search[readonly]:focus,
.emoji-picker__search[disabled]:focus,
.rt-editor__area[readonly]:focus,
.rt-editor__area[disabled]:focus {
  border-color: var(--border);
  box-shadow: none;
}

select.field__control[disabled],
select.file-input[disabled] {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%),
    linear-gradient(var(--border), var(--border));
}

.field__control--invalid,
.file-input.field__control--invalid,
.emoji-picker__search.field__control--invalid,
.rt-editor__area.field__control--invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(158, 42, 43, 0.13);
}

.field__control--valid,
.file-input.field__control--valid,
.emoji-picker__search.field__control--valid,
.rt-editor__area.field__control--valid {
  border-color: #1f7a5c;
  box-shadow: 0 0 0 3px rgba(31, 122, 92, 0.14);
}

input.field__control--valid:not([type="file"]),
textarea.field__control--valid {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231f7a5c' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-repeat: no-repeat;
  background-size: 14px 14px;
  padding-right: 34px;
}

input.field__control:-webkit-autofill,
input.field__control:-webkit-autofill:hover,
input.field__control:-webkit-autofill:focus,
textarea.field__control:-webkit-autofill,
select.field__control:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  box-shadow: 0 0 0 1000px #fff inset;
  transition: background-color 9999s ease-out 0s;
}

.field__hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin: 0;
  min-height: 16px;
}

.field__hint--danger {
  color: var(--danger, #c0392b);
}

.field__hint--success {
  color: var(--success, #2e7d32);
}

.password-checklist {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.password-checklist[hidden] {
  display: none;
}

.password-checklist__item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.password-checklist__item::before {
  content: "\2716";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--color-danger, #c62828);
}

.password-checklist__item.is-valid {
  color: var(--color-success, #2e7d32);
}

.password-checklist__item.is-valid::before {
  content: "\2714";
  color: var(--color-success, #2e7d32);
}

.field__control--readonly {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  display: flex;
  min-height: 36px;
  overflow-wrap: anywhere;
  padding: 7px 9px;
  word-break: break-word;
}

.file-drop {
  background:
    repeating-linear-gradient(135deg, rgba(11, 61, 46, 0.04) 0 10px, transparent 10px 20px),
    var(--surface-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px;
}

input[type="file"].field__control,
.file-input {
  color: var(--text-soft);
  min-height: 38px;
  padding: 6px;
}

input[type="file"].field__control::file-selector-button,
.file-input::file-selector-button {
  background: rgba(11, 61, 46, 0.08);
  border: 1px solid rgba(11, 61, 46, 0.2);
  border-radius: var(--radius-xs);
  color: var(--brand);
  font-weight: 700;
  margin-bottom: 4px;
  margin-right: 10px;
  padding: 6px 10px;
}

input[type="file"].field__control:hover::file-selector-button,
.file-input:hover::file-selector-button {
  background: rgba(11, 61, 46, 0.13);
  border-color: rgba(11, 61, 46, 0.32);
  color: var(--brand-strong);
}

.file-input--inline {
  max-width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  width: min(100%, 360px);
}

.file-input--inline::file-selector-button {
  min-width: 120px;
}

.check-list {
  display: grid;
  gap: 9px;
}

.check-row {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-soft);
  display: flex;
  font-size: 13px;
  font-weight: 600;
  gap: 10px;
  justify-content: space-between;
  padding: 9px 10px;
}

.check-row input,
.inline-check input {
  -moz-appearance: none;
  -webkit-appearance: none;
  appearance: none;
  accent-color: var(--brand);
  align-items: center;
  background: #fff;
  border: 1px solid var(--border-strong);
  box-sizing: border-box;
  color: var(--brand);
  display: inline-grid;
  flex: 0 0 auto;
  height: 16px;
  justify-content: center;
  margin: 0;
  place-content: center;
  width: 16px;
}

.check-row input[type="checkbox"],
.inline-check input[type="checkbox"] {
  border-radius: 4px;
}

.check-row input[type="radio"],
.inline-check input[type="radio"] {
  border-radius: 999px;
}

.check-row input::before,
.inline-check input::before {
  content: "";
  transform: scale(0);
  transition: transform 120ms ease;
}

.check-row input[type="checkbox"]::before,
.inline-check input[type="checkbox"]::before {
  border-bottom: 2px solid #fff;
  border-right: 2px solid #fff;
  height: 9px;
  transform: rotate(45deg) scale(0);
  width: 5px;
}

.check-row input[type="radio"]::before,
.inline-check input[type="radio"]::before {
  background: #fff;
  border-radius: 999px;
  height: 6px;
  width: 6px;
}

.check-row input:checked,
.inline-check input:checked {
  background: var(--brand);
  border-color: var(--brand);
}

.check-row input[type="checkbox"]:checked::before,
.inline-check input[type="checkbox"]:checked::before {
  transform: rotate(45deg) scale(1);
}

.check-row input[type="radio"]:checked::before,
.inline-check input[type="radio"]:checked::before {
  transform: scale(1);
}

.check-row input:focus-visible,
.inline-check input:focus-visible {
  box-shadow: 0 0 0 3px rgba(11, 61, 46, 0.15);
  outline: none;
}

.check-row input:disabled,
.inline-check input:disabled {
  background: var(--surface);
  border-color: var(--border);
  cursor: not-allowed;
  opacity: 1;
}

.inline-check {
  align-items: center;
  color: var(--text-soft);
  display: inline-flex;
  font-size: 13px;
  font-weight: 600;
  gap: 8px;
}

.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.actions--end {
  align-items: center;
  justify-content: flex-end;
}

.action-toolbar {
  align-items: center;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
  padding: 8px 10px;
}

.action-toolbar--producer {
  justify-content: flex-start;
}

.action-toolbar--plain {
  background: transparent;
  border: 0;
  border-radius: 0;
  margin-top: 0;
  padding: 0 0 14px;
}

.inline-form-inline {
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 100%;
  width: 100%;
}

.inline-form-inline > .btn,
.inline-form-inline > a.btn {
  flex: 0 0 auto;
}

.required-marker {
  color: var(--danger);
  display: inline-block;
  font-weight: 700;
  line-height: 1;
  margin-left: 3px;
}

.required-legend {
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}

.doc-actions-stack {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.doc-actions-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.doc-actions-upload {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.doc-actions-upload[hidden] {
  display: none;
}

.doc-actions-upload .file-input--inline {
  max-width: 250px;
}

.doc-upload-form--inline {
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 10px;
}

.doc-upload-form__row {
  display: grid;
  gap: 8px;
}

.doc-upload-form__row--two {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.doc-upload-form__actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.rt-editor {
  display: grid;
  gap: 8px;
  position: relative;
}

.rt-editor__toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.emoji-picker {
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.16);
  display: grid;
  gap: 8px;
  left: 0;
  max-width: min(100%, 520px);
  padding: 10px;
  position: absolute;
  top: calc(100% + 6px);
  width: 100%;
  z-index: 12;
}

.emoji-picker__header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.emoji-picker__title {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.emoji-picker__hint {
  color: var(--muted);
  font-size: 12px;
}

.emoji-picker__search {
  min-height: 38px;
}

.emoji-picker__grid {
  display: grid;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}

.emoji-picker__item {
  align-items: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  cursor: pointer;
  display: grid;
  gap: 10px;
  grid-template-columns: 28px minmax(0, 1fr);
  padding: 8px 10px;
  text-align: left;
  width: 100%;
}

.emoji-picker__item:hover,
.emoji-picker__item.is-active {
  background: var(--surface-muted);
  border-color: var(--brand);
}

.emoji-picker__symbol {
  font-size: 16px;
  line-height: 1;
}

.emoji-picker__meta {
  display: grid;
  gap: 2px;
}

.emoji-picker__name {
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.emoji-picker__code {
  color: var(--muted);
  font-size: 12px;
}

.emoji-picker__empty {
  color: var(--muted);
  font-size: 13px;
  padding: 8px 4px;
}

/* ── Barra de ação de seção ─────────────────────────────────────────────── */

.section-actions-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-actions-bar__title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

/* ── Comunicado: tabela ─────────────────────────────────────────────────── */

.comunicado-actions-cell {
  min-width: 180px;
  vertical-align: top;
}

.table-actions-inline--comunicado {
  justify-content: flex-end;
  width: 100%;
}

.comunicado-preview-cell {
  max-width: 320px;
}

/* ── Modal largo para comunicados ───────────────────────────────────────── */

.modal__dialog--comunicado {
  max-width: 860px;
}

/* ── Rich text editor ───────────────────────────────────────────────────── */

.rt-editor {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: visible;
}

.rt-editor__area {
  border: none !important;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm) !important;
  min-height: 180px;
  outline: none !important;
  resize: vertical;
}

.rt-toolbar {
  align-items: center;
  background: var(--surface-raised, #f6f8fa);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 5px 8px;
}

.rt-toolbar__group {
  align-items: center;
  display: flex;
  gap: 1px;
}

.rt-toolbar__sep {
  background: var(--border);
  display: inline-block;
  height: 18px;
  margin: 0 4px;
  width: 1px;
}

.rt-btn {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-soft, #555);
  cursor: pointer;
  display: inline-flex;
  font-size: 12px;
  font-weight: 600;
  gap: 3px;
  height: 27px;
  justify-content: center;
  line-height: 1;
  min-width: 27px;
  padding: 0 6px;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
  white-space: nowrap;
}

.rt-btn:hover {
  background: rgba(0, 0, 0, 0.07);
  border-color: var(--border);
  color: var(--text);
}

.rt-btn:active {
  background: rgba(0, 0, 0, 0.12);
}

.rt-btn--bold {
  font-weight: 900;
}

.rt-btn--italic {
  font-style: italic;
}

.rt-btn--strike {
  text-decoration: line-through;
}

.rt-btn--underline {
  text-decoration: underline;
}

.rt-btn--code {
  font-family: monospace;
  font-size: 11px;
}

.rt-btn--color {
  border-bottom: 3px solid #E65100;
  font-weight: 900;
}

.rt-btn--mark {
  background: rgba(255, 241, 118, 0.55);
  font-weight: 700;
}

.rt-btn--emoji {
  font-size: 14px;
}

/* ── Picker de cor / emoji ──────────────────────────────────────────────── */

.rt-picker-wrap {
  position: relative;
}

.rt-palette {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(4, 1fr);
  left: 0;
  padding: 8px;
  position: absolute;
  top: calc(100% + 4px);
  width: 116px;
  z-index: 50;
}

.rt-palette.is-hidden {
  display: none;
}

.rt-swatch {
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 3px;
  cursor: pointer;
  height: 22px;
  transition: transform 0.1s, box-shadow 0.1s;
  width: 22px;
}

.rt-swatch:hover {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
  transform: scale(1.2);
}

.rt-emoji-grid {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.14);
  display: grid;
  gap: 2px;
  grid-template-columns: repeat(5, 1fr);
  left: 0;
  max-height: 180px;
  overflow-y: auto;
  padding: 6px;
  position: absolute;
  top: calc(100% + 4px);
  width: 180px;
  z-index: 50;
}

.rt-emoji-grid.is-hidden {
  display: none;
}

.rt-emoji-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 4px;
  text-align: center;
  transition: background 0.1s;
}

.rt-emoji-btn:hover {
  background: var(--surface-muted, #f0f0f0);
  border-color: var(--border);
}
