/* account.css — Profile card (Settings), sidebar user-row avatar image, and
   the sidebar-history "…" menu.
   Loaded last (index.html) so it can refine app.css's shared .btn/.field-input/
   .settings-* rules without !important. Uses the same CSS custom properties
   app.css defines per theme/edition; no colours are hard-coded here. */

/* ---------------------------------------------------------------------
   Sidebar user row: #user-avatar carries an <img> when the account has an
   avatar, otherwise app.css's plain initials text — this only styles the
   image case, since app.css already sizes/rounds the .avatar circle.
--------------------------------------------------------------------- */

.avatar { overflow: hidden; position: relative; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

/* ---------------------------------------------------------------------
   Profile card
--------------------------------------------------------------------- */

.profile-card { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }

.profile-avatar-col { display: flex; flex-direction: column; align-items: center; gap: 8px; flex-shrink: 0; }

.profile-avatar-frame {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  overflow: hidden;
  /* the same seal as the chat avatar: --accent-contrast is written for the
     kit's fill, and ivory initials on the plain champagne accent read 1.4:1 */
  background: var(--kit-accent-grad, var(--accent));
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  border: 1px solid var(--border);
}
.profile-avatar-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }

.profile-avatar-actions { display: flex; gap: 8px; }
.profile-avatar-actions .btn { min-height: 36px; padding: 0 12px; font-size: 12.5px; }

.profile-avatar-hint { font-size: 11px; color: var(--text-faint); text-align: center; max-width: 110px; }

.profile-fields { flex: 1; min-width: 240px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.profile-fields .field-full { grid-column: 1 / -1; }

.profile-field label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.profile-field .field-input:disabled { opacity: .65; cursor: not-allowed; }
.profile-field .field-note { font-size: 11px; color: var(--text-faint); margin-top: 4px; }
.profile-field .field-error { color: var(--danger); font-size: 11.5px; margin-top: 4px; min-height: 1em; }
.profile-field .field-input.is-invalid { border-color: var(--danger); }

.profile-actions-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
}
.profile-save-note { font-size: 12px; color: var(--text-faint); }
.profile-save-note.is-error { color: var(--danger); }
.profile-save-note.is-ok { color: var(--accent-strong); }

@media (max-width: 560px) {
  .profile-card { flex-direction: column; align-items: center; }
  .profile-fields { grid-template-columns: 1fr; width: 100%; }
}

/* ---------------------------------------------------------------------
   Sidebar history: pinned group + "…" item menu
--------------------------------------------------------------------- */

.history-item-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 2px;
}
.history-item-row .history-item {
  flex: 1;
  min-width: 0;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.history-pin-mark {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--accent-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.history-item-menu-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--text-faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s ease, background .12s ease, color .12s ease;
}
.history-item-row:hover .history-item-menu-btn,
.history-item-row:focus-within .history-item-menu-btn,
.history-item-menu-btn[aria-expanded="true"] {
  opacity: 1;
}
.history-item-menu-btn:hover,
.history-item-menu-btn[aria-expanded="true"] {
  background: var(--bg-sunken);
  color: var(--text);
}
@media (max-width: 720px), (hover: none) {
  /* Touch devices have no hover to reveal it by, and rely on long-press
     (see js: contextmenu) — but the button stays reachable by tap too. */
  .history-item-menu-btn { opacity: 1; }
}

.history-item-popover {
  position: absolute;
  top: 100%;
  right: 4px;
  z-index: 40;
  min-width: 190px;
  margin-top: 4px;
  padding: 6px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--panel);
  backdrop-filter: blur(10px) saturate(1.1);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.history-item-popover button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  border-radius: var(--radius-sm, 8px);
  cursor: pointer;
}
.history-item-popover button:hover,
.history-item-popover button:focus-visible {
  background: var(--bg-sunken);
  outline: none;
}
.history-item-popover button.is-danger { color: var(--danger); }
.history-item-popover button svg { flex-shrink: 0; }
.history-item-popover hr { border: none; border-top: 1px solid var(--border); margin: 4px 2px; }

.history-item-rename-input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 0 8px;
  border-radius: var(--radius-sm, 8px);
  border: 1px solid var(--accent);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

/* ---------------------------------------------------------------------
   Delete-conversation confirm dialog (reuses the app's scrim/sheet look)
--------------------------------------------------------------------- */

.confirm-sheet-scrim {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
  padding: 16px;
}
.confirm-sheet {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  backdrop-filter: blur(10px) saturate(1.1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px;
}
.confirm-sheet h2 { margin: 0 0 8px; font-size: 15.5px; }
.confirm-sheet p { margin: 0 0 16px; font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.confirm-sheet-actions { display: flex; gap: 10px; }
.confirm-sheet-actions .btn { flex: 1; min-height: 44px; }
