/* ============================================================
   auth.css - 로그인/회원가입/모달 전체 스타일
   
   왜 #auth-gate 접두사를 사용하는가?
   → style.css의 전역 규칙(input, button 등)이 CSS 변수
     (--text-primary: #1a1a2e)를 사용하므로 라이트 모드에서
     어두운 배경 위에 어두운 텍스트가 되어 안 보임.
     #auth-gate 접두사로 특이성을 높여 전역 규칙을 덮어씀.
   ============================================================ */

/* ─── 게이트 (전체 오버레이) ─── */
#auth-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
  font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #e2e8f0;
  /* 왜 color를 여기서 명시? → 모든 자식 요소가 기본으로 밝은 텍스트를 상속 */
}

/* ─── 컨테이너 ─── */
#auth-gate .auth-container {
  text-align: center;
  max-width: 420px;
  padding: 40px 24px;
  width: 100%;
}

/* ─── 로고·타이틀 ─── */
#auth-gate .auth-logo {
  font-size: 56px;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 12px rgba(59,130,246,0.3));
}

#auth-gate .auth-title {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 4px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #3b82f6; /* Firefox 폴백 */
}

#auth-gate .auth-subtitle {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 24px;
  line-height: 1.6;
}

/* ─── 탭 전환 (로그인 / 회원가입) ─── */
#auth-gate .auth-tabs {
  display: flex;
  margin-bottom: 20px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.15);
}

#auth-gate .auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: transparent;
  color: #94a3b8;
  transition: all 0.2s;
  font-family: inherit;
}

#auth-gate .auth-tab.active {
  background: rgba(59,130,246,0.15);
  color: #3b82f6;
}

/* 회원가입 탭 활성 시 보라색 */
#auth-gate .auth-tab.active-signup {
  background: rgba(139,92,246,0.15);
  color: #8b5cf6;
}

/* ─── 폼 ─── */
#auth-gate .auth-form {
  margin-bottom: 16px;
}

#auth-gate .auth-field {
  margin-bottom: 10px;
}

/* ─── 입력 필드 (핵심) ───
   왜 background: #1e293b?
   → rgba(255,255,255,0.05)는 #0f172a 배경에서 거의 투명.
     #1e293b는 배경보다 밝아서 입력 영역이 시각적으로 구분됨.
   왜 color: #ffffff?
   → CSS 변수를 쓰면 라이트 모드에서 #1a1a2e(어두움)가 적용.
     하드코딩해서 어떤 테마든 흰색 텍스트를 보장.
*/
#auth-gate .auth-input {
  width: 100% !important;
  padding: 12px 14px !important;
  border: 1px solid rgba(255,255,255,0.2) !important;
  border-radius: 8px !important;
  background: #1e293b !important;
  color: #ffffff !important;
  font-size: 14px !important;
  font-family: inherit !important;
  outline: none !important;
  box-sizing: border-box !important;
  transition: border-color 0.2s, box-shadow 0.2s !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
}

/* placeholder - 모든 브라우저 대응 */
#auth-gate .auth-input::placeholder {
  color: #94a3b8 !important;
  opacity: 1 !important;
}
#auth-gate .auth-input::-webkit-input-placeholder { color: #94a3b8 !important; opacity: 1 !important; }
#auth-gate .auth-input::-moz-placeholder { color: #94a3b8 !important; opacity: 1 !important; }
#auth-gate .auth-input:-ms-input-placeholder { color: #94a3b8 !important; opacity: 1 !important; }

/* 포커스 */
#auth-gate .auth-input:focus {
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.25) !important;
}

/* ─── Chrome/Safari/Edge 자동완성(autofill) 보정 ─── */
#auth-gate .auth-input:-webkit-autofill,
#auth-gate .auth-input:-webkit-autofill:hover,
#auth-gate .auth-input:-webkit-autofill:focus,
#auth-gate .auth-input:-webkit-autofill:active {
  -webkit-text-fill-color: #ffffff !important;
  -webkit-box-shadow: 0 0 0px 1000px #1e293b inset !important;
  box-shadow: 0 0 0px 1000px #1e293b inset !important;
  border-color: rgba(255,255,255,0.2) !important;
  transition: background-color 5000s ease-in-out 0s !important;
  caret-color: #ffffff !important;
}

/* ─── 비밀번호 찾기 링크 ─── */
#auth-gate .auth-forgot {
  text-align: right;
  margin-bottom: 14px;
}

#auth-gate .auth-link-small {
  font-size: 11px;
  color: #3b82f6;
  text-decoration: none;
}
#auth-gate .auth-link-small:hover {
  text-decoration: underline;
}

/* ─── 버튼 공통 ─── */
#auth-gate .auth-btn {
  width: 100%;
  padding: 13px;
  border: none !important;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.15s, box-shadow 0.15s, background 0.2s;
  color: #ffffff;
}
#auth-gate .auth-btn:hover {
  transform: translateY(-1px);
}
#auth-gate .auth-btn:active {
  transform: translateY(0);
}

/* 로그인 버튼 */
#auth-gate .auth-btn-primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 16px rgba(59,130,246,0.3);
}
#auth-gate .auth-btn-primary:hover {
  box-shadow: 0 6px 24px rgba(59,130,246,0.4);
}

