/* K2M Chat Bot Widget
   Site paleti: pink primary (#E91E63), white bg, dark text (#333)
   Tamamen self-contained; layout CSS'ine bulaşmaz.
*/

:root {
  --k2m-chat-primary: #E91E63;
  --k2m-chat-primary-dark: #C2185B;
  --k2m-chat-bg: #ffffff;
  --k2m-chat-bg-alt: #f6f6f7;
  --k2m-chat-text: #2a2d34;
  --k2m-chat-text-muted: #7a808c;
  --k2m-chat-border: #e6e6ea;
  --k2m-chat-shadow: 0 20px 60px -10px rgba(0,0,0,.20), 0 8px 20px -8px rgba(0,0,0,.10);
  --k2m-chat-radius: 18px;
}

/* ---------- FAB ---------- */
.k2m-chat-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: var(--k2m-chat-primary);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 30px -6px rgba(233,30,99,.55), 0 4px 10px -4px rgba(0,0,0,.25);
  z-index: 999998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s ease, background .2s ease;
  animation: k2m-chat-pulse 2.4s ease-out infinite;
}
.k2m-chat-fab:hover { background: var(--k2m-chat-primary-dark); transform: scale(1.06); }
.k2m-chat-fab:active { transform: scale(0.96); }
.k2m-chat-fab svg { width: 28px; height: 28px; }
.k2m-chat-fab .k2m-chat-fab-close { display: none; }
.k2m-chat-fab.k2m-open .k2m-chat-fab-open { display: none; }
.k2m-chat-fab.k2m-open .k2m-chat-fab-close { display: block; }
.k2m-chat-fab.k2m-open { animation: none; }

/* ---------- Welcome bubble (karşılama balonu) ---------- */
.k2m-chat-welcome {
  position: fixed;
  bottom: 100px;           /* FAB'ın tam üstünde */
  right: 24px;
  max-width: 260px;
  background: #fff;
  color: var(--k2m-chat-text);
  padding: 12px 36px 12px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.25), 0 4px 12px -4px rgba(0,0,0,.12);
  z-index: 999997;
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  transform-origin: bottom right;
  transition: opacity .25s ease, transform .25s ease;
  pointer-events: none;
  border: 1px solid var(--k2m-chat-border);
}
.k2m-chat-welcome.k2m-show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  animation: k2m-welcome-float 3s ease-in-out 1s infinite;
}
.k2m-chat-welcome::after {
  content: "";
  position: absolute;
  bottom: -7px;
  right: 26px;
  width: 14px; height: 14px;
  background: #fff;
  border-right: 1px solid var(--k2m-chat-border);
  border-bottom: 1px solid var(--k2m-chat-border);
  transform: rotate(45deg);
}
.k2m-chat-welcome-title {
  font-weight: 600;
  color: var(--k2m-chat-primary);
  margin-bottom: 2px;
  font-size: 13px;
}
.k2m-chat-welcome-close {
  position: absolute;
  top: 6px; right: 6px;
  width: 22px; height: 22px;
  border: 0; background: transparent;
  color: var(--k2m-chat-text-muted);
  border-radius: 50%;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.k2m-chat-welcome-close:hover { background: var(--k2m-chat-bg-alt); color: var(--k2m-chat-text); }
.k2m-chat-welcome-close svg { width: 12px; height: 12px; }

@keyframes k2m-welcome-float {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-4px) scale(1); }
}

@media (max-width: 480px) {
  .k2m-chat-welcome { bottom: 86px; right: 16px; max-width: 220px; }
}

@keyframes k2m-chat-pulse {
  0%   { box-shadow: 0 10px 30px -6px rgba(233,30,99,.55), 0 4px 10px -4px rgba(0,0,0,.25), 0 0 0 0 rgba(233,30,99,.45); }
  70%  { box-shadow: 0 10px 30px -6px rgba(233,30,99,.55), 0 4px 10px -4px rgba(0,0,0,.25), 0 0 0 14px rgba(233,30,99,0); }
  100% { box-shadow: 0 10px 30px -6px rgba(233,30,99,.55), 0 4px 10px -4px rgba(0,0,0,.25), 0 0 0 0 rgba(233,30,99,0); }
}

/* ---------- Panel ---------- */
.k2m-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 140px);
  background: var(--k2m-chat-bg);
  border-radius: var(--k2m-chat-radius);
  box-shadow: var(--k2m-chat-shadow);
  z-index: 999999;
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: k2m-chat-pop .22s ease-out both;
}
.k2m-chat-panel.k2m-visible { display: flex; }

