/* WhatsApp-style Chat Page Styles */

.chat-page {
  --wa-dark: #075e54;
  --wa-teal: #128c7e;
  --wa-green: #25d366;
  --wa-bubble-user: #dcf8c6;
  --wa-bubble-ai: #ffffff;
  --wa-bg: #e5ddd5;
  --wa-header-bg: linear-gradient(180deg, #075e54 0%, #128c7e 100%);
  --wa-input-bg: #f0f0f0;
  --wa-text: #111b21;
  --wa-text-secondary: #667781;
  --wa-time: #667781;
  --wa-border: #d1d7db;
}

/* Layout: full viewport chat container */
.chat-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  background: var(--wa-bg);
  position: relative;
  overflow: hidden;
}

/* WhatsApp dot pattern background */
.chat-container::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d1d7db' fill-opacity='0.25'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.6;
  pointer-events: none;
  z-index: 0;
}

/* Chat Header */
.chat-header {
  background: var(--wa-header-bg);
  color: #fff;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.chat-header-back {
  color: #fff;
  text-decoration: none;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: background 0.2s;
}

.chat-header-back:hover {
  background: rgba(255,255,255,0.15);
}

.chat-header-new {
  color: #fff;
  text-decoration: none;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: background 0.2s;
  background: transparent;
  border: none;
  cursor: pointer;
}

.chat-header-new:hover {
  background: rgba(255,255,255,0.15);
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.chat-header-info {
  flex: 1;
  min-width: 0;
}

.chat-header-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.3;
}

.chat-header-status {
  font-size: 0.8rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-header-status::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--wa-green);
  border-radius: 50%;
  display: inline-block;
}

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  z-index: 1;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Day separator */
.chat-day {
  align-self: center;
  background: rgba(225, 245, 254, 0.92);
  color: #54656f;
  font-size: 0.75rem;
  padding: 5px 12px;
  border-radius: 8px;
  margin: 8px 0;
  font-weight: 500;
  box-shadow: 0 1px 1px rgba(0,0,0,0.05);
}

/* Message bubbles */
.chat-msg {
  max-width: 75%;
  padding: 8px 10px 6px 12px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.4;
  word-break: break-word;
  position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,0.10), 0 0.5px 1px rgba(0,0,0,0.06);
  animation: msgAppear 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  transition: transform 0.15s ease;
}

.chat-msg:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
}

@keyframes msgAppear {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-msg-user {
  align-self: flex-end;
  background: var(--wa-bubble-user);
  color: var(--wa-text);
  border-bottom-right-radius: 4px;
}

.chat-msg-ai {
  align-self: flex-start;
  background: var(--wa-bubble-ai);
  color: var(--wa-text);
  border-bottom-left-radius: 4px;
}

.chat-msg-system {
  align-self: center;
  background: rgba(241, 241, 241, 0.9);
  color: var(--wa-text-secondary);
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 12px;
  max-width: 90%;
  text-align: center;
}

.chat-msg-content {
  padding-right: 4px;
}

.chat-msg-content a {
  color: #039be5;
  text-decoration: underline;
}

.chat-msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 2px;
}

.chat-msg-time {
  font-size: 0.7rem;
  color: var(--wa-time);
  white-space: nowrap;
}

.chat-msg-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--wa-teal);
  margin-bottom: 2px;
}

/* Typing indicator */
.chat-typing {
  align-self: flex-start;
  background: var(--wa-bubble-ai);
  padding: 10px 14px;
  border-radius: 8px;
  border-bottom-left-radius: 2px;
  display: none;
  box-shadow: 0 1px 1px rgba(0,0,0,0.08);
}

.chat-typing.active {
  display: flex;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  background: #9ea7b0;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

/* Input Area */
.chat-input-area {
  background: var(--wa-input-bg);
  padding: 10px 14px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
  z-index: 10;
  border-top: 1px solid var(--wa-border);
  box-shadow: 0 -1px 4px rgba(0,0,0,0.04);
}

.chat-input-wrap {
  flex: 1;
  background: #fff;
  border-radius: 22px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  min-height: 44px;
  max-height: 140px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  transition: box-shadow 0.2s ease;
}

.chat-input-wrap:focus-within {
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}

.chat-input-wrap textarea {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  max-height: 120px;
  line-height: 1.4;
  color: var(--wa-text);
}

.chat-input-wrap textarea::placeholder {
  color: var(--wa-text-secondary);
}

.chat-send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--wa-teal);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 6px rgba(18, 140, 126, 0.35);
}

