/* ==========================================================
   CHARM AFRIKA STUDIOS — AI / WHATSAPP CHAT
   Production stylesheet
   ========================================================== */

.charm-wa{
  position:fixed;
  right:22px;
  bottom:22px;
  z-index:99990;
  font-family:"DM Sans",system-ui,sans-serif;
}


/* ==========================================================
   LAUNCH BUTTON
   ========================================================== */

.charm-wa-launch{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:9px;

  border:1px solid rgba(0,0,0,.06);
  border-radius:999px;

  padding:10px 15px 10px 11px;

  background:#1f8f54;
  color:#fff;

  box-shadow:
    0 16px 38px rgba(0,0,0,.18);

  font:800 12px/1 "DM Sans",sans-serif;

  cursor:pointer;

  transition:
    transform .18s ease,
    box-shadow .18s ease,
    background .18s ease;
}

.charm-wa-launch:hover{
  transform:translateY(-2px);

  box-shadow:
    0 20px 44px rgba(0,0,0,.22);
}

.charm-wa-launch:active{
  transform:translateY(0);
}

.charm-wa-launch:focus-visible{
  outline:none;

  box-shadow:
    0 0 0 3px rgba(255,255,255,.95),
    0 0 0 6px rgba(31,143,84,.45),
    0 20px 44px rgba(0,0,0,.22);
}

.charm-wa-icon{
  width:28px;
  height:28px;

  border-radius:50%;

  display:grid;
  place-items:center;

  background:#fff;
  color:#1f8f54;

  font-size:15px;
  font-weight:900;

  flex:none;
}


/* ==========================================================
   PANEL
   ========================================================== */

.charm-wa-panel{
  position:absolute;

  right:0;
  bottom:60px;

  width:min(390px,calc(100vw - 28px));

  background:#fff;

  border:1px solid rgba(17,17,17,.09);

  border-radius:22px;

  box-shadow:
    0 28px 80px rgba(0,0,0,.20),
    0 6px 20px rgba(0,0,0,.08);

  overflow:hidden;

  opacity:0;
  visibility:hidden;

  transform:
    translateY(10px)
    scale(.98);

  transform-origin:
    bottom right;

  transition:
    opacity .18s ease,
    transform .18s ease,
    visibility .18s ease;

  will-change:
    transform,
    opacity;
}

.charm-wa.is-open .charm-wa-panel{
  opacity:1;
  visibility:visible;

  transform:
    translateY(0)
    scale(1);
}


/* ==========================================================
   HEADER
   ========================================================== */

.charm-wa-head{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px;

  padding:16px 16px 14px;

  background:#1f8f54;
  color:#fff;
}

.charm-wa-head div{
  display:grid;
  gap:3px;
  min-width:0;
}

.charm-wa-head strong{
  font-size:14px;
  line-height:1.25;
  font-weight:800;
  letter-spacing:-.01em;
}

.charm-wa-head span{
  font-size:10px;
  line-height:1.35;
  opacity:.80;
}

.charm-wa-close{
  width:30px;
  height:30px;

  flex:none;

  border:0;
  border-radius:50%;

  background:rgba(255,255,255,.16);
  color:#fff;

  display:grid;
  place-items:center;

  font-size:20px;
  line-height:1;

  cursor:pointer;

  transition:
    background .16s ease,
    transform .16s ease;
}

.charm-wa-close:hover{
  background:rgba(255,255,255,.24);
  transform:scale(1.04);
}

.charm-wa-close:active{
  transform:scale(.96);
}

.charm-wa-close:focus-visible{
  outline:
    2px solid rgba(255,255,255,.95);
  outline-offset:2px;
}


/* ==========================================================
   CHAT THREAD
   ========================================================== */

.charm-wa-thread{
  height:340px;

  overflow-y:auto;
  overflow-x:hidden;

  padding:14px;

  background:
    linear-gradient(
      180deg,
      #eef1ed 0%,
      #edf0ec 100%
    );

  scroll-behavior:smooth;

  overscroll-behavior:contain;

  scrollbar-width:thin;
  scrollbar-color:
    rgba(67,73,69,.35)
    transparent;
}

.charm-wa-thread::-webkit-scrollbar{
  width:7px;
}

.charm-wa-thread::-webkit-scrollbar-track{
  background:transparent;
}

.charm-wa-thread::-webkit-scrollbar-thumb{
  background:
    rgba(67,73,69,.28);

  border-radius:999px;
}

.charm-wa-thread::-webkit-scrollbar-thumb:hover{
  background:
    rgba(67,73,69,.40);
}


