/* ============================================
   WHISPR — Chats List (ChatGPT Style)
   Compatible with sessions.js chat-row structure
   ============================================ */

.chats-screen {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: 100vh;
  background: var(--bg-primary);
}

/* --- Header --- */
.chats-header {
  flex-shrink: 0;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--separator);
}

.chats-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
}

.chats-header__title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.chats-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chats-header__settings-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.15s ease;
}

.chats-header__settings-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.chats-header__settings-icon svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2; }

/* --- Chat List --- */
.chats-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.chats-list::-webkit-scrollbar { width: 4px; }
.chats-list::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

/* --- Chat Row (sessions.js structure) --- */
.chat-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.1s ease;
  position: relative;
}

.chat-row:hover { background: var(--bg-hover); }
.chat-row--hermes { background: var(--accent-light); }
.chat-row--hermes:hover { background: #10a37f20; }

.chat-row__avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  overflow: hidden;
}

.chat-row__body {
  flex: 1;
  min-width: 0;
}

.chat-row__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 2px;
}

.chat-row__name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-row__time {
  font-size: 12px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.chat-row__bottom {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-row__message,
.chat-row__desc {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.chat-row__meta {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.chat-row__hermes-badge {
  font-size: 14px;
  margin-left: 4px;
}

.chat-row__group-badge {
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 6px;
  border-radius: 4px;
}

/* --- Swipe Infrastructure --- */
.chat-row--swipe {
  position: relative;
  overflow: hidden;
  contain: layout style paint;
}

.chat-row--swipe-open .chat-row__actions {
  display: flex;
}

.chat-row__inner {
  position: relative;
  z-index: 2;
  background: var(--bg-primary);
  will-change: transform;
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  touch-action: pan-y;
}

.chat-row__delete-hit,
.chat-row__group-hit {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  z-index: 3;
  cursor: pointer;
}

.chat-row__delete-hit { right: 80px; }
.chat-row__group-hit { right: 40px; }

@media (prefers-reduced-motion: reduce) {
  .chat-row__inner {
    will-change: auto;
    -webkit-transform: none;
    transform: none;
  }
}

/* --- Swipe Actions --- */
.chat-row__actions {
  display: none;
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  align-items: center;
  gap: 8px;
  padding-right: 16px;
  background: linear-gradient(to right, transparent 20%, var(--bg-primary) 40%);
}

.chat-row__action {
  width: 80px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.1s ease;
}

.chat-row__action--delete { background: #e74c3c; color: #fff; }
.chat-row__action--group { background: var(--accent); color: #fff; }
.chat-row__action svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2; }
.chat-row__action-label { display: none; }

/* --- Modal / Dialog --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--surface-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  backdrop-filter: blur(4px);
}

.modal-overlay--visible {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface-elevated);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.95);
  transition: transform 0.2s ease;
  border: 1px solid var(--border);
}

.modal-overlay--visible .modal {
  transform: scale(1);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--separator);
}

.modal__title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal__close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.modal__close:hover { background: var(--bg-hover); }

.modal__body {
  padding: 20px;
}

.modal__field {
  margin-bottom: 16px;
}

.modal__label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.modal__input,
.modal__textarea,
.modal__select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.modal__input:focus,
.modal__textarea:focus,
.modal__select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-light);
}

.modal__input::placeholder,
.modal__textarea::placeholder {
  color: var(--text-tertiary);
}

.modal__input--emoji {
  width: 64px;
  text-align: center;
  font-size: 28px;
  padding: 8px 10px;
}

.modal__textarea {
  resize: none;
  min-height: 80px;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--separator);
}

.modal__btn {
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s ease, transform 0.1s ease;
}

.modal__btn:active {
  transform: scale(0.97);
}

.modal__btn--primary {
  background: var(--accent);
  color: #fff;
}

.modal__btn--primary:hover {
  background: var(--accent-dim);
}

.modal__btn--secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.modal__btn--secondary:hover {
  background: var(--bg-hover);
}

.modal__btn--cancel {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.modal__btn--cancel:hover {
  background: var(--bg-hover);
}

/* --- FAB (New Chat) --- */
.chats-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  transition: background 0.15s ease, transform 0.1s ease;
  z-index: 100;
}

.chats-fab:hover { background: var(--accent-dim); transform: scale(1.05); }
.chats-fab:active { transform: scale(0.95); }

/* --- Empty State --- */
.chats-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-tertiary);
  font-size: 13px;
}

/* --- Responsive --- */
@media (max-width: 600px) {
  .chats-header__inner { padding: 12px 16px; }
  .chats-header__title { font-size: 20px; }
  .chat-row { padding: 12px; }
  .chat-row__avatar { width: 42px; height: 42px; font-size: 18px; }
  .chats-fab { bottom: 16px; right: 16px; width: 52px; height: 52px; }
}
