/* =====================================================
   OKEY 101 - Sohbet Balonu (Lobi Canlı Destek Widget'ı)
   ===================================================== */

.cw-bubble-btn {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(160deg, var(--ok-green, #0b6e4f), var(--ok-green-dark, #084d38));
  color: #fff;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(8, 77, 56, 0.35);
  z-index: 2147483000; /* DÜZELTME: en yüksek olası z-index — modal (100000), oyun ekranı (200000) dahil HİÇBİR şeyin arkasında kalmasın */
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cw-bubble-btn:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 8px 26px rgba(8, 77, 56, 0.45); }
.cw-bubble-btn .cw-unread-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--ok-red, #c0392b);
  border: 2px solid #fff;
  display: none;
}
.cw-bubble-btn.has-unread .cw-unread-dot { display: block; }
/* ADIM 149/N — lobide bir pencere açıkken (Para Geçmişi, Para Çek, Profil …) yuvarlak düğme pencerenin düğmelerinin üstüne binmesin */
.cw-modal-acik .cw-bubble-btn { opacity: 0; visibility: hidden; pointer-events: none; transform: scale(0.7); transition: opacity .15s ease, transform .15s ease, visibility 0s linear .15s; }

.cw-panel {
  position: fixed;
  right: 20px;
  bottom: 90px;
  width: 340px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 14px 46px rgba(10, 30, 22, 0.28);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 2147483000;
  border: 1px solid var(--ok-border, #e3e8e4);
}
.cw-panel.open { display: flex; }

.cw-header {
  background: linear-gradient(160deg, var(--ok-green, #0b6e4f), var(--ok-green-dark, #084d38));
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}
.cw-header-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cw-header-avatar {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255,255,255,0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 800;
}
.cw-header-title { font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.cw-header-status { font-size: 10.5px; font-weight: 600; opacity: 0.9; margin-top: 2px; }
.cw-status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: #7be89a; }
.cw-status-dot.offline { background: #f0b0a5; }
.cw-header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.cw-close-btn, .cw-end-btn { background: rgba(255,255,255,0.18); border: none; color: #fff; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center; }
.cw-close-btn svg, .cw-end-btn svg { display: block; }   /* ADIM 167b: aşağı ok = gizle, X = sohbeti sonlandır */
.cw-close-btn:hover, .cw-end-btn:hover { background: rgba(255,255,255,0.3); }
.cw-end-btn { display: none; }
.cw-end-btn.visible { display: flex; }

.cw-offline-banner, .cw-closed-banner {
  font-size: 12px;
  padding: 9px 14px;
  line-height: 1.4;
  flex-shrink: 0;
}
.cw-offline-banner { background: rgba(192,57,43,0.08); color: #8c2a20; border-bottom: 1px solid rgba(192,57,43,0.15); }
.cw-closed-banner { background: rgba(107,125,116,0.1); color: #445c50; border-bottom: 1px solid rgba(107,125,116,0.18); }

/* --- Ön form: Ad Soyad + E-posta --- */
.cw-prechat { padding: 18px 16px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.cw-prechat p { font-size: 13px; color: var(--ok-muted, #6b7d74); margin: 0 0 2px; line-height: 1.4; }
.cw-prechat label { font-size: 11.5px; font-weight: 700; color: var(--ok-ink, #1c2b24); margin-bottom: 4px; display: block; }
.cw-prechat input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--ok-border, #e3e8e4);
  border-radius: 9px;
  font-size: 13.5px;
  box-sizing: border-box;
}
.cw-prechat input:focus { outline: none; border-color: var(--ok-green, #0b6e4f); }
.cw-prechat-error { color: var(--ok-red, #c0392b); font-size: 12px; min-height: 14px; }
.cw-start-btn {
  border: none;
  border-radius: 10px;
  padding: 11px;
  background: linear-gradient(160deg, var(--ok-green, #0b6e4f), var(--ok-green-dark, #084d38));
  color: #fff;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
}
.cw-start-btn:hover { filter: brightness(1.08); }

/* --- Mesaj listesi --- */
.cw-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f6f9f7;
}
.cw-msg { max-width: 82%; padding: 9px 12px; border-radius: 13px; font-size: 13px; line-height: 1.4; word-wrap: break-word; }
.cw-msg.visitor { align-self: flex-end; background: linear-gradient(160deg, var(--ok-green, #0b6e4f), var(--ok-green-dark, #084d38)); color: #fff; border-bottom-right-radius: 4px; }
.cw-msg.admin { align-self: flex-start; background: #fff; color: var(--ok-ink, #1c2b24); border: 1px solid var(--ok-border, #e3e8e4); border-bottom-left-radius: 4px; }
.cw-msg-time { font-size: 9.5px; opacity: 0.65; margin-top: 3px; }
.cw-msg-via-email { font-size: 9.5px; opacity: 0.75; margin-top: 3px; font-style: italic; }
.cw-msg img { max-width: 100%; max-height: 200px; border-radius: 8px; margin-top: 4px; display: block; cursor: zoom-in; transition: opacity 0.1s; }
.cw-msg img:hover { opacity: 0.9; }
.cw-msg-empty { text-align: center; color: var(--ok-muted, #6b7d74); font-size: 12px; margin: auto; }

/* --- Mesaj yazma alanı --- */
.cw-composer { border-top: 1px solid var(--ok-border, #e3e8e4); padding: 10px; display: flex; gap: 8px; align-items: flex-end; background: #fff; flex-shrink: 0; }
.cw-composer textarea {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--ok-border, #e3e8e4);
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: inherit;
  max-height: 70px;
  box-sizing: border-box;
}
.cw-composer textarea:focus { outline: none; border-color: var(--ok-green, #0b6e4f); }
.cw-attach-btn, .cw-send-btn {
  border: none;
  border-radius: 10px;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cw-attach-btn { background: rgba(11,110,79,0.1); color: var(--ok-green, #0b6e4f); }
.cw-attach-btn:hover { background: rgba(11,110,79,0.18); }
.cw-send-btn { background: linear-gradient(160deg, var(--ok-green, #0b6e4f), var(--ok-green-dark, #084d38)); color: #fff; }
.cw-send-btn:hover { filter: brightness(1.08); }
.cw-send-btn:disabled, .cw-attach-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.cw-image-preview {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #f6f9f7;
  border-top: 1px solid var(--ok-border, #e3e8e4);
  flex-shrink: 0;
}
.cw-image-preview.active { display: flex; }
.cw-image-preview img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }
.cw-image-preview span { font-size: 11.5px; color: var(--ok-muted, #6b7d74); flex: 1; }
.cw-image-preview button { background: none; border: none; color: var(--ok-red, #c0392b); cursor: pointer; font-size: 13px; }

/* --- Büyütülmüş resim penceresi (lightbox) — sohbet balonu ve admin paneli ortak kullanır --- */
.cw-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(8, 18, 13, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2147483000;
  cursor: zoom-out;
  padding: 24px;
  box-sizing: border-box;
}
.cw-lightbox.show { display: flex; }
.cw-lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; box-shadow: 0 12px 40px rgba(0,0,0,0.5); }

@media (max-width: 480px) {
  .cw-panel { right: 12px; left: 12px; width: auto; bottom: 84px; }
  .cw-bubble-btn { right: 14px; bottom: 14px; }
}

/* ADIM 166 — telefonda alt çubuk (Masa Kur / +) yalnız 101 Okey sekmesinde: başka oyunun sekmesinde balon yine en altta (Oyna düğmesine binmesin) */
@media (max-width: 720px) {
  body.has-qs-dock.gx-game-tab .cw-bubble-btn { bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
  body.has-qs-dock.gx-game-tab .cw-panel { bottom: 84px; }
  /* açık sohbet penceresi üst çubuğu (bakiye, hesabım) kapatmasın */
  .cw-panel { max-height: calc(100vh - 180px); }
  body.has-qs-dock .cw-panel { max-height: calc(100vh - 252px); }
  body.has-qs-dock.gx-game-tab .cw-panel { max-height: calc(100vh - 180px); }
}
/* ADIM 166 — telefonda İddaa'nın kupon çubuğu açıkken balon ve sohbet penceresi çubuğun üstünde (çubuğun "Kupon" düğmesini kapatmasın) */
body:has(.iz.iz-g1.kupon-dolu) .cw-bubble-btn { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
body:has(.iz.iz-g1.kupon-dolu) .cw-panel { bottom: calc(152px + env(safe-area-inset-bottom, 0px)); max-height: calc(100vh - 248px); }
/* ADIM 167/N — yetkilinin adı "Müşteri Temsilcisi"; otomatik mesaj (sıra / temsilci yok) hafif ayrık görünür */
.cw-msg-ad { font-size: 11px; font-weight: 800; letter-spacing: .2px; color: #0b6e4f; margin-bottom: 3px; }
.cw-msg.admin.oto { background: #f3f8f5; border-style: dashed; }
.cw-msg-ad.sistem { color: #6b7a71; }   /* ADIM 167b: otomatik mesajlar "Sistem" adıyla */

/* ADIM 169 (12. madde) — "Sistem Robotu" robot simgesi + canlı temsilci bekleme animasyonu */
.cw-msg-ad.sistem { display: flex; align-items: center; gap: 5px; }
.cw-robot { color: #2f7de1; }
.cw-bekleme { display: flex; align-items: center; gap: 10px; margin: 0 12px 8px; padding: 10px 12px; border-radius: 14px; background: linear-gradient(135deg, #eef3ff, #f6f9ff); border: 1px solid #c9d6f5; color: #1a2e58; font-size: 12.5px; font-weight: 600; }
.cw-bekleme[hidden] { display: none; }
.cw-bekleme-ik { position: relative; width: 34px; height: 34px; border-radius: 50%; background: #1d4fb3; color: #fff; display: grid; place-items: center; flex: none; }
.cw-bekleme-ik i { position: absolute; inset: -4px; border-radius: 50%; border: 2px solid rgba(29,79,179,.55); animation: cwBeklemeHalka 1.6s ease-out infinite; }
@keyframes cwBeklemeHalka { 0% { transform: scale(.8); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
.cw-bekleme-metin { flex: 1; line-height: 1.35; }
.cw-bekleme-nokta { display: inline-flex; gap: 3px; } .cw-bekleme-nokta b { width: 6px; height: 6px; border-radius: 50%; background: #1d4fb3; animation: cwBeklemeNokta 1.2s infinite; }
.cw-bekleme-nokta b:nth-child(2) { animation-delay: .2s; } .cw-bekleme-nokta b:nth-child(3) { animation-delay: .4s; }
@keyframes cwBeklemeNokta { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-4px); opacity: 1; } }
