/* ============================================================
   Karadeniz Emlak — Floating WP + AI Asistan (Aylin)
   Mobile-first, hem mobil hem PC'de premium görünüm
   ============================================================ */

/* ---------- WhatsApp (sol alt) ---------- */
.ke-wa{
  position: fixed !important;
  left: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 51px; height: 51px;
  background: #25D366;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  z-index: 99990;
  box-shadow: 0 14px 36px -10px rgba(37,211,102,.55), 0 4px 12px rgba(0,0,0,.18);
  cursor: pointer;
  text-decoration: none;
  transition: transform .25s cubic-bezier(.16,1,.3,1), box-shadow .25s;
  -webkit-tap-highlight-color: transparent;
  transform: translateZ(0);  /* yeni katman → fixed garantilenir */
  -webkit-transform: translateZ(0);
}
.ke-wa::before{
  content:'';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: #25D366;
  opacity: .35;
  animation: kePulse 2s ease-out infinite;
  z-index: -1;
}
@keyframes kePulse{
  0%{ transform: scale(.85); opacity: .35; }
  100%{ transform: scale(1.35); opacity: 0; }
}
.ke-wa:hover{ transform: translateY(-3px) scale(1.04); }
.ke-wa svg{ width: 24px; height: 24px; }

/* ---------- Sahibinden butonu (WP'nin üstünde, sol alt) ---------- */
.ke-sh{
  position: fixed !important;
  left: 18px;
  bottom: calc(92px + env(safe-area-inset-bottom, 0px));
  width: 51px; height: 51px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  z-index: 99990;
  box-shadow: 0 14px 36px -10px rgba(255,200,0,.55), 0 4px 12px rgba(0,0,0,.18);
  transition: transform .25s cubic-bezier(.16,1,.3,1), box-shadow .25s;
  -webkit-tap-highlight-color: transparent;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  overflow: hidden;
}
.ke-sh:hover{ transform: translateY(-3px) scale(1.04); }
.ke-sh{ background: transparent; box-shadow: 0 14px 36px -10px rgba(255,237,0,.65), 0 4px 12px rgba(0,0,0,.18); }
.ke-sh::before{
  content:'';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: #ffed00;
  opacity: .4;
  animation: keShPulse 2s ease-out infinite;
  z-index: -1;
}
@keyframes keShPulse{
  0%{ transform: scale(.85); opacity: .4; }
  100%{ transform: scale(1.35); opacity: 0; }
}
.ke-sh{
  background: #ffed00;
}
.ke-sh img{
  width: 60%; height: 60%;
  object-fit: contain;
  display: block;
  -webkit-mask-image: radial-gradient(circle, #000 50%, transparent 52%);
          mask-image: radial-gradient(circle, #000 50%, transparent 52%);
}
@media (max-width: 559px){
  .ke-sh{
    left: 14px;
    width: 47px; height: 47px;
    bottom: calc(75px + env(safe-area-inset-bottom, 0px));
  }
}

/* ---------- AI Chat trigger (sağ alt) ---------- */
.ke-chat-fab{
  position: fixed !important;
  right: 18px;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  width: 51px; height: 51px;
  background: linear-gradient(135deg, var(--gold, #c5a55a), var(--gold-deep, #b18b3a));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  z-index: 99990;
  box-shadow: 0 14px 36px -10px rgba(177,139,58,.55), 0 4px 12px rgba(0,0,0,.18);
  cursor: pointer;
  border: 0;
  transition: transform .25s cubic-bezier(.16,1,.3,1);
  -webkit-tap-highlight-color: transparent;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  padding: 0;
}
.ke-chat-fab:hover{ transform: translateY(-3px) scale(1.04); }
.ke-chat-fab svg{ width: 22px; height: 22px; }
.ke-chat-fab .ke-dot{
  position: absolute;
  top: 2px; right: 4px;
  width: 12px; height: 12px;
  background: #ff5252;
  border: 2px solid #fff;
  border-radius: 50%;
}
.ke-chat-fab.open .ke-dot{ display: none; }

/* ---------- Chat paneli ---------- */
.ke-chat-panel{
  position: fixed;
  right: 18px;
  bottom: 90px;
  width: min(380px, calc(100vw - 36px));
  height: min(580px, calc(100vh - 130px));
  background: #fff;
  border-radius: 20px;
  box-shadow:
    0 30px 80px -16px rgba(20,15,5,.4),
    0 6px 18px rgba(0,0,0,.08);
  z-index: 9991;
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  border: 1px solid var(--line-soft, #ece7da);
}
.ke-chat-panel.open{
  display: flex;
  animation: keChatIn .25s cubic-bezier(.16,1,.3,1);
}
@keyframes keChatIn{
  from{ opacity: 0; transform: translateY(12px) scale(.96); }
  to{ opacity: 1; transform: none; }
}

/* Header */
.ke-chat-head{
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #1a1410, #2a221a);
  color: #fff;
  flex: 0 0 auto;
}
.ke-chat-head .ke-av{
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #2a221a url('../img/aylin.png') center/cover;
  flex: 0 0 auto;
  position: relative;
  box-shadow: 0 0 0 2px rgba(197,165,90,.55);
}
.ke-chat-head .ke-av::after{
  content:'';
  position: absolute;
  bottom: -1px; right: -1px;
  width: 12px; height: 12px;
  background: #4ade80;
  border: 2px solid #1a1410;
  border-radius: 50%;
}
.ke-chat-head .ke-info{ flex: 1; min-width: 0; }
.ke-chat-head .ke-name{
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .01em;
}
.ke-chat-head .ke-role{
  font-size: 12px;
  color: #a8a39a;
  margin-top: 2px;
}
.ke-chat-close{
  background: rgba(255,255,255,.08);
  border: 0;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 10px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  line-height: 1;
  transition: background .15s;
}
.ke-chat-close:hover{ background: rgba(255,255,255,.16); }

/* Mesaj alanı */
.ke-chat-body{
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  background: #fafaf7;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}
.ke-chat-body::-webkit-scrollbar{ width: 8px; }
.ke-chat-body::-webkit-scrollbar-thumb{ background: #d6d0bf; border-radius: 8px; }

.ke-msg{
  max-width: 84%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: keMsgIn .2s ease;
}
@keyframes keMsgIn{ from{ opacity: 0; transform: translateY(4px); } to{ opacity: 1; transform: none; } }

.ke-msg.bot{
  background: #fff;
  color: var(--text, #1f1f1f);
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  border: 1px solid var(--line-soft, #ece7da);
}
.ke-msg.user{
  background: linear-gradient(135deg, var(--gold-deep, #b18b3a), #95711a);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 6px;
}

/* Typewriter cursor */
.ke-cursor{
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--gold-deep, #b18b3a);
  margin-left: 1px;
  vertical-align: -2px;
  animation: keCursorBlink 1s steps(2) infinite;
}
@keyframes keCursorBlink{
  0%, 50%{ opacity: 1; }
  51%, 100%{ opacity: 0; }
}
.ke-msg.ke-typing-msg{ white-space: pre-wrap; }
.ke-typed{ white-space: pre-wrap; }

.ke-msg.typing{
  display: inline-flex;
  gap: 4px;
  padding: 14px 16px;
}
.ke-msg.typing span{
  width: 7px; height: 7px;
  background: #b3aa97;
  border-radius: 50%;
  animation: keBounce 1.2s infinite ease-in-out;
}
.ke-msg.typing span:nth-child(2){ animation-delay: .15s; }
.ke-msg.typing span:nth-child(3){ animation-delay: .3s; }
@keyframes keBounce{
  0%,80%,100%{ transform: scale(.6); opacity: .5; }
  40%{ transform: scale(1); opacity: 1; }
}

/* Quick action chips */
.ke-chips{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 0 4px;
}
.ke-chip{
  background: #fff;
  border: 1.5px solid var(--line-soft, #ece7da);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #1f1f1f);
  cursor: pointer;
  transition: all .15s;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.ke-chip:hover{
  border-color: var(--gold, #c5a55a);
  background: rgba(197,165,90,.08);
  color: var(--gold-deep, #b18b3a);
}

/* Input */
.ke-chat-input{
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid var(--line-soft, #ece7da);
  flex: 0 0 auto;
}
.ke-chat-input textarea{
  flex: 1;
  border: 0;
  outline: 0;
  resize: none;
  font-size: 14.5px;
  font-family: inherit;
  background: var(--cream-2, #f5f1e8);
  border-radius: 12px;
  padding: 10px 14px;
  max-height: 100px;
  line-height: 1.4;
  color: var(--text, #1f1f1f);
}
.ke-chat-input textarea:focus{
  background: #fff;
  box-shadow: 0 0 0 2px var(--gold, #c5a55a);
}
.ke-chat-send{
  width: 40px; height: 40px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold, #c5a55a), var(--gold-deep, #b18b3a));
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
  transition: transform .15s, opacity .15s;
}
.ke-chat-send:disabled{ opacity: .4; cursor: not-allowed; }
.ke-chat-send:not(:disabled):hover{ transform: scale(1.06); }
.ke-chat-send svg{ width: 18px; height: 18px; }

/* Bot mesajındaki link/ID highlight */
.ke-msg.bot a, .ke-msg.bot strong{ color: var(--gold-deep, #b18b3a); font-weight: 600; }
.ke-msg.bot a{ text-decoration: none; }
.ke-msg.bot a:hover{ text-decoration: underline; }

/* AI tarafından önerilen ilanlar — görsel kart */
.ke-ilan-card{
  display: flex;
  align-items: stretch;
  gap: 10px;
  margin: 8px 0 4px;
  padding: 8px;
  background: #fff;
  border: 1px solid var(--line-soft, #ece7da);
  border-radius: 12px;
  text-decoration: none !important;
  color: inherit !important;
  box-shadow: 0 4px 14px -8px rgba(0,0,0,.18);
  transition: transform .18s, box-shadow .2s;
  overflow: hidden;
}
.ke-ilan-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 10px 22px -10px rgba(0,0,0,.25);
}
.ke-ilan-thumb{
  width: 90px;
  height: 70px;
  flex: 0 0 90px;
  border-radius: 8px;
  background: #0e141b center/cover no-repeat;
}
.ke-ilan-meta{
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
}
.ke-ilan-title{
  font-weight: 600;
  font-size: 13px;
  color: var(--text, #1f1f1f);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ke-ilan-sub{
  font-size: 11.5px;
  color: var(--muted, #828c98);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ke-ilan-price{
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-deep, #b18b3a);
  margin-top: 2px;
}
.ke-msg.bot ul{ padding-left: 18px; margin: 6px 0; }
.ke-msg.bot ol{ padding-left: 18px; margin: 6px 0; }

/* Mobil (<560 px) — chat panel full screen */
@media (max-width: 559px){
  .ke-wa{
    left: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    width: 47px; height: 47px;
  }
  .ke-wa svg{ width: 22px; height: 22px; }
  .ke-chat-fab{
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    width: 47px; height: 47px;
  }
  .ke-chat-fab svg{ width: 21px; height: 21px; }
  .ke-chat-panel{
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh;
    height: 100vh;
    border-radius: 0;
    max-width: 100vw;
  }
}
