/* ==========================================================================
   İMA Chatbot — widget stilleri (sol alt köşe)
   Sitenin lacivert + altın paletini kullanır (style.css içindeki --c-* değişkenleri)
   ========================================================================== */

:root {
  --imab-x: clamp(16px, 3vw, 26px);   /* sol boşluk */
  --imab-y: clamp(16px, 3vw, 26px);   /* alt boşluk */
}

/* ---- Açma düğmesi: İMA logolu, altın halkalı ---- */
.imab-btn {
  position: fixed; left: var(--imab-x); bottom: var(--imab-y); z-index: 90;
  width: 64px; height: 64px; border-radius: 50%; border: 3px solid var(--c-gold, #C6A250);
  padding: 0; cursor: pointer; display: grid; place-items: center; overflow: visible;
  background: #fff; box-shadow: 0 12px 32px -10px rgba(11,31,58,.45);
  transition: transform .25s cubic-bezier(.2,.8,.2,1), box-shadow .25s ease;
  animation: imab-pop .6s cubic-bezier(.2,.8,.2,1) both; animation-delay: .3s;
}
.imab-btn:hover { transform: translateY(-3px) scale(1.05); box-shadow: 0 16px 36px -10px rgba(11,31,58,.55); }
.imab-btn img { width: 44px; height: 44px; object-fit: contain; border-radius: 50%; }
.imab-btn .imab-ico-x { display: none; width: 26px; height: 26px; color: #fff; }
.imab-btn[aria-expanded="true"] { background: var(--c-navy, #12355F); }
.imab-btn[aria-expanded="true"] img { display: none; }
.imab-btn[aria-expanded="true"] .imab-ico-x { display: block; }

/* "AI" rozeti */
.imab-btn .imab-badge {
  position: absolute; right: -4px; top: -4px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: var(--c-gold, #C6A250); color: var(--c-black, #05070D);
  font: 700 10px/22px "Manrope", system-ui, sans-serif; letter-spacing: .04em; border: 2px solid #fff;
}
.imab-btn[aria-expanded="true"] .imab-badge { display: none; }

/* Dikkat çeken altın halka (ilk açılana kadar) */
.imab-btn.is-attn::before, .imab-btn.is-attn::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%;
  border: 2px solid var(--c-gold, #C6A250); opacity: 0; pointer-events: none;
  animation: imab-ring 2.4s ease-out infinite;
}
.imab-btn.is-attn::after { animation-delay: 1.2s; }
@keyframes imab-ring { 0% { transform: scale(1); opacity: .8; } 100% { transform: scale(1.9); opacity: 0; } }
@keyframes imab-pop { from { transform: scale(0) rotate(-20deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- Karşılama balonu (siteye girince belirir) ---- */
.imab-teaser {
  position: fixed; left: var(--imab-x); bottom: calc(var(--imab-y) + 78px); z-index: 91;
  width: min(330px, calc(100vw - 32px));
  background: #fff; color: var(--c-ink, #0B1F3A); border-radius: 18px; border-bottom-left-radius: 6px;
  border: 1px solid var(--c-line, #E1E9F3); box-shadow: 0 24px 50px -18px rgba(10,27,51,.4);
  padding: 14px 14px 12px; font-family: "Manrope", system-ui, sans-serif; font-size: 14px; line-height: 1.5;
  opacity: 0; visibility: hidden; transform: translateY(16px) scale(.96); transform-origin: bottom left;
  transition: opacity .3s ease, transform .35s cubic-bezier(.2,.8,.2,1), visibility .3s;
}
.imab-teaser.is-in { opacity: 1; visibility: visible; transform: none; animation: imab-wobble .8s .35s ease; }
@keyframes imab-wobble { 0%,100% { transform: none; } 30% { transform: translateY(-6px); } 60% { transform: translateY(2px); } }
.imab-teaser::after { /* balon kuyruğu */
  content: ""; position: absolute; left: 22px; bottom: -8px; width: 16px; height: 16px;
  background: #fff; border-right: 1px solid var(--c-line, #E1E9F3); border-bottom: 1px solid var(--c-line, #E1E9F3);
  transform: rotate(45deg);
}
.imab-teaser-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.imab-teaser-head img { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--c-gold, #C6A250); object-fit: contain; background: #fff; }
.imab-teaser-name { font-weight: 800; font-size: 14px; }
.imab-teaser-org { font-size: 11px; color: var(--c-muted, #56667E); letter-spacing: .02em; }
.imab-teaser-x {
  margin-left: auto; border: 0; background: var(--c-mist, #F3F6FB); color: var(--c-muted, #56667E);
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer; display: grid; place-items: center;
}
.imab-teaser-x svg { width: 14px; height: 14px; }
.imab-teaser-text { margin: 0 0 10px; min-height: 42px; }
.imab-teaser-text .imab-cursor { display: inline-block; width: 2px; height: 1em; background: var(--c-gold, #C6A250); vertical-align: -2px; margin-left: 1px; animation: imab-blink-c .8s steps(1) infinite; }
@keyframes imab-blink-c { 50% { opacity: 0; } }
.imab-teaser-btn {
  display: inline-flex; align-items: center; gap: 6px; border: 0; cursor: pointer; font: 700 13px "Manrope", system-ui, sans-serif;
  background: var(--c-navy, #12355F); color: #fff; padding: 9px 14px; border-radius: 999px;
  transition: background .15s ease, transform .15s ease;
}
.imab-teaser-btn:hover { background: var(--c-blue, #1E6FB8); transform: translateY(-1px); }
.imab-teaser-btn svg { width: 15px; height: 15px; }

/* ---- Panel ---- */
.imab-panel {
  position: fixed; z-index: 95;
  left: var(--imab-x); bottom: var(--imab-y);
  width: min(390px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 48px));
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; color: var(--c-ink, #0B1F3A);
  border-radius: 22px; border: 1px solid var(--c-line, #E1E9F3);
  box-shadow: 0 30px 60px -22px rgba(10,27,51,.45);
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14.5px; line-height: 1.5;
  opacity: 0; visibility: hidden; transform: translateY(16px) scale(.97); transform-origin: bottom left;
  transition: opacity .25s ease, transform .3s cubic-bezier(.2,.8,.2,1), visibility .25s;
}
.imab-panel.is-open { opacity: 1; visibility: visible; transform: none; }
@media (max-width: 480px) {
  .imab-panel { left: 8px; right: 8px; width: auto; bottom: 8px; height: min(88vh, calc(100vh - 16px)); }
}

.imab-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: linear-gradient(135deg, var(--c-black, #05070D), var(--c-navy, #12355F));
  color: #fff; position: relative; overflow: hidden;
}
.imab-head::after { /* altın ışık süpürmesi */
  content: ""; position: absolute; top: -60%; left: -30%; width: 40%; height: 220%;
  background: linear-gradient(100deg, transparent, rgba(230,205,140,.18), transparent);
  transform: rotate(12deg); animation: imab-sheen 5s 1s ease-in-out infinite;
}
@keyframes imab-sheen { 0%, 20% { left: -40%; } 60%, 100% { left: 130%; } }
.imab-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: #fff; display: grid; place-items: center; overflow: hidden;
  border: 2px solid var(--c-gold, #C6A250);
}
.imab-avatar img { width: 32px; height: 32px; object-fit: contain; }
.imab-title { font-weight: 800; font-size: 15px; letter-spacing: .01em; }
.imab-title small { font-weight: 600; font-size: 10px; color: var(--c-gold-2, #E6CD8C); margin-left: 6px; letter-spacing: .08em; }
.imab-sub { font-size: 11.5px; opacity: .85; display: flex; align-items: center; gap: 6px; }
.imab-sub::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #3ddc84; box-shadow: 0 0 0 0 rgba(61,220,132,.6); animation: imab-online 2s infinite; }
@keyframes imab-online { 70% { box-shadow: 0 0 0 6px rgba(61,220,132,0); } 100% { box-shadow: 0 0 0 0 rgba(61,220,132,0); } }
.imab-close {
  margin-left: auto; border: 0; background: rgba(255,255,255,.1); color: #fff; position: relative; z-index: 1;
  width: 32px; height: 32px; border-radius: 50%; cursor: pointer; display: grid; place-items: center;
}
.imab-close:hover { background: rgba(255,255,255,.2); }
.imab-close svg { width: 18px; height: 18px; }

.imab-body {
  flex: 1; overflow-y: auto; padding: 16px 14px 8px;
  background: var(--c-mist, #F3F6FB); scroll-behavior: smooth;
}
.imab-msg { display: flex; margin-bottom: 10px; animation: imab-msg-in .3s cubic-bezier(.2,.8,.2,1) both; }
@keyframes imab-msg-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.imab-msg--bot { justify-content: flex-start; }
.imab-msg--user { justify-content: flex-end; }
.imab-bubble {
  max-width: 84%; padding: 10px 13px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word;
}
.imab-msg--bot .imab-bubble {
  background: #fff; border: 1px solid var(--c-line, #E1E9F3); border-bottom-left-radius: 6px;
}
.imab-msg--user .imab-bubble {
  background: var(--c-navy, #12355F); color: #fff; border-bottom-right-radius: 6px;
}
.imab-bubble a { color: var(--c-blue, #1E6FB8); text-decoration: underline; word-break: break-all; }
.imab-msg--user .imab-bubble a { color: var(--c-gold-2, #E6CD8C); }
.imab-bubble ul { margin: 6px 0 0 18px; padding: 0; }
.imab-bubble li { margin: 2px 0; }
.imab-bubble strong { font-weight: 700; }
.imab-bubble--err { border-color: #f3c6c6 !important; background: #fff5f5 !important; color: #8a2a2a; }

.imab-typing { display: inline-flex; gap: 4px; align-items: center; height: 16px; }
.imab-typing i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--c-muted, #56667E);
  animation: imab-blink 1.2s infinite ease-in-out;
}
.imab-typing i:nth-child(2) { animation-delay: .2s; }
.imab-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes imab-blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.imab-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; background: var(--c-mist, #F3F6FB); }
.imab-chip {
  border: 1px solid var(--c-blue-light, #86B6DE); background: #fff; color: var(--c-navy, #12355F);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; cursor: pointer; font-family: inherit;
  transition: background .15s ease, color .15s ease; animation: imab-msg-in .35s both;
}
.imab-chip:nth-child(2) { animation-delay: .06s; } .imab-chip:nth-child(3) { animation-delay: .12s; } .imab-chip:nth-child(4) { animation-delay: .18s; }
.imab-chip:hover { background: var(--c-navy, #12355F); color: #fff; }

.imab-foot { border-top: 1px solid var(--c-line, #E1E9F3); background: #fff; padding: 10px 12px 8px; }
.imab-form { display: flex; gap: 8px; align-items: flex-end; }
.imab-input {
  flex: 1; resize: none; border: 1px solid var(--c-line, #E1E9F3); border-radius: 14px;
  padding: 10px 12px; font: inherit; color: inherit; max-height: 110px; min-height: 42px;
  outline: none; background: var(--c-mist, #F3F6FB);
}
.imab-input:focus { border-color: var(--c-blue, #1E6FB8); background: #fff; }
.imab-send {
  width: 42px; height: 42px; border-radius: 50%; border: 0; cursor: pointer; flex: none;
  background: var(--c-gold, #C6A250); color: var(--c-black, #05070D); display: grid; place-items: center;
  transition: transform .15s ease, opacity .15s ease;
}
.imab-send:hover { transform: scale(1.05); }
.imab-send:disabled { opacity: .5; cursor: default; transform: none; }
.imab-send svg { width: 20px; height: 20px; }
.imab-wa {
  display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 8px;
  font-size: 12px; color: var(--c-muted, #56667E); text-decoration: none;
}
.imab-wa svg { width: 14px; height: 14px; color: var(--c-wa, #25D366); }
.imab-wa:hover { color: var(--c-navy, #12355F); }

/* Panel açıkken düğme ve balon gizlenir; mobil menü açıkken hepsi gizlenir */
body.imab-open .imab-btn, body.imab-open .imab-teaser { opacity: 0; visibility: hidden; pointer-events: none; }
body.nav-open .imab-panel, body.nav-open .imab-btn, body.nav-open .imab-teaser { opacity: 0; visibility: hidden; pointer-events: none; }

@media (max-width: 640px) {
  .imab-btn { width: 56px; height: 56px; } .imab-btn img { width: 38px; height: 38px; }
  .imab-teaser { bottom: calc(var(--imab-y) + 70px); }
}
@media (prefers-reduced-motion: reduce) {
  .imab-btn, .imab-btn::before, .imab-btn::after, .imab-head::after, .imab-teaser.is-in, .imab-msg, .imab-chip { animation: none !important; }
}
