/* ===================================================================
   visitor-chat  ·  design-system rewrite
   class names preserved — visuals identical — zero legacy overlap
   =================================================================== */

/* -------------------------------------------------------------------
   DESIGN TOKENS
   ------------------------------------------------------------------- */
:root {
  --wa-bg: hsl(31 24% 87%);
  --wa-out: hsl(111 91% 91%);
  --wa-in: hsl(0 0% 100%);
  --wa-grn: hsl(142 70% 49%);
  --wa-grn-hi: hsl(142 71% 45%);
  --wa-grn-dk: hsl(150 71% 43%);
  --wa-grn-dp: hsl(142 76% 36%);
  --wa-tl: hsl(151 80% 34%);
  --wa-deep: hsl(174 85% 20%);
  --bbl-grn: hsl(141 70% 44%);
  --bbl-sys: hsl(46 100% 90%);
  --bbl-sys-bd: hsl(45 100% 83%);
  --bbl-sys-fg: hsl(43 93% 27%);
  --fg: hsl(202 31% 10%);
  --fg2: hsl(0 0% 20%);
  --fg3: hsl(197 10% 45%);
  --fg-a6: hsl(202 31% 10% / .6);
  --fg-w: hsl(0 0% 100%);
  --sf: hsl(0 0% 100%);
  --sf2: hsl(210 17% 98%);
  --sf3: hsl(36 29% 94%);
  --c-pri: hsl(211 100% 50%);
  --c-ok: hsl(134 61% 41%);
  --c-err: hsl(354 70% 54%);
  --c-wrn: hsl(45 100% 51%);
  --c-nfo: hsl(187 77% 40%);
  --c-dk: hsl(210 10% 23%);
  --bd: hsl(210 14% 89%);
  --bd-lt: hsl(0 0% 88%);
  --bd-inp: hsl(210 16% 93%);
  --sp-xs: .25rem;
  --sp-sm: .5rem;
  --sp-md: .75rem;
  --sp-lg: 1rem;
  --sp-xl: 1.25rem;
  --sp-2x: 1.5rem;
  --sp-3x: 2.5rem;
  --rd-2: .1875rem;
  --rd-4: .375rem;
  --rd-8: .5rem;
  --rd-16: 1rem;
  --rd-20: 1.25rem;
  --rd-pill: 1.5625rem;
  --rd-o: 50%;
  --rd-bbl: .46875rem;
  --elev-bbl: 0 .0625rem .03125rem rgb(0 0 0 / .13);
  --elev-1: 0 .125rem .25rem rgb(0 0 0 / .1);
  --elev-2: 0 .25rem .5rem rgb(0 0 0 / .15);
  --elev-3: 0 .25rem .75rem rgb(0 0 0 / .15);
  --elev-4: 0 .625rem 1.875rem rgb(0 0 0 / .2);
  --ff: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --ff-mono: 'Courier New', monospace;
  --t-xs: .6875rem;
  --t-sm: .75rem;
  --t-base: .8875rem;
  --t-md: .875rem;
  --t-inp: 1rem;
  --t-lg: 1.125rem;
  --ez: cubic-bezier(.4, 0, .2, 1);
  --ez-pop: cubic-bezier(.34, 1.56, .64, 1);
  --ez-out: cubic-bezier(.2, 0, .2, 1);
  --z-hdr: 999;
  --z-inp: 10000;
  --z-dlg: 9999;
  --z-top: 99999;
  --tail-l-grn: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='13' viewBox='0 0 8 13'%3E%3Cpath d='M1.533 3.568L8 12.193V1H2.812C1.042 1 .474 2.156 1.533 3.568z' fill='%23000' opacity='.13'/%3E%3Cpath d='M1.533 2.568L8 11.193V0L2.812 0C1.042 0 .474 1.156 1.533 2.568z' fill='%2322bf58'/%3E%3C/svg%3E");
  --tail-r-grn: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='13' viewBox='0 0 8 13'%3E%3Cpath d='M5.188 1H0v11.193l6.467-8.625C7.526 2.156 6.958 1 5.188 1z' fill='%23000' opacity='.13'/%3E%3Cpath d='M5.188 0H0v11.193l6.467-8.625C7.526 1.156 6.958 0 5.188 0z' fill='%23d9fdd3'/%3E%3C/svg%3E");
  --tail-l-wht: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='13' viewBox='0 0 8 13'%3E%3Cpath d='M1.533 3.568L8 12.193V1H2.812C1.042 1 .474 2.156 1.533 3.568z' fill='%23000' opacity='.13'/%3E%3Cpath d='M1.533 2.568L8 11.193V0L2.812 0C1.042 0 .474 1.156 1.533 2.568z' fill='%23fff'/%3E%3C/svg%3E");
  --svg-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' width='16' height='11' viewBox='0 0 16 11'%3E%3Cpath d='M11.071.653C10.991.585 10.889.551 10.767.551c-.148 0-.275.06-.381.178L4.197 8.365 1.791 6.093a.588.588 0 0 0-.152-.108.538.538 0 0 0-.184-.039c-.131 0-.245.049-.343.146l-.31.311a.453.453 0 0 0-.14.337c0 .136.046.25.14.343l2.996 2.996c.148.136.315.203.501.203a.64.64 0 0 0 .305-.07.64.64 0 0 0 .241-.197l6.646-8.417A.462.462 0 0 0 11.598 1.3c0-.156-.063-.281-.19-.374l-.337-.273zM8.621 8.327c-.19-.119-.372-.237-.546-.355a.437.437 0 0 0-.317-.12c-.148 0-.269.053-.362.159l-.292.33a.42.42 0 0 0-.127.324c0 .131.046.245.14.343l1.079 1.073c.136.135.301.203.495.203a.64.64 0 0 0 .305-.07.64.64 0 0 0 .247-.197l6.621-8.391a.438.438 0 0 0 .108-.299c0-.144-.06-.269-.178-.373l-.355-.273a.434.434 0 0 0-.299-.124c-.144 0-.269.059-.375.178L8.621 8.327z' fill='rgba(17,27,33,.6)'/%3E%3C/svg%3E");
  --bg-desk: url('/static/images/visitor-bg.png');
  --bg-mob: url('/static/images/visitor-bgwap.png');
}

/* -------------------------------------------------------------------
   RESET & FOUNDATION
   ------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box; scrollbar-width: none; -ms-overflow-style: none;
}

:is(*, body)::-webkit-scrollbar { display: none }
html { scroll-behavior: smooth }

body {
  font-family: var(--ff); margin: 0; padding: 0;
  background: var(--sf2); overflow: hidden;
  transform: translateZ(0); backface-visibility: hidden; -webkit-backface-visibility: hidden;
}

/* -------------------------------------------------------------------
   BOOTSTRAP OVERRIDES
   ------------------------------------------------------------------- */
.card {
  border: none; border-radius: var(--rd-8);
  box-shadow: var(--elev-1); transition: transform 200ms, box-shadow 200ms;
}

.card:hover {
  box-shadow: var(--elev-2); transform: translateY(-.125rem);
}

.btn {
  border-radius: var(--rd-20); font-weight: 500; transition: all 200ms;
}

