/* ============================================================
   Sentimind — Profile Components
   프로필 카드, 설정, 페르소나, 알림, 토글, 비밀번호, 로그아웃
   ============================================================ */

/* ===== Profile Section ===== */
.profile-screen {
  animation: fadeInUp 400ms cubic-bezier(0.25,0.46,0.45,0.94) both;
}
.profile-screen[hidden] { display: none; }

.profile-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.profile-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--gradient-response);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}
.profile-info {
  flex: 1;
  min-width: 0;
}
.profile-nickname {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--color-text);
}
.profile-email {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-stats-row {
  display: flex;
  gap: 0;
  border: 1px solid var(--color-divider);
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.profile-stat {
  flex: 1;
  text-align: center;
  padding: 0.75rem 0.5rem;
}
.profile-stat + .profile-stat {
  border-left: 1px solid var(--color-divider);
}
.profile-stat-value {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-text);
  display: block;
}
.profile-stat-label {
  font-size: 0.7rem;
  color: var(--color-text-muted);
}

.profile-admin-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
}
.profile-admin-entry[hidden] {
  display: none;
}

.profile-admin-kicker {
  margin: 0 0 0.25rem;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  font-weight: var(--weight-semibold);
  color: var(--color-text-muted);
}

.profile-admin-copy {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: var(--leading-base);
}

.profile-admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  transition: opacity 150ms ease;
}

.profile-admin-link:hover {
  opacity: 0.88;
}

.profile-admin-link:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .profile-admin-entry {
    flex-direction: column;
    align-items: stretch;
  }
  .profile-admin-link {
    text-align: center;
  }
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.profile-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.profile-field label {
  font-size: 0.85rem;
  color: var(--color-text-light);
  font-weight: 500;
}
.profile-field input,
.profile-field textarea {
  font-family: var(--font-body);
  font-size: 0.9rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: none;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color 200ms ease;
  resize: none;
}
.profile-field input:focus,
.profile-field textarea:focus {
  border-color: var(--color-primary);
}

.profile-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}
.btn-profile-save {
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 200ms ease;
}
.btn-profile-save:hover { background: var(--color-primary-hover); }
.btn-profile-save:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-profile-save:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.btn-profile-back {
  background: var(--color-surface-warm);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 200ms ease;
}
.btn-profile-back:hover { background: var(--color-divider); }
.btn-profile-back:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.profile-section {
  margin-top: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.profile-section-title {
  padding: 0.7rem 1rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  background: var(--color-surface-warm);
  user-select: none;
}
.profile-section-title:hover { background: var(--color-divider); }
.profile-section[open] > .profile-section-title { border-bottom: 1px solid var(--color-border); }
.profile-section .profile-form { padding: 1rem; }
.profile-section-danger { border-color: #e74c3c44; }
.profile-section-danger > .profile-section-title { color: #c0392b; }
.danger-warning {
  padding: 0.8rem 1rem 0;
  font-size: 0.8rem;
  color: #c0392b;
  line-height: 1.5;
}
.btn-danger {
  display: block;
  margin: 0.8rem 1rem 1rem;
  background: #c0392b;
  color: #fff;
  border: none;
  padding: 0.55rem 1.2rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 200ms ease;
}
.btn-danger:hover { background: #a93226; }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }

/* Profile Section Cards */
.profile-section-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  margin-bottom: 1rem;
  overflow: hidden;
}
.profile-section-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--color-divider);
  background: var(--color-surface-warm);
}
.profile-section-card-header svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--color-text-light);
}
.profile-section-card-header h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0;
}
.profile-section-card-body {
  padding: 1rem;
}

/* Profile streak in profile tab */
.profile-streak-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 0;
}
.profile-streak-number {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1;
  min-width: 3rem;
  text-align: center;
}
.profile-streak-info {
  flex: 1;
}
.profile-streak-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text);
}
.profile-streak-sub {
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
}

/* Bio character counter */
.profile-field-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.15rem;
}
.char-counter {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  transition: color 200ms;
}
.char-counter.near-limit { color: var(--color-warning, #e67e22); }
.char-counter.at-limit { color: var(--color-error); font-weight: 600; }

.profile-choice-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.profile-choice-btn {
  background: var(--color-surface-warm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--color-text);
  cursor: pointer;
  transition: all 200ms ease;
}
.profile-choice-btn:hover {
  border-color: var(--color-primary);
  background: var(--color-surface);
}
.profile-choice-btn[aria-pressed="true"] {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.profile-choice-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.persona-preset-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
.persona-preset-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  min-height: 92px;
  background: var(--color-surface-warm);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  font-family: var(--font-body);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  transition: border-color 200ms ease, background 200ms ease, transform 200ms ease;
}
.persona-preset-btn:hover {
  border-color: var(--color-primary);
  background: var(--color-surface);
}
.persona-preset-btn[aria-pressed="true"] {
  border-color: var(--color-primary);
  background: rgba(139,126,116,0.1);
}
.persona-preset-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}
.persona-preset-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}
.persona-preset-desc {
  font-size: var(--text-xs);
  line-height: var(--leading-base);
  color: var(--color-text-light);
}
@media (max-width: 560px) {
  .persona-preset-group { grid-template-columns: 1fr; }
}

