/* ============================================
   HISTORY ENTRY (SIDEBAR) (sidebar.css)
   ============================================ */
#popupPanel {
  flex: 0 0 var(--history-w);
  width: var(--history-w);
  padding: 12px 0 12px 12px;
  box-sizing: border-box;
  border-right: 1px solid var(--border);
  background: #f3f4f6;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#historyList {
  flex: 1 1 auto;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding-right: 12px;
  touch-action: pan-y !important;
  -webkit-overflow-scrolling: touch !important;
  overscroll-behavior: none !important;
  scrollbar-width: none;
}

#historyList:hover {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

#historyList::-webkit-scrollbar {
  width: 5px;
}

#historyList::-webkit-scrollbar-thumb {
  background-color: transparent;
  border-radius: 10px;
}

#historyList:hover::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.1);
}

.history-entry {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 44px 10px 12px;
  margin: 0 0 4px;
  box-sizing: border-box;
  background: transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.2s ease;
  overflow: hidden;
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-tap-highlight-color: transparent !important;
  outline: none !important;
}

.history-entry:hover {
  background: #e5e7eb;
}

.history-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: #3c4043;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-entry:hover .history-title {
  color: #111827;
}

.history-more-btn {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: #5f6368;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s, background 0.2s;
  cursor: pointer;
  z-index: 10;
}

.history-entry:hover .history-more-btn {
  opacity: 1;
}

.history-more-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #111827;
}

.history-entry.active-chat {
  background: #e5e7eb !important;
}

.history-entry:hover:not(.active-chat) {
  background: #ededf0;
}

/* --- HISTORY ENTRY MOBILE (TIKLAMA VE BOŞLUK KESİN ÇÖZÜM) --- */
@media (max-width: 820px) {
  #popupPanel {
    position: absolute !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 80vw !important;
    min-width: 80vw !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    height: 100% !important;
    max-height: 100% !important;
    z-index: 10001 !important;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    background: #ffffff !important;
    border-right: 1px solid #e5e7eb;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.15);
  }

  #popupPanel.active {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  /* JS'nin "Sohbet Seçildi, Paneli Kapat" emrine CSS'in kesin itaat etmesini sağlar */
  #popupContainer.history-closed #popupPanel {
    display: none !important;
    transform: translateX(-100%) !important;
  }

  .history-entry .history-more-btn {
    opacity: 1 !important;
  }
}