.btn:hover {
  box-shadow: 0 .25rem .5rem rgb(0 0 0 / .2); transform: translateY(-.0625rem);
}

.badge { font-size: .75em; font-weight: 500 }

.text-truncate {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.shadow-sm {
  box-shadow: 0 .125rem .25rem rgb(0 0 0 / .075) !important;
}

/* -------------------------------------------------------------------
   FORM & MODAL
   ------------------------------------------------------------------- */
:is(.form-control):focus {
  border-color: var(--c-pri); box-shadow: 0 0 0 .2rem hsl(211 100% 50% / .25);
}

:is(.form-check-input):checked {
  border-color: var(--c-pri); background-color: var(--c-pri);
}

.modal-content {
  border: none; border-radius: var(--rd-8); box-shadow: var(--elev-4);
}

.modal-header {
  border-bottom: .0625rem solid var(--bd); background: var(--sf2);
}

/* -------------------------------------------------------------------
   AVATAR & STATUS
   ------------------------------------------------------------------- */
.avatar {
  display: flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; border-radius: var(--rd-o);
  font-weight: 700; background: linear-gradient(135deg, var(--c-pri), var(--c-nfo));
}

.whatsapp-avatar {
  display: flex; align-items: center; justify-content: center;
  width: 2.5rem; height: 2.5rem; border-radius: var(--rd-o);
  background: var(--sf); box-shadow: var(--elev-1);
}

.whatsapp-avatar :is(img) {
  border: .0625rem solid rgb(0 0 0 / .1);
}

.status-online { color: var(--c-ok) }
.status-offline { color: var(--c-dk) }

.online-status {
  display: inline-block; width: .625rem; height: .625rem;
  margin-left: .625rem; border-radius: var(--rd-o);
  background: hsl(122 39% 49%); animation: pulse 2s ease-in-out infinite;
}

.online-indicator {
  display: inline-block; width: 1rem; height: 1rem;
  border-radius: var(--rd-o); font-size: var(--t-sm);
  line-height: 1rem; text-align: center; flex-shrink: 0;
}

.online-indicator:is(.online) {
  color: var(--c-ok); animation: pulse 2s ease-in-out infinite;
}

.online-indicator:is(.offline) {
  color: hsl(208 7% 46%); opacity: .7;
}

/* -------------------------------------------------------------------
   SIDEBAR & NAVIGATION
   ------------------------------------------------------------------- */
.sidebar {
  min-height: 100vh; border-right: .0625rem solid var(--bd);
  background: var(--sf); overflow-y: auto;
}

.sidebar .nav-link {
  padding: .9375rem var(--sp-xl); border-bottom: .0625rem solid var(--sf2);
  border-radius: 0; color: hsl(210 7% 31%); transition: all 200ms;
}

.sidebar .nav-link:is(:hover, .active) {
  background: var(--c-pri); color: var(--fg-w);
}

/* -------------------------------------------------------------------
   CONVERSATION LIST
   ------------------------------------------------------------------- */
.conversation-list {
  padding: 0; margin: 0; list-style: none;
  max-height: calc(100vh - 18.75rem); overflow-y: auto;
}

.conversation-item {
  position: relative; padding: .9375rem;
  border-bottom: .0625rem solid hsl(0 0% 93%);
  cursor: pointer; transition: all 200ms;
}

.conversation-item:is(:hover) {
  background: var(--sf2);
}

.conversation-item:is(.active) {
  background: var(--c-pri); color: var(--fg-w);
}

.conversation-item:is(.active) .text-muted {
  color: rgb(255 255 255 / .8) !important;
}

.unread-badge {
  display: flex; align-items: center; justify-content: center;
  position: absolute; inset: .625rem .625rem auto auto;
  width: 1.25rem; height: 1.25rem; border-radius: var(--rd-o);
  font-size: var(--t-sm); font-weight: 700;
  color: var(--fg-w); background: var(--c-err);
}

/* -------------------------------------------------------------------
   STATS CARD
   ------------------------------------------------------------------- */
.stats-card {
  padding: 1.875rem var(--sp-xl); margin-bottom: var(--sp-xl);
  border-radius: var(--rd-8); text-align: center;
  color: var(--fg-w); transition: transform 200ms;
  background: linear-gradient(135deg, hsl(231 79% 66%), hsl(279 36% 47%));
}

.stats-card:hover { transform: translateY(-.3125rem) }

:is(.stats-card) .stats-number {
  margin-bottom: .625rem; font-size: 2.5rem; font-weight: 700;
  text-shadow: 0 .125rem .25rem rgb(0 0 0 / .3);
}

/* -------------------------------------------------------------------
   CHAT LAYOUT — container / window / header
   ------------------------------------------------------------------- */
.chat-container {
  width: 100vw; height: 100vh; margin: 0; padding: 0;
  background: var(--sf3); will-change: scroll-position;
  transition: all .25s var(--ez-out);
}

.chat-window {
  display: flex; flex-direction: column;
  width: 100%; height: 100vh; border-radius: 0;
  background: var(--sf); box-shadow: none; overflow: hidden;
}

.chat-window:not(:is(.content-ready)) {
  opacity: 0 !important; visibility: hidden !important; pointer-events: none !important;
}

.chat-window:is(.content-ready) {
  opacity: 1 !important; visibility: visible !important;
  transition: opacity .5s ease .1s, visibility .5s ease .1s;
}

.chat-header {
  padding: .9375rem var(--sp-xl); border-bottom: .0625rem solid var(--bd-lt);
  border-radius: 0; color: var(--fg2); background: var(--sf);
}

/* -------------------------------------------------------------------
   CHAT MESSAGES AREA
   ------------------------------------------------------------------- */
.chat-messages {
  flex: 1; overflow-y: auto; padding: .9375rem; padding-bottom: 5rem;
  background-color: var(--wa-bg); background-image: var(--bg-desk);
  background-size: cover; background-position: center;
  background-repeat: no-repeat; background-attachment: fixed;
  scroll-behavior: auto !important; will-change: scroll-position;
  transform: translateZ(0); -webkit-overflow-scrolling: touch;
}

#chatMessages {
  scroll-behavior: smooth; scrollbar-width: thin;
  scrollbar-color: rgb(0 0 0 / .2) transparent;
}

#chatMessages::-webkit-scrollbar { width: .375rem }
#chatMessages::-webkit-scrollbar-track { background: transparent }

#chatMessages::-webkit-scrollbar-thumb { border-radius: var(--rd-2); background: rgb(0 0 0 / .2) }
#chatMessages::-webkit-scrollbar-thumb:hover { background: rgb(0 0 0 / .4) }

:is(.chat-messages-container) {
  transition: opacity 200ms var(--ez-out);
}




/* -------------------------------------------------------------------
   MESSAGE CORE
   ------------------------------------------------------------------- */
.message {
  display: flex; flex-direction: column; margin-bottom: .9375rem;
  clear: both; contain: layout; will-change: auto;
  transform-origin: bottom center; animation: msgSlideIn .3s var(--ez-pop) both;
}

.history-message:is(.message) {
  animation: none !important; transition: none !important;
  transform: none !important; opacity: 1 !important; will-change: auto !important;
}

