/* ===== Binderim floating message widget ===== */
.bmw-root {
  --bmw-accent: #4f6edb;
  --bmw-accent-strong: #3b54c4;
  --bmw-surface: #ffffff;
  --bmw-surface-alt: #f8fbff;
  --bmw-border: #e1e8f6;
  --bmw-border-soft: #edf1fa;
  --bmw-text: #1f2a44;
  --bmw-text-muted: #7a859d;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 1080;
}

/* ----- Floating action button ----- */
.bmw-fab {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--bmw-accent);
  color: #fff;
  font-size: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px rgba(31, 42, 68, 0.28);
  cursor: pointer;
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.bmw-fab:hover {
  background: var(--bmw-accent-strong);
  transform: translateY(-2px);
}

.bmw-fab:active {
  transform: translateY(0);
}

.bmw-fab-icon-close {
  display: none;
}

.bmw-root.bmw-open .bmw-fab-icon {
  display: none;
}

.bmw-root.bmw-open .bmw-fab-icon-close {
  display: inline-block;
}

.bmw-fab-dot {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.4);
}

/* ----- Panel ----- */
.bmw-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 110px);
  background: var(--bmw-surface);
  border: 1px solid var(--bmw-border);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(15, 26, 75, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: translateY(12px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.bmw-root.bmw-open .bmw-panel {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.bmw-head {
  /* site.css applies `header { position: fixed !important }` on mobile (<768px) for the
     site navbar (.bx-header). That bare tag selector leaks into this widget's
     <header class="bmw-head"> element. Override is required here because the leaking
     rule uses !important and widget CSS declares no position at all (so it wins).
     position: relative keeps the element in flex flow; top/left/right:0 offsets from
     the leaked rule are harmless on a relative element. Tested live: overlap 58px -> 0. */
  position: relative !important;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--bmw-accent);
  color: #fff;
  flex-shrink: 0;
}

.bmw-head-title {
  font-weight: 700;
  font-size: 1rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bmw-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.bmw-icon-btn {
  border: none;
  background: transparent;
  color: inherit;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.bmw-head .bmw-icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.bmw-body {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}

.bmw-list-view,
.bmw-chat-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
}

/* ----- Conversation list ----- */
.bmw-conversation-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.bmw-conversation-item {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--bmw-border-soft);
  background: transparent;
  color: inherit;
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.bmw-conversation-item:hover {
  background: var(--bmw-surface-alt);
}

.bmw-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bmw-accent);
  color: #fff;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 0.82rem;
}

.bmw-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bmw-conversation-body {
  min-width: 0;
  flex: 1;
}

.bmw-conversation-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.bmw-conversation-top strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
  font-size: 0.92rem;
  color: var(--bmw-text);
}

.bmw-conversation-top small {
  color: var(--bmw-text-muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.bmw-conversation-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.bmw-conversation-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #596176;
  font-size: 0.82rem;
}

.bmw-unread-pill {
  min-width: 19px;
  height: 19px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ef4444;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0 6px;
  flex-shrink: 0;
}

.bmw-empty-inline {
  text-align: center;
  color: var(--bmw-text-muted);
  padding: 28px 16px;
  font-size: 0.88rem;
}

.bmw-empty-inline i {
  font-size: 1.6rem;
  display: block;
  margin-bottom: 6px;
}

/* ----- Chat view ----- */
.bmw-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--bmw-border-soft);
  background: var(--bmw-surface-alt);
  flex-shrink: 0;
}

.bmw-participant {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.bmw-participant strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
  color: var(--bmw-text);
}

.bmw-participant-link {
  color: inherit;
  text-decoration: none;
}

.bmw-participant-link:hover {
  color: var(--bmw-accent);
  text-decoration: underline;
}

.bmw-chat-head-actions {
  display: inline-flex;
  gap: 2px;
}

.bmw-chat-view .bmw-icon-btn {
  color: var(--bmw-text-muted);
}

.bmw-chat-view .bmw-icon-btn:hover {
  background: #eef1f8;
  color: var(--bmw-text);
}

.bmw-icon-btn.is-blocked {
  color: #16a34a;
}

.bmw-status-banner {
  padding: 9px 14px;
  border-bottom: 1px solid #f0d7a6;
  background: #fff5da;
  color: #8a5200;
  font-size: 0.84rem;
  flex-shrink: 0;
}

