/* ===== AI 검색 결과 전용 스타일 ===== */

/* AI 섹션 전체 래퍼 */
.ai_result_wrap {
    border: 2px solid #004294;
    border-radius: 8px;
    margin-bottom: 24px;
    background: #fff;
    overflow: hidden;
    margin-top:15px;
}

/* AI 섹션 헤더 */
.ai_result_header {
    background: #004294;
    color: #fff;
    padding: 11px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ai_result_header .ai_title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: bold;
    letter-spacing: -0.3px;
}
.ai_result_header .ai_title .ai_icon {
    width: 22px;
    height: 22px;
    background: #ffcc00;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #004294;
    font-weight: 900;
    flex-shrink: 0;
}
.ai_result_header .ai_badge_beta {
    background: #ffcc00;
    color: #004294;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 7px;
    border-radius: 10px;
    letter-spacing: 0;
    line-height: 1.6;
}
.ai_result_header .ai_feedback {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* a:link 명시도(0,1,1)를 이기기 위해 태그+클래스 선택자(0,1,1) 사용 → 순서 우선 */
a.ai_feedback_btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.4);
    color: #fff;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
a.ai_feedback_btn:hover {
    background: rgba(255,255,255,0.28);
    color: #fff;
}
a.ai_feedback_btn.active_good {
    background: #28a745;
    border-color: #28a745;
}
a.ai_feedback_btn.active_bad {
    background: #dc3545;
    border-color: #dc3545;
}
.ai_feedback_label {
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    margin-right: 4px;
}

/* 중지 버튼 - 헤더(파란 배경) 위에 얹히는 버튼이라 ai_feedback_btn과 동일한 톤을 사용 */
button.ai_stop_btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.4);
    color: #fff;
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
}
button.ai_stop_btn:hover {
    background: rgba(255,255,255,0.28);
}