.history-message:is(.message) :is(*, .rich-button, .rich-input-group) {
  animation: none !important; transition: none !important;
  transform: none !important; will-change: auto !important;
}

.message:is(.new-message) { animation: msgAppear .25s var(--ez) }
.message:is(.message-fade-out) { animation: msgFadeOut .25s var(--ez) forwards }
.message:is(.restored) { animation: msgRestore .4s ease-out }
.message:is(.visitor-left, .agent-left) { align-items: flex-start }
.message:is(.visitor-right, .agent-right, .welcome-right) { align-items: flex-end }
.message:is(.visitor) { align-items: flex-start }
.message:is(.agent) { align-items: flex-end }
.message:is(.system, .system-message) { align-items: center }

/* -------------------------------------------------------------------
   MESSAGE BUBBLE
   ------------------------------------------------------------------- */
.message-bubble {
  display: block; position: relative; max-width: 70%; min-height: 1.25rem;
  padding: .375rem .4375rem .5rem .5625rem; border-radius: var(--rd-bbl);
  font-size: var(--t-base); line-height: 1.4; overflow-wrap: break-word;
  box-shadow: var(--elev-bbl); contain: layout style;
  transform: translateZ(0); backface-visibility: hidden; -webkit-backface-visibility: hidden;
}

.message-bubble::after { content: ""; display: table; clear: both }

.message-content { margin-right: 3.75rem; margin-bottom: -.25rem }

.message:is(.visitor-left, .agent-left) .message-content {
  margin-left: 0; margin-right: 3.75rem;
}

/* -------------------------------------------------------------------
   BUBBLE VARIANTS & TAILS
   ------------------------------------------------------------------- */
:is(.message.visitor-left, .message.visitor) .message-bubble {
  border-bottom-left-radius: var(--rd-2); color: var(--fg-w); background: var(--bbl-grn);
}

:is(.message.visitor-left, .message.visitor) .message-bubble::after {
  content: ''; position: absolute; bottom: -.0625rem; left: -.4375rem;
  width: .5rem; height: .8125rem;
  background: var(--tail-l-grn) no-repeat center / contain;
  filter: drop-shadow(0 .0625rem .03125rem rgb(0 0 0 / .13));
}

.visitor-right:is(.message) .message-bubble {
  border-bottom-right-radius: var(--rd-2); color: var(--fg); background: var(--wa-out);
}

.visitor-right:is(.message) .message-bubble::after {
  content: ''; position: absolute; bottom: -.0625rem; right: -.4375rem;
  width: .5rem; height: .8125rem;
  background: var(--tail-r-grn) no-repeat center / contain;
  filter: drop-shadow(0 .0625rem .03125rem rgb(0 0 0 / .13));
}

.agent-left:is(.message) .message-bubble {
  border-bottom-left-radius: var(--rd-2); color: var(--fg);
  background: var(--wa-in); box-shadow: var(--elev-bbl);
}

.agent-left:is(.message) .message-bubble::after {
  content: ''; position: absolute; bottom: -.0625rem; left: -.4375rem;
  width: .5rem; height: .8125rem;
  background: var(--tail-l-wht) no-repeat center / contain;
  filter: drop-shadow(0 .0625rem .03125rem rgb(0 0 0 / .13));
}

:is(.message.agent-right, .message.agent) .message-bubble {
  border-bottom-right-radius: var(--rd-2); color: var(--fg);
  background: var(--wa-in); box-shadow: var(--elev-bbl);
}

.welcome-right:is(.message) .message-bubble {
  border: .0625rem solid var(--bbl-sys-bd); border-bottom-right-radius: var(--rd-4);
  color: var(--bbl-sys-fg); background: var(--bbl-sys);
}


/* ── WhatsApp system notice ─── */
.sys-pill {
  display: inline-block; max-width: 92%;
  padding: .5rem 1.25rem; border-radius: .5rem;
  font-size: .8125rem; font-weight: 500; line-height: 1.45;
  letter-spacing: .01em; text-align: center;
  color: hsl(200 6% 34%);
  background: hsla(48 53% 88% / .92);
  box-shadow: 0 1px 6px rgb(11 20 26 / .08);
}

.sys-pill-time {
  display: inline; margin-left: .5rem;
  font-size: .6875rem; font-weight: 400; opacity: .55;
}

.system-warning .sys-pill {
  color: hsl(35 55% 26%);
  background: hsla(46 70% 87% / .95);
}

.system-success .sys-pill {
  color: hsl(152 45% 24%);
  background: hsla(152 40% 88% / .95);
}

/* ── Restart conversation ─── */
#restartConversationBtn {
  display: flex; justify-content: center;
  padding: .625rem 0 .25rem;
}

#restartConversationBtn .btn {
  border: none; border-radius: var(--rd-pill);
  padding: .5rem 1.75rem; font-size: .8125rem; font-weight: 500;
  letter-spacing: .02em;
  color: #fff; background: var(--wa-grn);
  box-shadow: 0 2px 8px rgb(37 211 102 / .25);
  transition: transform .15s, box-shadow .15s;
}

#restartConversationBtn .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgb(37 211 102 / .3);
}

/* -------------------------------------------------------------------
   WHATSAPP HEADER INSIDE BUBBLE
   ------------------------------------------------------------------- */
:is(.whatsapp-header, .wa-hdr) {
  padding-bottom: var(--sp-sm); margin-bottom: var(--sp-sm) !important;
  border-bottom: .0625rem solid rgb(0 0 0 / .1);
}

:is(.whatsapp-header, .wa-hdr) h6 {
  font-size: var(--t-md); font-weight: 600; color: var(--fg2);
}

.message:is(.agent-left, .agent-right, .welcome-right) :is(.whatsapp-header, .wa-hdr) {
  opacity: .95;
}

.message:is(.visitor-left, .visitor-right) :is(.whatsapp-header, .wa-hdr) {
  display: none;
}

/* -------------------------------------------------------------------
   MESSAGE TIME
   ------------------------------------------------------------------- */
.message-time {
  display: flex; align-items: center; gap: .125rem;
  position: relative; bottom: 0; float: right; clear: both;
  padding: 0; margin: .125rem 0 0 var(--sp-sm);
  font-size: var(--t-xs); line-height: 1; color: var(--fg-a6);
}

.message:is(.visitor-left, .agent-left) .message-time {
  float: right; margin-left: var(--sp-sm); margin-right: 0;
}

:is(.message.visitor-left, .message.visitor) .message-time { color: var(--fg-w) }

.message:is(.visitor-right, .agent-right, .welcome-right, .agent) .message-time {
  float: right; margin-left: var(--sp-sm);
}

.visitor-right:is(.message) .message-time { color: var(--fg) }

:is(.message.visitor-right, .message.visitor) .message-time::after {
  content: ''; width: 1rem; height: .6875rem; margin-left: var(--sp-xs);
  background: var(--svg-check) no-repeat center / contain;
}

.system:is(.message) .message-time {
  display: block; float: none; margin-inline: auto; text-align: center;
}

/* -------------------------------------------------------------------
   CHAT INPUT AREA
   ------------------------------------------------------------------- */
.chat-input {
  display: flex; flex-direction: column; min-height: 3.75rem;
  padding: var(--sp-md) var(--sp-lg); border-top: .0625rem solid var(--bd-lt);
  background: var(--sf);
}

