/* =============================================
   Contact Chat Widget — OFFART
   WhatsApp-style contact form + testimonials
   ============================================= */

/* --- Prevent page scroll on contact page --- */
body.page-template-template-contact {
  overflow: hidden !important;
  height: 100vh !important;
  height: 100dvh !important;
  background: #070d11 !important;
}
body.page-template-template-contact #page,
body.page-template-template-contact .site-content,
body.page-template-template-contact .entry-content,
body.page-template-template-contact .ast-container,
body.page-template-template-contact #content {
  background: #070d11 !important;
}

body.page-template-template-contact {
  --contact-chat-top-offset: 9vh;
}

/* --- WhatsApp Dark Mode Palette (darkened) --- */
.whatsapp-widget-container {
  --wa-bg-deep: #070d11;
  --wa-bg-panel: #0c1317;
  --wa-bg-header: #0c1317;
  --wa-bg-input: #1c2830;
  --wa-bg-hover: #111920;
  --wa-bg-active: #1a2530;
  --wa-border: #1e2930;
  --wa-sent: #00382d;
  --wa-sent-darker: #002e25;
  --wa-received: #161e24;
  --wa-green: #00a884;
  --wa-text: #d9dee1;
  --wa-text-secondary: #7a8b95;
  --wa-text-muted: #5a6a73;
  --wa-link: #53bdeb;
}

/* --- GENERAL RESET (scoped to widget) --- */
.whatsapp-widget-container * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Roboto", "Inter", sans-serif;
  line-height: inherit;
}
.whatsapp-widget-container a {
  color: var(--wa-link);
  text-decoration: none;
}
.whatsapp-widget-container a:hover {
  text-decoration: underline;
}

/* --- MAIN LAYOUT --- */
.whatsapp-widget-container {
  position: fixed;
  top: var(--contact-chat-top-offset);
  left: 0;
  width: 100vw;
  height: calc(100vh - var(--contact-chat-top-offset));
  height: calc(100dvh - var(--contact-chat-top-offset));
  display: flex;
  overflow: hidden;
  z-index: 90;
}

.whatsapp-desktop {
  width: 100%;
  height: 100%;
  display: flex;
  background: var(--wa-bg-deep);
}

/* --- SIDEBAR --- */
.chat-sidebar {
  width: 35%;
  max-width: 380px;
  min-width: 300px;
  background: var(--wa-bg-panel);
  border-right: 1px solid var(--wa-border);
  display: flex;
  flex-direction: column;
  transition: left 0.3s ease-in-out;
  flex-shrink: 0;
  height: 100%;
}

