/* ============================================================
   WhatsApp TypeBot — CSS
   Mobile-first + Desktop (WhatsApp Web) via media query
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --wa-green-dark:     #075E54;
  --wa-green-medium:   #128C7E;
  --wa-green-light:    #25D366;
  --wa-green-sent:     #DCF8C6;
  --wa-teal-btn:       #1EBEA5;
  --wa-bg:             #ECE5DD;
  --wa-bubble-bot:     #FFFFFF;
  --wa-bubble-user:    #DCF8C6;
  --wa-text-main:      #111B21;
  --wa-text-secondary: #667781;
  --wa-text-time:      #8696A0;
  --wa-footer-bg:      #F0F2F5;
  --wa-sidebar-bg:     #FFFFFF;
  --wa-sidebar-hover:  #F5F6F6;
  --wa-sidebar-active: #EFEAE2;
  --wa-divider:        #E9EDEF;
  --font:              'Inter', sans-serif;
  --radius-bubble:     8px;
  --shadow-bubble:     0 1px 1px rgba(0,0,0,0.12);
}

html, body {
  height: 100%;
  font-family: var(--font);
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════════
   SHARED BUBBLE / ANIMATION STYLES
   (used by both mobile #messages-container-mobile
    and desktop #messages-container)
   ══════════════════════════════════════════════════════════ */

/* The two containers share the same children styles */
#messages-container,
#messages-container-mobile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-bottom: 8px;
}

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

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  max-width: 100%;
  opacity: 0;
  transform: translateY(8px);
  animation: msgFadeIn 0.35s ease forwards;
}

.msg-row.bot-row {
  align-self: flex-start;
  flex-direction: row;
  max-width: 75%;
}
.msg-row.user-row {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 75%;
}

.bot-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  align-self: flex-end;
  background: #ccc;
}
.bot-avatar.hidden { opacity: 0; pointer-events: none; }

.bubble {
  padding: 7px 10px 6px;
  border-radius: var(--radius-bubble);
  font-size: 14.5px;
  line-height: 1.45;
  color: var(--wa-text-main);
  box-shadow: var(--shadow-bubble);
  word-break: break-word;
  position: relative;
}

.bot-row .bubble {
  background: var(--wa-bubble-bot);
  border-top-left-radius: 2px;
}
.user-row .bubble {
  background: var(--wa-bubble-user);
  border-top-right-radius: 2px;
}

.bot-row .bubble::before {
  content: '';
  position: absolute;
  top: 0; left: -8px;
  border-width: 8px 8px 0 0;
  border-style: solid;
  border-color: var(--wa-bubble-bot) transparent transparent transparent;
}
.user-row .bubble::before {
  content: '';
  position: absolute;
  top: 0; right: -8px;
  border-width: 8px 0 0 8px;
  border-style: solid;
  border-color: var(--wa-bubble-user) transparent transparent transparent;
}
.msg-row.no-tail .bubble::before { display: none; }

.msg-time {
  font-size: 11px;
  color: var(--wa-text-time);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 3px;
  float: right;
  margin-left: 8px;
  line-height: 1;
}
.tick svg { width: 16px; height: 11px; fill: #53bdeb; }

/* Typing indicator */
.typing-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  align-self: flex-start;
  max-width: 75%;
  opacity: 0;
  animation: msgFadeIn 0.35s ease forwards;
}
.typing-bubble {
  background: var(--wa-bubble-bot);
  border-radius: var(--radius-bubble);
  border-top-left-radius: 2px;
  padding: 10px 14px;
  box-shadow: var(--shadow-bubble);
  display: flex;
  align-items: center;
  gap: 4px;
}
.dot {
  width: 7px; height: 7px;
  background: #B0BEC5;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.dot:nth-child(1) { animation-delay: 0s; }
.dot:nth-child(2) { animation-delay: 0.2s; }
.dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); background: #B0BEC5; }
  30% { transform: translateY(-5px); background: var(--wa-green-medium); }
}

/* Date separator */
.date-sep {
  display: flex;
  justify-content: center;
  margin: 8px 0;
  opacity: 0;
  animation: msgFadeIn 0.35s ease forwards;
}
.date-sep span {
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(4px);
  color: var(--wa-text-secondary);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Choice buttons */
.choices-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 0 4px;
  justify-content: center;
  opacity: 0;
  animation: msgFadeIn 0.35s ease forwards;
}
.choice-btn {
  background: var(--wa-teal-btn);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 9px 20px;
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 6px rgba(18,140,126,0.35);
  white-space: nowrap;
}
.choice-btn:hover { background: var(--wa-green-medium); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(18,140,126,0.45); }
.choice-btn:active { transform: translateY(0); }
.choice-btn.disabled { pointer-events: none; opacity: 0.55; box-shadow: none; }

