/* PWA 전용 스타일 오버라이드 */
/* 이 파일은 PWA로 설치된 앱에서만 로드됩니다 */

/* 고대비 모드 감지 및 처리 */
@media (prefers-contrast: high) and (display-mode: standalone) {
  /* PWA에서 고대비 모드 스타일 오버라이드 */
  * {
    forced-color-adjust: none !important;
    -ms-high-contrast-adjust: none !important;
  }
}

/* PWA에서 강제 라이트 모드 적용 */
@media (display-mode: standalone) {
  /* Service Worker 업데이트 팝업 스타일 강제 */
  [class*="fixed"][class*="bottom-"][class*="z-"] {
    background-color: #ffffff !important;
    color: #000000 !important;
  }
  
  [class*="fixed"][class*="bottom-"][class*="z-"] * {
    color: inherit !important;
  }
  
  [class*="fixed"][class*="bottom-"][class*="z-"] button {
    cursor: pointer !important;
    pointer-events: auto !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -webkit-touch-callout: none !important;
  }
  /* 최상위 레벨에서 다크모드 비활성화 */
  html {
    color-scheme: light !important;
  }

  /* 루트 CSS 변수 강제 라이트 모드 */
  :root,
  :root.dark,
  :root[data-theme="dark"],
  html.dark {
    /* 라이트 모드 색상 강제 적용 */
    --background: 0 0% 100% !important;
    --foreground: 222.2 84% 4.9% !important;
    --card: 0 0% 100% !important;
    --card-foreground: 222.2 84% 4.9% !important;
    --popover: 0 0% 100% !important;
    --popover-foreground: 222.2 84% 4.9% !important;
    --primary: 24 9.8% 10% !important;
    --primary-foreground: 60 9.1% 97.8% !important;
    --secondary: 60 4.8% 95.9% !important;
    --secondary-foreground: 24 9.8% 10% !important;
    --muted: 60 4.8% 95.9% !important;
    --muted-foreground: 25 5.3% 44.7% !important;
    --accent: 60 4.8% 95.9% !important;
    --accent-foreground: 24 9.8% 10% !important;
    --destructive: 0 84.2% 60.2% !important;
    --destructive-foreground: 60 9.1% 97.8% !important;
    --border: 20 5.9% 90% !important;
    --input: 20 5.9% 90% !important;
    --ring: 20 14.3% 4.1% !important;
  }

  /* body 스타일 강제 */
  body,
  body.dark,
  body[data-theme="dark"] {
    background-color: #ffffff !important;
    color: #0a0a0a !important;
    background: #ffffff !important;
  }

  /* 모든 배경 요소 라이트 모드 강제 */
  .bg-background,
  .bg-card,
  .bg-popover,
  [class*="bg-gray-"],
  [class*="bg-slate-"],
  [class*="bg-zinc-"],
  [class*="bg-neutral-"],
  [class*="bg-stone-"] {
    background-color: var(--background) !important;
    color: var(--foreground) !important;
  }

  /* 다크모드 클래스 무효화 */
  .dark,
  [data-theme="dark"],
  [class*="dark:"] {
    /* 다크모드 스타일 무시 */
  }

  /* 텍스트 색상 강제 */
  * {
    color: inherit;
  }

  h1, h2, h3, h4, h5, h6,
  p, span, div, a, button,
  input, textarea, select {
    color: inherit;
  }

  /* 카드 및 컴포넌트 배경 */
  .card,
  [class*="rounded-"],
  [class*="shadow-"] {
    background-color: #ffffff !important;
  }

  /* 버튼 스타일 유지 */
  button,
  .btn,
  [role="button"] {
    /* 버튼은 원래 스타일 유지하되 텍스트는 읽을 수 있게 */
    color: var(--primary-foreground) !important;
  }

  /* 네비게이션 바 */
  nav,
  header,
  footer {
    background-color: #ffffff !important;
    border-color: #e5e7eb !important;
  }

  /* 입력 필드 */
  input,
  textarea,
  select {
    background-color: #ffffff !important;
    border-color: #d1d5db !important;
    color: #0a0a0a !important;
  }

  /* 모달 및 다이얼로그 */
  [role="dialog"],
  .modal,
  .dialog {
    background-color: #ffffff !important;
    color: #0a0a0a !important;
  }
}

/* iOS PWA 특별 처리 */
@supports (-webkit-touch-callout: none) {
  @media (display-mode: standalone) {
    /* iOS 상태바 영역 */
    html {
      background-color: #ffffff !important;
    }

    /* iOS 안전 영역 */
    body {
      padding-top: env(safe-area-inset-top);
      padding-bottom: env(safe-area-inset-bottom);
      padding-left: env(safe-area-inset-left);
      padding-right: env(safe-area-inset-right);
    }
  }
}

/* Android PWA 특별 처리 */
@media (display-mode: standalone) and (orientation: portrait) {
  /* Android 시스템 바 영역 */
  body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 24px;
    background-color: #ff6b35;
    z-index: 9999;
  }
}