/* 기본 레이아웃 */
body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  background-color: #f5f7fa;
  color: #333;
  margin: 0;
  padding: 20px;
  display: flex;
  justify-content: center;
}

/* 1. 배경 설정: 고정된 높이를 없애는 것이 핵심입니다 */
body {
  margin: 0;
  padding: 0;
  display: block;
  min-height: 100vh;
  height: auto;
  background-color: #f4f7f6;
  font-family: 'Pretendard', sans-serif;
}

.container {
  width: 90%;
  max-width: 800px;
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  margin: 80px auto;
  height: auto !important;
  overflow: visible;
}

/* 3. 리스트 스타일 추가 (가독성 향상) */
.passage-list {
  margin-top: 30px;
}

.passage-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-bottom: 1px solid #eee;
}

h1 {
  text-align: center;
  color: #2c3e50;
  margin-bottom: 30px;
}

/* 지문 리스트 스타일 */
.passage-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.passage-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 20px;
  background-color: #fff;
  border: 1px solid #e1e4e8;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.passage-item:hover {
  border-color: #4A90E2;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.p-info {
  font-size: 1.1em;
  font-weight: 600;
}

/* 모드 선택 버튼 스타일 */
.mode-buttons {
  display: flex;
  gap: 10px;
}

.btn {
  padding: 10px 16px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9em;
  color: white;
  cursor: pointer;
  transition: background 0.2s;
}

.btn.meaning {
  background-color: #2c3e50;
  border: 2px solid #2c3e50;
}

.btn.composition {
  background-color: #fff;
  color: #2c3e50;
  border: 2px solid #2c3e50;
}

.btn:hover {
  filter: brightness(90%);
}

/* 테스트 화면 스타일 */
.test-container {
  text-align: center;
}

.question-box {
  background-color: #f8f9fa;
  padding: 40px;
  border-radius: 10px;
  margin: 20px 0;
  font-size: 1.5em;
  font-weight: bold;
}

input[type="text"] {
  width: 80%;
  padding: 12px;
  font-size: 1.1em;
  border: 2px solid #ddd;
  border-radius: 6px;
  outline: none;
}

input[type="text"]:focus {
  border-color: #4A90E2;
}

.control-buttons {
  margin-top: 30px;
  display: flex;
  justify-content: center;
  gap: 15px;
}

.btn-secondary {
  background-color: #fff;
  color: #2c3e50;
}

/* 기본 초기화 */
* {
  box-sizing: border-box;
}

body,
html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Pretendard', sans-serif;
}

/*로그인 페이지*/
:root {
  --red: #EF6161;
  --green: #2c3e50;
}

body,
html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.login-page form.wrapper-box input {
  width: 100%;
  margin-top: 25px;
  border: none !important;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
  outline: none !important;
  background: transparent;
  border-radius: 0;
  padding: 10px 0;
  box-shadow: none !important;

  font-size: 13px;
  font-weight: 300;
  color: #666;
  transition: all 0.2s ease-in-out;
}

/* 포커스(클릭) 했을 때 밑줄 색상만 변경 */
.login-page form.wrapper-box input:focus {
  border-bottom: 1px solid var(--green) !important;
  background: transparent;
}

.login-content {
    width: 420px;
    padding: 30px 40px;
    height: 500px !important;
    z-index: 100 !important; /* PC에서 배경보다 확실히 위로 */
    position: absolute;
    top: 50%;
    left: 50%;
    /* 🚩 트랜지션 설정: transform과 opacity를 부드럽게 연결 */
    transition: all 0.4s cubic-bezier(0.23, 1, 0.32, 1) !important;
    transform: translate(-50%, -50%);
    background: #FFF;
    box-shadow: 0 10px 70px rgba(0, 0, 0, 0.05);
    border-top: 5px solid var(--green);
    opacity: 1;
    overflow: hidden;
}

.login-page form.wrapper-box {
  display: flow-root; /* float된 버튼을 박스 안에 가두는 최신 기법 */
  padding-bottom: 20px;
}

.login-content-signin {
  margin-left: -130px;
}

.login-content-signup {
  margin-left: 130px;
}

.login-content.ng-hide {
    display: block !important; /* 🚩 중요: none으로 바꾸지 말고 공간을 유지해야 트랜지션이 작동함 */
    opacity: 0;
    visibility: hidden;
    pointer-events: none; /* 숨겨진 상태에서 클릭 방해 금지 */
    z-index: -1;
}