.input-group {
  display: flex !important; align-items: center;
  gap: .625rem; flex-wrap: nowrap !important;
  width: 100%;
}

.input-wrapper { position: relative; flex: 1 }

:is(.input-group) .form-control {
  width: 100%; height: 2.5rem; padding: .625rem 2.8125rem .625rem var(--sp-lg);
  border: .0625rem solid var(--bd-lt) !important; border-radius: var(--rd-20) !important;
  font-size: var(--t-inp); line-height: 1.2; color: var(--fg2);
  background: var(--sf) !important; box-shadow: none !important;
}

:is(.input-group) .form-control:focus {
  border-color: var(--bd-lt) !important; border-radius: var(--rd-20) !important;
  background: var(--sf) !important; box-shadow: none !important; outline: none !important;
}

.input-group > .form-control:is(:not(:last-child), :not(:first-child)) {
  border-radius: var(--rd-20) !important;
}

/* -------------------------------------------------------------------
   EMOJI BUTTON
   ------------------------------------------------------------------- */
.emoji-btn {
  display: flex; align-items: center; justify-content: center;
  position: absolute; right: .75rem; top: 50%; z-index: 10;
  padding: var(--sp-xs); border: none; border-radius: var(--rd-o);
  background: none; cursor: pointer; transform: translateY(-50%);
  transition: background-color 200ms ease;
}

.emoji-btn:hover { background: rgb(0 0 0 / .05) }

.emoji-picker {
  position: absolute; bottom: 100%; left: 0; right: 0;
  background: var(--sf); border-top: 1px solid #e0e0e0;
  padding: 8px; flex-wrap: wrap; gap: 4px; max-height: 160px;
  overflow-y: auto; z-index: 20;
}
.emoji-item {
  cursor: pointer; font-size: 1.25rem; padding: 4px 6px;
  border-radius: 4px; line-height: 1; user-select: none;
}
.emoji-item:hover { background: rgba(0,0,0,.06) }

/* -------------------------------------------------------------------
   SEND BUTTON
   ------------------------------------------------------------------- */
.whatsapp-send-btn {
  display: flex !important; align-items: center !important; justify-content: center !important;
  width: 2.5rem !important; height: 2.5rem !important;
  min-width: 2.5rem !important; min-height: 2.5rem !important;
  padding: 0 !important; margin: 0; border: none !important;
  border-radius: var(--rd-o) !important; background: var(--wa-tl) !important;
  box-shadow: var(--elev-1); cursor: pointer; flex-shrink: 0;
  transition: background-color 200ms ease;
}

.whatsapp-send-btn:is(:hover, :focus) {
  border: none !important; background: hsl(149 78% 29%) !important;
  box-shadow: 0 .125rem .375rem rgb(0 0 0 / .15) !important;
}

:is(.whatsapp-send-btn):active {
  background: hsl(148 78% 24%) !important; transform: scale(.95);
  box-shadow: 0 .0625rem .125rem rgb(0 0 0 / .1) !important;
}

:is(.whatsapp-send-btn) svg { width: 1rem; height: 1rem; margin-left: .125rem }

/* -------------------------------------------------------------------
   QUICK REPLIES
   ------------------------------------------------------------------- */
.quick-replies-container {
  width: 100%;
}

.quick-replies-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: .375rem;
}

