/* ============================================================
   Balabanlar Otomotiv — AI Chat Widget
   ============================================================ */

:root {
  /* Yapay zeka asistanı moru — markanın turuncusundan ayrı bir kimlik */
  --chat-org:     #8B5CF6;
  --chat-org-dk:  #6D28D9;
  --chat-bg:      #1E242A;
  --chat-panel:   #242B32;
  --chat-card:    #2A323A;
  --chat-border:  #3E4852;
  --chat-white:   #F5F2EC;
  --chat-muted:   #8A929B;
  --chat-radius:  14px;
  --chat-shadow:  0 8px 40px rgba(0,0,0,.65);
}

/* ── Floating toggle button ─────────────────────────────── */
#chat-toggle {
  position: fixed;
  bottom: 153px;        /* iki fab'in tam üstünde, eşit boşlukla */
  right: 1.2rem;         /* .fixed-btns ile aynı sağ hiza */
  z-index: 901;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--chat-org);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(139,92,246,.55);
  transition: background .2s, transform .2s;
  color: #fff;
}
#chat-toggle:hover { background: var(--chat-org-dk); transform: scale(1.07); }
#chat-toggle svg   { transition: opacity .15s, transform .15s; }
#chat-toggle .icon-open  { position: absolute; }
#chat-toggle .icon-close { position: absolute; opacity: 0; transform: rotate(-90deg); }
#chat-toggle.open .icon-open  { opacity: 0; transform: rotate(90deg); }
#chat-toggle.open .icon-close { opacity: 1; transform: rotate(0deg); }

/* Unread badge */
#chat-badge {
  position: absolute;
  top: 3px; right: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  color: var(--chat-org);
  font-size: 11px;
  font-weight: 700;
  align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
  display: none;
}
#chat-badge.visible { display: flex; }

/* ── Panel ──────────────────────────────────────────────── */
#chat-panel {
  position: fixed;
  top: 150px;
  bottom: 224px;
  right: 1.2rem;
  z-index: 901;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: auto;
  max-height: 520px;
  background: var(--chat-panel);
  border: 1px solid var(--chat-border);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(.97);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
#chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
.chat-header {
  background: linear-gradient(135deg, var(--chat-org), var(--chat-org-dk));
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.chat-header-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.chat-header-info { flex: 1; }
.chat-header-name  { color: #fff; font-weight: 700; font-size: .95rem; line-height: 1.2; }
.chat-header-status { color: rgba(255,255,255,.85); font-size: .75rem; }
.chat-header-status::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ade80;
  margin-right: 5px;
  vertical-align: middle;
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--chat-border); border-radius: 4px; }

/* Bubbles */
.chat-bubble {
  max-width: 82%;
  padding: 9px 13px;
  border-radius: 16px;
  font-size: .875rem;
  line-height: 1.45;
  word-break: break-word;
}
.chat-bubble.bot {
  background: var(--chat-card);
  color: var(--chat-white);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.chat-bubble.user {
  background: var(--chat-org);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.chat-bubble-wrap { display: flex; flex-direction: column; gap: 4px; }
.chat-bubble-wrap.user { align-items: flex-end; }
.chat-bubble-wrap.bot  { align-items: flex-start; }

/* Typing indicator */
.chat-typing { display: flex; gap: 5px; padding: 10px 14px; align-self: flex-start; }
.chat-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--chat-muted);
  animation: chat-bounce .9s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes chat-bounce {
  0%,80%,100% { transform: translateY(0); }
  40%         { transform: translateY(-6px); }
}

/* Action buttons inside bot message */
.chat-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-self: flex-start; }
.chat-action-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 12px; border-radius: 20px;
  font-size: .78rem; font-weight: 700; cursor: pointer;
  border: none; text-decoration: none; transition: opacity .15s;
}
.chat-action-btn:hover { opacity: .85; }
.chat-action-btn.wa   { background: #25d366; color: #fff; }
.chat-action-btn.call { background: var(--chat-card); color: var(--chat-white); border: 1px solid var(--chat-border); }
.chat-action-btn.map  { background: var(--chat-card); color: var(--chat-white); border: 1px solid var(--chat-border); }

/* Input row */
.chat-input-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--chat-border);
  background: var(--chat-bg);
  flex-shrink: 0;
}
#chat-input:focus { font-size: 16px; }
#chat-input {
  flex: 1;
  background: var(--chat-card);
  border: 1px solid var(--chat-border);
  border-radius: 22px;
  color: var(--chat-white);
  font-size: .875rem;
  padding: 9px 14px;
  outline: none; resize: none;
  font-family: inherit;
  max-height: 100px; line-height: 1.4;
  transition: border-color .15s;
  overflow-y: auto;
  scrollbar-width: none;            /* Firefox — kaydırma çubuğunu gizle */
}
#chat-input::-webkit-scrollbar { display: none; }  /* Chrome/Edge/Safari — ok/çubuk gizle */
#chat-input:focus { border-color: var(--chat-org); }
#chat-input::placeholder { color: var(--chat-muted); }
#chat-send {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--chat-org);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .15s;
  color: #fff;
}
#chat-send:hover { background: var(--chat-org-dk); transform: scale(1.05); }
#chat-send:disabled { background: var(--chat-border); cursor: not-allowed; transform: none; }

