/* Chat History Modal Window */
dialog.chat-history-dialog {
  width: 520px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 24px 26px 22px;
  border-radius: 20px;
  background: linear-gradient(155deg, rgba(28, 29, 36, 0.96) 0%, rgba(16, 17, 22, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(28px);
}

.chat-history-dialog .modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 2px;
}

.chat-history-dialog .modal-head h2 {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f5f5f7;
  margin: 0;
}

.chat-history-dialog .modal-head .icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #a4a4b2;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  margin-right: -4px;
}

.chat-history-dialog .modal-head .icon-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
  transform: scale(1.04);
}

/* Chat History List */
.chat-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: min(58vh, 480px);
  overflow-y: auto;
  padding: 2px 4px 2px 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}

.chat-history-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 12px;
  min-width: 0;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-history-item:hover {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.14);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.chat-history-item.current-chat {
  background: rgba(154, 239, 210, 0.035);
  border-color: rgba(154, 239, 210, 0.22);
}

.chat-history-open {
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 0;
  background: none;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font: inherit;
}

.chat-history-open strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #f2f2f5;
  transition: color 0.15s ease;
}

.chat-history-item:hover .chat-history-open strong {
  color: #fff;
}

.chat-history-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--muted, #9494a2);
  line-height: 1.4;
  flex-wrap: wrap;
}

.chat-history-model {
  font-family: var(--mono, monospace);
  font-size: 11px;
  color: #a4a4b4;
  background: rgba(255, 255, 255, 0.04);
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: -0.01em;
}

.chat-history-dot {
  color: rgba(255, 255, 255, 0.2);
  font-size: 10px;
}

.chat-history-date {
  color: #848492;
}

.chat-history-badge {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--accent, #9aefd2);
  background: rgba(154, 239, 210, 0.1);
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: 2px;
}

/* Action buttons */
.chat-history-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity 0.18s ease;
}

.chat-history-item:hover .chat-history-actions {
  opacity: 1;
}

.chat-history-actions .icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #a4a4b2;
  transition: all 0.16s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.chat-history-actions .icon-btn svg {
  width: 15px;
  height: 15px;
}

.chat-history-actions .icon-btn[data-action="chat-history-rename"]:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
  transform: translateY(-1px);
}

.chat-history-actions .icon-btn[data-action="chat-history-delete"]:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  transform: translateY(-1px);
}

/* Empty State */
.history-empty {
  padding: 40px 16px;
  color: var(--muted, #929aa6);
  text-align: center;
  font-size: 13.5px;
  background: rgba(255, 255, 255, 0.015);
  border: 1px dashed rgba(255, 255, 255, 0.08);
  border-radius: 12px;
}

/* Status in chat */
#chat-history-status {
  min-height: 16px;
  margin: 6px 12px 0;
  color: var(--muted, #929aa6);
  font-size: 11.5px;
  line-height: 1.4;
}

#chat-history-status.history-error {
  color: #fca5a5;
}

/* Pager */
.chat-history-dialog .pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 12px;
  color: var(--muted, #9494a2);
}

/* Dialog actions and buttons */
.danger-btn {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: rgba(239, 68, 68, 0.45) !important;
  color: #fca5a5 !important;
}

.danger-btn:hover {
  background: rgba(239, 68, 68, 0.35) !important;
  border-color: rgba(239, 68, 68, 0.65) !important;
  color: #fff !important;
}

/* Responsive */
@media (max-width: 600px) {
  dialog.chat-history-dialog {
    width: calc(100vw - 24px);
    padding: 18px 16px 16px;
    border-radius: 16px;
  }
  .chat-history-item {
    padding: 10px 12px;
    gap: 10px;
  }
  .chat-history-actions {
    opacity: 1;
  }
  .chat-history-actions .icon-btn {
    width: 28px;
    height: 28px;
  }
}