/* 회원가입 버튼 */
#auth-gate .auth-btn-signup {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9) !important;
  color: #ffffff !important;
  box-shadow: 0 4px 16px rgba(139,92,246,0.3);
}
#auth-gate .auth-btn-signup:hover {
  box-shadow: 0 6px 24px rgba(139,92,246,0.4);
}

/* Google 소셜 로그인 버튼 */
#auth-gate .auth-btn-google {
  padding: 12px 24px;
  border: 1px solid rgba(255,255,255,0.15) !important;
  background: rgba(255,255,255,0.06) !important;
  color: #e2e8f0 !important;
  font-weight: 500;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
#auth-gate .auth-btn-google:hover {
  background: rgba(255,255,255,0.12) !important;
  border-color: rgba(255,255,255,0.25) !important;
  transform: translateY(-1px);
}

/* ─── 약관 동의 ───
   왜 <label>이 아니라 <div>?
   → <label> 안의 <a>에서 e.preventDefault()를 호출하면
     일부 브라우저에서 checkbox 토글도 막힘.
     <div>로 바꾸면 체크박스와 링크가 독립적으로 동작.
*/
#auth-gate .auth-agree {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: #94a3b8;
}

#auth-gate .auth-checkbox {
  margin-top: 2px;
  accent-color: #8b5cf6;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  /* 체크박스는 일반 appearance 유지 */
  -webkit-appearance: checkbox !important;
  -moz-appearance: checkbox !important;
  appearance: checkbox !important;
  background: transparent !important;
  border: none !important;
}

#auth-gate .auth-link-purple {
  color: #a78bfa;
  text-decoration: underline;
}
#auth-gate .auth-link-purple:hover {
  color: #c4b5fd;
}

#auth-gate .auth-required {
  color: #ef4444;
}

/* ─── 구분선 ─── */
#auth-gate .auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}
#auth-gate .auth-divider-line {
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.1);
}
#auth-gate .auth-divider-text {
  font-size: 11px;
  color: #64748b;
}

/* ─── 로딩 ─── */
#auth-gate .auth-loading {
  margin-top: 20px;
  font-size: 14px;
  color: #94a3b8;
}

/* ─── 푸터 텍스트 ─── */
#auth-gate .auth-footer-text {
  color: #64748b;
  font-size: 11px;
  margin-top: 20px;
  line-height: 1.6;
}

#auth-gate .auth-link-blue {
  color: #3b82f6;
  text-decoration: none;
}
#auth-gate .auth-link-blue:hover {
  text-decoration: underline;
}

#auth-gate .auth-security {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
}
#auth-gate .auth-security p {
  font-size: 11px;
  color: #475569;
}

/* ============================================================
   법률 문서 모달 스타일 (이용약관, 개인정보처리방침)
   왜 하드코딩 색상?
   → 모달은 항상 어두운 배경 위에 표시되므로
     CSS 변수(라이트/다크 모드)에 의존하면 안 보일 수 있음.
   ============================================================ */
.legal-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.legal-modal {
  background: #1e293b;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 12px;
  max-width: 600px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.legal-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.legal-modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.legal-modal-close {
  background: none !important;
  border: none !important;
  color: #94a3b8 !important;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}
.legal-modal-close:hover {
  background: rgba(255,255,255,0.1) !important;
  color: #ffffff !important;
}

.legal-modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.8;
  color: #cbd5e1;
}

/* 모달 내 제목 (제1조, 제2조 등) */
.legal-modal-body h4 {
  color: #60a5fa !important;
  font-size: 14px;
  font-weight: 700;
  margin: 16px 0 8px;
}

.legal-modal-body h4:first-child {
  margin-top: 0;
}

/* 모달 내 본문 텍스트 */
.legal-modal-body p {
  color: #cbd5e1;
  margin-bottom: 12px;
}

/* 모달 내 테이블 */
.legal-modal-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 8px 0;
}

.legal-modal-body td {
  padding: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  color: #cbd5e1;
}

.legal-modal-body td:first-child {
  color: #94a3b8;
  white-space: nowrap;
}

/* 모달 내 시행일 */
.legal-modal-body .legal-date {
  margin-top: 20px;
  color: #64748b;
  font-size: 11px;
}

/* ============================================================
   모바일 반응형 (320px ~ 480px)
   ============================================================ */
@media (max-width: 480px) {
  #auth-gate .auth-container {
    padding: 24px 16px;
  }
  #auth-gate .auth-logo {
    font-size: 44px;
    margin-bottom: 12px;
  }
  #auth-gate .auth-title {
    font-size: 26px;
  }
  #auth-gate .auth-subtitle {
    font-size: 12px;
    margin-bottom: 18px;
  }
  #auth-gate .auth-input {
    padding: 14px 12px !important;
    font-size: 16px !important;
    /* 왜 16px? → iOS Safari에서 font-size < 16px이면
       입력 시 자동 확대(zoom)가 발생하는 것을 방지 */
  }
  #auth-gate .auth-btn {
    padding: 14px;
    font-size: 15px;
  }
  #auth-gate .auth-tab {
    padding: 12px;
  }

  /* 모달 모바일 대응 */
  .legal-modal {
    max-height: 90vh;
    border-radius: 8px;
  }
  .legal-modal-body {
    padding: 16px;
    font-size: 12px;
  }
}