/* Quick reply chips */
.chat-quick-replies { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 4px; flex-shrink: 0; }
.chat-chip {
  padding: 5px 11px; border-radius: 16px;
  border: 1px solid var(--chat-border);
  background: transparent; color: var(--chat-white);
  font-size: .78rem; cursor: pointer;
  transition: background .15s, border-color .15s;
  font-family: inherit; white-space: nowrap;
}
.chat-chip:hover { background: var(--chat-org); border-color: var(--chat-org); }

/* Header close button (mobile) */
.chat-header-close {
  display: none; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.15); border: none; cursor: pointer;
  color: #fff; flex-shrink: 0; transition: background .15s;
}
.chat-header-close:hover { background: rgba(255,255,255,0.28); }

/* ── Mobile bottom nav ───────────────────────────────────── */
#mobile-bottom-nav { display: none; }

@media (max-width: 600px) {
  .fixed-btns,
  #chat-toggle { display: none !important; }

  #mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 902;
    background: #1A1F24;
    border-top: 1px solid #2E353A;
    height: 62px;
    align-items: stretch;
  }
  .mbn-btn {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 4px;
    border: none; background: transparent;
    color: #9aa1a8; font-size: 0.65rem; font-weight: 600; letter-spacing: 0.03em;
    cursor: pointer; text-decoration: none;
    transition: color .15s, background .15s;
    padding: 0; position: relative;
  }
  .mbn-btn:not(:last-child)::after {
    content: ''; position: absolute;
    right: 0; top: 16%; bottom: 16%;
    width: 1px; background: #2E353A;
  }
  .mbn-btn svg { width: 24px; height: 24px; }
  .mbn-btn:hover, .mbn-btn:active { background: rgba(255,255,255,.04); }
  .mbn-btn.mbn-chat { color: #8B5CF6; }
  .mbn-btn.mbn-chat:hover, .mbn-btn.mbn-chat.active { color: #A78BFA; }
  .mbn-btn.mbn-wa { color: #25d366; }
  .mbn-btn.mbn-wa:hover { color: #40e87a; }
  .mbn-btn.mbn-call { color: #E07B39; }
  .mbn-btn.mbn-call:hover { color: #F0A062; }

  /* Chat: tam ekran modal — navbar dahil her şeyin üstünde */
  #chat-panel {
    inset: 0;
    width: 100%; max-width: 100%;
    height: 100%; max-height: 100%;
    border-radius: 0; border: none;
    transform: translateY(100%);        /* aşağıdan kayarak gelir */
    transition: opacity .25s ease, transform .25s ease;
  }
  #chat-panel.open {
    transform: translateY(0);
    z-index: 9999;                      /* navbar (1000) ve her şeyin üstünde */
  }
  .chat-header-close {
    display: flex;
    width: 38px; height: 38px;
    font-size: 1.2rem;
  }
  body.chat-open { overflow: hidden; }  /* arka sayfa kaymaz */
}
