:root {
  --rose-50: #fff7fa;
  --rose-100: #f8d7e3;
  --rose-200: #efb9cb;
  --rose-300: #d995a6;
  --gold: #d8a63c;
  --gold-light: #f2c65f;
  --gold-dark: #a87824;
  --ivory: #fffaf7;
  --card: rgba(255, 250, 249, 0.92);
  --ink: #52444d;
  --muted: #8c7880;
  --line: rgba(183, 116, 133, 0.22);
  --shadow: 0 24px 70px rgba(121, 59, 78, 0.18);
  --danger-bg: rgba(254, 226, 226, 0.94);
  --danger-text: #9f3a46;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f7d9dd;
}

body.modal-open { overflow: hidden; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.72; }
.hidden { display: none !important; }

.app-shell {
  min-height: 100vh;
  width: 100%;
}

.visual-stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  isolation: isolate;
  background-image: url("background.jpeg");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
}

.visual-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(255, 242, 244, 0.04), rgba(255, 223, 229, 0.18));
}

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: clamp(20px, 5vw, 72px);
}

.login-card {
  width: min(470px, 100%);
  margin-right: clamp(18px, 7vw, 120px);
  padding: clamp(30px, 4vw, 50px) clamp(26px, 4vw, 42px);
  border-radius: 34px 8px 34px 8px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  background: var(--card);
  box-shadow: 0 26px 70px rgba(132, 71, 88, 0.16);
  backdrop-filter: blur(10px);
}

.login-icon {
  position: relative;
  width: 82px;
  height: 60px;
  margin: 0 auto 16px;
}

.bubble-one, .bubble-two {
  position: absolute;
  border: 4px solid #dfa0a8;
  background: rgba(255, 249, 249, 0.72);
}

.bubble-one {
  left: 4px;
  top: 0;
  display: grid;
  width: 58px;
  height: 43px;
  place-items: center;
  border-radius: 50%;
  color: #dfa0a8;
  font-weight: 900;
  letter-spacing: 3px;
}

.bubble-one::after {
  content: "";
  position: absolute;
  left: 8px;
  bottom: -9px;
  width: 16px;
  height: 16px;
  border-left: 4px solid #dfa0a8;
  border-bottom: 4px solid #dfa0a8;
  background: rgba(255, 249, 249, 0.72);
  transform: rotate(-18deg);
}

.bubble-two {
  right: 3px;
  bottom: 5px;
  width: 43px;
  height: 34px;
  border-radius: 50%;
  opacity: 0.85;
}

.welcome {
  margin: 0 0 8px;
  text-align: center;
  color: #c9838e;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: clamp(1rem, 2vw, 1.22rem);
}

h1 {
  margin: 0;
  font-family: "Playfair Display", Georgia, serif;
  color: var(--gold-dark);
  font-size: clamp(2.25rem, 4vw, 3.15rem);
  line-height: 1.08;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  text-wrap: balance;
}

.heart-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  margin: 20px auto 22px;
  color: #cf8b95;
}

.heart-divider span {
  width: 58px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(207, 139, 149, 0.55));
}

.heart-divider span:last-child {
  background: linear-gradient(90deg, rgba(207, 139, 149, 0.55), transparent);
}

.heart-divider b { font-size: 1.2rem; }

.intro-text {
  max-width: 390px;
  margin: 0 auto 30px;
  color: #777077;
  font-size: clamp(1.02rem, 1.5vw, 1.18rem);
  line-height: 1.7;
  text-align: center;
}