.bmw-thread {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  background: #f8faff;
  overscroll-behavior: contain;
}

.bmw-empty-thread {
  text-align: center;
  color: var(--bmw-text-muted);
  margin-top: 36px;
  font-size: 0.86rem;
}

.bmw-msg-row {
  display: flex;
  margin-bottom: 9px;
}

.bmw-msg-row.outgoing {
  justify-content: flex-end;
}

.bmw-msg-row.incoming {
  justify-content: flex-start;
}

.bmw-bubble {
  max-width: 80%;
  border-radius: 14px;
  padding: 9px 11px 7px;
  background: #fff;
  border: 1px solid #e8edfa;
  box-shadow: 0 1px 2px rgba(12, 26, 75, 0.08);
}

.bmw-msg-row.outgoing .bmw-bubble {
  background: #dfe9ff;
  border-color: #bfd1ff;
}

.bmw-bubble.is-offer {
  background: #fffbeb;
  border-color: #fde68a;
}

.bmw-msg-row.outgoing .bmw-bubble.is-offer {
  background: #fef3c7;
  border-color: #fcd34d;
}

.bmw-msg-text {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--bmw-text);
  font-size: 0.9rem;
}

.bmw-msg-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 5px;
}

.bmw-msg-tag--request {
  background: #e0f2fe;
  color: #075985;
}

.bmw-msg-tag--response {
  background: #dcfce7;
  color: #166534;
}

.bmw-msg-image-link {
  display: block;
  margin-top: 7px;
}

.bmw-msg-image-link img {
  max-width: 200px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid #d8e3fb;
}

.bmw-msg-meta {
  text-align: right;
  margin-top: 5px;
}

.bmw-msg-meta small {
  color: #6e7892;
  font-size: 0.68rem;
}

/* Offer card (compact) */
.bmw-offer-card {
  border: 1px solid #fcd34d;
  border-radius: 10px;
  background: #fffbeb;
  margin-top: 7px;
  overflow: hidden;
}

.bmw-offer-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  color: #92400e;
  font-size: 0.78rem;
  font-weight: 700;
}

.bmw-offer-head .bmw-offer-title {
  flex: 1;
}

.bmw-offer-status {
  font-size: 0.66rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #fde68a;
  color: #92400e;
}

.bmw-offer-status.accepted { background: #d1fae5; border-color: #6ee7b7; color: #065f46; }
.bmw-offer-status.rejected { background: #fee2e2; border-color: #fecaca; color: #991b1b; }
.bmw-offer-status.expired,
.bmw-offer-status.cancelled { background: #f3f4f6; border-color: #d1d5db; color: #4b5563; }

.bmw-offer-body {
  padding: 8px 10px;
}

.bmw-offer-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #475569;
  padding: 2px 0;
}

.bmw-offer-row strong {
  color: #1e293b;
}

.bmw-offer-note {
  margin-top: 6px;
  padding: 6px 8px;
  background: #f8fafc;
  border-left: 3px solid #fcd34d;
  border-radius: 6px;
  color: #475569;
  font-size: 0.76rem;
  font-style: italic;
}

.bmw-offer-actions {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid #fde68a;
}

.bmw-offer-actions .btn {
  flex: 1;
  font-size: 0.8rem;
  padding: 4px 6px;
}

/* ----- Composer ----- */
.bmw-composer {
  border-top: 1px solid var(--bmw-border-soft);
  padding: 10px;
  background: #fff;
  flex-shrink: 0;
}

.bmw-composer.disabled {
  opacity: 0.6;
  pointer-events: none;
}

.bmw-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.bmw-attach-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #eef2fb;
  color: var(--bmw-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1.05rem;
  margin: 0;
}

.bmw-attach-btn:hover {
  background: #e2e9f9;
}

.bmw-composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid #d8e1f3;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 0.9rem;
  max-height: 110px;
  line-height: 1.35;
  outline: none;
  overflow-y: hidden;
}

.bmw-composer textarea:focus {
  border-color: var(--bmw-accent);
}

.bmw-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--bmw-accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1rem;
  transition: background-color 0.15s ease;
}

.bmw-send-btn:hover:not(:disabled) {
  background: var(--bmw-accent-strong);
}

.bmw-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.bmw-attachment-preview {
  margin-bottom: 8px;
}