/* Notification time presets */
.notification-time-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.notification-time-btn {
  background: var(--color-surface-warm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-text);
  cursor: pointer;
  transition: all 200ms ease;
}
.notification-time-btn:hover {
  border-color: var(--color-primary);
  background: var(--color-surface);
}
.notification-time-btn[aria-pressed="true"] {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.notification-time-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Dark mode toggle improved */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.65rem 0;
}
.setting-row + .setting-row {
  border-top: 1px solid var(--color-divider);
}
.setting-row-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}
.setting-row-desc {
  font-size: var(--text-xs);
  color: var(--color-text-light);
  margin-top: 0.2rem;
  line-height: var(--leading-base);
}
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--color-border);
  border-radius: 12px;
  transition: background 200ms;
}
.toggle-switch input:checked + .toggle-track {
  background: var(--color-primary);
}
.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 200ms;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked ~ .toggle-knob {
  transform: translateX(20px);
}
.toggle-switch input:focus-visible ~ .toggle-track {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Password strength in profile */
.profile-pw-strength {
  display: flex;
  gap: 3px;
  margin-top: 0.3rem;
}
.profile-pw-bar {
  height: 3px;
  flex: 1;
  border-radius: 2px;
  background: var(--color-divider);
  transition: background 300ms;
}
.profile-pw-strength[data-level="weak"] .profile-pw-bar:nth-child(1) { background: #e74c3c; }
.profile-pw-strength[data-level="fair"] .profile-pw-bar:nth-child(-n+2) { background: #e67e22; }
.profile-pw-strength[data-level="good"] .profile-pw-bar:nth-child(-n+3) { background: #f1c40f; }
.profile-pw-strength[data-level="strong"] .profile-pw-bar { background: #27ae60; }

.btn-logout {
  display: block;
  width: 100%;
  background: none;
  border: 1px solid var(--color-error);
  color: var(--color-error);
  padding: 0.6rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 200ms ease;
  margin-top: 1rem;
}
.btn-logout:hover { background: var(--color-error-bg); }
.btn-logout:focus-visible { outline: 2px solid var(--color-error); outline-offset: 2px; }

.profile-message {
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-top: 0.5rem;
  text-align: center;
}
.profile-message[hidden] { display: none; }
.profile-message.success { background: var(--color-success-bg); color: var(--color-success); }
.profile-message.error { background: var(--color-error-bg); color: var(--color-error); }
.profile-message.warning { background: #fff8e1; color: #b8860b; }
[data-theme="dark"] .profile-message.warning { background: #2e2a1a; color: #fbbf24; }

/* Notification time custom input */
.notification-time-custom {
  width: 5.5rem;
  text-align: center;
}

/* Profile section resets */
.profile-section--no-top { margin-top: 0; border: none; }
.profile-section-title--reset { background: none; padding-left: 0; }
.profile-form--top-pad { padding: 0.75rem 0 0; }
.profile-section--danger-gap { margin-top: 0.75rem; }
.danger-warning--reset { padding-left: 0; }
.btn-danger--reset { margin-left: 0; }

/* Profile Sub-Tabs — stats-sub와 동일 패턴 */
.profile-sub-nav {
  display: flex;
  gap: 2px;
  background: var(--color-surface-warm);
  border-radius: var(--radius-md);
  padding: 3px;
  margin-bottom: 1.25rem;
}
.profile-sub-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 0.55rem 0.75rem;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 200ms ease;
}
.profile-sub-tab:hover { color: var(--color-text-light); }
.profile-sub-tab.active,
.profile-sub-tab[aria-selected="true"] {
  color: var(--color-text);
  font-weight: var(--weight-semibold);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}
.profile-sub-tab:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}
.profile-tab-panel[hidden] { display: none; }
.profile-tab-panel { animation: tabFadeIn 250ms ease-out both; }

@media (prefers-reduced-motion: reduce) {
  .profile-tab-panel { animation: none; }
}