.chat-send-btn:hover {
  background: var(--wa-dark);
  box-shadow: 0 3px 8px rgba(7, 94, 84, 0.40);
}

.chat-send-btn:active {
  transform: scale(0.92);
}

.chat-send-btn:disabled {
  background: #a5a5a5;
  cursor: not-allowed;
  box-shadow: none;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
  width: 5px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.18);
  border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.28);
}

/* Loading state */
.chat-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--wa-text-secondary);
  font-size: 0.9rem;
  gap: 8px;
}

/* Responsive */
@media (max-width: 640px) {
  .chat-container {
    height: 100dvh;
  }

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

  .chat-header-avatar {
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
  }

  .chat-msg {
    max-width: 85%;
    font-size: 0.9rem;
    padding: 7px 9px 5px 11px;
  }

  .chat-messages {
    padding: 12px;
  }

  .chat-input-area {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .chat-msg {
    animation: none;
  }
  .typing-dots span {
    animation: none;
  }
}

/* SEO Content Section */
.chat-seo-section {
  background: #ffffff;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  margin-top: -16px;
  position: relative;
  z-index: 5;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
}

.chat-seo-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 20px 60px;
}

.chat-seo-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: #075e54;
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.3;
}

.chat-seo-intro {
  font-size: 1.05rem;
  color: #374151;
  text-align: center;
  max-width: 640px;
  margin: 0 auto 40px;
  line-height: 1.7;
}

.chat-seo-intro strong {
  color: #0f766e;
}

/* Como Funciona Steps */
.chat-seo-steps {
  margin-bottom: 48px;
}

.chat-seo-steps h2,
.chat-seo-topics h2,
.chat-seo-faq h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #111827;
  text-align: center;
  margin-bottom: 24px;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.step-item {
  background: #f0fdfa;
  border-radius: 16px;
  padding: 24px 20px;
  text-align: center;
  border: 1px solid #ccfbf1;
  transition: transform 0.2s, box-shadow 0.2s;
}

.step-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(7, 94, 84, 0.10);
}

.step-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #075e54, #128c7e);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  margin: 0 auto 14px;
}

.step-item h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 8px;
}

.step-item p {
  font-size: 0.9rem;
  color: #4b5563;
  line-height: 1.55;
}

/* Topics Grid */
.chat-seo-topics {
  margin-bottom: 48px;
}

.topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.topic-card {
  background: #ffffff;
  border-radius: 14px;
  padding: 22px 18px;
  border: 1px solid #e5e7eb;
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.topic-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.08);
  border-color: #99f6e4;
}

.topic-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin: 0 auto 12px;
}

.topic-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #111827;
  margin-bottom: 6px;
}

.topic-card p {
  font-size: 0.88rem;
  color: #6b7280;
  line-height: 1.5;
}

/* FAQ */
.chat-seo-faq {
  margin-bottom: 20px;
}

.faq-item {
  background: #f9fafb;
  border-radius: 12px;
  margin-bottom: 12px;
  border: 1px solid #e5e7eb;
  overflow: hidden;
  transition: border-color 0.2s;
}

.faq-item:hover {
  border-color: #99f6e4;
}

.faq-item summary {
  padding: 18px 20px;
  font-weight: 600;
  color: #111827;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 1rem;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: "+";
  font-size: 1.4rem;
  color: #0f766e;
  font-weight: 400;
  line-height: 1;
  flex-shrink: 0;
}

.faq-item[open] summary::after {
  content: "−";
}

.faq-item p {
  padding: 0 20px 18px;
  color: #4b5563;
  font-size: 0.95rem;
  line-height: 1.65;
}

/* Responsive */
@media (max-width: 640px) {
  .chat-seo-inner {
    padding: 28px 16px 40px;
  }

  .chat-seo-title {
    font-size: 1.4rem;
  }

  .chat-seo-intro {
    font-size: 0.95rem;
  }

  .steps-grid,
  .topics-grid {
    grid-template-columns: 1fr;
  }

  .faq-item summary {
    padding: 14px 16px;
    font-size: 0.95rem;
  }

  .faq-item p {
    padding: 0 16px 14px;
    font-size: 0.9rem;
  }
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .step-item,
  .topic-card {
    transition: none;
  }
  .step-item:hover,
  .topic-card:hover {
    transform: none;
  }
}
