/* ============================================================================
   USER PROFILE DIALOG
   Prefix: up-
   ============================================================================ */

/* Overlay */
.up-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 200ms ease;
}

.up-overlay.up-visible {
  opacity: 1;
}

/* Dialog */
.up-dialog {
  width: 600px;
  max-width: 95vw;
  max-height: 80vh;
  background: var(--card-bg, #ffffff);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(10px);
  transition: transform 200ms ease;
  overflow: hidden;
}

.up-overlay.up-visible .up-dialog {
  transform: scale(1) translateY(0);
}

/* Header */
.up-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0 24px;
}

.up-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.up-header-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--color-primary, #2563eb);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.up-header-avatar-img {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.up-header-info h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--color-gray-800, #1f2937);
  margin: 0;
  line-height: 1.3;
}

.up-header-info p {
  font-size: 13px;
  color: var(--color-gray-500, #6b7280);
  margin: 0;
}

.up-close {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-gray-400, #9ca3af);
  transition: all 150ms;
}

.up-close:hover {
  background: var(--color-primary-bg, #eff6ff);
  color: var(--color-gray-600, #4b5563);
}

/* Tabs */
.up-tabs {
  display: flex;
  gap: 0;
  padding: 16px 24px 0 24px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.up-tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-gray-500, #6b7280);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 150ms;
  margin-bottom: -1px;
}

.up-tab:hover {
  color: var(--color-gray-700, #374151);
}

.up-tab.up-tab-active {
  color: var(--color-primary, #2563eb);
  border-bottom-color: var(--color-primary, #2563eb);
}

/* Content area */
.up-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* --- Profile tab --- */
.up-profile-fields {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Mugshot section */
.up-mugshot-section {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  margin-bottom: 4px;
}

.up-mugshot-preview {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.up-mugshot-img {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border-color, #e2e8f0);
}

.up-mugshot-remove {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  background: var(--color-error, #ef4444);
  color: white;
  border: 2px solid var(--card-bg, white);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 150ms;
}

.up-mugshot-remove:hover {
  transform: scale(1.15);
}

.up-mugshot-empty {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--content-bg, #f1f5f9);
  border: 2px dashed var(--border-color, #d1d5db);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-gray-400, #9ca3af);
  flex-shrink: 0;
}

.up-mugshot-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.up-mugshot-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-primary, #2563eb);
  background: var(--color-primary-bg, #eff6ff);
  border: 1px solid var(--color-primary, #2563eb);
  border-radius: 8px;
  cursor: pointer;
  transition: all 150ms;
}

.up-mugshot-btn:hover {
  background: var(--color-primary, #2563eb);
  color: white;
}

.up-mugshot-hint {
  font-size: 11px;
  color: var(--color-gray-400, #9ca3af);
}

/* Field styling */
.up-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.up-field-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-gray-500, #6b7280);
}

.up-field-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--color-gray-800, #1f2937);
  padding: 10px 14px;
  background: var(--content-bg, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
}

.up-field-value-muted {
  color: var(--color-gray-400, #9ca3af);
  font-style: italic;
}

/* Editable field input */
.up-field-input {
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  color: var(--color-gray-800, #1f2937);
  padding: 10px 14px;
  background: var(--card-bg, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  transition: border-color 150ms, box-shadow 150ms;
}

.up-field-input:focus {
  outline: none;
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 0 0 3px var(--color-primary-bg, #eff6ff);
}

.up-field-input::placeholder {
  color: var(--color-gray-400, #9ca3af);
  font-weight: 400;
}

.up-field-textarea {
  resize: vertical;
  min-height: 48px;
}

/* Action bar (Edit / Save+Cancel) */
.up-action-bar {
  display: flex;
  justify-content: flex-end;
  padding-top: 20px;
  margin-top: 8px;
  border-top: 1px solid var(--border-color, #e2e8f0);
}

.up-action-bar-edit {
  gap: 10px;
}

.up-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-primary, #2563eb);
  background: var(--color-primary-bg, #eff6ff);
  border: 1px solid var(--color-primary, #2563eb);
  border-radius: 8px;
  cursor: pointer;
  transition: all 150ms;
}

.up-edit-btn:hover {
  background: var(--color-primary, #2563eb);
  color: white;
}

.up-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: 600;
  color: white;
  background: var(--color-primary, #2563eb);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 150ms;
}

.up-save-btn:hover {
  background: var(--color-primary-dark, #1d4ed8);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.up-cancel-btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-gray-600, #4b5563);
  background: var(--card-bg, white);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  cursor: pointer;
  transition: all 150ms;
}

.up-cancel-btn:hover {
  background: var(--content-bg, #f8fafc);
  border-color: var(--color-gray-400, #9ca3af);
}

/* View-mode mugshot (no edit controls) */
.up-mugshot-preview-view {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

/* --- Preferences tab --- */
.up-section {
  margin-bottom: 28px;
}

.up-section:last-child {
  margin-bottom: 0;
}

.up-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-gray-800, #1f2937);
  margin-bottom: 4px;
}

.up-section-desc {
  font-size: 12px;
  color: var(--color-gray-500, #6b7280);
  margin-bottom: 14px;
}

/* Language selector */
.up-language-select {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  background: var(--card-bg, #ffffff);
  color: var(--color-gray-800, #1f2937);
  cursor: pointer;
  appearance: auto;
}

.up-language-select:focus {
  outline: none;
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 0 0 3px var(--color-primary-bg, #eff6ff);
}

/* Dark mode toggle row */
.up-darkmode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--content-bg, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
}

.up-darkmode-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.up-darkmode-text h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-gray-800, #1f2937);
  margin: 0;
}

.up-darkmode-text p {
  font-size: 12px;
  color: var(--color-gray-500, #6b7280);
  margin: 0;
}

.up-darkmode-icons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.up-darkmode-icons svg {
  transition: opacity 200ms;
}

/* Toggle switch */
.up-switch {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
  display: inline-block;
}

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

.up-slider {
  position: absolute;
  inset: 0;
  background: #cbd5e1;
  border-radius: 12px;
  transition: background 200ms;
}

.up-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 200ms;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.up-switch input:checked + .up-slider {
  background: var(--color-primary, #2563eb);
}

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

/* Preset grid inside dialog */
.up-presets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.up-preset {
  position: relative;
  padding: 12px;
  background: var(--card-bg, white);
  border: 2px solid var(--border-color, #e5e7eb);
  border-radius: 10px;
  cursor: pointer;
  transition: all 200ms ease;
}

.up-preset:hover {
  border-color: var(--color-gray-300, #d1d5db);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.up-preset.up-preset-active {
  border-color: var(--color-primary, #2563eb);
  background: var(--color-primary-bg, #eff6ff);
}

.up-preset-colors {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.up-preset-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.up-preset-name {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-gray-700, #374151);
}

.up-preset-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  background: var(--color-primary, #2563eb);
  border-radius: 50%;
  display: none;
  align-items: center;
  justify-content: center;
  color: white;
}

.up-preset.up-preset-active .up-preset-check {
  display: flex;
}

/* --- Dark mode overrides --- */
[data-theme="dark"] .up-dialog {
  background: #18181b;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .up-header-info h2,
[data-theme="dark"] .up-section-title,
[data-theme="dark"] .up-darkmode-text h4 {
  color: #e4e4e7;
}

[data-theme="dark"] .up-header-info p,
[data-theme="dark"] .up-section-desc,
[data-theme="dark"] .up-field-label,
[data-theme="dark"] .up-darkmode-text p,
[data-theme="dark"] .up-mugshot-hint {
  color: #a1a1aa;
}

[data-theme="dark"] .up-field-value {
  background: #27272a;
  border-color: #3f3f46;
  color: #e4e4e7;
}

[data-theme="dark"] .up-field-input {
  background: #27272a;
  border-color: #3f3f46;
  color: #e4e4e7;
}

[data-theme="dark"] .up-field-input::placeholder {
  color: #71717a;
}

[data-theme="dark"] .up-language-select {
  background: #27272a;
  border-color: #3f3f46;
  color: #e4e4e7;
}

[data-theme="dark"] .up-darkmode-row {
  background: #27272a;
  border-color: #3f3f46;
}

[data-theme="dark"] .up-preset {
  border-color: #3f3f46;
}

[data-theme="dark"] .up-preset-name {
  color: #d4d4d8;
}

[data-theme="dark"] .up-close:hover {
  background: #27272a;
}

[data-theme="dark"] .up-tabs {
  border-bottom-color: #3f3f46;
}

[data-theme="dark"] .up-tab {
  color: #a1a1aa;
}

[data-theme="dark"] .up-tab:hover {
  color: #d4d4d8;
}

[data-theme="dark"] .up-preset-dot {
  border-color: #3f3f46;
}

[data-theme="dark"] .up-action-bar {
  border-top-color: #3f3f46;
}

[data-theme="dark"] .up-edit-btn {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.5);
}

[data-theme="dark"] .up-cancel-btn {
  background: #27272a;
  border-color: #3f3f46;
  color: #a1a1aa;
}

[data-theme="dark"] .up-mugshot-section {
  border-bottom-color: #3f3f46;
}

[data-theme="dark"] .up-mugshot-empty {
  background: #27272a;
  border-color: #52525b;
  color: #71717a;
}

[data-theme="dark"] .up-mugshot-btn {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.5);
}

[data-theme="dark"] .up-mugshot-remove {
  border-color: #18181b;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .up-dialog {
    width: 100%;
    max-height: 90vh;
    border-radius: 12px;
    margin: 16px;
  }

  .up-presets-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .up-mugshot-section {
    flex-direction: column;
    text-align: center;
  }

  .up-mugshot-actions {
    align-items: center;
  }
}