/* CTA button */
.cta-btn {
  background: var(--wa-teal-btn);
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 12px 28px;
  font-size: 15px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 14px rgba(18,140,126,0.45);
  animation: bounceCTA 1s ease-in-out infinite;
  display: block;
  margin: 8px auto;
  max-width: 340px;
  text-align: center;
}
@keyframes bounceCTA {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.cta-btn:hover { background: var(--wa-green-medium); animation-play-state: paused; }
.cta-btn.disabled { pointer-events: none; animation: none; opacity: 0.55; }

/* Video bubble */
.video-bubble {
  background: var(--wa-bubble-bot);
  border-radius: var(--radius-bubble);
  border-top-left-radius: 2px;
  overflow: hidden;
  box-shadow: var(--shadow-bubble);
  max-width: 280px;
}
.video-thumbnail {
  width: 100%;
  height: 160px;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.9);
  gap: 8px;
  cursor: pointer;
  transition: opacity 0.2s;
}
.video-thumbnail:hover { opacity: 0.88; }
.video-play-icon {
  width: 50px; height: 50px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.5);
}
.video-play-icon svg { fill: #fff; width: 24px; height: 24px; margin-left: 3px; }
.video-caption { font-size: 12px; opacity: 0.75; text-align: center; padding: 0 12px; }
.video-duration { font-size: 11px; opacity: 0.6; }

/* ---- Image bubble ---- */
.image-bubble {
  background: var(--wa-bubble-bot);
  border-radius: var(--radius-bubble);
  border-top-left-radius: 2px;
  box-shadow: var(--shadow-bubble);
  padding: 4px;
  max-width: 300px;
  position: relative;
}
.image-bubble img.chat-image {
  width: 100%;
  border-radius: calc(var(--radius-bubble) - 2px);
  display: block;
  cursor: pointer;
}
.image-bubble .msg-time {
  padding: 4px 6px 2px;
}/* ---- Audio bubble ---- */
.audio-bubble {
  background: var(--wa-bubble-bot);
  border-radius: var(--radius-bubble);
  border-top-left-radius: 2px;
  box-shadow: var(--shadow-bubble);
  padding: 10px 16px 8px 12px;
  min-width: 200px;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.audio-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.audio-play-btn {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--wa-teal-btn);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.audio-play-btn:hover { background: var(--wa-green-medium); transform: scale(1.05); }
.audio-play-btn svg { fill: #fff; width: 20px; height: 20px; margin-left: 2px; }
.audio-play-btn.playing .icon-play  { display: none; }
.audio-play-btn.playing .icon-pause { display: block !important; margin-left: 0; }
.icon-pause { display: none; }
.audio-waveform { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.waveform-bars {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 32px;
  cursor: pointer;
  overflow: hidden;
  justify-content: flex-start;
}
.wf-bar {
  border-radius: 2px;
  background: #C8D3D5;
  transition: background 0.15s;
  flex-shrink: 0;
}
.wf-bar.played { background: var(--wa-teal-btn); }
.audio-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.audio-timer {
  font-size: 11px;
  color: var(--wa-text-time);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
}

/* Speed toggle button (1x / 1,5x / 2x) */
.audio-speed-btn {
  background: var(--wa-divider);
  border: none;
  border-radius: 12px;
  color: var(--wa-text-secondary);
  font-size: 11px;
  font-family: var(--font);
  font-weight: 600;
  padding: 4px 0;
  width: 44px;
  text-align: center;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.audio-speed-btn:hover {
  background: #dfe3e5;
  color: var(--wa-text-main);
}


/* ══════════════════════════════════════════════════════════
   MOBILE LAYOUT  (< 900px) — #whatsapp-wrapper
   ══════════════════════════════════════════════════════════ */

#wa-web {
  display: none;
}

#whatsapp-wrapper {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  background: var(--wa-bg);
  overflow: hidden;
}

/* Mobile header */
#wa-header-mobile {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 60px;
  background: var(--wa-green-dark);
  padding: 0 12px;
  flex-shrink: 0;
}
#back-btn {
  background: none; border: none; color: rgba(255,255,255,0.85);
  cursor: pointer; padding: 4px; display: flex; align-items: center; border-radius: 50%;
  transition: background 0.2s;
}
#back-btn:hover { background: rgba(255,255,255,0.1); }
#header-avatar-mobile { position: relative; flex-shrink: 0; }
#header-avatar-mobile img {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(255,255,255,0.25); background: #ccc;
}
#online-dot-mobile {
  position: absolute; bottom: 1px; right: 1px;
  width: 10px; height: 10px;
  background: var(--wa-green-light);
  border-radius: 50%; border: 2px solid var(--wa-green-dark);
}
#header-info-mobile { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#contact-name-mobile { color: #fff; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#contact-status-mobile { color: rgba(255,255,255,0.75); font-size: 12px; }
#header-icons-mobile { display: flex; gap: 4px; }
#header-icons-mobile button {
  background: none; border: none; color: rgba(255,255,255,0.85);
  cursor: pointer; padding: 6px; border-radius: 50%; display: flex;
  align-items: center; transition: background 0.2s;
}
#header-icons-mobile button:hover { background: rgba(255,255,255,0.1); }

