/**
 (( 생략 ))
 * 20260123 | @m |
 * 20260126 | @m |
 * 20260127 | @m | 이전 대화 내용 보기 버튼 위치, 문제 잠깐 보기 버튼 기능 추가
 * 20260129 | @m | 자판 있으면 스크롤 안됨 이슈 해결 [삼성인터넷]
 * 20260210 | @m | #ai-tutor-popup, .go-chat-body-top1
 */


/* ◇◆◇◆ */


/*  */
html, body {
	height:100%;
  overscroll-behavior-y: none;
}

html:has(#ai-tutor-popup[style*='flex']:not([class='is-collapsed'])),
body:has(#ai-tutor-popup[style*='flex']:not([class='is-collapsed'])){
	position: fixed;
  width: 100%;
	overflow:hidden;
}


/* 대화창 상단으로 20260210 */
.go-chat-body-top1{
	display:flex;
	justify-content:center;
	align-items:center;
	z-index:10;
	position:absolute;
	right:0;
	bottom:0;
	box-sizing:border-box;
	width:2.5em;
	height:2.5em;
	margin:84px 20px;
	border-radius:9999px;
	background:#5e6ad222;
	color:#fff;
	overflow:hidden;
	transform:translateY(400%);
	transition:.4s;
}
.go-chat-body-top1.on{
	transform:none;
}
.go-chat-body-top1 .t1{
	display:none;
	margin:.5em 0 0;
	font-weight:300;
	font-size:.875em;
	line-height:1.375;
	letter-spacing:0;
}
.go-chat-body-top1 .ic1{
	display:block;
	position:relative;
	width:1em;
	height:.75em;
}
.go-chat-body-top1 .ic1:before{content:''; /* / */
	display:block;
	position:absolute;left:50%;top:0;
	width:2px;
	height:.75em;
	margin:0 -.5px;
	border-radius:9999px;
	background:#5e6ad2;
	transform:rotate(45deg);
	transform-origin:50% 0;
	transition:.2s;
}
.go-chat-body-top1 .ic1:after{content:''; /* ＼ */
	display:block;
	position:absolute;right:50%;top:0;
	width:2px;
	height:.75em;
	margin:0 -.5px;
	border-radius:9999px;
	background:#5e6ad2;
	transform:rotate(-45deg);
	transform-origin:50% 0;
	transition:.2s;
}
/* 질문 입력영역 높이 확장 시 */
#ai-tutor-popup:has(#ai-user-input.multiline) .go-chat-body-top1{
	margin:124px 20px;
}


/* 대화 몸통 상단 고정 20260127 */
.ai-chat-body-hg1{
	display:flex;
	justify-content:space-between;
	align-items:center;
	gap:6px;
	padding:6px 12px;
}


/* 문제 잠깐 보기 20260127 */
#ai-tutor-popup.look-question-hold{
  opacity: 0;
  pointer-events: none; /* 투명일 때 클릭도 막음 */
  transition: opacity .12s ease;
}


/* ===============================
   AI Tutor Chatbot CSS
   =============================== */

/* 아이콘 */
#ai-tutor-icon {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 56px;
    height: 56px;
    cursor: pointer;
    z-index: 9999;
}

#ai-tutor-icon img {
    width: 100%;
    height: 100%;
}

/* 팝업 */
#ai-tutor-popup {
    display: flex;
    flex-direction: column;
    z-index: 9999;
		position: fixed;
    right: 12px;
    bottom: 76px;
		width: min(92vw, 420px);
    height: min(80vh, 640px);
    max-height: calc(100vh - 120px);
		border-radius: 12px;
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
		overflow:hidden;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    /* 기준 안정화 */
    transform-origin: top;
		/*  */
}

/* ◇◆ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #ai-tutor-popup {
        padding-bottom: env(safe-area-inset-bottom);
    }
    .ai-input-area {
        padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
}

/* 헤더 */
#ai-tutor-popup .ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    box-sizing: border-box;
    height: 48px;
    min-height: 48px;
    padding: 0 12px 0 22px;
    border-radius: 12px 12px 0 0;
    background: #5e6ad2;
    color: #fff;
    font-size: 14px;
    line-height: 1;
}