/* 2. 사라질 때의 위치값 (이것도 아래처럼 정리하세요) */
.login-content-signin.ng-hide {
    transform: translate(-45%, -50%);
}

.login-content-signup.ng-hide {
    transform: translate(-55%, -50%);
}

/* 3. 회원가입 버튼 위치 조정 */
.btn-submit {
    float: right;
    /* 🚩 기존 50px에서 20px 정도로 줄여서 박스 하단에 안착 */
    margin-top: 20px !important; 
    background: var(--green);
    border: none;
    border-radius: 20px;
    padding: 8px 25px;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

/* 입력창: 글꼴 크기 대폭 축소 및 밑줄 스타일 */
.form-control {
  width: 100%;
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding: 10px 0;
  outline: none;
  font-size: 13px;
  /* 유찬님 요청: Username 등 글꼴 크기 조절 */
  font-weight: 300;
  color: #666;
  transition: border-color 0.2s;
}

.form-control::placeholder {
  color: rgba(0, 0, 0, 0.4);
}

.form-control:focus {
  border-bottom: 1px solid var(--green);
}

/* 버튼 */
/* 3. 회원가입 버튼 위치 조정 */
.btn-submit {
    float: right;
    /* 🚩 기존 50px에서 20px 정도로 줄여서 박스 하단에 안착 */
    margin-top: 20px !important; 
    background: var(--green);
    border: none;
    border-radius: 20px;
    padding: 8px 25px;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

.btn-submit:hover {
  opacity: 0.8;
}

.outer-link {
  display: inline-block;
  margin-top: 20px ;
  color: rgba(0, 0, 0, 0.4);
  text-decoration: none;
  font-size: 13px;
}

.mobile-only-switcher {
    /* 🚩 PC에서는 무슨 일이 있어도 절대 보이지 않게 차단 */
    display: none !important; 
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

/* 스위처 (뒷배경) */
.login-switcher {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  margin: auto;
  width: 660px;
  z-index:5 !important;
  height: 400px;
}

/* 3. 스위처 안의 버튼: 이건 클릭이 돼야 하므로 다시 살림 */
.login-switcher button {
    pointer-events: auto !important;
}

.login-switcher>div {
  width: 40%;
  margin-top: 130px;
  transition: all 0.3s ease-out;
  transition-delay: 0.1s; /* 박스 이동 속도와 맞춤 */
  opacity: 1;
  transform: translateY(0);
}

.login-switcher-signin {
  float: left;
}

.login-switcher-signup {
  float: right;
}

.login-switcher h3 {
  color: rgba(0, 0, 0, 0.4);
  text-align: center;
  font-size: 14px;
  font-weight: 400;
}

.login-switcher button {
  display: block;
  margin: 20px auto 0 auto;
  background: none;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 20px;
  color: rgba(0, 0, 0, 0.3);
  font-weight: bold;
  font-size: 13px;
  padding: 6px 18px;
  cursor: pointer;
}

.login-switcher > div.ng-hide {
    display: block !important; /* 애니메이션 도중 사라지지 않게 고정 */
    opacity: 0;
    /* 🚩 사라질 때 살짝 아래로 내려가는 효과 (박스 이동과 대비되어 세련된 느낌) */
    transform: translateY(15px);
    transition-delay: 0.1s;
}

.login-switcher button {
    transition: all 0.2s ease-in-out;
}

.login-switcher button:hover {
    background: rgba(0, 0, 0, 0.05);
    border-color: var(--green);
    color: var(--green);
}

/* 브라우저 자동완성 시 생기는 노란 배경색 제거 */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0px 1000px white inset !important;
}

/* 2. 입력창 간격 축소 (500px 안에 다 넣기 위해) */
.custom-group, .input-wrapper {
    position: relative !important;
    width: 100%;
    /* 🚩 기존 30~35px에서 15px 정도로 축소하여 세로 공간 절약 */
    margin-top: 15px !important; 
    margin-bottom: 10px !important; 
}

/* 2. 입력창: 버튼이 들어갈 오른쪽 공간 확보 */
.input-wrapper .form-control {
  padding-right: 65px !important;
  /* 버튼이 글자를 가리지 않도록 여백 추가 */
  margin-top: 25px;
  /* 기존 간격 유지 */
}

/* 3. 박스 안으로 들어가는 버튼 스타일 */
.btn-check-inside {
  position: absolute;
  right: 0;
  /* 오른쪽 끝으로 */
  bottom: 8px;
  /* 밑줄(border-bottom) 바로 위에 배치 */

  background: none;
  border: 1px solid var(--green);
  color: var(--green);
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 15px;
  cursor: pointer;
  transition: all 0.2s;
  z-index: 11;
  /* 입력창보다 위에 보이게 */
}

.btn-check-inside:hover {
  background: var(--green);
  color: #fff;
}

/* 입력창 포커스 시 버튼과 조화 */
.input-wrapper .form-control:focus+.btn-check-inside {
  border-color: var(--green);
}

/* 안내 메시지 간격 조정 */
.msg-text {
  position: absolute;
  /* 🚩 입력창 바로 위(Bottom 100%)에 유령처럼 띄움 */
  top: 100%; 
  left: 0;
  margin-top: 10px; /* 입력창과의 미세 간격 */
  
  font-size: 11px;
  font-weight: bold;
  white-space: nowrap; /* 줄바꿈으로 인한 레이아웃 깨짐 방지 */
  pointer-events: none; /* 메시지가 마우스 클릭을 가로막지 않음 */
  
  /* 부드러운 등장 효과 */
  transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
}

.msg-text.ng-enter, .msg-text:not(.ng-hide) {
  opacity: 1;
  transform: translateY(0);
}

.msg-text.ng-hide {
  opacity: 0;
  transform: translateY(5px);
  display: block !important; /* 애니메이션 도중 사라짐 방지 */
}

/* 기존 style.css의 input 스타일은 유지하되, input-group 안의 input은 가로를 꽉 채우도록 */
.input-group input {
  flex: 1;
}

/* 햄버거 버튼 */
.menu-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 999 !important;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.menu-btn span {
  display: block;
  width: 30px;
  height: 4px;
  background-color: #333;
  border-radius: 2px;
  transition: 0.3s;
}

/* 사이드바 본체 */
.sidebar {
  position: fixed;
  top: 0;
  left: -280px;
  /* 처음에는 화면 밖에 숨김 */
  width: 280px;
  height: 100%;
  background-color: #2c3e50;
  /* 다크한 네이비 톤 */
  color: white;
  transition: 0.3s ease;
  z-index: 1001 !important;
  box-shadow: 4px 0 10px rgba(0, 0, 0, 0.1);
  padding-top: 60px;
}

.sidebar.active {
  left: 0;
  /* 활성화 시 화면 안으로 들어옴 */
}

/* 메뉴 항목 */
.sidebar-menu {
  list-style: none;
  padding: 0;
}

.sidebar-menu li a {
  display: block;
  padding: 15px 25px;
  color: #ecf0f1;
  text-decoration: none;
  transition: 0.2s;
}

.sidebar-menu li a:hover {
  background-color: #34495e;
  padding-left: 35px;
  /* 호버 시 살짝 밀리는 효과 */
}

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

.overlay.active {
  display: block;
}

h3 {
  padding: 15px 25px;
}

/* 사이드바 메뉴 기본 설정 */
.sidebar-menu li {
  position: relative;
}

/* 활성화된 페이지 표시 */
.active-page {
  background-color: #34495e;
  font-weight: bold;
}

/* 서브메뉴 기본 상태: 숨김 */
.submenu {
  list-style: none;
  padding: 0;
  max-height: 0;
  /* 높이를 0으로 설정 */
  overflow: hidden;
  transition: max-height 0.3s ease-out;
  /* 부드럽게 내려오는 효과 */
  background-color: #1a252f;
  /* 부모보다 조금 더 어두운 색상 */
}

/* 부모 메뉴에 호버했을 때 서브메뉴 표시 */
.has-submenu:hover .submenu {
  max-height: 100px;
  /* 서브메뉴 내용에 맞게 조절 */
}

/* 서브메뉴 내부 링크 스타일 */
.submenu li a {
  padding: 12px 25px 12px 45px !important;
  /* 왼쪽 여백을 더 주어 들여쓰기 효과 */
  font-size: 0.9em;
  color: #bdc3c7 !important;
}

.submenu li a:hover {
  background-color: #243342 !important;
}

/* 서브메뉴 화살표 표시 (선택 사항) */
.has-submenu>a::after {
  content: '▾';
  float: right;
  font-size: 0.8em;
  transition: transform 0.3s;
}

.has-submenu:hover>a::after {
  transform: rotate(180deg);
  /* 호버 시 화살표 회전 */
}

.global-action-section {
  margin-top: 40px;
  padding: 30px;
  background-color: #f9fbfd;
  border-radius: 12px;
  text-align: center;
}

.section-divider {
  border: 0;
  height: 1px;
  background: #eee;
  margin-bottom: 20px;
}

.section-desc {
  color: #666;
  font-size: 0.95rem;
  margin-bottom: 15px;
}

.master-btn {
  display: inline-block;
  width: 100%;
  padding: 15px;
  background-color: #2c3e50;
  /* 오렌지색으로 포인트 */
  color: white;
  font-size: 1.1rem;
  font-weight: bold;
  text-decoration: none;
  border-radius: 10px;
  border: 2px solid #2c3150;
  transition: transform 0.2s, background-color 0.2s;
}

.master-btn:hover {
  background-color: #2c3450;
  transform: translateY(-3px);
  box-shadow: 0 5px 15px rgba(18, 108, 243, 0.3);
}

@media screen and (max-width: 768px) {

    /* 1. 상단 그라데이션 바: 배경색만 시계 영역까지 채우는 역할 */
    body::before {
        content: "";
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        /* 🚩 높이: 안전 영역(시계) + 기본 여백(80px)을 계산해서 동적으로 확보 */
        height: calc(80px + env(safe-area-inset-top)); 
        
        /* 유찬님의 정교한 그라데이션 이식 */
        background: linear-gradient(
            to bottom, 
            rgba(245, 247, 246, 1) 0%,
            rgba(245, 247, 246, 1) 25%,
            rgba(245, 247, 246, 1) 40%,
            rgba(245, 247, 246, 1) 70%,
            rgba(245, 247, 246, 0.6) 80%,
            rgba(245, 247, 246, 0.2) 90%,
            rgba(245, 247, 246, 0) 100%
        );
        
        border-bottom: none;
        z-index: 999; 
        pointer-events: none; /* 컨텐츠 클릭 방해 금지 */
    }

    /* 2. 바디 전체: 상단 안전 영역만큼 패딩을 주어 글자가 위로 뚫고 나가는 것 방지 */
    body {
        /* 🚩 이 한 줄이 있어야 본문이 시계 아래로 안전하게 밀려납니다 */
        padding-top: env(safe-area-inset-top) !important;
        background-color: rgb(245, 247, 246);
    }

    /* 3. 햄버거 버튼: 시계 영역 바로 아래에 위치하도록 수정 */
    .menu-btn {
        position: fixed !important;
        /* 🚩 시계 높이 + 15px 지점에 배치 */
        top: calc(15px + env(safe-area-inset-top)) !important;
        z-index: 999 !important;
    }

    /* 4. 로그인/회원가입 박스: 고정 80px을 버리고 안전 영역을 더함 */
    .login-content {
        margin: 0 !important;
        position: absolute !important;
        /* 🚩 핵심 수정: 시계 영역 + 헤더 높이(80px)만큼 확실히 내림 */
        top: calc(80px + env(safe-area-inset-top)) !important;
        left: 50% !important;
        transform: translateX(-50%) !important;

        width: 92% !important;
        height: auto !important;
        z-index: 100 !important;
        background: #FFF;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
        transition: all 0.2s ease-in-out;
    }

    /* 5. 메인 리스트 컨테이너(학습지 리스트)도 함께 내려줍니다 */
    .container {
        margin-top: calc(20px + env(safe-area-inset-top)) !important;
        width: 95% !important;
        padding: 20px 15px;
    }

    /* 이하 기존 설정 유지 */
    .login-content.ng-hide {
        display: block !important;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translate(-50%, -10px) !important;
        transition-delay: 0.1s;
    }

    .login-switcher { display: none !important; }

    .mobile-only-switcher {
        display: block !important;
        margin-top: 20px;
        font-size: 13px;
        color: #999;
        text-align: left;
    }

    .mobile-only-switcher span {
        color: var(--green);
        font-weight: bold;
        text-decoration: none !important;
        cursor: pointer;
        margin-left: 5px;
        padding: 5px 0;
    }

    .btn-submit {
        width: 100%;
        float: none;
        margin-top: 35px !important;
        padding: 12px;
    }
}