.bmw-upload-preview-card {
  border: 1px solid #d7e2fb;
  border-radius: 10px;
  padding: 7px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: #f6f9ff;
}

.bmw-upload-preview-card img {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: cover;
}

.bmw-upload-preview-meta {
  flex: 1;
  min-width: 0;
}

.bmw-upload-preview-meta strong {
  display: block;
  font-size: 0.8rem;
  color: #1f2a44;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bmw-upload-preview-meta small {
  color: var(--bmw-text-muted);
  font-size: 0.72rem;
}

/* ----- New message modal pieces ----- */
.bmw-preference-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bmw-radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  margin: 0;
  cursor: pointer;
}

.bmw-user-search-results {
  max-height: 280px;
  overflow-y: auto;
}

.bmw-user-search-item {
  width: 100%;
  border: 1px solid #e7edf9;
  border-radius: 8px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px;
  text-align: left;
  margin-bottom: 8px;
  cursor: pointer;
}

.bmw-user-search-item.active {
  border-color: #7aa7ff;
  background: #eef5ff;
}

.bmw-user-search-meta {
  min-width: 0;
}

.bmw-user-search-meta strong {
  display: block;
  font-size: 0.9rem;
}

/* Mevcut "yukarı çık" butonu balonla ust uste binmesin diye yukari kaydir.
   Sadece widget (giris yapmis kullanici) render edildiginde uygulanir. */
body:has(#binderimMsgWidget) .back-to-top-btn {
  bottom: 92px;
}

/* ----- Desktop fullscreen toggle ----- */
.bmw-root.bmw-fullscreen .bmw-panel {
  position: fixed;
  inset: 0;
  width: auto;
  max-width: none;
  height: auto;
  max-height: none;
  border-radius: 0;
  border: none;
}

.bmw-root.bmw-fullscreen.bmw-open .bmw-fab {
  display: none;
}

/* Lock page scroll while fullscreen so the body scrollbar doesn't peek through. */
body.bmw-fullscreen-lock {
  overflow: hidden;
}

/* ----- Mobile: fullscreen ----- */
@media (max-width: 575.98px) {
  body:has(#binderimMsgWidget) .back-to-top-btn {
    bottom: 84px;
    right: 16px;
  }

  .bmw-root {
    right: 16px;
    bottom: 16px;
  }

  .bmw-root.bmw-open .bmw-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: none;
  }

  .bmw-root.bmw-open .bmw-fab {
    display: none;
  }

  /* Mobile is already fullscreen — hide the toggle */
  .bmw-fullscreen-btn {
    display: none;
  }
}

/* ----- Dark theme ----- */
.theme-dark .bmw-root {
  --bmw-surface: #1e1e1e;
  --bmw-surface-alt: #181818;
  --bmw-border: #2c2c2c;
  --bmw-border-soft: #262626;
  --bmw-text: #e6e6e6;
  --bmw-text-muted: #9aa3b5;
}

.theme-dark .bmw-conversation-top strong,
.theme-dark .bmw-participant strong {
  color: #e6e6e6;
}

.theme-dark .bmw-conversation-preview {
  color: #aab2c2;
}

.theme-dark .bmw-thread {
  background: #161616;
}

.theme-dark .bmw-bubble {
  background: #242424;
  border-color: #313131;
}

.theme-dark .bmw-msg-text {
  color: #e6e6e6;
}

.theme-dark .bmw-msg-row.outgoing .bmw-bubble {
  background: #2a3a63;
  border-color: #38508c;
}

.theme-dark .bmw-composer,
.theme-dark .bmw-chat-head {
  background: #1e1e1e;
}

.theme-dark .bmw-composer textarea {
  background: #161616;
  border-color: #313131;
  color: #e6e6e6;
}

.theme-dark .bmw-conversation-item:hover {
  background: #242424;
}

.theme-dark .bmw-attach-btn {
  background: #242424;
}

.theme-dark .bmw-upload-preview-card {
  background: #242424;
  border-color: #313131;
}

.theme-dark .bmw-upload-preview-meta strong {
  color: #e6e6e6;
}

.theme-dark .bmw-user-search-item {
  background: #242424;
  border-color: #313131;
  color: #e6e6e6;
}

.theme-dark .bmw-user-search-item.active {
  background: #2a3a63;
  border-color: #38508c;
}