/* 내부 요소 리셋 */
#ai-tutor-popup .ai-header * {
    margin: 0;
    padding: 0;
    line-height: 1;
}
#ai-tutor-popup .ai-header .title {
    margin: 0 1em 0 0;
    font-weight: bold;
}
#ai-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
}


/* 대화 몸통 */
#ai-chat-body {
    flex: 1 1 auto;
		min-height:0;
    padding: 12px 12px calc(55px + 12px) 12px;
		overflow: hidden;
    overflow-y: auto;
    background: #fff;
		scroll-behavior:smooth;
		overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

/* 메시지 공통 */
.ai-msg {
    max-width: 80%;
    padding: 12px 14px;
    margin: 8px 0;
    line-height: 1.6;
    font-size: 14px;
    border-radius: 12px;
    word-break: break-word;
}

/* 입력박스+버튼 */
.ai-input-area {
    flex: none;
		display:flex;
		align-items:flex-end;
		gap:8px;
		z-index:10;
		position:relative;
		padding:10px;
    border-top: 1px solid #e5e8f0;
		background:#fff;
}
/* 입력박스 */
#ai-user-input {
		flex:1;
		display: inline-block;
		box-sizing: border-box;
		width: 100%;
		height: 42px;
		margin: 0;
    padding: 10px 12px;
    border-radius: 0;
    border: 1px solid #ddd;
    font-size: 14px;
		vertical-align: bottom;
}
/* 전송버튼 */
#ai-send {
		flex:none;
		display: inline-block;
		height: 42px;
		margin: 0;
    padding: 0 16px;
    border: none;
    border-radius: 8px;
    background: #5e6ad2;
    color: #fff;
		vertical-align: bottom;
    cursor: pointer;
}

.ai-msg.loading {
    opacity: 0.5;
    font-style: italic;
    animation: aiPulse 1.5s infinite;
}

@keyframes aiPulse {
    0%   { opacity: 0.4; }
    50%  { opacity: 0.7; }
    100% { opacity: 0.4; }
}

.ai-msg.ai-user {
    margin-left: auto;
    background: #e8f0ff;           /* 파스텔 블루 */
    color: #1f3a8a;                /* 진하지 않은 네이비 */
    border-bottom-right-radius: 4px;
}


.ai-msg.ai-tutor {
    margin-right: auto;
    background: #f5f7fb;
    color: #222;
    border: 1px solid #e2e6f0;
    border-bottom-left-radius: 4px;
    position: relative;
    padding-left: 44px;
}

/*
.ai-msg.ai-tutor::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 12px;
    font-size: 20px;
}
*/

.ai-msg.ai-tutor::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 10px;

    width: 24px;
    height: 24px;

    background-image: url("/ai_tutorV1/assets/img/chatbot_icon.png");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.ai-msg.ai-system {
    margin: 12px auto;
    background: transparent;
    color: #888;
    font-size: 13px;
    text-align: center;
}

/* mjx 관련 추후 필요시
.ai-msg {
  overflow-x: auto;
}

.ai-msg mjx-container {
  max-width: 100%;
  overflow-x: auto;
}
*/


/* ◇◆ */
@media (max-width: 768px) {

    #ai-tutor-popup {
        left: 8px;
        right: 8px;
        bottom: 8px;
        width: auto;
        height: 75vh; /* 75vh ◆◇ YYYYMMDD. @m. ★☆ToEdit) ★☆ToDo(할일) ◇◆ */
        max-height: calc(100vh - 80px);
    }

    #ai-tutor-popup .ai-header {
        height: 44px;
        min-height: 44px;
        font-size: 14px;
    }

    .ai-msg {
        font-size: 13px;
    }
}

/*------------------*/
.ai-header-actions {
    display: flex;
    gap: 0; /* (( 8px */
}

#ai-toggle,
#ai-close {
		justify-content:center;
		align-items:center;
		background: none;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    line-height: 1;
}
#ai-toggle  {
    font-size: 12px;
}


/* 접힘 상태 */
#ai-tutor-popup.is-collapsed {
    left: auto;
		width: auto;
    height: 48px !important; /* 헤더 높이만 */
    overflow: hidden;
}
#ai-tutor-popup.is-collapsed #ai-toggle{
    font-size: 18px;
}