/* Mobile notice */
#commercial-notice-mobile {
  display: flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 16px;
  background: rgba(255,255,255,0.55);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  font-size: 12px; color: var(--wa-text-secondary);
  flex-shrink: 0;
}
#commercial-notice-mobile svg { flex-shrink: 0; opacity: 0.7; }

/* Mobile chat area */
#chat-area-mobile {
  flex: 1;
  overflow-y: auto; overflow-x: hidden;
  background: var(--wa-bg) url('bg-pattern.svg') repeat;
  padding: 10px 12px;
  scroll-behavior: smooth;
}
#chat-area-mobile::-webkit-scrollbar { width: 5px; }
#chat-area-mobile::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 4px; }

/* Mobile footer */
#chat-footer-mobile {
  background: var(--wa-footer-bg);
  padding: 8px 12px;
  border-top: 1px solid #d9d9d9;
  flex-shrink: 0;
}
#input-bar-mobile {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 24px; padding: 8px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
#input-bar-mobile button {
  background: none; border: none; cursor: default;
  color: var(--wa-text-secondary); display: flex; align-items: center; padding: 2px;
}


/* ══════════════════════════════════════════════════════════
   DESKTOP LAYOUT (≥ 900px) — #wa-web (WhatsApp Web)
   ══════════════════════════════════════════════════════════ */