/* ==========================================================
   MESSAGE BUBBLES
   ========================================================== */

.charm-wa-bubble{
  max-width:84%;

  padding:10px 12px;

  margin:0 0 9px;

  border-radius:16px;

  font-size:12px;
  line-height:1.52;

  white-space:pre-wrap;
  overflow-wrap:anywhere;

  animation:
    charmBubbleIn .18s ease both;
}

@keyframes charmBubbleIn{
  from{
    opacity:0;
    transform:
      translateY(4px)
      scale(.99);
  }

  to{
    opacity:1;
    transform:
      translateY(0)
      scale(1);
  }
}

.charm-wa-bubble.bot{
  background:#fff;
  color:#24262a;

  border-radius:
    15px 15px 15px 5px;

  box-shadow:
    0 3px 12px rgba(0,0,0,.035);
}

.charm-wa-bubble.user{
  margin-left:auto;

  background:#d8f3de;
  color:#15341e;

  border-radius:
    15px 15px 5px 15px;

  box-shadow:
    0 2px 9px rgba(0,0,0,.025);
}


/* ==========================================================
   TYPING INDICATOR
   ========================================================== */

.charm-wa-bubble.typing{
  width:52px;

  padding:12px;

  min-height:18px;

  display:flex;
  align-items:center;
}

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

.charm-wa-dots i{
  width:5px;
  height:5px;

  border-radius:50%;

  background:#90959a;

  animation:
    waDot 900ms infinite;
}

.charm-wa-dots i:nth-child(2){
  animation-delay:120ms;
}

.charm-wa-dots i:nth-child(3){
  animation-delay:240ms;
}

@keyframes waDot{
  0%,
  60%,
  100%{
    opacity:.3;
    transform:translateY(0);
  }

  30%{
    opacity:1;
    transform:translateY(-2px);
  }
}


/* ==========================================================
   AI GALLERY
   ========================================================== */

.charm-ai-samples{
  display:grid;

  grid-template-columns:
    repeat(2,minmax(0,1fr));

  gap:8px;

  width:100%;
  max-width:100%;

  margin:2px 0 11px;

  animation:
    charmGalleryIn .2s ease both;
}

@keyframes charmGalleryIn{
  from{
    opacity:0;
    transform:translateY(5px);
  }

  to{
    opacity:1;
    transform:translateY(0);
  }
}


/* ==========================================================
   GALLERY TILE
   ========================================================== */

.charm-ai-sample{
  position:relative;

  display:block;

  width:100%;
  min-width:0;

  padding:0;

  border:
    1px solid rgba(17,17,17,.07);

  border-radius:14px;

  overflow:hidden;

  background:#111;

  color:inherit;

  appearance:none;

  text-align:left;

  cursor:pointer;

  box-shadow:
    0 5px 16px rgba(0,0,0,.055);

  transition:
    transform .22s cubic-bezier(.2,.7,.2,1),
    box-shadow .22s ease,
    border-color .22s ease;
}

.charm-ai-sample:hover{
  transform:
    translateY(-1px);

  border-color:
    rgba(17,17,17,.13);

  box-shadow:
    0 10px 24px rgba(0,0,0,.10);
}

.charm-ai-sample:active{
  transform:
    scale(.985);
}

.charm-ai-sample:focus-visible{
  outline:none;

  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px rgba(31,143,84,.55),
    0 10px 24px rgba(0,0,0,.10);
}


/* ==========================================================
   IMAGE
   ========================================================== */

.charm-ai-sample img{
  display:block;

  width:100%;

  height:auto;

  aspect-ratio:1 / 1;

  object-fit:cover;

  object-position:center;

  background:
    #ececec;

  transform:
    scale(1);

  transition:
    transform .28s cubic-bezier(.2,.7,.2,1),
    filter .28s ease;
}

.charm-ai-sample:hover img{
  transform:
    scale(1.035);
}


/* ==========================================================
   IMAGE TITLE
   ========================================================== */

.charm-ai-sample-title{
  position:absolute;

  left:0;
  right:0;
  bottom:0;

  z-index:2;

  padding:
    30px 9px 9px;

  color:#fff;

  font:
    700 10px/1.25
    "DM Sans",
    system-ui,
    sans-serif;

  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;

  background:
    linear-gradient(
      to top,
      rgba(0,0,0,.82),
      rgba(0,0,0,.38) 44%,
      rgba(0,0,0,0) 100%
    );

  pointer-events:none;
}


/* ==========================================================
   +N / MORE TILE
   ========================================================== */

