// src/components/TermsPopup/TermsPopup.module.less

// 컬러 변수 정의
@lg-primary-color: #C70850;
@background-color: #E6EBF0;
@white: #FFFFFF;
@border-color: #CCCCCC;
@scrollbar-color: #666666;
@scrollbar-track-color: #CCCCCC;
@button-secondary-color: #777D8A;
@button-text-color: #E6E6E6;
@black: #000000;
@button-shadow: rgba(0, 0, 0, 0.50);
@popup-shadow: rgba(0, 0, 0, 0.30);

// 폰트 변수
@font-family: 'LG Smart UI', sans-serif;

// 크기 변수
@popup-padding-top: 60px;
@popup-padding-bottom: 40px;  
@popup-padding-horizontal: 57px;
@header-padding: 17px 31px;
@content-padding: 31px;
@button-width: 240px;
@button-height: 80px;
@button-gap: 12px;
@content-height: 460px;
@border-radius-small: 4px;
@border-radius-medium: 12px;

// TPopUp 오버라이드 스타일
.popup {
  // TPopUp 컴포넌트 기본 스타일 오버라이드
  :global(.enact_ui_Popup_Popup_popup) {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    padding: @popup-padding-top @popup-padding-horizontal @popup-padding-bottom @popup-padding-horizontal;
    background: @background-color;
    box-shadow: 0px 20px 12px @popup-shadow;
    border-radius: @border-radius-small;
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    overflow: hidden;
  }
}

// 메인 컨테이너
.container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
  max-width: calc(100vw - 114px); // 좌우 패딩 57px * 2 = 114px 제외
  max-height: calc(100vh - 100px); // 상하 패딩 60px + 40px = 100px 제외
}

// 약관 카드
.termsCard {
  width: 100%;
  flex: 1; // 남은 공간을 모두 차지
  background: @white;
  border-radius: @border-radius-small;
  border: 1px solid @border-color;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  overflow: hidden; // 내용이 넘치지 않도록
}

// 헤더 영역
.header {
  width: 100%;
  padding: @header-padding;
  background: @white;
  border-bottom: 1px solid @border-color;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  
  .title {
    text-align: center;
    color: @lg-primary-color;
    font-size: 30px;
    font-family: @font-family;
    font-weight: 700;
    line-height: 36px;
    word-wrap: break-word;
  }
}

// 내용 영역
.contentArea {
  width: 100%;
  flex: 1; // 헤더를 제외한 남은 공간 차지
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  min-height: 0; // flexbox 축소 허용
}

// 스크롤러 컨테이너 - 전체 영역 차지
.scrollerContainer {
  width: 100%;
  height: 100%; // contentArea의 높이에 맞춤
  padding: @content-padding;
  display: flex;
  justify-content: flex-start;
  align-items: flex-start;
  min-width: 0; // flexbox 축소 허용
}

// TButtonScroller 커스터마이징
.scroller {
  width: 100%;
  height: 100%;
  
  // TButtonScroller 컴포넌트 스타일 오버라이드
  :global(.enact_ui_Scroller_Scroller_scroller) {
    width: 100%;
    height: 100%;
  }
  
  // 스크롤바를 오른쪽에 표시하고 커스텀 스타일 적용
  :global(.enact_ui_Scroller_Scroller_scrollbar) {
    position: absolute !important;
    right: 0 !important;
    top: 0 !important;
    width: 44px !important;
    height: 100% !important;
    background: transparent !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    align-items: center !important;
  }
  
  // 스크롤바 썸 (가운데 트랙 부분)
  :global(.enact_ui_Scroller_Scroller_thumb) {
    width: 4px !important;
    background: @scrollbar-color !important;
    border-radius: 0 !important;
    position: absolute !important;
    left: 20px !important; // 44px의 중앙
  }
  
  // 스크롤바 트랙 영역
  :global(.enact_ui_Scroller_Scroller_track) {
    width: 4px !important;
    background: @scrollbar-track-color !important;
    position: absolute !important;
    left: 20px !important; // 44px의 중앙
    top: 44px !important; // 상단 버튼 높이만큼
    bottom: 44px !important; // 하단 버튼 높이만큼
  }
  
  // 스크롤바 영역에 상하 버튼 추가 (CSS로 구현)
  :global(.enact_ui_Scroller_Scroller_scrollbar)::before {
    content: '';
    width: 44px;
    height: 44px;
    background: #9C9898;
    box-shadow: 0px 8px 6.6px rgba(156, 152, 152, 0.34);
    position: relative;
    flex-shrink: 0;
  }
  
  :global(.enact_ui_Scroller_Scroller_scrollbar)::after {
    content: '';
    width: 44px;
    height: 44px;
    background: #9C9898;
    box-shadow: 0px 8px 6.6px rgba(156, 152, 152, 0.34);
    position: relative;
    flex-shrink: 0;
  }
}