/* AI 답변 본문 */
.ai_answer_body {
    background: linear-gradient(180deg, #f8fafd 0%, #eef2f8 100%);
    padding: 22px 24px 20px;
    border-bottom: 1px solid #dde4ee;
}
.ai_answer_body p {
    font-size: 14px;
    line-height: 1.9;
    color: #262b34;
    letter-spacing: -0.1px;
    margin: 0;
}
.ai_answer_body p + p,
.ai_answer_body p + h1, .ai_answer_body p + h2, .ai_answer_body p + h3,
.ai_answer_body p + h4, .ai_answer_body p + h5, .ai_answer_body p + h6,
.ai_answer_body p + ul, .ai_answer_body p + ol,
.ai_answer_body ul + p, .ai_answer_body ol + p {
    margin-top: 12px;
}
.ai_answer_body strong, .ai_answer_body b {
    color: #003b7a;
    font-weight: 700;
}
.ai_answer_body em, .ai_answer_body i {
    font-style: italic;
    color: #4a5364;
}

/* 답변 본문에 소제목이 오는 경우 */
.ai_answer_body h1, .ai_answer_body h2, .ai_answer_body h3,
.ai_answer_body h4, .ai_answer_body h5, .ai_answer_body h6 {
    color: #0a1f42;
    font-weight: 700;
    line-height: 1.5;
    margin: 18px 0 8px;
}
.ai_answer_body h1:first-child, .ai_answer_body h2:first-child, .ai_answer_body h3:first-child,
.ai_answer_body h4:first-child, .ai_answer_body h5:first-child, .ai_answer_body h6:first-child {
    margin-top: 0;
}
.ai_answer_body h1 { font-size: 18px; }
.ai_answer_body h2 { font-size: 16.5px; }
.ai_answer_body h3 { font-size: 15px; }
.ai_answer_body h4, .ai_answer_body h5, .ai_answer_body h6 { font-size: 14px; }

/* 답변 본문에 목록이 오는 경우 - 브라우저 기본 불릿 대신 AI 테마 색상의 도트/숫자로 */
.ai_answer_body ul, .ai_answer_body ol {
    margin: 0;
    padding-left: 2px;
    list-style: none;
}
.ai_answer_body ul li, .ai_answer_body ol li {
    position: relative;
    padding-left: 18px;
    font-size: 14px;
    line-height: 1.85;
    color: #262b34;
}
.ai_answer_body ul li + li, .ai_answer_body ol li + li {
    margin-top: 5px;
}
.ai_answer_body ul li::before {
    content: '';
    position: absolute;
    left: 3px;
    top: 10px;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #7391c2;
}
.ai_answer_body ol {
    counter-reset: ai-ol;
}
.ai_answer_body ol li {
    padding-left: 22px;
    counter-increment: ai-ol;
}
.ai_answer_body ol li::before {
    content: counter(ai-ol) '.';
    position: absolute;
    left: 0;
    top: 0;
    color: #004294;
    font-weight: 700;
    font-size: 13px;
}

/* AI가 답변을 준비/실패했을 때 보여주는 안내 문구 */
.ai_answer_body p.ai_progress_msg {
    display: flex;
    align-items: center;
    gap: 9px;
    color: #5b6472;
}
.ai_answer_body p.ai_progress_msg::before {
    content: '';
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    border: 2px solid #c7d2e3;
    border-top-color: #004294;
    border-radius: 50%;
    animation: ai_spin 0.8s linear infinite;
}
.ai_answer_body p.ai_progress_msg.ai_error_msg {
    color: #c0392b;
}
.ai_answer_body p.ai_progress_msg.ai_error_msg::before {
    display: none;
}
.ai_answer_body p.ai_progress_msg.ai_stopped_msg {
    color: #c0392b;
}
.ai_answer_body p.ai_progress_msg.ai_stopped_msg::before {
    display: none;
}
@keyframes ai_spin {
    to { transform: rotate(360deg); }
}

/* 인용 마커 - 각진 뱃지 대신 은은한 pill 형태의 위첨자 */
a.ai_cite {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    background: rgba(0, 66, 148, 0.1);
    color: #004294;
    font-size: 10px;
    font-weight: 700;
    border-radius: 999px;
    vertical-align: super;
    line-height: 1;
    margin-left: 2px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
a.ai_cite:hover {
    background: #004294;
    color: #fff;
}

/* 카드 번호 뱃지 */
.ai_book_card .card_num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: #004294;
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    margin-bottom: 8px;
    flex-shrink: 0;
}

/* Follow-up questions 영역 */
.ai_followup {
    padding: 14px 22px 18px;
    border-top: 1px solid #e8e8e8;
    background: #fafcff;
}
.ai_followup_title {
    font-size: 12px;
    font-weight: bold;
    color: #004294;
    margin-bottom: 10px;
    letter-spacing: -0.2px;
}
.ai_followup_list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 7px;
}
.ai_followup_list li a {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid #d0daea;
    border-radius: 6px;
    font-size: 13px;
    color: #1b1f27;
    background: #fff;
    text-decoration: none;
    transition: all 0.2s;
    width: 100%;
    box-sizing: border-box;
}
.ai_followup_list li a:hover {
    border-color: #004294;
    color: #004294;
    background: #f0f5ff;
}
.ai_followup_list li a .fq_icon {
    width: 16px;
    height: 16px;
    border: 1.5px solid #75777b;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #75777b;
    flex-shrink: 0;
    font-style: normal;
}
.ai_followup_list li a:hover .fq_icon {
    border-color: #004294;
    color: #004294;
}

/* AI 추천도서 영역 */
.ai_books_section {
    padding: 16px 22px 20px;
    background: #fff;
}
.ai_books_title {
    font-size: 13px;
    font-weight: bold;
    color: #1b1f27;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ai_books_title span {
    display: flex;
    align-items: center;
    gap: 6px;
}
.ai_books_title span::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 14px;
    background: #004294;
    border-radius: 2px;
}
.ai_book_cards {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}
.ai_book_card {
    flex: 1 1 calc(33.333% - 10px);
    min-width: 160px;
    box-sizing: border-box;
    border: 1px solid #e0e8f0;
    border-radius: 6px;
    padding: 14px 12px 12px;
    transition: box-shadow 0.25s, border-color 0.25s;
    background: #fff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    /* 카드 전체가 <a> 태그이므로 기본 링크 스타일(파란 글씨/밑줄) 초기화 */
    color: inherit;
    text-decoration: none;
}
.ai_book_card:hover .card_title {
    color: #004294;
}
.ai_book_card:hover {
    box-shadow: 0 4px 16px rgba(0, 66, 148, 0.13);
    border-color: #004294;
}
/* ===== 표지 3D 입체 효과 (참고: library.postech.ac.kr 신착자료) =====
   card_img 안에 book-front(앞면)/book-bone(책등)/book-back(뒷면) 3개 면을 세워서
   비스듬히 기울여두고(rotate3d 30deg), 카드에 마우스를 올리면 정면(0deg)으로 회전한다. */
