/* 오버레이 */
.custom-popup-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(0,0,0,0.4);
  z-index: 9998;
  display: none;
}

/* 팝업 래퍼 (flex로 세로 배치) */
.custom-popup {
  display: flex;
  flex-direction: column;
  background: #FFF;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  overflow: hidden;
  /* 반응형을 위한 최소 크기 설정 */
  min-width: 200px;
  min-height: 150px;
  /* 모바일에서 화면을 벗어나지 않도록 */
  max-width: 95vw;
  max-height: 95vh;
}

/* 팝업 콘텐츠 영역 */
.popup-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  background: transparent;
  /* 높이는 inline style 로 설정됨 */
  overflow: auto; /* 내용이 넘칠 경우 스크롤 */
  /* 모바일에서 텍스트 줄바꿈 개선 */
  word-wrap: break-word;
  hyphens: auto;
}

/* 닫기/오늘하루 영역 */
.popup-controls {
  background: #f5f5f5;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0; /* 크기 고정 */
  min-height: 60px; /* 최소 높이 보장 */
}

/* 오늘 하루 보지 않기 */
.popup-controls .hide-for-today {
  padding: 0;
  border: none;
  background: none;
  font-size: 15px;
  color: #1d1d1d;
  font-weight: 400;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: color 0.2s ease;
}
.popup-controls .hide-for-today:hover {
  color: #0073aa;
}
.popup-controls .hide-for-today:focus {
  outline: 2px solid #0073aa;
  outline-offset: 2px;
}
.popup-controls .hide-for-today::before {
  content: "";
  display: inline-block;
  width: 16px; height: 16px;
  margin-right: 8px;
  border: 1px solid #ccc;
  border-radius: 2px;
}

/* 닫기 버튼 */
.popup-controls .close-popup {
  padding: 0;
  border: none;
  background: none;
  font-size: 15px;
  color: #888;
  font-weight: 400;
  cursor: pointer;
  transition: color 0.2s ease;
}
.popup-controls .close-popup:hover {
  color: #d63638;
}
.popup-controls .close-popup:focus {
  outline: 2px solid #d63638;
  outline-offset: 2px;
}

/* 페이드인, 페이드아웃 효과 */
/* 팝업과 오버레이 기본 상태: 투명도 1, 트랜지션 정의 */
.custom-popup,
.custom-popup-overlay {
  opacity: 1;
  transition: opacity 0.3s ease-in-out;
}

/* fade-out 클래스가 붙으면 opacity→0으로 0.3초간 서서히 사라짐 */
.custom-popup.fade-out,
.custom-popup-overlay.fade-out {
  opacity: 0;
}

/* 반응형 스타일 */
@media (max-width: 768px) {
  .custom-popup {
    /* 모바일에서는 더 작은 둥근 모서리 */
    border-radius: 12px;
    /* 모바일에서 그림자 조정 */
    box-shadow: 0 5px 20px rgba(0,0,0,0.25);
    /* 모바일에서 화면 경계 보장 */
    margin: 10px;
    /* 모바일에서 위치 강제 재설정 - 더 강력한 우선순위 */
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    /* 인라인 스타일 무효화 */
    margin-left: 0 !important;
    margin-right: 0 !important;
    /* 추가 보장 */
    max-width: 90vw !important;
    max-height: 90vh !important;
  }
  
  .popup-controls {
    /* 모바일에서 패딩 조정 */
    padding: 12px;
    min-height: 50px;
    /* 모바일에서 버튼 배치 개선 */
    flex-direction: column;
    gap: 8px;
  }
  
  .popup-controls .hide-for-today,
  .popup-controls .close-popup {
    /* 모바일에서 폰트 크기 조정 */
    font-size: 14px;
    /* 모바일에서 버튼 전체 너비 */
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .custom-popup {
    /* 매우 작은 화면에서는 더 작은 둥근 모서리 */
    border-radius: 8px;
    /* 매우 작은 화면에서 여백 조정 */
    margin: 5px;
    /* 매우 작은 화면에서 최대 크기 제한 */
    max-width: 95vw !important;
    max-height: 95vh !important;
    /* 매우 작은 화면에서 위치 강제 재설정 - 더 강력한 우선순위 */
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    /* 인라인 스타일 무효화 */
    margin-left: 0 !important;
    margin-right: 0 !important;
    /* 추가 보장 */
    width: auto !important;
    height: auto !important;
  }
  
  .popup-controls {
    /* 매우 작은 화면에서 패딩 조정 */
    padding: 10px;
    min-height: 45px;
  }
  
  .popup-controls .hide-for-today,
  .popup-controls .close-popup {
    /* 매우 작은 화면에서 폰트 크기 조정 */
    font-size: 13px;
  }
  
  .popup-inner {
    /* 매우 작은 화면에서 패딩 추가 */
    padding: 10px;
  }
}

/* 접근성 개선 */
.custom-popup:focus {
  outline: none; /* 기본 아웃라인 제거 */
}

.custom-popup[role="dialog"] {
  /* 스크린 리더를 위한 포커스 관리 */
  outline: none;
}

/* 고대비 모드 지원 */
@media (prefers-contrast: high) {
  .custom-popup {
    border: 2px solid #000;
  }
  
  .popup-controls {
    background: #000;
    color: #fff;
  }
  
  .popup-controls .hide-for-today,
  .popup-controls .close-popup {
    color: #fff;
  }
}

/* 다크 모드 지원 */
@media (prefers-color-scheme: dark) {
  .custom-popup {
    background: #2d2d2d;
    color: #fff;
  }
  
  .popup-controls {
    background: #3d3d3d;
  }
  
  .popup-controls .hide-for-today {
    color: #fff;
  }
  
  .popup-controls .close-popup {
    color: #ccc;
  }
}

/* 애니메이션 성능 최적화 */
.custom-popup,
.custom-popup-overlay {
  will-change: opacity;
  transform: translateZ(0); /* 하드웨어 가속 */
} 