.intro-text strong { color: #c77d87; font-weight: 800; }

form { margin: 0; }
.field-group { display: grid; gap: 10px; margin-bottom: 24px; }
.field-group label { color: #c77d87; font-size: 1.02rem; font-weight: 700; }

.input-wrap { position: relative; }
.mail-icon {
  position: absolute;
  left: 20px;
  top: 50%;
  transform: translateY(-50%);
  color: #c88f98;
  font-size: 1.35rem;
  opacity: 0.9;
}

.input-field {
  width: 100%;
  min-height: 64px;
  border: 1px solid rgba(207, 139, 149, 0.36);
  border-radius: 18px;
  padding: 0 18px 0 70px;
  background: rgba(255, 250, 250, 0.76);
  color: var(--ink);
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}
.input-field::placeholder { color: rgba(117, 102, 109, 0.56); }
.input-field:focus { border-color: rgba(216, 166, 60, 0.7); box-shadow: 0 0 0 4px rgba(216, 166, 60, 0.12); }

.terms-check {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 6px 0 28px;
  color: #6f666d;
  font-size: 1rem;
  line-height: 1.55;
}
.terms-check input {
  appearance: none;
  width: 32px;
  height: 32px;
  margin: 0;
  flex: 0 0 auto;
  border: 2px solid rgba(207, 139, 149, 0.64);
  border-radius: 7px;
  background: rgba(255, 250, 250, 0.65);
}
.terms-check input:checked {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-color: var(--gold);
}
.terms-check input:checked::after {
  content: "✓";
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: white;
  font-weight: 900;
}
.terms-link { border: none; background: none; color: #bd7680; font-weight: 800; padding: 0; text-align: left; }

.login-button, .secondary-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 58px;
  padding: 0 24px;
  border-radius: 18px;
  font-weight: 800;
}
.login-button {
  width: 100%;
  border: none;
  background: linear-gradient(180deg, #e7b854, #d69c30);
  color: #fff;
  font-size: 1.16rem;
  box-shadow: 0 16px 34px rgba(174, 116, 39, 0.22);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.login-button.compact { width: auto; }
.login-button:hover { transform: translateY(-1px); box-shadow: 0 20px 42px rgba(174, 116, 39, 0.28); }
.secondary-button { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.login-error { margin: 0 0 16px; padding: 12px 14px; border-radius: 16px; background: var(--danger-bg); border: 1px solid #f5c2c7; color: var(--danger-text); }


.visual-stage.chat-mode {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background-image: url("chat-background.jpeg");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center center;
}

.visual-stage.chat-mode::after {
  background: radial-gradient(circle at center, rgba(255, 250, 250, 0.28), rgba(255, 207, 216, 0.14));
}

.chat-interface {
  width: min(860px, calc(100% - 42px));
  height: calc(100svh - 44px);
  max-height: 920px;
  margin: 22px auto;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  overflow: hidden;
  border-radius: 34px;
  border: 1px solid rgba(255,255,255,.82);
  background: rgba(255, 250, 249, .72);
  box-shadow: 0 28px 85px rgba(121, 59, 78, 0.18);
  backdrop-filter: blur(18px);
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid rgba(216, 166, 60, 0.22);
  background: rgba(255, 250, 249, 0.58);
}
.bot-identity { display: flex; align-items: center; min-width: 0; gap: 14px; }
.bot-avatar { display: grid; flex: 0 0 auto; width: 52px; height: 52px; place-items: center; border-radius: 18px; background: linear-gradient(135deg, var(--rose-100), #fff8fb); color: var(--gold-dark); font-family: "Playfair Display", Georgia, serif; font-weight: 800; box-shadow: inset 0 0 0 1px rgba(212, 175, 55, 0.28); }
.bot-identity p {
  margin: 0 0 4px;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(1.75rem, 3vw, 2.65rem);
  line-height: 1.04;
  font-weight: 800;
  color: var(--gold-dark);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.bot-identity span { color: var(--muted); font-size: 0.9rem; }
.header-actions { display: flex; gap: 10px; align-items: center; }
.schedule-button, .logout-button, .quick-prompts button, .composer button { border: 1px solid rgba(212, 175, 55, 0.42); background: rgba(255, 255, 255, 0.78); color: var(--ink); transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease, background 160ms ease; }
.schedule-button, .logout-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 16px; border-radius: 999px; font-size: 0.9rem; font-weight: 800; white-space: nowrap; }
.logout-button { border-color: rgba(45, 39, 48, 0.12); }
.schedule-button:hover, .logout-button:hover, .quick-prompts button:hover, .composer button:hover { transform: translateY(-1px); border-color: rgba(212, 175, 55, 0.72); background: white; box-shadow: 0 12px 28px rgba(103, 72, 83, 0.12); }
.quick-prompts { display: flex; gap: 10px; overflow-x: auto; padding: 14px 28px; border-bottom: 1px solid rgba(216, 166, 60, 0.18); background: rgba(255, 250, 249, 0.42); scrollbar-width: none; }
.quick-prompts::-webkit-scrollbar { display: none; }
.quick-prompts button { flex: 0 0 auto; min-height: 36px; padding: 0 14px; border-radius: 999px; color: var(--gold-dark); font-size: 0.86rem; font-weight: 800; }
.messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
  min-height: 0;
  padding: 26px 28px;
  scroll-behavior: smooth;
}
.message { display: flex; animation: riseIn 220ms ease both; }
.message.user { justify-content: flex-end; }
.bubble { max-width: min(78%, 640px); padding: 14px 16px; border: 1px solid var(--line); border-radius: 20px; background: white; color: var(--ink); line-height: 1.6; box-shadow: 0 12px 30px rgba(72, 48, 60, 0.08); white-space: pre-wrap; }
.message.user .bubble { border-color: rgba(212, 175, 55, 0.34); background: linear-gradient(135deg, #2d2730, #4d3f48); color: white; }
.message.bot .bubble { background: linear-gradient(135deg, white, var(--rose-50)); }
.message.system .bubble { max-width: 100%; border-color: rgba(139, 154, 134, 0.24); background: rgba(139, 154, 134, 0.1); color: #53604f; font-size: 0.92rem; }
.typing .bubble { color: var(--muted); }
.composer {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 52px;
  gap: 12px;
  padding: 18px 28px 24px;
  border-top: 1px solid rgba(216, 166, 60, 0.22);
  background: rgba(255, 250, 249, 0.88);
  backdrop-filter: blur(12px);
}
.composer input { width: 100%; min-height: 52px; border: 1px solid rgba(45, 39, 48, 0.12); border-radius: 999px; outline: none; padding: 0 20px; background: white; color: var(--ink); transition: border-color 160ms ease, box-shadow 160ms ease; }
.composer input:focus { border-color: rgba(212, 175, 55, 0.62); box-shadow: 0 0 0 4px rgba(248, 215, 227, 0.55); }
.composer button { display: grid; min-width: 52px; min-height: 52px; place-items: center; border-radius: 50%; background: linear-gradient(135deg, var(--gold), #f1d779); color: var(--ink); font-weight: 900; }

.terms-modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 20; padding: 22px; background: rgba(45, 39, 48, 0.42); backdrop-filter: blur(10px); }
.terms-card { width: min(720px, 100%); max-height: min(82vh, 760px); overflow: hidden; display: grid; grid-template-rows: auto 1fr auto; border-radius: 28px; background: rgba(255, 253, 248, 0.98); box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,.82); }
.terms-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding: 26px 26px 14px; border-bottom: 1px solid var(--line); }
.terms-header h2 { margin: 0; font-size: 1.5rem; }
.modal-close { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: white; color: var(--ink); font-size: 1.4rem; }
.terms-body { overflow: auto; padding: 20px 26px; color: var(--muted); line-height: 1.72; }
.terms-body p { margin: 0 0 14px; }
.terms-actions { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 26px 24px; border-top: 1px solid var(--line); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
@keyframes riseIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

@media (max-width: 980px) {
  .visual-stage { background-position: 38% center; }
  .login-screen { justify-content: center; align-items: flex-end; padding: 26px 18px; }
  .login-card { margin: 0; width: min(510px, 100%); }
}

@media (max-width: 620px) {
  .visual-stage {
    background-size: auto 100%;
    background-position: 34% center;
  }
  .visual-stage::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: rgba(255, 229, 234, 0.34);
  }
  .login-screen { align-items: flex-end; min-height: 100svh; padding: 16px 12px; }
  .login-card { border-radius: 28px 8px 28px 8px; padding: 24px 20px; }
  .login-icon { transform: scale(.82); margin-bottom: 4px; }
  h1 { font-size: clamp(1.95rem, 9vw, 2.55rem); }
  .welcome { font-size: .95rem; }
  .intro-text { font-size: .96rem; margin-bottom: 22px; }
  .input-field { min-height: 58px; }
  .terms-check { font-size: .9rem; gap: 12px; margin-bottom: 22px; }
  .terms-check input { width: 28px; height: 28px; }
  .login-button { min-height: 56px; }
  .chat-interface { width: calc(100% - 20px); height: calc(100svh - 20px); margin: 10px auto; border-radius: 22px; }
  .chat-header { align-items: stretch; flex-direction: column; padding: 18px; }
  .header-actions { width: 100%; }
  .schedule-button, .logout-button { flex: 1; padding: 0 12px; }
  .quick-prompts { padding: 12px 16px; }
  .messages { padding: 18px; }
  .bubble { max-width: 92%; }
  .composer { grid-template-columns: 1fr 46px; padding: 14px; }
  .bot-identity p { font-size: clamp(1.35rem, 8vw, 1.85rem); }
  .terms-actions { flex-direction: column-reverse; }
  .terms-actions .login-button, .terms-actions .secondary-button { width: 100%; }
}

/* =========================================================
   Ajustes responsivos finais - apenas visual
   Mantém JS, IDs, forms, rotas e integração intactos.
   ========================================================= */

html {
  min-height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  overflow-x: hidden;
}

.visual-stage {
  min-height: 100svh;
  background-size: cover;
  background-position: center center;
}

.login-screen {
  min-height: 100svh;
  width: 100%;
}

.login-card {
  max-height: calc(100svh - 32px);
  overflow-y: auto;
  scrollbar-width: thin;
}

.input-field,
.login-button,
.secondary-button,
.composer input,
.composer button {
  touch-action: manipulation;
}

@media (min-width: 1440px) {
  .login-screen {
    padding-right: clamp(72px, 10vw, 180px);
  }

  .login-card {
    width: min(500px, 100%);
    margin-right: clamp(40px, 6vw, 130px);
  }
}

@media (max-width: 1180px) {
  .visual-stage {
    background-position: 32% center;
  }

  .login-screen {
    justify-content: flex-end;
    padding: clamp(18px, 4vw, 48px);
  }

  .login-card {
    margin-right: clamp(0px, 3vw, 60px);
  }
}

@media (max-width: 980px) {
  .visual-stage {
    background-position: 28% center;
  }

  .login-screen {
    justify-content: center;
    align-items: flex-end;
    padding: 24px 18px;
  }

  .login-card {
    width: min(520px, 100%);
    margin: 0;
  }
}

@media (max-width: 760px) {
  .visual-stage {
    background-size: auto 100%;
    background-position: 30% center;
  }

  .visual-stage::after {
    background: linear-gradient(180deg, rgba(255, 236, 240, 0.08), rgba(255, 224, 230, 0.38));
  }

  .login-screen {
    align-items: flex-end;
    padding: 16px 12px max(16px, env(safe-area-inset-bottom));
  }

  .login-card {
    width: 100%;
    max-height: calc(100svh - 24px);
    padding: clamp(20px, 5vw, 28px);
    border-radius: 26px 8px 26px 8px;
  }

  .login-icon {
    width: 70px;
    height: 52px;
    margin-bottom: 8px;
    transform: scale(.88);
  }

  h1 {
    font-size: clamp(1.82rem, 8vw, 2.45rem);
    line-height: 1.05;
  }

  .intro-text {
    max-width: 100%;
    margin-bottom: 20px;
    font-size: .95rem;
    line-height: 1.55;
  }

  .field-group {
    margin-bottom: 18px;
  }

  .input-field {
    min-height: 54px;
    padding-left: 56px;
    border-radius: 16px;
  }

  .mail-icon {
    left: 18px;
    font-size: 1.15rem;
  }

  .terms-check {
    gap: 10px;
    margin-bottom: 18px;
    font-size: .88rem;
    line-height: 1.45;
  }

  .terms-check input {
    width: 26px;
    height: 26px;
  }

  .login-button {
    min-height: 52px;
    font-size: 1rem;
  }
}

@media (max-width: 420px) {
  .visual-stage {
    background-position: 28% center;
  }

  .login-screen {
    padding: 10px 8px max(10px, env(safe-area-inset-bottom));
  }

  .login-card {
    max-height: calc(100svh - 16px);
    padding: 18px 16px;
    border-radius: 22px 8px 22px 8px;
  }

  .welcome {
    font-size: .82rem;
  }

  .heart-divider {
    margin: 14px auto 16px;
  }

  .heart-divider span {
    width: 42px;
  }

  .intro-text {
    font-size: .9rem;
    margin-bottom: 16px;
  }

  .field-group label {
    font-size: .92rem;
  }
}

@media (max-height: 720px) and (max-width: 760px) {
  .login-card {
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .login-icon,
  .heart-divider,
  .intro-text {
    margin-bottom: 12px;
  }

  .terms-check {
    margin-bottom: 14px;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .login-screen {
    align-items: center;
    justify-content: flex-end;
    padding: 10px 18px;
  }

  .login-card {
    width: min(430px, 54vw);
    max-height: calc(100svh - 20px);
    padding: 18px;
  }

  .login-icon,
  .heart-divider {
    display: none;
  }

  h1 {
    font-size: clamp(1.5rem, 4vw, 2rem);
  }

  .intro-text {
    margin-bottom: 12px;
    font-size: .84rem;
  }

  .input-field,
  .login-button {
    min-height: 44px;
  }
}