.quick-replies-title {
  display: flex; align-items: center; gap: .25rem;
  font-size: .8em; font-weight: 600; color: var(--fg-m, #666);
}

.quick-replies-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 1.25rem; height: 1.25rem; padding: 0 .375rem;
  font-size: .75em; font-weight: 600; color: #fff;
  background: var(--c-pri, #25d366); border-radius: .625rem;
}

.quick-replies {
  display: flex; flex-wrap: wrap; gap: .375rem;
  max-height: 4.5rem; overflow-y: auto; overflow-x: hidden;
  margin-bottom: .5rem; padding-right: .25rem;
  scrollbar-width: thin;
}

.quick-replies::-webkit-scrollbar { width: 4px; }
.quick-replies::-webkit-scrollbar-thumb { background: var(--bd, #ddd); border-radius: 2px; }

.quick-reply-btn {
  padding: .25rem .625rem; border: .0625rem solid var(--bd);
  border-radius: var(--rd-20); font-size: .8em; white-space: nowrap;
  background: var(--sf2); cursor: pointer; transition: all 180ms;
  line-height: 1.4;
}

:is(.quick-reply-btn):hover {
  border-color: var(--c-pri); color: var(--fg-w);
  background: var(--c-pri); transform: translateY(-.0625rem);
}

.quick-replies-placeholder {
  display: flex; align-items: center; justify-content: center;
  padding: .5rem; font-size: .8em; color: var(--fg-m, #999);
}

/* -------------------------------------------------------------------
   TYPING INDICATOR
   ------------------------------------------------------------------- */
.typing-indicator {
  display: none; padding: .625rem var(--sp-xl); margin: 0;
  border: none; font-style: italic; color: hsl(0 0% 40%);
  background-color: transparent;
}

:is(.typing-indicator) i { animation: typing 1.4s infinite }

/* -------------------------------------------------------------------
   RICH TEXT & TRANSLATED
   ------------------------------------------------------------------- */
:is(.text-message-content, .rich-message-content) { line-height: 1.4 }
:is(.rich-message-content) .rich-text-content { margin-bottom: var(--sp-xs) }
.rich-text-content { margin-bottom: var(--sp-sm) }
.translated-message .translated-text { margin-bottom: var(--sp-xs) }

.translated-message .translation-label {
  font-size: var(--t-sm); font-weight: 500; color: var(--c-pri);
}

/* -------------------------------------------------------------------
   RICH IMAGES
   ------------------------------------------------------------------- */
.rich-images {
  display: flex; flex-wrap: wrap; gap: var(--sp-sm);
  margin: var(--sp-sm) 0;
}

.rich-image {
  max-width: 20rem; max-height: 20rem; width: auto; height: auto;
  border-radius: var(--rd-8); object-fit: contain; cursor: pointer;
  box-shadow: 0 .125rem .5rem rgb(0 0 0 / .1);
}

:is(.rich-image)[style*="width"],
:is(.rich-image)[style*="height"] {
  max-width: none !important; max-height: none !important;
}

.rich-image:hover {
  box-shadow: 0 .25rem 1rem rgb(0 0 0 / .15);
}

.message-bubble :is(.rich-image) { max-width: 16rem; max-height: 16rem }

.message-bubble :is(.rich-image)[style*="width"],
.message-bubble :is(.rich-image)[style*="height"] {
  max-width: none !important; max-height: none !important;
}

/* -------------------------------------------------------------------
   CLICKABLE IMAGE
   ------------------------------------------------------------------- */
.clickable-image { cursor: pointer; transition: transform 200ms ease, box-shadow 200ms ease }

:is(.clickable-image):hover {
  box-shadow: 0 .25rem .75rem rgb(0 0 0 / .15); transform: scale(1.02) translateZ(0);
}

:is(.clickable-image):active { transform: scale(.98) translateZ(0) }

/* -------------------------------------------------------------------
   RICH BUTTONS
   ------------------------------------------------------------------- */
.rich-buttons {
  display: flex; flex-direction: column; gap: var(--sp-sm);
  max-width: 17.5rem; margin-top: var(--sp-md); animation: btnsSlideIn .4s ease-out;
}

:is(.rich-buttons).horizontal { flex-direction: row; flex-wrap: wrap; gap: var(--sp-sm) }

:is(.rich-buttons).horizontal .rich-button {
  flex: 1; min-width: 7.5rem; max-width: 10rem;
}

.message-bubble :is(.rich-buttons) { gap: .375rem; margin-top: var(--sp-sm) }

.rich-button {
  display: flex; align-items: center; justify-content: center;
  position: relative; min-height: 2.75rem;
  padding: var(--sp-md) var(--sp-xl); border: none; border-radius: var(--rd-pill);
  font-size: var(--t-md); font-weight: 500; line-height: 1.3;
  text-align: center; overflow-wrap: break-word; white-space: normal;
  text-overflow: ellipsis; overflow: hidden;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; max-height: 2.6em;
  cursor: pointer;
}

.rich-button:focus, .rich-button:focus-visible,
.rich-input-submit:focus, .rich-input-submit:focus-visible {
  outline: none !important; box-shadow: none !important; border-color: transparent !important;
}

:is(.rich-button):disabled {
  cursor: default; pointer-events: none;
}


.message-bubble :is(.rich-button) {
  min-height: 2.25rem; padding: .5rem var(--sp-lg);
  border-radius: var(--rd-20); font-size: var(--t-sm);
}

.rich-button:is(.btn-primary, .btn-success, .btn-warning, .btn-danger, .btn-secondary) {
  color: var(--fg-w);
  background: linear-gradient(135deg, var(--wa-grn), var(--wa-grn-dk));
}


/* --- whatsapp action buttons --- */
:is(.rich-button).whatsapp-call {
  color: var(--fg-w); background: linear-gradient(135deg, var(--wa-grn), var(--wa-grn-dk));
}

:is(.rich-button).whatsapp-call::after {
  content: '\1F4DE'; margin-left: var(--sp-sm);
  font-size: var(--t-inp);
}

:is(.rich-button).whatsapp-link {
  color: var(--fg-w); background: linear-gradient(135deg, hsl(213 70% 59%), hsl(213 59% 49%));
}

:is(.rich-button).whatsapp-link::after {
  content: '\1F517'; margin-left: var(--sp-sm);
  font-size: var(--t-md);
}

:is(.rich-button).whatsapp-reply::before {
  content: '\1F4AC'; margin-right: .375rem; font-size: var(--t-md);
}

:is(.rich-button).whatsapp-location {
  color: var(--fg-w); background: linear-gradient(135deg, hsl(0 66% 70%), hsl(4 82% 63%));
}

:is(.rich-button).whatsapp-location::after {
  content: '\1F4CD'; margin-left: var(--sp-sm); font-size: var(--t-inp);
}

:is(.rich-button).whatsapp-download {
  color: var(--fg-w); background: linear-gradient(135deg, hsl(282 39% 53%), hsl(282 44% 49%));
}

:is(.rich-button).whatsapp-download::after {
  content: '\1F4C4'; margin-left: var(--sp-sm); font-size: var(--t-md);
}

/* -------------------------------------------------------------------
   RICH INPUT FIELDS
   ------------------------------------------------------------------- */
.rich-inputs { margin: var(--sp-md) 0 }

:is(.rich-input-container) {
  position: relative; padding: 0; margin-bottom: var(--sp-md);
  border-radius: var(--rd-16); background-color: transparent;
}

.rich-input-label {
  display: block; padding-left: 0; margin-bottom: var(--sp-sm);
  font-size: var(--t-md); font-weight: 500; line-height: 1.4;
  letter-spacing: .0125rem; text-align: left; color: var(--wa-grn);
}

:is(.rich-input-container):is(:hover, :focus-within) .rich-input-label {
  color: var(--wa-grn-hi);
}

.rich-input {
  width: 100%; height: 2.75rem; padding: .625rem var(--sp-lg);
  border: .125rem solid var(--bd-inp); border-radius: var(--rd-20);
  font-size: var(--t-inp); font-weight: 400; color: var(--fg2);
  background: var(--sf); box-shadow: 0 .125rem .75rem rgb(38 211 103 / .08);
}

.rich-input:focus { border-color: var(--wa-grn); outline: none; box-shadow: none }

:is(.rich-input)::placeholder { font-weight: 400; color: hsl(214 16% 65%) }
:is(.rich-input):focus::placeholder { color: hsl(0 0% 75%) }
:is(.rich-input):hover:not(:focus) { border-color: var(--wa-grn) }

:is(.rich-input):disabled {
  border-color: var(--bd-inp); color: hsl(208 7% 46%); background: var(--sf2);
  box-shadow: 0 .0625rem .1875rem rgb(0 0 0 / .05); cursor: not-allowed; transform: none;
}

/* -------------------------------------------------------------------
   PHONE VALIDATION
   ------------------------------------------------------------------- */
:is(.phone-validation-message) {
  padding: .375rem 0;
  margin-top: var(--sp-sm) !important; margin-bottom: var(--sp-xs) !important;
  border: .0625rem solid transparent; border-radius: var(--rd-8);
  font-size: .8125rem; line-height: 1.3; text-align: left; background-color: transparent;
}

.text-success:is(.phone-validation-message) {
  font-weight: 400; color: hsl(210 6% 56%) !important;
  opacity: .7; transition: opacity .3s ease;
}

/* -------------------------------------------------------------------
   RICH INPUT SUBMIT
   ------------------------------------------------------------------- */
.rich-input-submit {
  display: flex; align-items: center; justify-content: center;
  position: relative; min-width: 7.5rem; min-height: 2.75rem;
  padding: var(--sp-md) var(--sp-2x); margin-top: var(--sp-md);
  border: none; border-radius: var(--rd-pill); font-size: var(--t-md);
  font-weight: 500; line-height: 1.3; text-align: center; color: var(--fg-w);
  overflow: hidden; cursor: pointer;
}


:is(.rich-input-submit):disabled {
  cursor: default; pointer-events: none;
}

.rich-input-submit:is(.btn-primary, .btn-success, .btn-warning, .btn-danger, .btn-secondary) {
  color: var(--fg-w);
  background: linear-gradient(135deg, var(--wa-grn), var(--wa-grn-dk));
}


/* -------------------------------------------------------------------
   IMAGE MESSAGE
   ------------------------------------------------------------------- */
.image-message { padding: 0; background-color: transparent }

:is(.image-message-container) {
  display: inline-block; max-width: 20rem;
  border-radius: var(--rd-16); background: var(--sf);
  box-shadow: 0 .125rem .5rem rgb(0 0 0 / .1); overflow: hidden;
}

:is(.image-message-container):hover {
  box-shadow: 0 .25rem 1rem rgb(0 0 0 / .15);
}

.visitor-right:is(.message) .image-message-container {
  max-width: 20rem; width: auto; background-color: transparent;
  box-shadow: 0 .125rem .5rem rgb(0 0 0 / .15);
}

.visitor-right:is(.message) .message-image {
  max-width: 20rem; max-height: 20rem; width: auto; height: auto;
  border-radius: var(--rd-16);
}

.message-image {
  display: block; max-width: 100%; max-height: 20rem;
  width: auto; height: auto;
  object-fit: contain; cursor: pointer;
}

:is(.message-image):hover { opacity: .9 }

:is(.image-message-caption) {
  display: flex; align-items: center;
  padding: var(--sp-sm) var(--sp-md); border-top: .0625rem solid var(--bd-inp);
  font-size: .8125rem; color: hsl(208 7% 46%); background: var(--sf2);
}

/* -------------------------------------------------------------------
   IMAGE OVERLAY (full-screen viewer)
   ------------------------------------------------------------------- */
.img-overlay {
  position: fixed; inset: 0; z-index: var(--z-dlg);
  opacity: 0; visibility: hidden; transition: all .3s ease;
}

.img-overlay.show { opacity: 1; visibility: visible }

.img-overlay-bg {
  position: absolute; inset: 0; background: rgb(0 0 0 / .8); cursor: pointer;
}

.img-overlay-body {
  display: flex; align-items: center; justify-content: center;
  position: fixed; inset: 0; padding: 2.5rem 1.25rem 1.25rem;
}

.img-overlay-x {
  display: flex; align-items: center; justify-content: center;
  position: fixed; top: 1.25rem; right: 1.25rem; z-index: 1001;
  width: 2.75rem; height: 2.75rem; border: none; border-radius: var(--rd-o);
  font-size: var(--t-lg); color: var(--fg-w); background: rgb(0 0 0 / .8);
  cursor: pointer; transition: all 200ms ease;
}

.img-overlay-x:hover { background: rgb(0 0 0); transform: scale(1.1) translateZ(0) }

.img-overlay-pic {
  display: block; max-width: 100%; max-height: 100%; width: auto; height: auto;
  border-radius: var(--rd-8); object-fit: contain;
  box-shadow: 0 .5rem 2rem rgb(0 0 0 / .6); cursor: zoom-in;
  transition: transform 200ms ease;
}

.img-overlay-pic:hover { transform: scale(1.02) translateZ(0) }

.img-overlay-hint {
  position: absolute; bottom: 1.25rem; left: 50%;
  padding: var(--sp-sm) var(--sp-lg); border-radius: var(--rd-20);
  font-size: var(--t-sm); white-space: nowrap;
  color: var(--fg-w); background: rgb(0 0 0 / .7);
  transform: translateX(-50%); animation: hintFade 3s ease-in-out forwards;
}

/* -------------------------------------------------------------------
   HIGHLIGHT NUMBER (.hl-num)
   ------------------------------------------------------------------- */
.hl-num {
  display: inline; padding: .125rem .375rem;
  border: .0625rem solid rgb(37 211 102 / .25); border-radius: var(--rd-4);
  font-family: var(--ff-mono); font-size: inherit; font-weight: 500;
  letter-spacing: .03125rem; white-space: nowrap;
  color: hsl(149 77% 23%);
  background: linear-gradient(135deg, rgb(37 211 102 / .12), rgb(37 211 102 / .06));
  cursor: pointer; user-select: all; transition: all 200ms ease;
}

.hl-num i { margin-right: var(--sp-xs); font-size: var(--t-sm); vertical-align: middle }

.hl-num:hover {
  border-color: var(--wa-grn); box-shadow: 0 .125rem .5rem rgb(37 211 102 / .2);
  background: linear-gradient(135deg, rgb(37 211 102 / .25), rgb(37 211 102 / .15));
  transform: translateY(-.0625rem);
}

.hl-num:active { transform: translateY(0px) scale(.98) }

/* -------------------------------------------------------------------
   PHONE INPUT MESSAGE
   ------------------------------------------------------------------- */
:is(.phone-input-message) {
  padding: var(--sp-lg); margin: var(--sp-sm) 0;
  border: .0625rem solid hsl(158 58% 84%); border-radius: var(--rd-16);
  background: linear-gradient(135deg, hsl(160 33% 98%), hsl(162 57% 94%));
}

:is(.phone-message-header) {
  display: flex; align-items: center; margin-bottom: var(--sp-sm);
  font-weight: 500; color: hsl(134 56% 24%);
}

:is(.phone-number-container) {
  position: relative; padding: var(--sp-md);
  border: .125rem solid var(--c-ok); border-radius: var(--rd-8); background: var(--sf);
}

:is(.phone-number-display) {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-md);
}

.phone-number {
  flex: 1; padding: var(--sp-sm) var(--sp-md);
  border: .0625rem solid var(--bd-inp); border-radius: var(--rd-4);
  font-family: var(--ff-mono); font-size: var(--t-lg); font-weight: 700;
  letter-spacing: .0625rem; text-align: center;
  color: hsl(134 56% 24%); background: var(--sf2); user-select: all;
}

.copy-phone-btn {
  display: flex; align-items: center; justify-content: center;
  min-width: 2.75rem; height: 2.75rem; padding: var(--sp-sm) var(--sp-md);
  border: .0625rem solid var(--c-ok); border-radius: var(--rd-4);
  color: var(--fg-w); background: var(--c-ok); cursor: pointer;
  transition: all .3s ease;
}

:is(.copy-phone-btn):hover {
  border-color: hsl(134 61% 35%); box-shadow: 0 .125rem .5rem rgb(40 167 69 / .3);
  background: hsl(134 55% 33%); transform: translateY(-.0625rem);
}

:is(.copy-phone-btn):active { transform: translateY(0px) }
:is(.copy-phone-btn) i { font-size: var(--t-inp) }

:is(.copy-success-indicator) {
  display: flex; align-items: center; gap: var(--sp-xs);
  position: absolute; top: -.5rem; right: -.5rem; z-index: 10;
  padding: var(--sp-xs) var(--sp-sm); border: .0625rem solid hsl(134 30% 80%);
  border-radius: var(--rd-16); font-size: var(--t-sm); white-space: nowrap;
  color: hsl(134 56% 24%); background: hsl(134 41% 88%);
  animation: scaleIn .3s ease-out;
}

/* -------------------------------------------------------------------
   COPY MESSAGE BUTTON
   ------------------------------------------------------------------- */
:is(.copy-message-container) {
  display: flex; justify-content: flex-start; margin-top: var(--sp-sm);
}

:is(.copy-message-btn) {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-xs);
  min-width: 4.375rem; padding: var(--sp-xs) var(--sp-sm);
  border-radius: var(--rd-16); font-size: var(--t-sm); transition: all .3s ease;
}

:is(.copy-message-btn):hover {
  box-shadow: 0 .125rem .5rem rgb(0 0 0 / .15); transform: translateY(-.0625rem);
}

:is(.copy-message-btn):active { transform: translateY(0px) }
:is(.copy-message-btn) i { font-size: var(--t-xs) }
:is(.copy-message-btn).btn-success { animation: copyBounce .3s ease-out }

/* -------------------------------------------------------------------
   RECALL / RECALLED
   ------------------------------------------------------------------- */
.recall-btn-inline {
  padding: .125rem var(--sp-sm); border-radius: var(--rd-16);
  font-size: var(--t-xs); opacity: .6; transition: opacity 200ms;
}

.recall-btn-inline:hover { opacity: 1 }
.recalled-message { opacity: .6 }
.recall-info { font-size: var(--t-sm) }

/* -------------------------------------------------------------------
   LOADING & EMPTY
   ------------------------------------------------------------------- */
.loading {
  display: inline-block; width: 1.25rem; height: 1.25rem;
  border: .1875rem solid rgb(255 255 255 / .3); border-radius: var(--rd-o);
  border-block-start-color: var(--fg-w); animation: spin 1s ease-in-out infinite;
}

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; padding: var(--sp-3x); text-align: center; color: hsl(208 7% 46%);
}

.empty-state i { margin-bottom: var(--sp-xl); opacity: .5 }

/* -------------------------------------------------------------------
   CHAT LOADING MASK
   ------------------------------------------------------------------- */
.chat-loading-mask {
  display: flex; align-items: center; justify-content: center;
  position: fixed; inset: 0; z-index: var(--z-top);
  background-color: var(--wa-bg); background-image: var(--bg-desk);
  background-size: cover; background-position: center; background-repeat: no-repeat;
  transition: opacity .4s ease, visibility .4s ease;
}

:is(.chat-loading-mask).hidden {
  opacity: 0; visibility: hidden; pointer-events: none;
}

.loading-content {
  padding: var(--sp-3x) 3.75rem; border-radius: var(--rd-16);
  text-align: center; color: hsl(0 0% 40%);
  background: rgb(255 255 255 / .9); box-shadow: 0 .25rem 1.25rem rgb(0 0 0 / .1);
}

.loading-text {
  margin: 0; font-size: var(--t-inp); font-weight: 500; color: hsl(0 0% 40%);
}

.spinner-border { width: 3rem !important; height: 3rem !important }

/* -------------------------------------------------------------------
   ADMIN INTERVENTION BANNER
   ------------------------------------------------------------------- */
:is(.admin-intervention-banner) {
  position: relative; z-index: 1000; padding: var(--sp-sm) 0;
  font-size: var(--t-md); font-weight: 500; color: var(--fg-w);
  background: linear-gradient(135deg, hsl(38 90% 51%), hsl(33 73% 44%));
  box-shadow: 0 .125rem .5rem rgb(245 158 11 / .3);
  border-bottom: .0625rem solid rgb(255 255 255 / .2);
  animation: bannerSlide .3s var(--ez-out);
}

:is(.admin-intervention-banner) i { color: rgb(255 255 255 / .9) }

:is(.admin-intervention-banner) strong {
  color: var(--fg-w); text-shadow: 0 .0625rem .125rem rgb(0 0 0 / .2);
}

:is(.workspace).admin-intervention { padding-top: 0 }
:is(.workspace).admin-intervention .row { height: calc(100vh - 2.5rem) }

/* -------------------------------------------------------------------
   WORKSPACE & TRANSITIONS
   ------------------------------------------------------------------- */

/* -------------------------------------------------------------------
   UTILITY CLASSES
   ------------------------------------------------------------------- */

/* -------------------------------------------------------------------
   DROPDOWN / LANGUAGE SELECTOR
   ------------------------------------------------------------------- */
.dropdown-toggle::after { display: none !important }

.dropdown button {
  display: flex !important; align-items: center !important; justify-content: center !important;
  border-color: var(--bd); transition: all 200ms ease;
}

.dropdown button i {
  display: inline-flex; align-items: center; justify-content: center;
}

:is(.dropdown) button:hover {
  border-color: var(--wa-grn); color: var(--wa-grn); background-color: var(--sf2);
  box-shadow: 0 .125rem .5rem rgb(37 211 102 / .2); transform: translateY(-.0625rem);
}

:is(.dropdown) button:focus {
  border-color: var(--wa-grn); box-shadow: 0 0 0 .2rem rgb(37 211 102 / .25);
}

#languageSelector {
  min-width: 10rem; margin-top: .3125rem;
  border: .0625rem solid rgb(0 0 0 / .1); border-radius: var(--rd-8);
  font-size: var(--t-md); box-shadow: var(--elev-3);
}