.ai_book_card .card_img {
    --book-cover-width: 150px;
    --book-cover-height: 220px;
    width: var(--book-cover-width);
    height: var(--book-cover-height);
    margin: 0 auto 10px;
    position: relative;
    perspective: calc(var(--book-cover-width) * 4.76);
}
.ai_book_card .cover-3d {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transform: rotate3d(0, 1, 0, 30deg);
    transition: transform 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
}
.ai_book_card:hover .cover-3d {
    transform: rotate3d(0, 1, 0, 0deg);
}
.ai_book_card .book-front {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    transform-style: preserve-3d;
    transform-origin: 0% 50%;
    transform: translate3d(0, 0, calc(var(--book-cover-width) * 0.08));
    background-repeat: no-repeat;
    background-position: center center;
    background-color: #eee;
    background-size: cover;
    backface-visibility: hidden;
    border-radius: 2px;
}
.ai_book_card .book-bone {
    width: calc(var(--book-cover-width) * 0.16);
    height: 100%;
    position: absolute;
    top: 0;
    left: calc(var(--book-cover-width) * -0.08);
    z-index: 2;
    background-color: #ccc;
    background-size: var(--book-cover-width) var(--book-cover-height);
    background-position: left center;
    background-repeat: no-repeat;
    transform: rotate3d(0, 1, 0, -90deg) scaleX(-1);
    filter: brightness(0.8);
}
.ai_book_card .book-back {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: transparent;
    box-shadow: 0 calc(var(--book-cover-width) * 0.03) calc(var(--book-cover-width) * 0.06) rgba(0, 0, 0, 0.3);
    transform: translate3d(0, 0, calc(var(--book-cover-width) * -0.08));
    z-index: -1;
}
.ai_book_card .card_title {
    font-size: 13px;
    font-weight: bold;
    color: #1b1f27;
    line-height: 1.4;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ai_book_card .card_title a {
    color: #1b1f27;
    text-decoration: none;
}
.ai_book_card .card_title a:hover {
    color: #004294;
    text-decoration: underline;
}
.ai_book_card .card_meta {
    font-size: 11px;
    color: #75777b;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ai_book_card .card_meta b {
    color: #353c48;
}
.ai_book_card .card_location {
    font-size: 11px;
    color: #75777b;
    margin-bottom: 10px;
    line-height: 1.4;
}
.ai_book_card .card_status {
    margin-top: auto;
}

/* AI 추천도서 더보기 버튼 */
.ai_books_section .btn_h22_t03 {
    font-size: 12px;
}

/* 대출중 상태 버튼 */
.btn_checkedout {
    background: #e8e8e8;
    color: #888;
    border-color: #e8e8e8;
}

/* 예약 버튼 간격 */
.btn_reserve {
    margin-left: 4px;
}

/* 상세검색 폼 내 AI 바 — float 해제 및 전체 너비 */
/* float 해제 전용 — clear:both를 AI바와 분리해 margin-top이 정상 동작하도록 */
.sub_search_box .sub_float_clear {
    float: none;
    clear: both;
    height: 0;
    padding: 0;
    margin: 0;
    font-size: 0;
    line-height: 0;
}
.sub_search_box .sub_ai_bar {
    float: none;
    width: 100%;
    margin-top: 10px;
    margin-bottom: 0;
}
.sub_search_box .sub_ai_bar .ai_opt_right {
    margin-left: auto;
}

/* AI 옵션 바 */
.ai_option_bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(90deg, #eef3fb 0%, #f5f8ff 100%);
    border: 1px solid #d0daea;
    border-radius: 6px;
    padding: 10px 18px;
    margin-top: 10px;
}
.ai_option_bar .ai_opt_left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai_option_bar .ai_opt_icon {
    width: 32px;
    height: 32px;
    background: #004294;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 900;
    color: #ffcc00;
    flex-shrink: 0;
    letter-spacing: -0.5px;
}
.ai_option_bar .ai_opt_text strong {
    display: block;
    font-size: 13px;
    font-weight: bold;
    color: #1b1f27;
    line-height: 1.3;
}
.ai_option_bar .ai_opt_text span {
    display: block;
    font-size: 11px;
    color: #75777b;
    margin-top: 1px;
}
.ai_option_bar .ai_opt_right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* 스위치 */
.ai_switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}
.ai_switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}
.ai_switch_slider {
    position: absolute;
    inset: 0;
    background: #c5cdd9;
    border-radius: 26px;
    cursor: pointer;
    transition: background 0.25s;
}
.ai_switch_slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.22);
}
.ai_switch input:checked + .ai_switch_slider {
    background: #004294;
}
.ai_switch input:checked + .ai_switch_slider::before {
    transform: translateX(20px);
}
.ai_switch_state {
    font-size: 12px;
    font-weight: bold;
    color: #004294;
    min-width: 22px;
}
.ai_switch_state.off {
    color: #aaa;
}