@keyframes k2m-chat-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)   scale(1);    }
}

/* Header */
.k2m-chat-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--k2m-chat-primary) 0%, #D81B60 100%);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
}
.k2m-chat-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center;
  flex: 0 0 38px;
}
.k2m-chat-avatar svg { width: 22px; height: 22px; }
.k2m-chat-title { font-weight: 600; font-size: 15px; line-height: 1.1; letter-spacing: .01em; }
.k2m-chat-subtitle { font-size: 11.5px; opacity: .85; margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.k2m-chat-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 0 rgba(74,222,128,.7);
  animation: k2m-chat-online 1.8s infinite;
}
@keyframes k2m-chat-online {
  0%,100% { box-shadow: 0 0 0 0 rgba(74,222,128,.6); }
  50%     { box-shadow: 0 0 0 5px rgba(74,222,128,0); }
}
.k2m-chat-header-actions { margin-left: auto; display: flex; gap: 4px; }
.k2m-chat-iconbtn {
  width: 30px; height: 30px;
  border: 0; background: transparent; color: #fff; opacity: .8;
  border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, opacity .15s;
}
.k2m-chat-iconbtn:hover { background: rgba(255,255,255,.15); opacity: 1; }
.k2m-chat-iconbtn svg { width: 16px; height: 16px; }

/* Messages */
.k2m-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: var(--k2m-chat-bg-alt);
  scroll-behavior: smooth;
}
.k2m-chat-messages::-webkit-scrollbar { width: 6px; }
.k2m-chat-messages::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 3px; }

.k2m-msg { display: flex; margin-bottom: 12px; gap: 8px; max-width: 100%; }
.k2m-msg-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
  max-width: 80%;
}
.k2m-msg.k2m-bot { justify-content: flex-start; }
.k2m-msg.k2m-bot .k2m-msg-bubble {
  background: #fff;
  color: var(--k2m-chat-text);
  border: 1px solid var(--k2m-chat-border);
  border-top-left-radius: 4px;
}
.k2m-msg.k2m-user { justify-content: flex-end; }
.k2m-msg.k2m-user .k2m-msg-bubble {
  background: var(--k2m-chat-primary);
  color: #fff;
  border-top-right-radius: 4px;
}
.k2m-msg-error .k2m-msg-bubble {
  background: #fff3f4;
  color: #b00020;
  border: 1px solid #ffd5d9;
}

/* Typing indicator */
.k2m-typing { display: flex; align-items: center; gap: 4px; padding: 12px 14px; }
.k2m-typing span {
  display: inline-block;
  width: 7px; height: 7px;
  background: #9ba2ad; border-radius: 50%;
  animation: k2m-type 1.1s infinite ease-in-out;
}
.k2m-typing span:nth-child(2) { animation-delay: .15s; }
.k2m-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes k2m-type {
  0%, 80%, 100% { transform: scale(0.7); opacity: .5; }
  40%           { transform: scale(1);   opacity: 1;  }
}

/* Input */
.k2m-chat-input {
  border-top: 1px solid var(--k2m-chat-border);
  padding: 10px 10px 12px;
  display: flex;
  gap: 8px;
  background: #fff;
  align-items: flex-end;
}
.k2m-chat-input textarea {
  flex: 1;
  border: 1px solid var(--k2m-chat-border);
  background: var(--k2m-chat-bg-alt);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 42px;
  transition: border-color .15s, background .15s;
}
.k2m-chat-input textarea:focus { border-color: var(--k2m-chat-primary); background: #fff; }
.k2m-chat-send {
  width: 42px; height: 42px;
  border: 0; border-radius: 50%;
  background: var(--k2m-chat-primary);
  color: #fff;
  cursor: pointer;
  flex: 0 0 42px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, transform .15s, opacity .15s;
}
.k2m-chat-send:hover:not(:disabled) { background: var(--k2m-chat-primary-dark); }
.k2m-chat-send:disabled { background: #d4d4d8; cursor: not-allowed; }
.k2m-chat-send svg { width: 18px; height: 18px; }
.k2m-chat-hint {
  padding: 6px 14px 8px;
  font-size: 10.5px;
  color: var(--k2m-chat-text-muted);
  background: #fff;
  text-align: center;
  border-top: 1px solid var(--k2m-chat-border);
}

/* Mobile */
@media (max-width: 480px) {
  .k2m-chat-panel {
    right: 8px; left: 8px; width: auto;
    bottom: 90px;
    height: calc(100vh - 120px);
  }
  .k2m-chat-fab { bottom: 16px; right: 16px; }
}
