/* ============================================================
   BRK Garage — AI Chat Widget
   ============================================================ */

:root {
  --chat-red:     #d41515;
  --chat-red-dk:  #b01010;
  --chat-bg:      #111111;
  --chat-panel:   #1a1a1a;
  --chat-card:    #242424;
  --chat-border:  #333333;
  --chat-white:   #f0f0f0;
  --chat-muted:   #888888;
  --chat-radius:  14px;
  --chat-shadow:  0 8px 40px rgba(0,0,0,.65);
}

/* ── Floating toggle button ─────────────────────────────── */
#chat-toggle {
  position: fixed;
  bottom: 160px;
  right: 24px;
  z-index: 901;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #ff7a00;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(255,122,0,.5);
  transition: background .2s, transform .2s;
  color: #fff;
}
#chat-toggle:hover { background: #e06a00; 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-red);
  font-size: 11px;
  font-weight: 700;
  display: flex; 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: 78px;              /* navbar altından başla — asla kaybolmaz */
  bottom: 224px;          /* toggle butonunun hemen üstünde bit */
  right: 24px;
  z-index: 901;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: auto;           /* top+bottom arası otomatik dolar */
  max-height: 520px;      /* geniş ekranda max bu kadar */
  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: var(--chat-red);
  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,.8); 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-red);
  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 {
  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;
}
#chat-input:focus { border-color: var(--chat-red); }
#chat-input::placeholder { color: var(--chat-muted); }
#chat-send {
  flex-shrink: 0;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--chat-red);
  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-red-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-red); border-color: var(--chat-red); }

/* Masaüstünde header kapat butonu gizli */
.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); }

/* ── Mobil Alt Navbar ────────────────────────────────────── */
#mobile-bottom-nav {
  display: none;
}

@media (max-width: 600px) {
  /* Mevcut yüzen butonları gizle */
  .fixed-btns,
  #chat-toggle {
    display: none !important;
  }

  /* Alt navbar göster */
  #mobile-bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 902;
    background: #111111;
    border-top: 1px solid #2a2a2a;
    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: #999;
    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: #2a2a2a;
  }

  .mbn-btn svg, .mbn-btn i {
    font-size: 1.3rem;
    width: 24px;
    height: 24px;
  }

  .mbn-btn:hover,
  .mbn-btn:active { background: rgba(255,255,255,.04); }

  .mbn-btn.mbn-chat { color: #ff7a00; }
  .mbn-btn.mbn-chat:hover { color: #ff9933; }

  .mbn-btn.mbn-wa { color: #25d366; }
  .mbn-btn.mbn-wa:hover { color: #40e87a; }

  .mbn-btn.mbn-call { color: #d41515; }
  .mbn-btn.mbn-call:hover { color: #f03030; }

  /* Aktif chat durumunda chat ikonu parlak */
  .mbn-btn.mbn-chat.active { color: #ff9933; }

  /* Chat paneli — site navbarının altından başla, mobil navbarın üstünde bit */
  #chat-panel {
    top: 80px;
    left: 0;
    right: 0;
    bottom: 62px;
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: none;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid #2a2a2a;
  }

  /* Panel açıkken z-index navbarın üstüne çık */
  #chat-panel.open {
    z-index: 950;
  }

  /* Header kapat butonu mobilde görünsün */
  .chat-header-close {
    display: flex;
  }

  /* Sayfa altı boşluğu — içerik navbarın altında kalmasın */
  body {
    padding-bottom: 62px;
  }
}