/* ===== 메인 검색창 AI 옵션 토글 ===== */
.ai_search_option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    background: linear-gradient(90deg, #001f5c 0%, #003080 45%, #001f5c 100%);
    background-size: 200% 100%;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
    animation: ai_bg_shift 5s ease infinite;
    transition: background 0.4s, border-top-color 0.4s;
}

/* 배경 그라디언트 흐름 */
@keyframes ai_bg_shift {
    0%, 100% { background-position: 0% center; }
    50%       { background-position: 100% center; }
}

/* 빛 sweep */
.ai_search_option::before {
    content: '';
    position: absolute;
    top: 0;
    left: -60%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.07), transparent);
    animation: ai_sweep 4s ease-in-out infinite;
    pointer-events: none;
}
@keyframes ai_sweep {
    0%   { left: -60%; }
    100% { left: 160%; }
}

/* AI 뱃지 */
.ai_search_opt_badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #ffcc00;
    color: #003080;
    font-size: 11px;
    font-weight: 900;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: -0.3px;
    flex-shrink: 0;
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.55);
}
.ai_search_opt_badge .ai_spark {
    display: inline-block;
    font-size: 10px;
    animation: ai_spark_pulse 2s ease infinite;
}
@keyframes ai_spark_pulse {
    0%, 100% { transform: scale(1);   opacity: 1;   }
    50%       { transform: scale(1.4); opacity: 0.65; }
}

/* 텍스트 영역 */
.ai_search_opt_texts {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.ai_search_opt_title {
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    letter-spacing: -0.2px;
}
.ai_search_opt_desc {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.55);
}

/* 스위치 ON → 옐로우 */
.ai_search_option .ai_switch input:checked + .ai_switch_slider {
    background: #ffcc00;
}
.ai_search_option .ai_switch_state {
    color: #ffcc00;
    min-width: 22px;
    font-size: 12px;
    font-weight: bold;
}
.ai_search_option .ai_switch_state.off {
    color: rgba(255, 255, 255, 0.4);
}

/* OFF 상태 — 전체 비활성 */
.ai_search_option.ai_off {
    background: linear-gradient(90deg, #1c1c2e 0%, #252540 100%);
    border-top-color: rgba(255, 255, 255, 0.15);
    animation: none;
}
.ai_search_option.ai_off::before {
    display: none;
}
.ai_search_option.ai_off .ai_search_opt_badge {
    background: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.45);
    box-shadow: none;
}
.ai_search_option.ai_off .ai_search_opt_badge .ai_spark {
    animation: none;
}
.ai_search_option.ai_off .ai_search_opt_title {
    color: rgba(255, 255, 255, 0.45);
}

