/* ---- Chat Features: Search, Pin, Export, Edit/Delete ---- */

/* Toolbar */
.chat-toolbar {
  display: flex;
  gap: 4px;
  padding: 6px 12px;
  background: rgba(15, 15, 35, 0.95);
  border-bottom: 1px solid rgba(99, 102, 241, 0.15);
  justify-content: flex-end;
}
.toolbar-btn {
  background: none;
  border: none;
  color: #a5a7c4;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  position: relative;
  display: flex;
  align-items: center;
}
.toolbar-btn:hover { background: rgba(99, 102, 241, 0.15); color: #6366f1; }

.pin-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: #6366f1;
  color: #fff;
  font-size: 10px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* Search Panel */
.search-panel {
  padding: 8px 12px;
  background: rgba(15, 15, 35, 0.98);
  border-bottom: 1px solid rgba(99, 102, 241, 0.15);
}
.search-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.search-panel input[type="text"] {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 8px;
  padding: 8px 12px;
  color: #e0e0f0;
  font-size: 14px;
  outline: none;
}
.search-panel input[type="text"]:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}
.search-filters {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.search-filters select, .search-filters input[type="date"] {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 6px;
  padding: 4px 8px;
  color: #c0c0d8;
  font-size: 12px;
  outline: none;
}
.search-filters select:focus, .search-filters input[type="date"]:focus {
  border-color: #6366f1;
}

/* Search Results */
.search-results {
  max-height: 200px;
  overflow-y: auto;
  margin-top: 8px;
}
.search-count {
  font-size: 12px;
  color: #8888aa;
  padding: 4px 0;
}
.search-result-item {
  display: flex;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  align-items: center;
}
.search-result-item:hover { background: rgba(99, 102, 241, 0.1); }
.search-role {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.search-role.user { background: rgba(99, 102, 241, 0.2); color: #818cf8; }
.search-role.assistant { background: rgba(16, 185, 129, 0.2); color: #34d399; }
.search-text { font-size: 13px; color: #c0c0d8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Search highlight on messages */
.msg.search-highlight { box-shadow: inset 0 0 0 2px rgba(99, 102, 241, 0.4); }
.msg.search-dim { opacity: 0.3; }
mark.search-mark { background: rgba(250, 204, 21, 0.4); color: inherit; border-radius: 2px; padding: 0 1px; }

/* Jump flash animation */
.msg.jump-flash { animation: jumpFlash 1.5s ease; }
@keyframes jumpFlash {
  0%, 100% { box-shadow: none; }
  20%, 60% { box-shadow: inset 0 0 0 2px #6366f1, 0 0 20px rgba(99, 102, 241, 0.3); }
}

/* Pinned Panel */
.pinned-panel {
  background: rgba(15, 15, 35, 0.98);
  border-bottom: 1px solid rgba(99, 102, 241, 0.15);
  max-height: 250px;
  overflow-y: auto;
  padding: 8px 12px;
}
.pinned-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.pinned-header h3 { margin: 0; font-size: 14px; color: #e0e0f0; }
.pinned-list { margin-top: 6px; }
.pinned-item {
  display: flex;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  align-items: center;
  transition: background 0.15s;
}
.pinned-item:hover { background: rgba(99, 102, 241, 0.1); }
.pinned-text { font-size: 13px; color: #c0c0d8; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.unpin-btn { background: none; border: none; color: #888; cursor: pointer; font-size: 16px; padding: 2px 6px; }
.unpin-btn:hover { color: #ef4444; }
.pinned-empty { font-size: 13px; color: #666; padding: 12px 0; text-align: center; }

/* Pinned indicator on messages */
.msg.pinned::before {
  content: '📌';
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 12px;
}
.msg { position: relative; }

/* Context Menu */
.msg-context-menu {
  position: fixed;
  z-index: 1000;
  background: rgba(20, 20, 40, 0.98);
  border: 1px solid rgba(99, 102, 241, 0.25);
  border-radius: 10px;
  padding: 4px;
  min-width: 140px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
}
.ctx-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: #e0e0f0;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.15s;
}
.ctx-btn:hover { background: rgba(99, 102, 241, 0.15); }
.ctx-btn-danger:hover { background: rgba(239, 68, 68, 0.15); color: #ef4444; }

/* Edit bar */
.edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(99, 102, 241, 0.1);
  border-top: 1px solid rgba(99, 102, 241, 0.25);
  font-size: 13px;
  color: #818cf8;
}
.edit-label { font-weight: 500; }
.msg.editing { box-shadow: inset 0 0 0 2px rgba(99, 102, 241, 0.5); }

/* Edited indicator */
.edited-indicator {
  display: inline-block;
  font-size: 11px;
  color: #888;
  margin-left: 6px;
  font-style: italic;
}

/* Delete animation */
.msg.msg-deleting {
  animation: msgDelete 0.3s ease forwards;
}
@keyframes msgDelete {
  to { opacity: 0; transform: translateX(-20px) scale(0.95); height: 0; margin: 0; padding: 0; overflow: hidden; }
}

/* Hidden utility */
.hidden { display: none !important; }