.sidebar-header {
  background: var(--wa-bg-header);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  height: 64px;
  min-height: 64px;
  flex-shrink: 0;
}
.sidebar-header .profile-pic {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.sidebar-header .profile-pic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.sidebar-header .studio-name,
.whatsapp-header .studio-name-header,
.mobile-header .studio-name-header {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  flex-grow: 1;
}
.studio-name-main {
  font-family: "Audiowide", sans-serif;
  color: var(--wa-text);
  font-size: 18px;
}
.online-status {
  display: flex;
  align-items: center;
  gap: 6px;
}
.online-dot {
  width: 8px;
  height: 8px;
  background-color: var(--wa-green);
  border-radius: 50%;
}
.online-text {
  font-size: 13px;
  color: var(--wa-text-secondary);
  font-family: "Roboto", sans-serif;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
}

.chat-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.chat-item:hover {
  background: var(--wa-bg-hover);
}
.chat-item.active {
  background: var(--wa-bg-active);
}
.chat-item + .chat-item {
  border-top: 1px solid rgba(134, 150, 160, 0.08);
}
.chat-item .profile-pic {
  width: 49px;
  height: 49px;
  border-radius: 50%;
  margin-right: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 500;
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
  transition: box-shadow 0.3s ease;
}
.chat-item .profile-pic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chat-item[data-chat="main"] .profile-pic {
  background-color: var(--wa-bg-header);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
  border-radius: 50%;
}

.chat-item .chat-info {
  min-width: 0;
  flex: 1;
}
.chat-item .chat-name {
  color: var(--wa-text);
  font-size: 16px;
  font-weight: 400;
  margin-bottom: 3px;
}
.chat-item .chat-preview {
  color: var(--wa-text-secondary);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- UNREAD COUNT --- */
.unread-count {
  background: var(--wa-green);
  color: #ffffff;
  border-radius: 50%;
  min-width: 20px;
  height: 20px;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
  flex-shrink: 0;
}
.unread-count.visible {
  display: flex;
}

/* --- AVATAR GRADIENTS --- */
.avatar-ia {
  background: linear-gradient(135deg, #d38312, #a83279);
}
.avatar-os {
  background: linear-gradient(135deg, #2193b0, #6dd5ed);
}
.avatar-ns {
  background: linear-gradient(135deg, #ee0979, #ff6a00);
}
.avatar-ik {
  background: linear-gradient(135deg, #00b09b, #96c93d);
}
.avatar-df {
  background: linear-gradient(135deg, #c31432, #240b36);
}

/* --- CHAT CONTENT AREA --- */
.chat-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.whatsapp-header {
  background: var(--wa-bg-header);
  padding: 16px 20px;
  height: 64px;
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 15px;
  flex-shrink: 0;
}
.whatsapp-header .profile-pic {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 16px;
  font-weight: bold;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: box-shadow 0.3s ease;
  overflow: hidden;
}
.whatsapp-header .profile-pic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.whatsapp-header .contact-name {
  color: var(--wa-text);
  font-size: 17px;
  font-weight: 400;
  flex-grow: 1;
}

/* --- CHAT MESSAGES --- */
.chat-messages {
  flex: 1;
  padding: 16px 9%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;

  /* WhatsApp dark doodle wallpaper */
  background-color: #070d11;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cdefs%3E%3Cpattern id='p' width='40' height='40' patternUnits='userSpaceOnUse'%3E%3Cpath d='M20 5 l2 3 l-4 0z' fill='rgba(255,255,255,0.018)'/%3E%3Ccircle cx='8' cy='25' r='1.5' fill='rgba(255,255,255,0.015)'/%3E%3Cpath d='M30 30 l3 0 l0 3 l-3 0z' fill='rgba(255,255,255,0.015)'/%3E%3Ccircle cx='35' cy='12' r='1' fill='rgba(255,255,255,0.018)'/%3E%3C/pattern%3E%3C/defs%3E%3Crect width='200' height='200' fill='url(%23p)'/%3E%3C/svg%3E");
}

.message {
  display: flex;
  max-width: 100%;
  position: relative;
}
.message.sent {
  justify-content: flex-end;
  padding-right: 10px;
}
.message.received {
  justify-content: flex-start;
  padding-left: 10px;
}

.message-bubble {
  padding: 6px 8px 8px;
  border-radius: 8px;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  font-size: 14.2px;
  line-height: 1.4;
  color: var(--wa-text);
  box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.2);
  position: relative;
  width: fit-content;
  max-width: 65%;
}

/* Invisible inline spacer — reserves room for time on the last line only */
.message-time-pad {
  display: inline-block;
  width: 58px;
  height: 1px;
  vertical-align: baseline;
}
.message.sent .message-time-pad {
  width: 75px;
}

/* Sent bubble — green with tail */
.message.sent .message-bubble {
  background: var(--wa-sent);
  border-bottom-right-radius: 3px;
}

/* Received bubble — dark with tail */
.message.received .message-bubble {
  background: var(--wa-received);
  border-bottom-left-radius: 3px;
}

/* Bubble tails */
.message.sent .message-bubble::before {
  content: "";
  position: absolute;
  top: 0;
  right: -8px;
  width: 0;
  height: 0;
  border-left: 8px solid var(--wa-sent);
  border-bottom: 8px solid transparent;
}
.message.received .message-bubble::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  width: 0;
  height: 0;
  border-right: 8px solid var(--wa-received);
  border-bottom: 8px solid transparent;
}

/* Hide tails on consecutive same-side messages */
.message.sent + .message.sent .message-bubble::before,
.message.received + .message.received .message-bubble::before {
  display: none;
}

.message-time {
  position: absolute;
  bottom: 4px;
  right: 7px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

/* Read receipts (double check) on sent messages */
.message.sent .message-time::after {
  content: "\2713\2713";
  font-size: 12px;
  color: #53bdeb;
  letter-spacing: -3px;
  margin-left: 1px;
}

/* --- TYPING INDICATOR --- */
.typing-indicator {
  display: none;
  align-items: center;
  padding: 0 9%;
  margin-bottom: 4px;
}
.typing-indicator::before {
  content: "";
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 32px;
  background: var(--wa-received);
  border-radius: 8px;
  background-image: radial-gradient(circle, var(--wa-text-secondary) 2px, transparent 2px);
  background-size: 12px 32px;
  background-position: 14px center, 26px center, 38px center;
  background-repeat: no-repeat;
  animation: typingPulse 1.4s ease-in-out infinite;
}

@keyframes typingPulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Dots animation */
.typing-indicator::after {
  content: "";
  display: inline-block;
  width: 48px;
  height: 20px;
  margin-left: -56px;
  margin-top: 2px;
  background: radial-gradient(circle, var(--wa-text-secondary) 2.5px, transparent 2.5px);
  background-size: 14px 20px;
  background-position: 4px center, 18px center, 32px center;
  background-repeat: no-repeat;
  animation: typingDots 1.4s steps(1) infinite;
}

@keyframes typingDots {
  0%       { clip-path: inset(0 100% 0 0); }
  25%      { clip-path: inset(0 66% 0 0); }
  50%      { clip-path: inset(0 33% 0 0); }
  75%      { clip-path: inset(0 0 0 0); }
  100%     { clip-path: inset(0 100% 0 0); }
}

/* --- ERROR MESSAGES --- */
.error-message {
  background: rgba(233, 68, 68, 0.15);
  color: #f15c6d;
  padding: 8px 16px;
  border-radius: 8px;
  margin: 4px 0;
  font-size: 13px;
  font-weight: 400;
  border: 1px solid rgba(241, 92, 109, 0.2);
  align-self: center;
  max-width: 80%;
  text-align: center;
  animation: errorSlide 0.3s ease-out;
}
@keyframes errorSlide {
  0% { transform: translateY(-4px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* --- INPUT AREA --- */
.chat-input {
  background: var(--wa-bg-deep);
  padding: 8px 16px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.input-container {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--wa-bg-input);
  border-radius: 21px;
  padding: 0 12px;
  height: 42px;
  gap: 8px;
}

/* Phone icon (visible only on phone step) */
.input-phone-icon {
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.input-phone-icon svg {
  width: 20px;
  height: 20px;
  fill: var(--wa-text-secondary);
}
.input-phone-icon.visible {
  display: flex;
}

#messageInput {
  flex: 1;
  font-size: 15px;
  background: transparent;
  color: var(--wa-text);
  border: none;
  outline: none;
  min-width: 0;
}
#messageInput::placeholder {
  color: var(--wa-text-muted);
}

.send-btn {
  width: 42px;
  height: 42px;
  background: var(--wa-green);
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.send-btn:hover {
  background: #06cf9c;
}
.send-btn:disabled {
  background: var(--wa-bg-input);
  cursor: not-allowed;
}
.send-btn:disabled svg {
  fill: var(--wa-text-secondary);
}
.send-btn svg {
  width: 20px;
  height: 20px;
  fill: var(--wa-bg-panel);
}

/* --- MOBILE HEADER (hidden on desktop) --- */
.mobile-header {
  display: none;
}

/* --- MOBILE RESPONSIVE --- */
@media (max-width: 768px) {
  body.page-template-template-contact {
    --contact-chat-top-offset: 60px;
  }

  .whatsapp-widget-container {
    top: var(--contact-chat-top-offset);
    height: calc(100vh - var(--contact-chat-top-offset));
    height: calc(100dvh - var(--contact-chat-top-offset));
  }
  .whatsapp-desktop {
    flex-direction: column;
    position: relative;
    height: 100%;
    overflow: visible;
  }
  .chat-content {
    flex-grow: 1;
    min-height: 0;
    height: 100%;
  }
  .chat-sidebar {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    max-width: none;
    height: 100%;
    z-index: 90;
    overflow: hidden;
  }
  .chat-sidebar .chat-list {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 10px);
  }
  .chat-sidebar.is-open {
    left: 0;
  }
  .chat-sidebar.is-open ~ .chat-content .chat-input {
    display: none;
  }
  .whatsapp-header {
    display: none;
  }

  .mobile-header {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background-color: var(--wa-bg-header);
    color: white;
    height: 60px;
    min-height: 60px;
    gap: 15px;
  }
  .mobile-back-arrow {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    background: rgba(37, 211, 102, 0.08);
    border: 1px solid rgba(37, 211, 102, 0.25);
    border-radius: 20px;
    padding: 6px 14px 6px 10px;
    transition: all 0.2s ease;
    color: var(--wa-green);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
  }
  .mobile-back-arrow:hover {
    background: rgba(37, 211, 102, 0.15);
    border-color: rgba(37, 211, 102, 0.4);
  }
  .mobile-back-arrow:active {
    transform: scale(0.97);
  }
  .mobile-back-arrow .pill-arrow {
    width: 14px;
    height: 14px;
    stroke: var(--wa-green);
    transition: transform 0.25s ease;
  }
  .mobile-back-arrow.open .pill-arrow {
    transform: rotate(180deg);
  }
  .mobile-back-arrow .menu-label {
    font-size: 12px;
    color: var(--wa-green);
    font-weight: 600;
    letter-spacing: 1px;
    line-height: 1;
  }
  .mobile-header .profile-pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }
  .mobile-header .profile-pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  .mobile-contact-name {
    font-size: 18px;
    flex-grow: 1;
    color: var(--wa-text);
  }

  .chat-messages {
    padding: 15px;
    padding-bottom: 100px;
  }

  .chat-input {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 9999;
    background: var(--wa-bg-header);
    padding: 10px 16px;
    border-top: 1px solid var(--wa-border);
  }
}

/* --- SCROLLBARS --- */
/* Desktop: thin subtle scrollbar */
.chat-messages::-webkit-scrollbar {
  width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}
.chat-messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* Sidebar list: hidden scrollbar */
.chat-list::-webkit-scrollbar {
  display: none;
}
.chat-list {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Mobile: hide all scrollbars */
@media (max-width: 768px) {
  .chat-messages::-webkit-scrollbar {
    display: none;
  }
  .chat-messages {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
}
