/* ============================================================
   인증 — 사이드 하단 사용자 메뉴 + 로그인 팝업 (ChatGPT 풍)
   ============================================================ */

/* ── 사이드바를 세로 플렉스로: 본문이 남는 공간을 채워 사용자 메뉴를 항상 맨 아래로 ── */
.sidebar { display: flex; flex-direction: column; }
.sidebar-body { flex: 1 0 auto; }
/* 하단 사용자 메뉴 호스트 — 플로팅(sticky) 아님. 마지막 메뉴와 100px 이상 띄우고 맨 아래에 배치 */
.user-menu-host {
  margin-top: 120px;
  padding-top: 16px; padding-bottom: 4px;
  border-top: 1px solid var(--line);
}

/* ── 공통 아바타 ── */
.user-avatar {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff;
  font-family: var(--font-ui); font-weight: 700; font-size: 13px; line-height: 1;
}
/* 게스트 아바타 — 배경 없이 사람 아이콘만 테마색으로.
   위쪽 그룹 아이콘과 좌측·크기를 맞추기 위해 고정폭 해제 + 왼쪽 정렬 */
.user-avatar.guest {
  background: transparent; color: var(--title);
  width: 16px; height: auto; justify-content: flex-start;
}
/* 프로필 사진(예: 구글) 아바타 */
.user-avatar.photo { background: transparent; object-fit: cover; }

/* ── 로그아웃 상태: 로그인 박스 (로그인 상태 행과 동일한 은은한 형식) ── */
.user-loginbox {
  display: flex; align-items: center; gap: 8px;
  /* 안쪽 패딩(10px)으로 hover 테두리·배경이 아이콘에 붙지 않게 + 음수 마진으로
     박스를 좌우로 넓혀 hover 면이 벽에 붙지 않고 떠 보이게.
     결과적으로 아이콘 자체는 위쪽 메뉴 아이콘과 같은 선상에 정렬됨 */
  width: calc(100% + 20px); margin: 0 -10px;
  padding: 8px 10px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink); cursor: pointer;
  font-family: var(--font-ui); text-align: left; transition: border-color .12s ease, background .12s ease;
}
.user-loginbox:hover { background: var(--surface); border-color: var(--line); }
/* 텍스트가 남는 폭을 채워 화살표를 오른쪽 끝으로 → 좌우 균형 */
.user-loginbox-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; flex: 1; }
/* '로그인' 글자 테마색 적용 */
.user-loginbox-title { font-size: 13.5px; font-weight: 700; color: var(--title); }
.user-loginbox-sub { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
/* 우측 진입 화살표 (디자인 요소) — 박스 균형 + 클릭 유도 */
.user-loginbox-arrow { flex-shrink: 0; color: var(--ink-3); margin-right: 2px; transition: color .12s ease, transform .12s ease; }
.user-loginbox:hover .user-loginbox-arrow { color: var(--title); transform: translateX(2px); }

/* ── 로그인 상태: 사용자 행 + 계정 메뉴 ── */
.user-menu-wrap { position: relative; }
.user-row {
  display: flex; align-items: center; gap: 8px;
  /* 로그아웃 박스와 동일: 음수 마진으로 hover 면을 띄우고 아바타는 메뉴 아이콘과 정렬 */
  width: calc(100% + 20px); margin: 0 -10px;
  padding: 8px 10px; border: 1px solid transparent; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink); cursor: pointer;
  font-family: var(--font-ui); text-align: left; transition: background .12s ease;
}
.user-row:hover { background: var(--surface); border-color: var(--line); }
.user-row-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; flex: 1; }
.user-row-name { font-size: 13.5px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-row-sub { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-row .user-chev { flex-shrink: 0; color: var(--ink-3); transition: transform .18s ease; }
.user-menu-wrap.open .user-chev { transform: rotate(180deg); }

.user-menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  box-shadow: 0 8px 28px rgba(0,0,0,.16); padding: 6px; min-width: 200px;
  display: none; flex-direction: column; gap: 2px; z-index: 30;
}
.user-menu-wrap.open .user-menu { display: flex; }
.user-menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 6px; background: transparent;
  color: var(--ink); font-family: var(--font-ui); font-size: 13.5px; cursor: pointer; text-align: left;
}
.user-menu-item:hover { background: var(--surface-2); }
.user-menu-item .umi-ico { color: var(--ink-2); flex-shrink: 0; }
.user-menu-item.danger { color: var(--warn); }
.user-menu-item.danger .umi-ico { color: var(--warn); }

