/* ================================================
   모달 콘텐츠 뷰어 스타일
================================================ */

/* 전체 불투명 레이어 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
  backdrop-filter: blur(2px);
  /* 모달이 열렸을 때 배경 스크롤 방지 */
  overflow: hidden;
}

/* 모달이 열렸을 때 body 스크롤 방지 */
body.modal-open {
  overflow: hidden !important;
  position: fixed !important;
  top: 0 !important;
  width: 100%;
  height: 100%;
}

/* 모달 콘텐츠 뷰어 */
.modal-content-viewer {
  position: relative;
  width: 90%;
  max-width: 1200px;
  max-height: 95vh;
  background: white;
  border-radius: 20px;
  overflow: hidden;
  display: flex;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

/* 모달 내부 콘텐츠 래퍼 */
.modal-content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 40px;
  padding-right: 60px;
}

/* 닫기 버튼 - 하단 가운데 고정 */
.modal-close-btn {
  width: 50px;
  height: 50px;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10002;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

/* 데스크탑용 닫기 버튼 - 하단 가운데 고정 */
.modal-close-btn.desktop {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 50px;
  height: 50px;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10002;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.modal-close-btn:hover {
  background: var(--button-blue);
}

/* 네비게이션 버튼 - 데스크탑용 */
.modal-nav-btn.desktop {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  z-index: 10002;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.modal-nav-btn.desktop:hover {
  background: var(--button-blue);
  transform: translateY(-50%);
}

.modal-nav-btn.desktop.prev {
  left: 20px;
}

.modal-nav-btn.desktop.next {
  right: 20px;
}

/* 콘텐츠 헤더 */
.modal-content-header {
  margin-bottom: 20px;
  flex-shrink: 0;
}

.modal-content-title {
  font-size: 28px;
  font-weight: var(--font-weight-bold);
  color: var(--text-secondary);
  margin-bottom: 15px;
  line-height: 1.3;
}

.modal-content-meta {
  display: flex;
  gap: 20px;
  align-items: center;
}

.modal-content-date {
  font-size: var(--font-size-base);
  color: #929292;
  font-weight: 300;
}

.modal-content-category {
  color: #39b3e7;
  font-size: var(--font-size-base);
  font-weight: 300;
  padding: 4px 12px;
  background-color: rgba(57, 179, 231, 0.1);
  border-radius: 20px;
}

/* 미디어 영역 */
.modal-content-media {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  margin-bottom: 20px;
  min-height: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.modal-content-media img {
  max-width: 100%;
  width: auto;
  height: auto;
  border-radius: 10px;
  margin-bottom: 15px;
  flex-shrink: 0;
  display: block;
}

.modal-content-media video {
  max-width: 100%;
  width: 100%;
  height: auto;
  max-height: 60vh;
  border-radius: 10px;
  flex-shrink: 0;
  object-fit: contain;
}

/* YouTube iframe 스타일 */
.modal-content-video-container iframe {
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  border: none;
  border-radius: 10px;
  flex-shrink: 0;
}

/* 비디오 컨테이너 내부 요소들 */
.modal-content-video-container .video-item {
  width: 100%;
  margin-bottom: 20px;
  flex-shrink: 0;
}

/* 비디오 컨테이너 */
.modal-content-video-container {
  width: 100%;
  max-height: 60vh;
  margin-bottom: 20px;
  flex-shrink: 0;
}

.modal-content-video-container video {
  width: 100%;
  max-height: 60vh;
  border-radius: 10px;
  object-fit: contain;
}

.modal-content-media .media-item {
  margin-bottom: 15px;
  flex-shrink: 0;
}

.modal-content-media .media-item:last-child {
  margin-bottom: 0;
}

/* 미디어 영역 내 텍스트 컨테이너 */
.modal-content-text-container {
  margin-top: auto;
  flex-shrink: 0;
  padding-right: 30%;
}

.modal-content-text-container .modal-content-text {
  font-size: var(--font-size-base);
  line-height: 1.7;
  color: var(--text-secondary);
  margin-top: 20px;
  white-space: pre-wrap;
}

/* 콘텐츠 본문 */
.modal-content-body {
  flex-shrink: 0;
  margin-bottom: 20px;
}

.modal-content-text {
  font-size: var(--font-size-base);
  line-height: 1.7;
  color: var(--text-secondary);
  margin-bottom: 20px;
  white-space: pre-wrap;
}

/* 첨부파일 (개선된 스타일) */

.attachments-container .attachments-title {
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 15px;
}

.attachment-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.attachment-item {
  display: flex;
}

.attachment-item a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  background-color: #f1f3f5;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #343a40;
  text-decoration: none;
  transition: all 0.2s ease-in-out;
  border: 1px solid #dee2e6;
  width: 100%;
}

.attachment-item a:hover {
  background-color: #e9ecef;
  border-color: #adb5bd;
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.attachment-item .download-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #495057;
}

.attachment-item .attachment-name {
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-item.invalid {
  color: #999;
  cursor: not-allowed;
  padding: 10px 15px;
  background-color: #f8f9fa;
  border-radius: 8px;
  font-size: 0.9rem;
}

/* 반응형 - 태블릿 */
@media (max-width: 1023px) {
  .modal-content-viewer {
    width: 95%;
    max-height: 90vh;
  }

  .modal-content-wrapper {
    padding: 30px;
    padding-right: 50px;
  }

  .modal-content-title {
    font-size: 24px;
  }

  .modal-content-header {
    margin-bottom: 15px;
  }

  /* 태블릿 모드에서는 데스크탑용 닫기 버튼 숨김 */
  .modal-close-btn {
    display: none;
  }

  /* 태블릿 모드에서는 데스크탑용 네비게이션 버튼 숨김 */
  .modal-nav-btn.desktop {
    display: none;
  }

  .modal-content-meta {
    gap: 15px;
  }

  .modal-content-media {
    min-height: 350px;
    margin-bottom: 15px;
  }

  .modal-content-video-container {
    max-height: 50vh;
  }

  .modal-content-video-container video {
    max-height: 50vh;
  }

  /* 태블릿용 YouTube iframe 높이 조정 */
  .modal-content-video-container iframe {
    height: auto;
    aspect-ratio: 16/9;
    max-height: 50vh;
  }

  /* 태블릿용 텍스트 컨테이너 패딩 조정 */
  .modal-content-text-container {
    padding-right: 20%;
  }
}

/* 반응형 - 모바일 */
@media (max-width: 767px) {
  .modal-overlay {
    align-items: flex-start;
    padding-top: 20px;
    overflow-y: auto;
  }

  .modal-content-viewer {
    width: 95%;
    max-height: none;
    border-radius: 15px;
    margin: 20px 0;
  }

  .modal-content-wrapper {
    padding: 20px;
    padding-bottom: 80px;
  }

  .modal-content-header {
    margin-bottom: 10px;
  }

  /* 모바일 모드에서는 데스크탑용 닫기 버튼 숨김 */
  .modal-close-btn {
    display: none;
  }

  /* 모바일 모드에서는 데스크탑용 네비게이션 버튼 숨김 */
  .modal-nav-btn.desktop {
    display: none;
  }

  .modal-content-title {
    font-size: 20px;
    margin-bottom: 10px;
  }

  .modal-content-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
  }

  .modal-content-date,
  .modal-content-category {
    font-size: var(--font-size-sm);
  }

  .modal-content-text {
    font-size: var(--font-size-sm);
  }

  .modal-content-media {
    min-height: 250px;
    margin-bottom: 15px;
  }

  .modal-content-video-container {
    max-height: 40vh;
  }

  .modal-content-video-container video {
    max-height: 40vh;
  }

  /* 모바일용 YouTube iframe 높이 조정 */
  .modal-content-video-container iframe {
    height: auto;
    aspect-ratio: 16/9;
    max-height: 40vh;
  }

  .modal-content-body {
    margin-bottom: 15px;
  }

  /* 모바일용 텍스트 컨테이너 패딩 조정 */
  .modal-content-text-container {
    padding-right: 15%;
  }
}

/* 데스크탑용 네비게이션 버튼 표시 */
@media (min-width: 1024px) {
  .modal-nav-btn.desktop {
    display: flex;
  }

  /* 데스크탑 모드에서는 닫기 버튼 표시 */
  .modal-close-btn.desktop {
    display: flex;
  }
}

/* 모바일 및 태블릿용 하단 버튼 컨테이너 */
.bottom-modal-controls {
  position: fixed;
  bottom: 20px;
  left: 0;
  right: 0;
  z-index: 10002;
  display: none;
  justify-content: center;
  align-items: center;
  gap: 20px;
  width: 100%;
  margin: 0 auto;
  pointer-events: none;
}

.bottom-modal-controls > * {
  pointer-events: auto;
}

/* 모바일 및 태블릿용 닫기 버튼 */
.bottom-modal-controls .modal-close-btn {
  position: static;
  width: 50px;
  height: 50px;
  font-size: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  font-weight: bold;
  cursor: pointer;
  z-index: 10003;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
  border: none;
}

.bottom-modal-controls .modal-close-btn:hover {
  background: rgba(255, 255, 255, 0.8);
}

/* 모바일 및 태블릿용 네비게이션 버튼 */
.bottom-modal-controls .modal-nav-btn.mobile {
  position: static;
  width: 40px;
  height: 40px;
  font-size: 20px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  font-weight: bold;
  cursor: pointer;
  z-index: 10003;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
  border: none;
}

.bottom-modal-controls .modal-nav-btn.mobile:hover {
  background: rgba(255, 255, 255, 0.8);
}

/* 태블릿 및 모바일 모드에서 하단 버튼 표시 */
@media (max-width: 1023px) {
  .bottom-modal-controls {
    display: flex;
  }

  /* 모바일/태블릿 모드에서 X 버튼 가로 넓이 25% */
  .bottom-modal-controls .modal-close-btn {
    width: 25%;
    min-width: 50px;
    max-width: 80px;
    border-radius: 30px;
  }
}

/* 모바일 모드에서 하단 컨트롤 정렬 개선 */
@media (max-width: 767px) {
  .bottom-modal-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 20px;
    box-sizing: border-box;
    gap: 20px;
  }

  .bottom-modal-controls .modal-nav-btn.mobile {
    flex: 0 0 auto;
  }

  .bottom-modal-controls .modal-close-btn {
    flex: 0 0 auto;
  }
}
