/*
 * REFLEXO — fechamento rastreável de requisitos (27/07/2026)
 * Fonte: RESGATE_LITERAL_REFLEXO_25_A_27_JUL_2026.md + Instrução 10 integral.
 */

/* Período: um único acionador, seguindo o padrão compacto do Dashboard. */
.rf-period-picker {
  position: relative;
  width: max-content;
  max-width: 100%;
  margin: 0 0 14px;
}

.rf-period-picker > summary {
  list-style: none;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
  user-select: none;
}

.rf-period-picker > summary::-webkit-details-marker { display: none; }
.rf-period-picker > summary::after { content: "⌄"; color: var(--muted); }
.rf-period-picker[open] > summary {
  border-color: var(--line2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 15%, transparent);
}

.rf-period-menu {
  position: absolute;
  z-index: 140;
  top: calc(100% + 7px);
  left: 0;
  width: 210px;
  max-width: calc(100vw - 28px);
  display: grid;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 20px 52px rgba(0, 0, 0, .3);
}

.rf-period-menu button {
  min-height: 39px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 700;
  cursor: pointer;
}

.rf-period-menu button:hover,
.rf-period-menu button.active {
  border-color: var(--line2);
  background: var(--surface);
}

.rf-history-filters {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.rf-history-filters .rf-period-picker { margin: 0; }
.rf-history-filters label { width: min(250px, 100%); }
.rf-history-filters label select { min-height: 42px; }

/* Bottom sheet real para Agenda. */
.modal.rf-bottom-sheet {
  z-index: 230 !important;
  display: flex !important;
  align-items: flex-end !important;
  justify-content: center !important;
  padding: 0 !important;
  background: color-mix(in srgb, #000 50%, transparent) !important;
  backdrop-filter: blur(4px) !important;
}

.modal.rf-bottom-sheet .modalCard {
  position: relative;
  width: min(720px, 100vw) !important;
  max-height: min(88svh, 860px) !important;
  margin: 0 !important;
  padding: 18px 22px max(20px, env(safe-area-inset-bottom)) !important;
  overflow: auto !important;
  border-radius: 24px 24px 0 0 !important;
  border-bottom: 0 !important;
  background: var(--panel) !important;
  animation: rfSheetIn .28s cubic-bezier(.22, 1, .36, 1) both;
}

.modal.rf-bottom-sheet .modalCard::before {
  content: "";
  display: block;
  width: 44px;
  height: 4px;
  margin: -5px auto 14px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 58%, transparent);
}

@keyframes rfSheetIn {
  from { opacity: .4; transform: translateY(24px); }
  to { opacity: 1; transform: translateY(0); }
}

.rf-agenda-form { gap: 14px !important; }
.rf-context-label {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.rf-context-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.rf-context-chip {
  min-height: 54px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--green) 44%, var(--line));
  border-radius: 13px;
  background: color-mix(in srgb, var(--green) 8%, var(--panel));
}

.rf-context-chip::before {
  content: "✓";
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--green) 16%, var(--surface));
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.rf-context-chip small,
.rf-context-chip b { display: block; }
.rf-context-chip small { color: var(--muted); font-size: 10px; }
.rf-context-chip b { margin-top: 2px; color: var(--text); font-size: 13px; }

.rf-field-label {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
}

.rf-adaptive-time {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.rf-optional {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--surface) 48%, transparent);
  overflow: hidden;
}

.rf-optional > summary {
  min-height: 46px;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 13px;
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.rf-optional > summary::-webkit-details-marker { display: none; }
.rf-optional > summary::before { content: "+ "; color: var(--blue2); }
.rf-optional[open] > summary::before { content: "– "; }
.rf-optional > div { padding: 0 12px 12px; }
.rf-optional textarea { min-height: 78px; }
.rf-deposit-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.rf-deposit-fields > small { grid-column: 1 / -1; }
.rf-form-intro { margin: -5px 0 2px; }

/* Componente central de identificação do cliente. */
.rf-customer-selector {
  position: relative;
  display: grid;
  gap: 8px;
}

.rf-customer-search-wrap { position: relative; }
.rf-customer-search-wrap::before {
  content: "";
  position: absolute;
  z-index: 1;
  left: 14px;
  top: 50%;
  width: 13px;
  height: 13px;
  border: 1.8px solid var(--muted);
  border-radius: 50%;
  transform: translateY(-58%);
  pointer-events: none;
}

.rf-customer-search-wrap::after {
  content: "";
  position: absolute;
  z-index: 1;
  left: 26px;
  top: calc(50% + 5px);
  width: 6px;
  height: 1.8px;
  background: var(--muted);
  transform: rotate(45deg);
  pointer-events: none;
}

.rf-customer-query { padding-left: 40px !important; }

.rf-customer-status {
  min-height: 17px;
  color: var(--muted);
  font-size: 10px;
}

.rf-customer-results {
  display: grid;
  gap: 6px;
}

.rf-customer-result {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.rf-customer-result:hover,
.rf-customer-result:focus-visible {
  border-color: var(--line2);
  background: var(--surface);
  outline: none;
}

.rf-customer-result b,
.rf-customer-result small { display: block; }
.rf-customer-result small { margin-top: 3px; color: var(--muted); }
.rf-customer-result span:last-child { color: var(--blue2); font-size: 11px; font-weight: 800; }

.rf-customer-selected {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--green) 48%, var(--line));
  border-radius: 13px;
  background: color-mix(in srgb, var(--green) 8%, var(--panel));
}