/* ── 축소 레일 상태: 아바타만 표시 ── */
@media (min-width: 901px) {
  .app.sidebar-collapsed .user-menu-host {
    /* 본문이 숨겨져 채울 요소가 없으므로 auto 로 맨 아래 정렬 */
    margin-top: auto; padding: 10px 0; border-top: 0;
    display: flex; justify-content: center;
  }
  .app.sidebar-collapsed .user-loginbox,
  .app.sidebar-collapsed .user-row {
    width: 42px; height: 42px; margin: 0; padding: 0; justify-content: center; gap: 0; border-color: transparent;
  }
  .app.sidebar-collapsed .user-loginbox-text,
  .app.sidebar-collapsed .user-row-text,
  .app.sidebar-collapsed .user-row .user-chev { display: none; }
  .app.sidebar-collapsed .user-menu { left: 8px; right: auto; min-width: 200px; }
}

/* ============================================================
   로그인 팝업 (ChatGPT 로그인 페이지 형태)
   ============================================================ */
.auth-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(0,0,0,.45);
  opacity: 0; transition: opacity .18s ease;
}
.auth-backdrop.open { opacity: 1; }

.auth-card {
  position: relative; width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 24px 64px rgba(0,0,0,.28);
  padding: 40px 36px 28px;
  transform: translateY(8px) scale(.985); transition: transform .18s ease;
}
.auth-backdrop.open .auth-card { transform: translateY(0) scale(1); }

.auth-close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-3); font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: background .12s ease, color .12s ease;
}
.auth-close:hover { background: var(--surface-2); color: var(--ink); }

.auth-head { text-align: center; margin-bottom: 26px; }
.auth-logo { width: 46px; height: 46px; object-fit: contain; margin-bottom: 16px; }
.auth-title { font-family: var(--font-ui); font-size: 24px; font-weight: 700; color: var(--ink); margin: 0; letter-spacing: -0.01em; }
.auth-sub { font-size: 13.5px; color: var(--ink-2); margin: 8px 0 0; }

.auth-form { display: flex; flex-direction: column; gap: 4px; }
.auth-label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.auth-input {
  width: 100%; font-family: var(--font-ui); font-size: 15px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 13px 14px; margin-bottom: 8px;
}
.auth-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.auth-err { font-size: 12px; color: var(--warn); margin: -4px 0 8px; }

.auth-primary {
  width: 100%; font-family: var(--font-ui); font-weight: 600; font-size: 15px;
  background: var(--accent); color: #fff; border: 0; border-radius: 999px;
  padding: 13px 16px; cursor: pointer; transition: background .15s ease; margin-top: 4px;
}
.auth-primary:hover { background: var(--accent-2); }

/* 이메일 표시 + 편집 (비밀번호 단계) */
.auth-pill {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; margin-bottom: 14px; padding: 11px 14px;
  border: 1px solid var(--line-2); border-radius: 999px; background: var(--surface-2);
  color: var(--ink); font-family: var(--font-ui); font-size: 14px; cursor: pointer; text-align: left;
}
.auth-pill:hover { border-color: var(--accent); }
.auth-pill-edit { color: var(--accent); font-size: 12.5px; font-weight: 600; flex-shrink: 0; }

.auth-foot { text-align: center; font-size: 13.5px; color: var(--ink-2); margin-top: 18px; }
.auth-link { color: var(--accent-2); font-weight: 600; }
.auth-link:hover { text-decoration: underline; }

.auth-or { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--ink-3); font-size: 12.5px; }
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.auth-social { display: flex; flex-direction: column; gap: 10px; }
.auth-social-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 11px 16px; border: 1px solid var(--line-2); border-radius: 999px;
  background: var(--surface); color: var(--ink); font-family: var(--font-ui); font-size: 14px;
  cursor: pointer; transition: background .12s ease, border-color .12s ease;
}
.auth-social-btn:hover { background: var(--surface-2); border-color: var(--line-2); }
.auth-social-btn svg { flex-shrink: 0; }
.auth-social-apple svg { color: var(--ink); }
.auth-social-err { margin-top: 10px; font-size: 12.5px; color: var(--warn); text-align: center; line-height: 1.4; }

@media (max-width: 480px) {
  .auth-card { padding: 34px 22px 22px; border-radius: 14px; }
  .auth-title { font-size: 21px; }
}