// 약관 내용
.termsContent {
  width: 100%;
  height: auto;
  
  .termsTitle {
    color: @black;
    font-size: 26px;
    font-family: @font-family;
    font-weight: 700;
    word-wrap: break-word;
    margin-bottom: 20px;
  }
  
  .termsText {
    color: @black;
    font-size: 26px;
    font-family: @font-family;
    font-weight: 400;
    word-wrap: break-word;
    line-height: 1.4;
  }
}

// 스크롤바 영역 제거 (TButtonScroller의 기본 스크롤바 사용)
// .scrollbarArea 클래스 전체 제거

// 버튼 영역
.buttonArea {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0 229px; // 상하 패딩 제거, 좌우만 유지
  flex-shrink: 0; // 축소되지 않도록
}

// 버튼 컨테이너
.buttonContainer {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: @button-gap;
}

// TButton 커스터마이징
.agreeButton {
  width: @button-width;
  height: @button-height;
  max-width: 450px;
  min-width: 150px;
  border-radius: @border-radius-medium;
  
  // TButton primary 타입 오버라이드
  :global(.enact_ui_Button_Button_button) {
    background: @lg-primary-color !important;
    box-shadow: 0px 0px 50px @button-shadow;
    border: none;
    width: 100%;
    height: 100%;
    border-radius: @border-radius-medium;
    transition: all 0.2s ease;
    
    color: @white !important;
    font-size: 30px !important;
    font-family: @font-family !important;
    font-weight: 700 !important;
    text-align: center;
    
    &:hover {
      transform: translateY(-2px);
      box-shadow: 0px 5px 55px @button-shadow;
    }
    
    &:active {
      transform: translateY(0);
      box-shadow: 0px 0px 50px @button-shadow;
    }
    
    &:focus {
      outline: 3px solid @white;
      outline-offset: 2px;
    }
  }
}

.closeButton {
  width: @button-width;
  height: @button-height;
  max-width: 450px;
  min-width: 150px;
  border-radius: @border-radius-medium;
  
  // TButton secondary 타입 오버라이드
  :global(.enact_ui_Button_Button_button) {
    background: @button-secondary-color !important;
    border-radius: @border-radius-medium;
    border: none;
    width: 100%;
    height: 100%;
    transition: all 0.2s ease;
    
    color: @button-text-color !important;
    font-size: 30px !important;
    font-family: @font-family !important;
    font-weight: 700 !important;
    text-align: center;
    
    &:hover {
      transform: translateY(-2px);
      background: lighten(@button-secondary-color, 10%) !important;
    }
    
    &:active {
      transform: translateY(0);
    }
    
    &:focus {
      outline: 3px solid @white;
      outline-offset: 2px;
    }
  }
}

// 반응형 디자인
@media screen and (max-width: 1280px) {
  .popup :global(.enact_ui_Popup_Popup_popup) {
    padding: 30px;
  }
  
  .container {
    max-width: calc(100vw - 60px);
    max-height: calc(100vh - 60px);
  }
  
  .buttonArea {
    padding: 0 100px;
  }
  
  .header .title,
  .termsContent .termsTitle,
  .termsContent .termsText {
    font-size: 24px;
  }
  
  .agreeButton,
  .closeButton {
    width: 200px;
    height: 70px;
    
    :global(.enact_ui_Button_Button_button) {
      font-size: 26px !important;
    }
  }
}

@media screen and (max-width: 960px) {
  .popup :global(.enact_ui_Popup_Popup_popup) {
    padding: 20px;
  }
  
  .container {
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
  }
  
  .buttonArea {
    padding: 0 50px;
  }
  
  .header .title,
  .termsContent .termsTitle,
  .termsContent .termsText {
    font-size: 20px;
  }
  
  .agreeButton,
  .closeButton {
    width: 180px;
    height: 60px;
    
    :global(.enact_ui_Button_Button_button) {
      font-size: 22px !important;
    }
  }
  
  .contentArea {
    flex-direction: column;
  }
  
  .scrollerContainer {
    height: 300px;
  }
  
  .scrollbarArea {
    display: none;
  }
}