.rf-customer-selected b,
.rf-customer-selected small { display: block; }
.rf-customer-selected small { margin-top: 3px; color: var(--muted); }
.rf-customer-selected button {
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.rf-customer-new {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 7px;
  padding: 10px;
  border: 1px dashed var(--line2);
  border-radius: 13px;
  background: color-mix(in srgb, var(--surface) 46%, transparent);
}

.rf-customer-new button { min-width: 94px; }

.rf-customer-error {
  color: var(--red);
  font-size: 10px;
  font-weight: 700;
}

/* Cadeira: nomes legíveis, sem ícones e listas escaláveis. */
body[data-reflexo-flow-state="collaborator"] .flow-node {
  width: clamp(126px, 19vw, 174px) !important;
  height: 48px !important;
  min-width: 126px !important;
  min-height: 48px !important;
  max-width: 174px !important;
  max-height: 48px !important;
  padding: 0 12px !important;
  border-radius: 13px !important;
}

body[data-reflexo-flow-state="collaborator"] .flow-node > span:last-child {
  max-width: 100% !important;
  min-width: 0;
}

body[data-reflexo-flow-state="collaborator"] .flow-node b {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px !important;
}

.flow-identity-list {
  display: grid;
  gap: 7px;
  max-height: min(54svh, 520px);
  overflow: auto;
}

.flow-list-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  padding: 3px 2px 8px;
}

.flow-list-heading b { font-size: 15px; }
.flow-list-heading small { color: var(--muted); font-size: 10px; }

.flow-identity-row {
  width: 100%;
  min-height: 62px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--panel2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.flow-identity-row:hover,
.flow-identity-row:focus-visible,
.flow-identity-row.selected {
  border-color: var(--line2);
  background: var(--surface);
  outline: none;
}

.flow-identity-row:active { transform: scale(.992); }
.flow-identity-row time {
  min-width: 48px;
  color: var(--blue2);
  font-size: 12px;
  font-weight: 850;
}

.flow-identity-row b,
.flow-identity-row small { display: block; }
.flow-identity-row b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}
.flow-identity-row small { margin-top: 3px; color: var(--muted); font-size: 10px; }
.flow-identity-row em {
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  font-weight: 700;
  white-space: nowrap;
}

/* Modais acionados dentro do fluxo da Cadeira ficam acima do overlay. */
.modal.rf-modal-over-flow { z-index: 240 !important; }

/* Fechamento: título centralizado e resumo alinhado, incluindo Nome/WhatsApp. */
.modal.flow-client-modal #modalTitle { text-align: center; }
.modal.flow-client-modal .v5-thanks { text-align: center; }
.modal.flow-client-modal .v5-final-summary {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.modal.flow-client-modal .v5-final-summary > p {
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.modal.flow-client-modal .v5-final-summary .formActions {
  justify-content: center;
  margin-top: 10px;
}

/* Métodos de pagamento nas Configurações. */
.rf-payment-methods { display: grid; gap: 8px; }
.rf-payment-method-list { display: flex; gap: 7px; flex-wrap: wrap; }
.rf-payment-method {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 7px 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  font-weight: 750;
}
.rf-payment-method button {
  width: 27px;
  height: 27px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.rf-payment-method-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.rf-payment-select {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.rf-payment-breakdown {
  margin: 13px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}

.rf-payment-breakdown > div:last-child {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.rf-payment-breakdown > div:last-child > span {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}

.rf-payment-breakdown b { color: var(--text); font-size: 11px; }
.rf-payment-breakdown strong { color: var(--green); font-size: 12px; white-space: nowrap; }

/* Performance e divulgação. */
.rf-metric-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.rf-metric-option {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
}

.rf-metric-option input { width: 17px; height: 17px; }
.rf-performance-note { margin: 8px 0 0; color: var(--muted); font-size: 10px; }

.rf-art-preview {
  position: fixed;
  z-index: 310;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, .84);
  backdrop-filter: blur(9px);
}

.rf-art-preview-card {
  width: min(420px, 100%);
  max-height: calc(100svh - 36px);
  display: grid;
  gap: 10px;
}

.rf-art-preview canvas {
  display: block;
  width: 100%;
  max-height: calc(100svh - 110px);
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 24px 72px rgba(0, 0, 0, .52);
}

.rf-art-preview-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.rf-product-upload {
  display: grid;
  grid-template-columns: 96px 1fr;
  align-items: center;
  gap: 12px;
}

.rf-product-preview {
  width: 96px;
  height: 96px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--line2);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.rf-product-preview img { width: 100%; height: 100%; object-fit: cover; }

/* Contraste explícito no tema claro para os elementos antes problemáticos. */
html[data-theme="arctic-drift"] #greeting,
html[data-theme="arctic-drift"] #sideName,
html[data-theme="arctic-drift"] .user b,
html[data-theme="arctic-drift"] .hello h2 {
  color: #2C3E50 !important;
  text-shadow: none !important;
}

html[data-theme="arctic-drift"] .modal,
html[data-theme="arctic-drift"] .rf-art-preview {
  color: var(--text);
}

@media (max-width: 700px) {
  .rf-customer-new { grid-template-columns: 1fr; }
  .rf-customer-new button { width: 100%; }
  .rf-context-grid,
  .rf-adaptive-time,
  .rf-metric-picker,
  .rf-deposit-fields { grid-template-columns: 1fr 1fr; }
  .flow-identity-row { grid-template-columns: auto minmax(0, 1fr); }
  .flow-identity-row em { grid-column: 2; white-space: normal; }
}

@media (max-width: 390px) {
  .modal.rf-bottom-sheet .modalCard { padding-inline: 14px !important; }
  .rf-context-grid,
  .rf-adaptive-time,
  .rf-metric-picker,
  .rf-deposit-fields { grid-template-columns: 1fr; }
  body[data-reflexo-flow-state="collaborator"] .flow-node {
    width: 116px !important;
    min-width: 116px !important;
    max-width: 116px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .modal.rf-bottom-sheet .modalCard { animation: none; }
}