.charm-ai-sample.is-more{
  isolation:isolate;
}

.charm-ai-sample.is-more img{
  filter:
    brightness(.38);
}

.charm-ai-sample.is-more:hover img{
  filter:
    brightness(.30);
}

.charm-ai-more-overlay{
  position:absolute;

  inset:0;

  z-index:3;

  display:flex;

  flex-direction:column;

  align-items:center;

  justify-content:center;

  gap:5px;

  color:#fff;

  text-align:center;

  background:
    rgba(0,0,0,.25);

  pointer-events:none;

  transition:
    background .2s ease;
}

.charm-ai-sample.is-more:hover
.charm-ai-more-overlay{
  background:
    rgba(0,0,0,.34);
}

.charm-ai-more-overlay strong{
  display:block;

  font:
    750 27px/1
    "DM Sans",
    system-ui,
    sans-serif;

  letter-spacing:
    -.045em;
}

.charm-ai-more-overlay span{
  font:
    600 10px/1.25
    "DM Sans",
    system-ui,
    sans-serif;

  opacity:.94;
}


/* ==========================================================
   IMAGE LOAD FAILURE
   ========================================================== */

.charm-ai-sample.image-error{
  background:#ededed;
}

.charm-ai-sample.image-error img{
  opacity:0;
}

.charm-ai-sample.image-error::after{
  content:"Image unavailable";

  position:absolute;

  inset:0;

  display:flex;

  align-items:center;
  justify-content:center;

  color:#777;

  font:
    600 10px/1
    "DM Sans",
    system-ui,
    sans-serif;
}


/* ==========================================================
   SUGGESTIONS
   ========================================================== */

.charm-wa-suggestions{
  display:flex;
  align-items:center;

  gap:7px;

  overflow-x:auto;
  overflow-y:hidden;

  padding:
    9px 12px;

  border-top:
    1px solid rgba(17,17,17,.06);

  background:#fff;

  scrollbar-width:none;
}

.charm-wa-suggestions::-webkit-scrollbar{
  display:none;
}

.charm-wa-suggestion{
  flex:none;

  border:
    1px solid rgba(17,17,17,.08);

  background:#fff;

  color:#24262a;

  border-radius:999px;

  padding:
    8px 10px;

  font:
    700 10px/1
    "DM Sans",
    sans-serif;

  cursor:pointer;

  transition:
    background .16s ease,
    border-color .16s ease,
    transform .16s ease;
}

.charm-wa-suggestion:hover{
  background:#f6f7f6;

  border-color:
    rgba(17,17,17,.15);

  transform:translateY(-1px);
}

.charm-wa-suggestion:active{
  transform:translateY(0);
}

.charm-wa-suggestion:focus-visible{
  outline:none;

  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px rgba(31,143,84,.38);
}


/* ==========================================================
   FORM
   ========================================================== */

.charm-wa-form{
  display:flex;

  align-items:center;

  gap:7px;

  padding:10px;

  border-top:
    1px solid rgba(17,17,17,.08);

  background:#fff;
}

.charm-wa-form input{
  flex:1;

  min-width:0;

  height:41px;

  border:
    1px solid rgba(17,17,17,.10);

  border-radius:999px;

  padding:
    11px 13px;

  outline:none;

  background:#fff;

  color:#24262a;

  font:
    500 12px/1.2
    "DM Sans",
    sans-serif;

  transition:
    border-color .16s ease,
    box-shadow .16s ease,
    background .16s ease;
}

.charm-wa-form input::placeholder{
  color:#8a8e92;
}

.charm-wa-form input:focus{
  border-color:#1f8f54;

  box-shadow:
    0 0 0 3px
    rgba(31,143,84,.10);
}

.charm-wa-form input:disabled{
  opacity:.65;
  cursor:not-allowed;
}


/* ==========================================================
   SEND
   ========================================================== */

.charm-wa-send{
  width:41px;
  height:41px;

  flex:none;

  border:0;

  border-radius:50%;

  background:#1f8f54;

  color:#fff;

  display:grid;
  place-items:center;

  cursor:pointer;

  font:
    900 17px/1
    "DM Sans",
    sans-serif;

  box-shadow:
    0 6px 16px rgba(31,143,84,.16);

  transition:
    transform .16s ease,
    box-shadow .16s ease,
    background .16s ease,
    opacity .16s ease;
}

.charm-wa-send:hover{
  transform:
    translateY(-1px);

  box-shadow:
    0 9px 20px rgba(31,143,84,.22);
}

.charm-wa-send:active{
  transform:scale(.96);
}

