/* ── User Profile Panel (slides from right) ── */
.profile-sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 32rem;
  background: var(--bg);
  backdrop-filter: var(--blur-xl);
  -webkit-backdrop-filter: var(--blur-xl);
  border-left: 1px solid rgba(0, 0, 0, 0.04);
  z-index: 300;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition);
}

[data-theme="dark"] .profile-sheet {
  background: rgba(10, 10, 10, 0.95);
  border-left-color: rgba(255, 255, 255, 0.04);
}

.profile-sheet.open {
  transform: translateX(0);
}

/* Header */
.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  flex-shrink: 0;
}

[data-theme="dark"] .profile-header {
  border-bottom-color: rgba(255, 255, 255, 0.04);
}

.profile-header-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--fg);
}

/* User info banner */
.profile-user-banner {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  flex-shrink: 0;
}

[data-theme="dark"] .profile-user-banner {
  border-bottom-color: rgba(255, 255, 255, 0.04);
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-2xl);
  background: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: var(--fg);
  opacity: 0.8;
  flex-shrink: 0;
}

.profile-user-info {
  flex: 1;
  min-width: 0;
}

.profile-user-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-user-email {
  font-size: 14px;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-user-location {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--fg-faint);
  opacity: 0.7;
  margin-top: 4px;
}

.profile-user-location svg {
  width: 12px;
  height: 12px;
}

/* Tabs */
.profile-tabs {
  display: flex;
  margin: 12px 16px 0;
  padding: 4px;
  background: var(--secondary);
  border-radius: var(--radius-xl);
  flex-shrink: 0;
}

.profile-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border: none;
  background: none;
  border-radius: calc(var(--radius-xl) - 4px);
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  cursor: pointer;
  font-family: var(--font);
  transition: all var(--transition-fast);
}

.profile-tab:hover {
  color: var(--fg);
}

.profile-tab.active {
  background: var(--bg);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

.profile-tab svg {
  width: 14px;
  height: 14px;
}

.profile-tab .tab-count {
  font-size: 10px;
  background: var(--secondary);
  padding: 1px 6px;
  border-radius: 9999px;
}

/* Tab content */
.profile-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  min-height: 0;
}

/* When messages tab is active, remove padding and make it flex */
.profile-content.messages-view {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.profile-tab-panel {
  display: none;
}

.profile-tab-panel.active {
  display: block;
}

/* Messages panel needs flex layout */
.profile-tab-panel[data-panel="messages"].active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#chatListView {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#chatThreadView {
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.chat-thread-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  flex-shrink: 0;
}

[data-theme="dark"] .chat-thread-header {
  border-bottom-color: rgba(255, 255, 255, 0.04);
}

.chat-thread-header .chat-header-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Form fields */
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.profile-field label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
}

.profile-field label svg {
  width: 12px;
  height: 12px;
}

.profile-field input,
.profile-field textarea {
  padding: 10px 14px;
  border: 1px solid rgba(0, 0, 0, 0.04);
  border-radius: var(--radius);
  background: var(--secondary);
  color: var(--fg);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition-fast);
}

[data-theme="dark"] .profile-field input,
[data-theme="dark"] .profile-field textarea {
  border-color: rgba(255, 255, 255, 0.04);
}

.profile-field input:focus,
.profile-field textarea:focus {
  border-color: var(--border-focus);
}

.profile-field input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.profile-field textarea {
  resize: none;
  min-height: 80px;
}

.profile-field .field-hint {
  font-size: 10px;
  color: var(--fg-faint);
  opacity: 0.6;
}

/* Location card */
.profile-location-card {
  border-radius: var(--radius-xl);
  border: 1px solid rgba(0, 0, 0, 0.04);
  background: var(--secondary);
  padding: 16px;
}

[data-theme="dark"] .profile-location-card {
  border-color: rgba(255, 255, 255, 0.04);
}

.profile-location-empty {
  border-radius: var(--radius-xl);
  border: 1px dashed rgba(0, 0, 0, 0.08);
  background: var(--secondary);
  padding: 24px;
  text-align: center;
}

[data-theme="dark"] .profile-location-empty {
  border-color: rgba(255, 255, 255, 0.04);
}

.profile-location-empty svg {
  width: 32px;
  height: 32px;
  color: var(--fg-faint);
  opacity: 0.3;
  margin: 0 auto 8px;
  display: block;
}

.profile-location-empty p {
  font-size: 14px;
  color: var(--fg-faint);
  opacity: 0.6;
}

.profile-location-empty .hint {
  font-size: 12px;
  color: var(--fg-faint);
  opacity: 0.4;
  margin-top: 4px;
}

/* Location header row */
.profile-location-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

/* Listings & Favorites items */
.profile-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-xl);
  background: var(--secondary);
  border: 1px solid rgba(0, 0, 0, 0.03);
  margin-bottom: 8px;
}

[data-theme="dark"] .profile-item {
  border-color: rgba(255, 255, 255, 0.03);
}

.profile-item-info {
  flex: 1;
  min-width: 0;
}

.profile-item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
}

.profile-item-desc {
  font-size: 12px;
  color: var(--fg-faint);
  opacity: 0.7;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.profile-item-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-light);
  color: var(--fg-muted);
}

.profile-item-date {
  font-size: 10px;
  color: var(--fg-faint);
  opacity: 0.5;
}

/* Empty state in tabs */
.profile-empty {
  text-align: center;
  padding: 48px 16px;
}

.profile-empty svg {
  width: 40px;
  height: 40px;
  color: var(--fg-faint);
  opacity: 0.3;
  margin: 0 auto 12px;
  display: block;
}

.profile-empty .title {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-muted);
}

.profile-empty .hint {
  font-size: 12px;
  color: var(--fg-faint);
  opacity: 0.6;
  margin-top: 4px;
  max-width: 200px;
  margin-left: auto;
  margin-right: auto;
}

/* Settings section */
.settings-section {
  margin-bottom: 24px;
}

.settings-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.settings-section-header svg {
  width: 12px;
  height: 12px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-radius: var(--radius-xl);
  background: var(--secondary);
  border: 1px solid rgba(0, 0, 0, 0.03);
  margin-bottom: 8px;
}

[data-theme="dark"] .settings-row {
  border-color: rgba(255, 255, 255, 0.03);
}

.settings-row-info {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.settings-row-info svg {
  width: 16px;
  height: 16px;
  color: var(--fg-muted);
  margin-top: 2px;
}

.settings-row-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg);
}

.settings-row-desc {
  font-size: 12px;
  color: var(--fg-faint);
  opacity: 0.7;
  margin-top: 2px;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch .slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 9999px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.toggle-switch .slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 9999px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform var(--transition-fast);
}

.toggle-switch input:checked + .slider {
  background: var(--primary);
}

.toggle-switch input:checked + .slider::before {
  transform: translateX(20px);
}

/* Loading state in profile */
.profile-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 16px;
}

.profile-loading .spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--fg-muted);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* Delete account button */
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-xl);
  background: transparent;
  color: var(--destructive);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
  transition: background var(--transition-fast);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

@media (max-width: 640px) {
  .profile-sheet { max-width: 100vw; }
  .profile-tab { font-size: 11px; gap: 4px; }
}
