/* ============================================================
   NESTIO — Vaultwarden / Bitwarden 프론트엔드 오버라이드 v2
   Angular SPA가 자체 스타일 덮어쓰므로 최대 특이성 + !important
   </body> 직전 주입으로 나중 로드 = 높은 우선순위
   ============================================================ */

:root,
html, body,
body.theme_dark,
body.theme_light,
body.theme_nord,
bit-layout {
  --nestio-warm: #1F1B17;
  --nestio-cream: #F5F0E6;
  --nestio-gold: #B8935A;
  --nestio-gold-light: #D9B984;

  /* Bitwarden tailwind CSS 변수 override */
  --color-background: #1F1B17 !important;
  --color-background-alt: #2A251F !important;
  --color-background-alt2: #2A251F !important;
  --color-text-main: #F5F0E6 !important;
  --color-text-muted: #A8A095 !important;
  --color-primary-500: #B8935A !important;
  --color-primary-600: #B8935A !important;
  --color-primary-700: #D9B984 !important;

  /* 구버전 Bitwarden 변수명 */
  --theme-background: #1F1B17 !important;
  --theme-text: #F5F0E6 !important;
  --primary: #B8935A !important;
  --primary-accent: #D9B984 !important;
}

/* ============================================================
   전역 배경 — 최대 특이성
   ============================================================ */
html,
html body,
html body.layout_frontend,
html body app-root,
html body app-root > *,
body > app-root,
bit-layout,
[class*="tw-bg-background"],
[class*="tw-bg-primary"],
.bg-background-alt,
.tw-min-h-screen {
  background-color: #1F1B17 !important;
  background-image: url('/brand/backgrounds/nestio-login-bg.svg') !important;
  background-size: cover !important;
  background-position: center !important;
  background-repeat: no-repeat !important;
  background-attachment: fixed !important;
  color: #F5F0E6 !important;
}

/* 어두운 오버레이 (배경 가독성) */
html body::before {
  content: '' !important;
  position: fixed !important;
  inset: 0 !important;
  background: rgba(31, 27, 23, 0.72) !important;
  z-index: 0 !important;
  pointer-events: none !important;
}
html body > * {
  position: relative !important;
  z-index: 1 !important;
}

/* ============================================================
   카드·패널 blur
   ============================================================ */
html body .card,
html body .modal-content,
html body .login-form,
html body .register-form,
html body form,
html body [class*="container"]:not(html):not(body),
html body [class*="bit-layout"] main,
html body [class*="ng-tns"] [class*="p-6"],
html body [class*="ng-tns"] [class*="p-8"] {
  background-color: rgba(42, 37, 31, 0.86) !important;
  backdrop-filter: blur(14px) !important;
  -webkit-backdrop-filter: blur(14px) !important;
  border: 1px solid rgba(245, 240, 230, 0.12) !important;
  border-radius: 12px !important;
}

/* ============================================================
   로고 교체 (배경 없는 트랜스패런트)
   Vault XPath:
   /html/body/app-root/ng-component/auth-anon-layout/
     bit-landing-layout/div/main/bit-landing-content/div/div/
     bit-landing-hero/div
   ============================================================ */

/* 핵심: Vault 로그인 랜딩 페이지 로고 영역 */
html body bit-landing-hero > div {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 140px !important;
  background-image: url('/brand/logos/logo-main-transparent.svg') !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  /* 기존 로고 SVG/텍스트 숨김 */
  overflow: hidden !important;
  color: transparent !important;
}
html body bit-landing-hero > div > * {
  visibility: hidden !important;
}

/* 일반 로고 셀렉터 (다른 페이지용) */
html body img[src*="logo-dark"],
html body img[src*="logo-light"],
html body img[src*="icon-white"],
html body img[src*="icon-dark"],
html body img[alt*="Vaultwarden" i],
html body img[alt*="Bitwarden" i],
html body .logo-image,
html body .login-logo,
html body [class*="logo"] img {
  content: url('/brand/logos/logo-main-transparent.svg') !important;
  max-width: 320px !important;
  width: auto !important;
  height: auto !important;
  display: inline-block !important;
}

/* ============================================================
   버튼 — 골드
   ============================================================ */
html body .btn-primary,
html body button[type="submit"],
html body button.btn.btn-primary,
html body [class*="bg-primary"],
html body bit-button[buttontype="primary"] button,
html body [class*="tw-bg-primary"] {
  background-color: #B8935A !important;
  border-color: #B8935A !important;
  color: #1F1B17 !important;
}
html body .btn-primary:hover,
html body button[type="submit"]:hover,
html body bit-button[buttontype="primary"] button:hover {
  background-color: #D9B984 !important;
  border-color: #D9B984 !important;
}

/* ============================================================
   링크
   ============================================================ */
html body a:not(.btn):not([class*="button"]):not([class*="tw-bg"]) {
  color: #B8935A !important;
}
html body a:not(.btn):hover {
  color: #D9B984 !important;
}

/* ============================================================
   입력 필드 — 어두운 톤
   ============================================================ */
html body input,
html body select,
html body textarea,
html body bit-form-field input {
  background-color: rgba(31, 27, 23, 0.6) !important;
  border-color: rgba(245, 240, 230, 0.2) !important;
  color: #F5F0E6 !important;
}
html body input:focus,
html body select:focus {
  border-color: #B8935A !important;
  outline: 2px solid #B8935A !important;
  outline-offset: 2px !important;
}

/* ============================================================
   스크롤바
   ============================================================ */
::-webkit-scrollbar { width: 8px !important; height: 8px !important; }
::-webkit-scrollbar-track { background: rgba(31,27,23,0.4) !important; }
::-webkit-scrollbar-thumb { background: rgba(184,147,90,0.5) !important; border-radius: 4px !important; }
::-webkit-scrollbar-thumb:hover { background: #B8935A !important; }