.charm-wa-send:focus-visible{
  outline:none;

  box-shadow:
    0 0 0 2px #fff,
    0 0 0 5px rgba(31,143,84,.38);
}

.charm-wa-send:disabled{
  opacity:.45;

  cursor:not-allowed;

  transform:none;

  box-shadow:none;
}


/* ==========================================================
   FOOTER
   ========================================================== */

.charm-wa-foot{
  display:flex;

  justify-content:space-between;
  align-items:center;

  gap:10px;

  padding:
    8px 12px 11px;

  background:#fff;

  color:#74787d;

  font:
    500 9px/1.25
    "DM Sans",
    system-ui,
    sans-serif;
}

.charm-wa-foot > span{
  min-width:0;

  overflow:hidden;

  white-space:nowrap;

  text-overflow:ellipsis;
}

.charm-wa-direct{
  flex:none;

  color:#1f8f54;

  font-weight:800;

  text-decoration:none;

  transition:
    opacity .16s ease;
}

.charm-wa-direct:hover{
  opacity:.72;
}

.charm-wa-direct:focus-visible{
  outline:
    2px solid rgba(31,143,84,.45);

  outline-offset:3px;

  border-radius:4px;
}


/* ==========================================================
   TABLET / MOBILE
   ========================================================== */

@media(max-width:820px){

  .charm-wa{
    right:14px;

    bottom:
      calc(
        82px +
        env(
          safe-area-inset-bottom,
          0px
        )
      );
  }

  .charm-wa-label{
    display:none;
  }

  .charm-wa-launch{
    width:48px;
    height:48px;

    padding:0;

    justify-content:center;
  }

  .charm-wa-icon{
    width:31px;
    height:31px;
  }

  .charm-wa-panel{
    right:0;

    bottom:58px;

    width:
      min(
        390px,
        calc(100vw - 28px)
      );

    border-radius:20px;
  }

  .charm-wa-thread{
    height:
      min(
        56vh,
        380px
      );
  }
}


/* ==========================================================
   SMALL PHONES
   ========================================================== */

@media(max-width:520px){

  .charm-wa{
    right:10px;

    bottom:
      calc(
        76px +
        env(
          safe-area-inset-bottom,
          0px
        )
      );
  }

  .charm-wa-panel{
    right:0;

    bottom:57px;

    width:
      calc(
        100vw - 20px
      );

    max-width:none;

    border-radius:19px;
  }

  .charm-wa-head{
    padding:
      14px 14px 13px;
  }

  .charm-wa-head strong{
    font-size:13px;
  }

  .charm-wa-head span{
    font-size:9px;
  }

  .charm-wa-thread{
    height:
      min(
        58vh,
        370px
      );

    padding:12px;
  }

  .charm-wa-bubble{
    max-width:88%;

    font-size:11.5px;
  }

  .charm-ai-samples{
    gap:6px;

    margin-top:2px;
  }

  .charm-ai-sample{
    border-radius:11px;
  }

  .charm-ai-sample-title{
    padding:
      25px 8px 8px;

    font-size:9px;
  }

  .charm-ai-more-overlay strong{
    font-size:23px;
  }

  .charm-ai-more-overlay span{
    font-size:9px;
  }

  .charm-wa-suggestions{
    padding:
      8px 10px;
  }

  .charm-wa-form{
    padding:9px;
  }

  .charm-wa-form input{
    height:40px;

    font-size:11.5px;
  }

  .charm-wa-send{
    width:40px;
    height:40px;
  }

  .charm-wa-foot{
    padding:
      8px 10px 10px;
  }
}


/* ==========================================================
   VERY SMALL PHONES
   ========================================================== */

@media(max-width:360px){

  .charm-wa-panel{
    width:
      calc(
        100vw - 14px
      );
  }

  .charm-wa{
    right:7px;
  }

  .charm-ai-samples{
    gap:5px;
  }

  .charm-ai-sample-title{
    font-size:8px;
  }
}


/* ==========================================================
   REDUCED MOTION
   ========================================================== */

@media(prefers-reduced-motion:reduce){

  .charm-wa-panel,
  .charm-wa-launch,
  .charm-wa-close,
  .charm-wa-send,
  .charm-wa-suggestion,
  .charm-ai-sample,
  .charm-ai-sample img,
  .charm-ai-more-overlay{
    transition:none !important;
  }

  .charm-wa-bubble,
  .charm-ai-samples{
    animation:none !important;
  }

  .charm-wa-thread{
    scroll-behavior:auto;
  }

}