/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

:root {
  --teal: #008069;
  --teal-dark: #00695a;
  --teal-deep: #005c4b;
  --ink: #111b21;
  --ink-soft: #54656f;
  --line: #d1d7db;
  --chat-bg: #efeae2;
  --bubble: #d9fdd3;
  --check-blue: #53bdeb;
  --field-height: 48px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #fff;
  line-height: 1.5;
}

.page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 30rem);
  min-height: 100vh;
}

/* ---------- Coluna do formulário ---------- */

.form-pane {
  padding: clamp(26px, 5vw, 60px);
  max-width: 36rem;
  justify-self: end;
  width: 100%;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 30px;
  color: var(--teal);
  font-weight: 800;
}

.brand svg {
  width: 26px;
  height: 26px;
  flex: none;
}

.form-pane h1 {
  margin: 0 0 6px;
  font-size: clamp(1.4rem, 3.5vw, 1.9rem);
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.lead {
  margin: 0 0 26px;
  color: var(--ink-soft);
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

/* Seletor de país e telefone na mesma altura */
.field input,
.field select {
  height: var(--field-height);
}

.field select {
  cursor: pointer;
}

.field textarea {
  padding: 11px 13px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
}

.field-row {
  display: flex;
  gap: 12px;
}

.field--ddi {
  flex: 0 0 8.2rem;
}

.field--phone {
  flex: 1;
  min-width: 0;
}

.hint {
  margin: -6px 2px 16px;
  font-size: 0.82rem;
  color: #a05e1b;
}

/* ---------- Resultado ---------- */

.result {
  margin-top: 22px;
  background: #f0f7f4;
  border: 1px solid #cfe6dc;
  border-radius: 14px;
  padding: 16px;
}

.result__label {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--teal);
  margin: 0 0 8px;
}

.result__link {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.88rem;
  word-break: break-all;
  margin-bottom: 12px;
  color: #0b3d2e;
}

.result__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  font: inherit;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  border-radius: 10px;
  padding: 11px 18px;
  cursor: pointer;
  flex: 1 1 11rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn:focus-visible {
  outline: 2px solid var(--teal-deep);
  outline-offset: 2px;
}

.btn--open {
  background: var(--teal);
  border: 1px solid var(--teal);
  color: #fff;
}

.btn--open:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.btn--copy {
  background: #fff;
  border: 1px solid var(--teal);
  color: var(--teal);
}

.btn--copy:hover {
  background: #eef7f4;
}

.btn--copy.copied {
  background: var(--teal-deep);
  border-color: var(--teal-deep);
  color: #fff;
  animation: pop 0.3s ease;
}

/* ---------- Check animado + toast de cópia ---------- */

.copy-done {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.copied .copy-label {
  display: none;
}

.copied .copy-done {
  display: inline-flex;
}

.check {
  width: 1.05em;
  height: 1.05em;
  flex: none;
}

.check__stroke {
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 26;
  stroke-dashoffset: 26;
}

.check__stroke--drawn {
  stroke-dashoffset: 0;
}

.copied .check__stroke {
  animation: check-draw 0.35s ease-out forwards;
}

@keyframes check-draw {
  to { stroke-dashoffset: 0; }
}

@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 10px);
  background: var(--ink);
  border: 1px solid #00a884;
  color: #e9edef;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 9px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 60;
}

.toast--on {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast .check {
  color: #00d9a5;
}

/* ---------- Coluna do preview (celular) ---------- */

.stage {
  background: var(--chat-bg);
  background-image: radial-gradient(rgba(103, 86, 56, 0.14) 1px, transparent 1.3px);
  background-size: 20px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(24px, 4vw, 48px);
}

.phone {
  /* Sobe o celular em relação ao centro para alinhá-lo com o título do formulário */
  margin-bottom: clamp(32px, 12vh, 120px);
  width: min(21rem, 100%);
  background: var(--chat-bg);
  border-radius: 30px;
  border: 10px solid #1c272e;
  box-shadow: 0 24px 60px rgba(17, 27, 33, 0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 30rem;
}

.chat-head {
  background: var(--teal);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #cfe9e2;
  color: var(--teal);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.avatar svg {
  width: 22px;
  height: 22px;
}

.who {
  min-width: 0;
}

.chat-name {
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-status {
  font-size: 0.75rem;
  opacity: 0.85;
}

.chat {
  flex: 1;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.day-chip {
  align-self: center;
  background: #fff;
  color: var(--ink-soft);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 8px;
  box-shadow: 0 1px 1px rgba(17, 27, 33, 0.1);
}

.chat-note {
  align-self: center;
  text-align: center;
  background: #fdf6de;
  color: #6e5f2e;
  font-size: 0.76rem;
  padding: 6px 12px;
  border-radius: 8px;
  max-width: 15rem;
  box-shadow: 0 1px 1px rgba(17, 27, 33, 0.1);
}

.bubble {
  align-self: flex-end;
  background: var(--bubble);
  border-radius: 10px 0 10px 10px;
  padding: 7px 9px 6px;
  max-width: 85%;
  font-size: 0.88rem;
  box-shadow: 0 1px 1px rgba(17, 27, 33, 0.12);
  word-break: break-word;
  animation: bubble-pop 0.25s ease;
}

@keyframes bubble-pop {
  from { opacity: 0; transform: translateY(5px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.bubble__meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  color: #667781;
  margin-top: 2px;
}

.bubble__meta svg {
  width: 15px;
  height: 15px;
  color: var(--check-blue);
}

/* ---------- Botão de exibir preview (só em telas pequenas) ---------- */

.preview-toggle {
  display: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  margin-top: 18px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--teal);
  color: var(--teal);
  background: #fff;
  cursor: pointer;
}

.preview-toggle:hover {
  background: #eef7f4;
}

.preview-toggle:focus-visible {
  outline: 2px solid var(--teal-deep);
  outline-offset: 2px;
}

.preview-toggle .eye {
  width: 18px;
  height: 18px;
  flex: none;
}

/* Olho aberto quando fechado; olho cortado quando o preview está visível */
.preview-toggle .eye--hide,
.preview-toggle[aria-expanded="true"] .eye--show {
  display: none;
}

.preview-toggle[aria-expanded="true"] .eye--hide {
  display: block;
}

/* ---------- Rodapé ---------- */

.page-footer {
  margin-top: 24px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.page-footer a {
  color: var(--teal);
}

/* ---------- Responsivo ---------- */

/* Em 1280px a coluna do preview equivale a 30rem (37.5%); acima disso ela passa a
   crescer junto com a tela, mantendo a proporção entre formulário e preview. */
@media (min-width: 1280px) {
  .page {
    grid-template-columns: minmax(0, 1fr) minmax(0, 37.5%);
  }

  .phone {
    width: min(24rem, 90%);
  }
}

@media (max-width: 900px) {
  .page {
    grid-template-columns: 1fr;
  }

  .form-pane {
    justify-self: stretch;
    margin: 0 auto;
  }

  /* Preview começa oculto; o botão "Exibir preview da conversa" alterna */
  .stage {
    display: none;
  }

  .stage.stage--open {
    display: flex;
  }

  .preview-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
  }

  .phone {
    min-height: 24rem;
    margin-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }

  .check__stroke {
    stroke-dashoffset: 0;
  }
}
