:root {
  --romero-primary: #213819;
  --romero-primary-dark: #172414;
  --romero-accent: #ae9551;
  --romero-ink: #1f2b1a;
  --romero-muted: #6d675a;
  --romero-line: #ddd1b8;
  --romero-bg: #fbf8f0;
  --romero-panel: #ffffff;
  --romero-danger: #b42318;
  --romero-success: #117a48;
  --shadow: 0 18px 50px rgba(31, 43, 26, 0.2);
}

* {
  box-sizing: border-box;
}

.chat-launcher-wrap {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1000;
}

.chat-launcher {
  position: relative;
  width: 78px;
  height: 78px;
  border: 0;
  border-radius: 50%;
  background: #f6efe1;
  color: white;
  box-shadow: 0 18px 48px rgba(31, 43, 26, 0.28);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-greeting {
  position: absolute;
  right: 88px;
  bottom: 18px;
  width: min(235px, calc(100vw - 132px));
  padding: 13px 16px;
  border: 1px solid rgba(174, 149, 81, 0.28);
  border-radius: 18px 18px 4px 18px;
  color: var(--romero-ink);
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 14px 36px rgba(31, 43, 26, 0.18);
  line-height: 1.25;
  animation: greetingFloat 5.2s ease-in-out infinite;
}

.chat-greeting::after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: 15px;
  width: 16px;
  height: 16px;
  border-right: 1px solid rgba(174, 149, 81, 0.28);
  border-bottom: 1px solid rgba(174, 149, 81, 0.28);
  background: rgba(255, 253, 248, 0.96);
  transform: rotate(-45deg);
}

.chat-greeting span,
.chat-greeting strong {
  display: block;
}

.chat-greeting span {
  color: var(--romero-muted);
  font-size: 13px;
  font-weight: 800;
}

.chat-greeting strong {
  margin-top: 3px;
  color: var(--romero-primary);
  font-size: 14px;
  font-weight: 950;
}

.chat-launcher:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 24px 58px rgba(31, 43, 26, 0.34);
}

.chat-launcher img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  transform-origin: 50% 100%;
  animation: chefHello 3.8s ease-in-out infinite;
  z-index: 2;
}

.chat-launcher-pulse {
  position: absolute;
  inset: -7px;
  border: 2px solid rgba(174, 149, 81, 0.42);
  border-radius: 50%;
  animation: chefPulse 2.8s ease-out infinite;
}

.chat-launcher-label {
  position: absolute;
  right: 58px;
  bottom: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  color: #fffdf8;
  background: var(--romero-primary);
  box-shadow: 0 12px 30px rgba(31, 43, 26, 0.2);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

@keyframes chefPulse {
  0% { opacity: 0.75; transform: scale(0.92); }
  70% { opacity: 0; transform: scale(1.22); }
  100% { opacity: 0; transform: scale(1.22); }
}

@keyframes chefHello {
  0%, 72%, 100% { transform: rotate(0deg); }
  78% { transform: rotate(-4deg); }
  84% { transform: rotate(4deg); }
  90% { transform: rotate(-2deg); }
}

@keyframes greetingFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.chat-widget {
  position: fixed;
  right: 22px;
  bottom: 98px;
  width: min(420px, calc(100vw - 32px));
  height: min(680px, calc(100vh - 128px));
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(174, 149, 81, 0.26);
  border-radius: 8px;
  background: var(--romero-panel);
  box-shadow: var(--shadow);
  z-index: 999;
}

.chat-widget.is-open {
  display: flex;
}

.chat-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  color: white;
  background: linear-gradient(135deg, var(--romero-primary), #2f4524);
  z-index: 2;
}

.chat-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chat-logo {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  object-fit: contain;
  border-radius: 50%;
  background: #f6efe1;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}

.chat-title {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
}

.chat-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.86;
}

.chat-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  color: white;
  font-size: 24px;
  cursor: pointer;
}

.chat-progress {
  flex: 0 0 auto;
  height: 4px;
  background: #f6efe1;
}

.chat-progress-bar {
  height: 100%;
  width: 0;
  background: var(--romero-accent);
  transition: width 0.2s ease;
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 16px;
  background: var(--romero-bg);
}

.message {
  width: fit-content;
  max-width: 92%;
  margin: 0 0 12px;
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message.bot {
  color: var(--romero-ink);
  background: white;
  border: 1px solid var(--romero-line);
}

.message.user {
  margin-left: auto;
  color: white;
  background: var(--romero-primary);
}

.message.error {
  color: var(--romero-danger);
  border-color: #f3b7ad;
  background: #fff4f2;
}

.chat-form {
  flex: 0 0 auto;
  display: grid;
  gap: 10px;
  padding: 14px;
  background: white;
  border-top: 1px solid var(--romero-line);
}

.chat-input,
.chat-select,
.chat-textarea {
  width: 100%;
  border: 1px solid var(--romero-line);
  border-radius: 8px;
  padding: 12px;
  color: var(--romero-ink);
  font: inherit;
  outline: none;
  background: white;
}

.chat-textarea {
  min-height: 88px;
  resize: vertical;
}

.chat-input:focus,
.chat-select:focus,
.chat-textarea:focus {
  border-color: var(--romero-primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.chat-file {
  width: 100%;
  padding: 11px;
  border: 1px dashed var(--romero-line);
  border-radius: 8px;
  background: #fbfdff;
}

.chat-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-actions-left,
.chat-actions-right {
  display: flex;
  gap: 8px;
}

.chat-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}

.chat-button:hover {
  transform: translateY(-1px);
}

.chat-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.chat-button.primary {
  color: white;
  background: var(--romero-primary);
}

.chat-button.primary:hover {
  background: var(--romero-primary-dark);
}

.chat-button.secondary {
  color: var(--romero-primary-dark);
  background: #f6efe1;
}

.chat-button.ghost {
  color: var(--romero-muted);
  background: transparent;
}

.chat-button.whatsapp {
  color: white;
  background: #128c7e;
}

.chat-status {
  min-height: 18px;
  color: var(--romero-muted);
  font-size: 12px;
}

.chat-status.error {
  color: var(--romero-danger);
}

.chat-status.success {
  color: var(--romero-success);
}

@media (max-width: 560px) {
  .chat-widget {
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: 0;
  }

  .chat-header {
    position: sticky;
    top: 0;
    padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  }

  .chat-logo {
    width: 42px;
    height: 42px;
    flex-basis: 42px;
  }

  .chat-title {
    font-size: 15px;
  }

  .chat-subtitle {
    font-size: 11px;
  }

  .chat-messages {
    padding: 14px 12px;
  }

  .chat-form {
    max-height: 50dvh;
    overflow-y: auto;
    padding: 12px 12px max(12px, env(safe-area-inset-bottom));
  }

  .chat-textarea {
    min-height: 74px;
  }

  .chat-launcher-wrap {
    right: 16px;
    bottom: 16px;
  }

  .chat-greeting {
    display: none;
  }

  .chat-launcher-label {
    display: none;
  }

  .chat-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-actions-left,
  .chat-actions-right {
    width: 100%;
  }

  .chat-button {
    flex: 1;
  }
}