#languageSelector :is(.dropdown-item) {
  padding: .625rem var(--sp-lg); font-size: var(--t-md); transition: all 200ms ease;
}

#languageSelector :is(.dropdown-item):hover {
  color: var(--wa-grn); background-color: var(--sf2); transform: translateX(.1875rem);
}

#languageSelector :is(.dropdown-item).active {
  color: var(--fg-w); background-color: var(--wa-grn);
}

/* -------------------------------------------------------------------
   GLOBAL SCROLLBAR (non-chat)
   ------------------------------------------------------------------- */
::-webkit-scrollbar { width: .375rem }
::-webkit-scrollbar-track { background: hsl(0 0% 95%) }
::-webkit-scrollbar-thumb { border-radius: var(--rd-2); background: hsl(0 0% 76%) }
::-webkit-scrollbar-thumb:hover { background: hsl(0 0% 66%) }

/* ===================================================================
   KEYFRAMES
   =================================================================== */
@keyframes pulse    { 0%, 100% { opacity: 1 } 50% { opacity: .5 } }
@keyframes typing   { 0%, 100% { opacity: 1 } 30% { opacity: .4 } 60% { opacity: 1 } }
@keyframes spin     { to { transform: rotate(1turn) } }


@keyframes msgSlideIn {
  from { opacity: 0; transform: translateY(.9375rem) scale(.95) }
  to   { opacity: 1; transform: none }
}