/* 투명느낌 20260126 */
#ai-tutor-popup.is-collapsed .ai-header {
    /* background-color: rgba(94, 106, 210, 0.45); */
    /* backdrop-filter: blur(3px); */
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
}

/* 헤더만 보이게 */
#ai-tutor-popup.is-collapsed #ai-chat-body,
#ai-tutor-popup.is-collapsed .ai-input-area {
    display: none;
}

/* 헤더 둥글게 */
#ai-tutor-popup.is-collapsed .ai-header {
    border-radius: 12px;
}

/* ◇◆ */
@media (max-width: 768px) {
    #ai-tutor-popup.is-collapsed {
        bottom: 8px;
        width: calc(100vw - 16px);
        width: auto;
    }
}

#ai-tutor-icon {
    display: none;   /* 🔥 기본적으로 숨김 */
}
/*
#ai-tutor-popup.is-collapsed .ai-header {
    cursor: grab;
}

#ai-tutor-popup.is-collapsed.dragging .ai-header {
    cursor: grabbing;
}
*/

#ai-history-wrap {
    text-align: center;
    /* margin-bottom: 8px; */
}

/* 버튼들 */
#ai-look-question-btn, /* 문제 잠깐 보기 */
#ai-history-btn { /* 이전 대화 내용 보기 */
		width:50%;
		justify-content:center;
    padding: 6px 14px;
    border: 1px solid #d6ddff;
    border-radius: 20px;
    background: #f1f4ff;
    color: #3b5bdb;
    font-size: 13px;
    cursor: pointer;
}

#ai-history-btn[disabled],
#ai-history-btn.loading {
    opacity: 0.6;
    pointer-events: none;
}

.ai-msg.history {
    animation: slideDown 0.25s ease-out;
    opacity: 0;
    animation-fill-mode: forwards;
}

@keyframes slideDown {
    from {
        transform: translateY(-6px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}


/* 별점 팝업 */
/* ===============================
   AI Tutor Rating Popup
   =============================== */

/* 팝업 전체 오버레이 */
#ai-rating-popup {
    position: fixed;
    inset: 0;
    z-index: 10000;

    display: none;
    align-items: center;
    justify-content: center;

    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* 팝업 박스 */
#ai-rating-popup .box {
    width: min(90vw, 320px);
    padding: 20px 18px 18px;

    background: #fff;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);

    text-align: center;
    animation: aiRatingPop 0.25s ease-out;
}

/* 제목 문구 */
#ai-rating-popup .box p {
    margin: 0 0 16px;
    font-size: 15px;
    font-weight: 600;
    color: #222;
}

/* 별점 영역 */
#ai-rating-popup .stars {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 14px;
}

/* 별 아이콘 */
#ai-rating-popup .stars span {
    font-size: 26px;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
    user-select: none;
}

/* 터치 / 호버 효과 */
#ai-rating-popup .stars span:hover,
#ai-rating-popup .stars span:active {
    transform: scale(1.2);
    opacity: 0.85;
}

/* 건너뛰기 버튼 */
#ai-rating-popup #rating-skip {
    border: none;
    background: transparent;
    color: #666;
    font-size: 13px;
    cursor: pointer;
    padding: 6px 10px;
}

/* 버튼 터치 피드백 */
#ai-rating-popup #rating-skip:active {
    opacity: 0.6;
}

#ai-rating-stars {
  display: flex;
  gap: 6px;
  justify-content: center;
}

#ai-rating-stars span {
  font-size: 32px;
  color: #ddd;               /* 기본 회색 */
  cursor: pointer;
  transition: color .2s;
  user-select: none;
}

#ai-rating-stars span.active {
  color: #ffb400;            /* 선택된 별 */
}


/* 등장 애니메이션 */
@keyframes aiRatingPop {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ===============================
   모바일 최적화
   =============================== */

/* ◇◆ */
@media (max-width: 768px) {
    #ai-rating-popup .box {
        padding: 18px 16px 16px;
    }

    #ai-rating-popup .stars span {
        font-size: 28px;
    }
}

/* ===============================
   iOS WebView Safe Area 대응
   =============================== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    #ai-rating-popup .box {
        margin-bottom: env(safe-area-inset-bottom);
    }
}