@media (min-width: 900px) {

  body {
    background: #000;
    overflow: hidden;
  }

  /* Hide mobile, show desktop */
  #whatsapp-wrapper { display: none; }
  #wa-web {
    display: flex;
    flex-direction: row;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
  }

  /* ── SIDEBAR ── */
  #sidebar {
    width: 380px;
    min-width: 280px;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    background: var(--wa-sidebar-bg);
    border-right: 1px solid var(--wa-divider);
    overflow: hidden;
    flex-shrink: 0;
  }

  /* Sidebar header */
  #sb-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    height: 60px;
    background: var(--wa-footer-bg);
    flex-shrink: 0;
  }
  #sb-self-avatar { position: relative; }
  #sb-self-img {
    width: 40px; height: 40px;
    border-radius: 50%; object-fit: cover;
    cursor: pointer; transition: opacity 0.2s;
    background: #ccc;
  }
  #sb-self-img:hover { opacity: 0.85; }
  #sb-header-icons {
    display: flex; gap: 4px;
  }
  #sb-header-icons button {
    background: none; border: none;
    color: var(--wa-text-secondary);
    cursor: pointer; padding: 8px;
    border-radius: 50%; display: flex; align-items: center;
    transition: background 0.2s;
  }
  #sb-header-icons button:hover { background: var(--wa-divider); color: var(--wa-text-main); }

  /* Archived */
  #sb-archived {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 13.5px; color: var(--wa-text-main);
    border-bottom: 1px solid var(--wa-divider);
    transition: background 0.15s;
    flex-shrink: 0;
  }
  #sb-archived:hover { background: var(--wa-sidebar-hover); }
  #sb-archived svg { color: var(--wa-text-secondary); }
  #sb-archived span:first-of-type { flex: 1; }
  #sb-archived-count {
    background: var(--wa-teal-btn);
    color: #fff; font-size: 11px; font-weight: 600;
    padding: 1px 7px; border-radius: 20px;
  }

  /* Search */
  #sb-search-bar {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    background: var(--wa-sidebar-bg);
    border-bottom: 1px solid var(--wa-divider);
    flex-shrink: 0;
  }
  #sb-search-inner {
    flex: 1; display: flex; align-items: center; gap: 10px;
    background: var(--wa-footer-bg);
    border-radius: 8px; padding: 8px 12px;
  }
  #sb-search-inner svg { color: var(--wa-text-secondary); flex-shrink: 0; }
  #sb-search-input {
    border: none; background: transparent;
    font-family: var(--font); font-size: 14px;
    color: var(--wa-text-main); outline: none;
    width: 100%;
  }
  #sb-search-input::placeholder { color: var(--wa-text-secondary); }
  #sb-filter-btn {
    background: none; border: none;
    color: var(--wa-text-secondary);
    cursor: pointer; padding: 8px;
    border-radius: 50%; display: flex; align-items: center;
    transition: background 0.2s;
  }
  #sb-filter-btn:hover { background: var(--wa-divider); }

  /* Contact list */
  #sb-contacts {
    flex: 1; overflow-y: auto;
  }
  #sb-contacts::-webkit-scrollbar { width: 4px; }
  #sb-contacts::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); border-radius: 4px; }

  .sb-contact {
    display: flex; align-items: center; gap: 14px;
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--wa-divider);
    transition: background 0.15s;
  }
  .sb-contact:hover { background: var(--wa-sidebar-hover); }
  .sb-contact--active { background: var(--wa-sidebar-active) !important; }

  .sb-contact-avatar-wrap { position: relative; flex-shrink: 0; }
  .sb-contact-avatar {
    width: 49px; height: 49px;
    border-radius: 50%; object-fit: cover; background: #ccc;
  }
  .sb-avatar-placeholder {
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 20px; font-weight: 600;
  }
  .sb-contact-online-dot {
    position: absolute; bottom: 2px; right: 2px;
    width: 11px; height: 11px;
    background: var(--wa-green-light);
    border-radius: 50%; border: 2px solid var(--wa-sidebar-active);
  }

  .sb-contact-info { flex: 1; overflow: hidden; }
  .sb-contact-top {
    display: flex; justify-content: space-between; align-items: baseline;
    gap: 8px; margin-bottom: 3px;
  }
  .sb-contact-name {
    font-size: 15px; font-weight: 500; color: var(--wa-text-main);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
  }
  .sb-contact-time { font-size: 12px; color: var(--wa-text-secondary); flex-shrink: 0; }
  .sb-contact-bottom {
    display: flex; align-items: center; justify-content: space-between; gap: 6px;
  }
  .sb-contact-preview {
    font-size: 13px; color: var(--wa-text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1;
  }
  .sb-unread-badge {
    background: var(--wa-green-light);
    color: #fff; font-size: 11px; font-weight: 700;
    min-width: 18px; height: 18px;
    padding: 0 5px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }

  /* ── CHAT PANEL ── */
  #chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--wa-bg);
  }

  /* Desktop chat header */
  #wa-header {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 60px;
    background: var(--wa-footer-bg);
    padding: 0 16px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--wa-divider);
  }
  #header-avatar { position: relative; flex-shrink: 0; cursor: pointer; }
  #header-avatar img {
    width: 40px; height: 40px;
    border-radius: 50%; object-fit: cover; background: #ccc;
  }
  #online-dot {
    position: absolute; bottom: 1px; right: 1px;
    width: 10px; height: 10px;
    background: var(--wa-green-light);
    border-radius: 50%; border: 2px solid var(--wa-footer-bg);
  }
  #header-info { flex: 1; display: flex; flex-direction: column; cursor: pointer; }
  #contact-name { font-size: 15px; font-weight: 600; color: var(--wa-text-main); line-height: 1.2; }
  #contact-status { font-size: 13px; color: var(--wa-text-secondary); }
  #header-icons { display: flex; gap: 2px; }
  #header-icons button {
    background: none; border: none;
    color: var(--wa-text-secondary);
    cursor: pointer; padding: 8px;
    border-radius: 50%; display: flex; align-items: center;
    transition: background 0.2s;
  }
  #header-icons button:hover { background: var(--wa-divider); color: var(--wa-text-main); }

  /* Desktop commercial notice */
  #commercial-notice {
    display: flex; align-items: center; gap: 6px; justify-content: center;
    padding: 8px 16px;
    background: rgba(255,255,255,0.55);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    font-size: 12px; color: var(--wa-text-secondary);
    flex-shrink: 0;
  }
  #commercial-notice svg { opacity: 0.7; }

  /* Desktop chat area */
  #chat-area {
    flex: 1;
    overflow-y: auto; overflow-x: hidden;
    background: var(--wa-bg) url('bg-pattern.svg') repeat;
    padding: 20px 8%;
    scroll-behavior: smooth;
  }
  #chat-area::-webkit-scrollbar { width: 6px; }
  #chat-area::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.18); border-radius: 4px; }

  /* Desktop footer */
  #chat-footer {
    background: var(--wa-footer-bg);
    padding: 10px 16px;
    border-top: 1px solid var(--wa-divider);
    flex-shrink: 0;
  }
  #input-bar {
    display: flex; align-items: center; gap: 10px;
    background: #fff; border-radius: 8px; padding: 10px 16px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  }
  #input-bar button {
    background: none; border: none; cursor: default;
    color: var(--wa-text-secondary); display: flex; align-items: center; padding: 2px;
  }
  #input-placeholder {
    flex: 1; font-size: 15px; color: var(--wa-text-secondary); user-select: none;
  }
}