@keyframes msgAppear {
  from { opacity: 0; transform: translateY(.5rem) scale(.98) }
  to   { opacity: 1; transform: none }
}

@keyframes msgFadeOut {
  from { opacity: 1; transform: none }
  to   { opacity: 0; transform: translateY(-.625rem) scale(.98) }
}

@keyframes msgRestore {
  from { opacity: 0; transform: translateX(-1.25rem) }
  to   { opacity: 1; transform: none }
}




@keyframes btnsSlideIn {
  from { opacity: 0; transform: translateY(1.25rem) }
  to   { opacity: 1; transform: none }
}

@keyframes copyBounce {
  0%   { transform: scale(1) }
  50%  { transform: scale(1.1) }
  100% { transform: scale(1) }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(.8) }
  to   { opacity: 1; transform: none }
}

@keyframes hintFade {
  0%   { opacity: 0; transform: translateX(-50%) translateY(.625rem) }
  15%  { opacity: 1; transform: translateX(-50%) translateY(0) }
  85%  { opacity: 1; transform: translateX(-50%) translateY(0) }
  100% { opacity: 0; transform: translateX(-50%) translateY(-.625rem) }
}



@keyframes bannerSlide {
  from { opacity: 0; transform: translateY(-100%) }
  to   { opacity: 1; transform: none }
}


/* ===================================================================
   MEDIA: prefers-color-scheme dark
   =================================================================== */
@media all and (prefers-color-scheme: dark) {
  .btn-secondary:is(.rich-button) {
    border-color: rgb(255 255 255 / .1); color: hsl(210 17% 98%);
    background: linear-gradient(135deg, hsl(210 7% 31%), hsl(210 10% 23%));
  }
}

/* ===================================================================
   MEDIA: prefers-contrast high
   =================================================================== */
