/* ==== Agroshop AI Widget (floating) ==== */

/* ========== Launcher (button) ========== */
.aiw-launcher{
  position: fixed;
  right: 16px;
  bottom: 50px;
  z-index: 6500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  background-color: #4b5563;
  background-image: url("/static/ai_assistant/al.ff889c72795c.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: #fff;
  box-shadow: 0 12px 30px rgba(0,0,0,.18);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  overflow: visible;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

.aiw-launcher__text{
  display: none;
  line-height: 1;
}

.aiw-launcher::before{
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 0;
  background: rgba(255,255,255,.95);
  pointer-events: none;
}

.aiw-launcher.aiw-launcher--intro{
  animation:
    aiwPop .42s cubic-bezier(.2, 1.2, .2, 1) both,
    aiwWiggle 1.1s ease-in-out .18s both;
}

.aiw-launcher.aiw-launcher--intro::before{
  opacity: 1;
  animation: aiwDot .40s ease-out both;
}

@keyframes aiwPop{
  0%   { transform: scale(0.12); }
  60%  { transform: scale(1.06); }
  100% { transform: scale(1.00); }
}

@keyframes aiwWiggle{
  0%   { transform: translateX(0) rotate(0deg); }
  15%  { transform: translateX(3px) rotate(3deg); }
  30%  { transform: translateX(-3px) rotate(-3deg); }
  45%  { transform: translateX(2px) rotate(2deg); }
  60%  { transform: translateX(-2px) rotate(-2deg); }
  75%  { transform: translateX(1px) rotate(1deg); }
  100% { transform: translateX(0) rotate(0deg); }
}

@keyframes aiwDot{
  0%   { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
  70%  { transform: translate(-50%, -50%) scale(2.2); opacity: .35; }
  100% { transform: translate(-50%, -50%) scale(3.0); opacity: 0; }
}

@media (prefers-reduced-motion: reduce){
  .aiw-launcher.aiw-launcher--intro{ animation: none; }
  .aiw-launcher.aiw-launcher--intro::before{ animation: none; }
}

@media (min-width: 769px){
  .aiw-launcher:hover{
    transform: translateY(-2px);
    box-shadow: 0 18px 44px rgba(0,0,0,.26);
    filter: brightness(1.02);
  }
  .aiw-launcher:active{
    transform: translateY(0);
    box-shadow: 0 12px 30px rgba(0,0,0,.18);
    filter: brightness(0.99);
  }
  .aiw-launcher:focus-visible{
    outline: none;
    box-shadow: 0 0 0 3px rgba(28,150,117,.22), 0 18px 44px rgba(0,0,0,.22);
  }
}

/* ========== Panel (chat) ========== */
.aiw{
  position: fixed;
  right: 16px;
  bottom: 72px;
  z-index: 6501;
  width: min(440px, calc(100vw - 32px));
  height: min(680px, calc(100dvh - 118px));
  display: none;
  flex-direction: column;
  overflow: hidden;

  background: rgba(255,255,255,.97);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(20,35,60,.14);
  border-radius: 18px;
  box-shadow: 0 20px 55px rgba(15,23,42,.24);
}

.aiw.aiw--open{
  display: flex;
}

.aiw__header{
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  flex: 0 0 auto;
  border-bottom: 1px solid rgba(0,0,0,.06);
  background: linear-gradient(180deg,#ffffff 0%,#f5f8fb 100%);
}

.aiw__title{
  font-family: "GTEestiPro","Arial",sans-serif;
  font-size: 13px;
  font-weight: 900;
  color: #232323;
}

.aiw__close{
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: rgba(0,0,0,.06);
  cursor: pointer;
  font-size: 20px;
  line-height: 34px;
}

/* ===== quick buttons ===== */
.aiw__quick{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 8px 12px;
  flex: 0 0 auto;
  border-bottom: 1px solid rgba(0,0,0,.06);
  background: #eff0f0;
}

.aiw__chip{
  width: 100%;
  white-space: normal;
  text-align: center;
  padding: 8px 10px;
  cursor: pointer;

  border: 1px solid rgba(28,150,117,.35);
  background: #fff;
  color: #4b5563;
  border-radius: 12px;

  font-family: "GTEestiPro","Arial",sans-serif;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.aiw__meta{
  padding: 6px 12px;
  font-size: 12px;
  color: #666;
  background: #fff;
}

/* ===== log / messages ===== */
.aiw__log{
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 12px 12px;
  font-size: 13px;
  color: #4b5563;

  background: #ebfff8;
  background-image: url("/static/ai_assistant/chat-pattern.c0ca44179409.svg");
  background-size: 260px;
  background-repeat: repeat;
}

.aiw__msg{
  max-width: 92%;
  margin: 0 0 10px 0;
  padding: 10px 12px;
  line-height: 1.35;
  word-break: break-word;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,.06);
  box-shadow: 0 6px 18px rgba(0,0,0,.06);
}

.aiw__msg--assistant{
  background: #ffffff;
  border: 1px solid rgba(20,35,60,.08);
}

.aiw__msg--user{
  margin-left: auto;
  background: #eefaf4;
  border: 1px solid rgba(27,150,117,.16);
}

.aiw__link{
  color: #1c9675;
  font-weight: 800;
  text-decoration: underline;
}

/* ===== file upload ===== */
.aiw__file{
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 12px;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,.06);
}

.aiw__file input{
  display: none;
}

.aiw__file-btn{
  flex: 0 0 auto;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(28,150,117,.28);
  background: #ffffff;
  color: #1f6f5d;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.aiw__file-status{
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #64748b;
  font-size: 12px;
}

.aiw__file--ready .aiw__file-btn{
  background: #dff8e8;
  border-color: rgba(22,163,74,.45);
  color: #166534;
}

.aiw__file--ready .aiw__file-status{
  color: #166534;
  font-weight: 700;
}

.aiw__file--error .aiw__file-btn{
  background: #fff1f2;
  border-color: rgba(225,29,72,.35);
  color: #9f1239;
}

.aiw__file--error .aiw__file-status{
  color: #9f1239;
  font-weight: 800;
}

/* ===== input ===== */
.aiw__input{
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 0 12px 12px;
  border-top: 0;
  background: #fff;
}

.aiw__input input{
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,.16);
  font-size: 14px;
}

.aiw__input button{
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 0;
  background: #4b5563;
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}


/* === AI MOBILE RESPONSIVE FIX v57 === */
@media (max-width: 768px){
  .aiw-launcher{
    right: 14px;
    bottom: calc(86px + env(safe-area-inset-bottom, 0px));
    z-index: 6502;
    pointer-events: auto;
    touch-action: manipulation;
  }

  .aiw{
    left: 10px;
    right: 10px;
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    top: auto;
    width: auto;
    height: min(82dvh, 720px);
    max-height: calc(100dvh - 96px);
    display: none;
    border-radius: 22px;
    overflow: hidden;
  }

  .aiw.aiw--open{
    display: flex;
  }

  .aiw__header{
    min-height: 38px;
    padding: 0 12px;
    align-items: center;
  }

  .aiw__title{
    font-size: 16px;
    line-height: 1.05;
    font-weight: 900;
  }

  .aiw__close{
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border-radius: 12px;
    line-height: 36px;
    font-size: 22px;
  }

  .aiw__quick{
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px 14px;
    max-height: 64px;
    overflow-y: auto;
  }

  .aiw__chip{
    min-height: 46px;
    padding: 10px 12px;
    font-size: 15px;
    line-height: 1.15;
    border-radius: 14px;
  }

  .aiw__meta{
    padding: 8px 14px;
    font-size: 14px;
    line-height: 1.25;
  }

  .aiw__log{
    flex: 1 1 auto;
    min-height: 320px;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 14px;
  }

  .aiw__file{
    padding: 9px 14px 0;
  }

  .aiw__file-btn{
    height: 36px;
    border-radius: 13px;
    font-size: 14px;
  }

  .aiw__file-status{
    font-size: 13px;
  }

  .aiw__msg{
    max-width: 94%;
    margin-bottom: 10px;
    padding: 11px 13px;
    font-size: 15px;
    line-height: 1.35;
    border-radius: 16px;
  }

  .aiw__input{
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .aiw__input input{
    min-width: 0;
    height: 46px;
    padding: 0 12px;
    font-size: 16px;
    border-radius: 15px;
  }

  .aiw__input button{
    height: 46px;
    min-width: 108px;
    padding: 0 14px;
    font-size: 15px;
    border-radius: 15px;
  }
}

@media (max-width: 390px){
  .aiw{
    left: 8px;
    right: 8px;
    height: min(70dvh, 610px);
    max-height: calc(100dvh - 108px);
  }

  .aiw__header{
    min-height: 40px;
    padding: 1px 10px;
  }

  .aiw__title{
    font-size: 15px;
  }

  .aiw__close{
    width: 34px;
    height: 34px;
    flex-basis: 34px;
    line-height: 34px;
  }

  .aiw__quick{
    max-height: 68px;
    padding: 8px 12px;
  }

  .aiw__log{
    min-height: 235px;
    max-height: none;
  }

  .aiw__input{
    padding-left: 12px;
    padding-right: 12px;
  }

  .aiw__input button{
    min-width: 96px;
    font-size: 14px;
  }
}


/* === AI answer action buttons === */
.aiw__msg-text{
  white-space: pre-line;
}

.aiw__link-buttons,
.aiw__cta-wrap{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.aiw__link-btn,
.aiw__cta-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg,#ff9f1c 0%,#f97316 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.15;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(249,115,22,.28);
}

.aiw__link-btn:hover,
.aiw__cta-btn:hover{
  filter: brightness(1.03);
  transform: translateY(-1px);
}

.aiw__file-btn{
  min-height: 32px;
  line-height: 1;
}

.aiw__file-status{
  line-height: 1.2;
}


/* === AI green place listing button === */
.aiw__cta-btn--place-ad{
  background: linear-gradient(180deg,#22c55e 0%,#16a34a 100%);
  box-shadow: 0 8px 18px rgba(22,163,74,.28);
}