@media all and (prefers-contrast: high) {
  :is(.phone-number-container) { border-width: .1875rem }
  .phone-number { border-width: .125rem; color: hsl(0 0% 0%); background: hsl(0 0% 100%) }
  .copy-phone-btn { border-width: .125rem }
}

/* ===================================================================
   MEDIA: desktop ≥ 769px
   =================================================================== */
@media (min-width: 769px) {
  .chat-input {
    position: relative !important; inset: auto !important;
    z-index: auto !important; margin: 0 !important;
    min-height: 3.75rem !important; box-shadow: none !important;
    flex-direction: column !important;
  }
}

/* ===================================================================
   MEDIA: tablet  769px – 1024px
   =================================================================== */
@media (max-width: 1024px) and (min-width: 769px) {
  .chat-messages { background-image: var(--bg-mob); background-attachment: scroll }
}

/* ===================================================================
   MEDIA: mobile ≤ 768px
   =================================================================== */
@media all and (max-width: 768px) {
  .sidebar { min-height: auto }
  .chat-window { height: 100vh; border-radius: 0 }
  .message-bubble { max-width: 85% }
  :is(.stats-card) .stats-number { font-size: 2rem }
  .conversation-item { padding: var(--sp-md) }
  .quick-reply-btn { padding: .3125rem .75rem; font-size: .8em }

  .chat-messages {
    height: calc(100vh - 12.5rem) !important;
    height: calc(var(--vh, 1vh) * 100 - 12.5rem) !important;
    margin-top: 4.375rem !important; margin-bottom: 0 !important;
    padding: .9375rem !important; padding-bottom: 6.25rem !important;
    background-image: var(--bg-mob); background-attachment: scroll;
    overflow-y: auto !important; -webkit-overflow-scrolling: touch !important;
  }

  .chat-header {
    position: fixed !important; inset: 0 0 auto 0 !important;
    z-index: var(--z-hdr) !important; height: 4.375rem !important;
    padding: .9375rem var(--sp-xl) !important;
    background: var(--sf) !important; border-bottom: .0625rem solid var(--bd-lt) !important;
  }

  body .chat-input {
    display: flex !important; flex-direction: column !important;
    position: fixed !important; inset: auto 0 0 0 !important;
    z-index: var(--z-inp) !important; width: 100% !important;
    min-height: 4rem !important; height: auto !important;
    padding: var(--sp-md) var(--sp-lg) !important; margin: 0 !important;
    border-top: .0625rem solid var(--bd-lt) !important;
    background: var(--sf) !important;
    box-shadow: 0 -.125rem .625rem rgb(0 0 0 / .15) !important;
  }

  .input-group { margin: 0 !important; gap: var(--sp-sm) !important }

  :is(.input-group) .form-control {
    height: 2.5rem !important; font-size: var(--t-inp) !important;
    padding: .625rem 2.5rem .625rem var(--sp-md) !important;
    border: .0625rem solid hsl(0 0% 87%) !important; margin: 0 !important;
  }

  .whatsapp-send-btn {
    width: 2.5rem !important; height: 2.5rem !important;
    min-width: 2.5rem !important; min-height: 2.5rem !important;
    padding: 0 !important; margin: 0 !important;
  }

  .emoji-btn { right: .5rem !important; width: 1.5rem !important; height: 1.5rem !important }
  .chat-window { margin: 0 !important; padding: 0 !important }

  :is(.chat-container .row, .chat-container .col-12) {
    margin: 0 !important; padding: 0 !important;
  }

  :is(body, html) { margin: 0 !important; padding: 0 !important }

  .chat-container {
    min-height: 100vh; min-height: calc(var(--vh, 1vh) * 100);
    height: 100vh; height: calc(var(--vh, 1vh) * 100); overflow: hidden;
  }

  .chat-window {
    position: relative; height: 100vh; height: calc(var(--vh, 1vh) * 100);
  }

  body {
    width: 100%; height: 100vh; height: calc(var(--vh, 1vh) * 100); overflow-x: hidden;
  }

  .typing-indicator { font-size: .75rem; padding: 4px 8px }

  .rich-input {
    height: 2.625rem; padding: .625rem var(--sp-md); font-size: var(--t-inp);
  }

  :is(.rich-input-container) { padding: 0; margin-bottom: var(--sp-sm) }
  .rich-input-label { padding-left: 0; font-size: .8125rem }

  :is(.phone-validation-message) {
    font-size: var(--t-sm); padding: .3125rem 0; margin-top: .375rem !important;
  }

  .rich-input-submit {
    min-width: 6.25rem; min-height: 2.5rem; padding: .625rem var(--sp-xl); font-size: .8125rem;
  }

  .rich-buttons { max-width: 100%; margin-top: var(--sp-sm) }

  .rich-button {
    min-height: 2.5rem; padding: .625rem var(--sp-lg); font-size: .8125rem;
  }

  :is(.image-message-container) { max-width: 14rem }
  .message-image { max-height: 14rem }
  .rich-image { max-width: 14rem; max-height: 14rem }
  .message-bubble :is(.rich-image) { max-width: 12rem; max-height: 12rem }
  .visitor-right:is(.message) .image-message-container { max-width: 14rem }
  .visitor-right:is(.message) .message-image { max-width: 14rem; max-height: 14rem }
  .img-overlay-body { padding: 3.75rem .9375rem .9375rem }

  .img-overlay-x {
    top: .9375rem; right: .9375rem; width: 2.5rem; height: 2.5rem; font-size: var(--t-inp);
  }

  .img-overlay-pic { border-radius: var(--rd-4) }
  .img-overlay-hint { bottom: .9375rem; padding: .375rem .75rem; font-size: var(--t-xs) }
  .chat-loading-mask { background-image: var(--bg-mob) }
  .loading-content { padding: 1.875rem var(--sp-3x) }
  .spinner-border { width: 2.5rem !important; height: 2.5rem !important }
  .loading-text { font-size: var(--t-md) }
  :is(.phone-input-message) { padding: var(--sp-md); margin: .375rem 0 }
  .phone-number { padding: .375rem .625rem; font-size: var(--t-inp) }
  .copy-phone-btn { min-width: 2.5rem; height: 2.5rem; padding: .375rem .625rem }
  :is(.copy-success-indicator) { padding: .1875rem .375rem; font-size: var(--t-xs) }
}

/* ===================================================================
   MEDIA: small mobile ≤ 480px
   =================================================================== */
@media all and (max-width: 480px) {
  .chat-messages {
    height: calc(100vh - 9.375rem) !important; padding: .625rem !important;
    padding-bottom: 5.625rem !important; background-image: var(--bg-mob);
    background-attachment: scroll; background-size: cover;
  }

  .chat-input { padding: var(--sp-md) !important }

  :is(.input-group) .form-control {
    height: 2.5rem !important; font-size: var(--t-inp) !important;
    padding: .625rem 2.5rem .625rem var(--sp-md) !important;
  }

  .whatsapp-send-btn {
    width: 2.5rem !important; height: 2.5rem !important;
    min-width: 2.5rem !important; min-height: 2.5rem !important;
  }

  :is(.whatsapp-send-btn) svg { width: .875rem !important; height: .875rem !important }
}
