/* ==========================================================================
   noricamp AI 감성 채팅 위젯
   "진짜 감성은, 나를 아는 것"
   Bootstrap 5 dark theme 호환
   ========================================================================== */

/* ── 플로팅 버튼 — nc-scroll-top 과 나란히, 동일 사이즈 ─────────────────── */
/*
   안정성 노트:
   · width 를 직접 transition 하지 않음 — CSS 가 'auto' 로 보간할 수 없어
     호버 중 jitter / 떨림이 발생하는 원인이었음.
     대신 자식 라벨의 max-width + 부모의 padding/gap 만 transition → inline-flex 가
     자식 폭에 맞춰 부드럽게 늘어남.
   · border-radius: 22px 를 처음부터 캡슐 값으로 고정 (44px 높이일 땐 원형으로 보임)
     → transition 대상 1개 감소, 시각적 동일.
   · transform: translateY(-3px) hover 제거 — 호버 진입 순간 버튼이 위로 이동하면
     마우스가 버튼 아래 경계 근처에 있을 때 호버 진입↔해제 무한 루프(떨림) 발생.
     대신 box-shadow 강화로 elevation 표현.
*/
#ncAiBtn {
    position: fixed;
    bottom: 28px;                          /* nc-scroll-top 과 동일 */
    right: 74px;                           /* 22px(scrollTop) + 44px + 8px gap */
    z-index: 1040;
    min-width: 44px;                       /* 기본: 원형 (자식 폭에 맞춰 자동 확장) */
    height: 44px;
    padding: 0;
    border-radius: 22px;                   /* 캡슐 — 44x44 일 땐 원형으로 보임 */
    background: rgba(20, 29, 26, .85);
    backdrop-filter: blur(10px);
    color: var(--nc-green-light, #74c69d);
    border: 1px solid var(--nc-border-lg, #2d4a38);
    box-shadow: var(--nc-shadow-lg, 0 4px 16px rgba(0,0,0,.4));
    font-size: 1.05rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;                                /* 라벨 max-width 0 일 때 */
    overflow: hidden;
    white-space: nowrap;
    transition:
        padding .26s cubic-bezier(.4, 0, .2, 1),
        gap .26s cubic-bezier(.4, 0, .2, 1),
        background .2s ease,
        border-color .2s ease,
        color .2s ease,
        box-shadow .2s ease;
}
#ncAiBtn .nc-ai-btn-icon {
    flex: 0 0 auto;
    font-size: 1.05rem;
    line-height: 1;
}
/* 라벨 — 기본 숨김, 호버/포커스/.nc-expanded 시 슬라이드 인 */
#ncAiBtn .nc-ai-btn-label {
    flex: 0 1 auto;
    max-width: 0;
    opacity: 0;
    font-size: .85rem;
    font-weight: 500;
    letter-spacing: -.01em;
    line-height: 1;
    overflow: hidden;
    transition:
        max-width .26s cubic-bezier(.4, 0, .2, 1),
        opacity .18s ease .04s;
}
/* 호버 / 키보드 포커스 / 강제 펼침(.nc-expanded) → 가로 확장 */
#ncAiBtn:hover,
#ncAiBtn:focus-visible,
#ncAiBtn.nc-expanded {
    padding: 0 16px 0 13px;
    gap: 8px;
}
#ncAiBtn:hover .nc-ai-btn-label,
#ncAiBtn:focus-visible .nc-ai-btn-label,
#ncAiBtn.nc-expanded .nc-ai-btn-label {
    max-width: 120px;
    opacity: 1;
}
#ncAiBtn:hover {
    background: var(--nc-green, #2d6a4f);
    color: #0a0e0d;
    border-color: var(--nc-green, #2d6a4f);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .5);   /* transform 대신 그림자 강화 */
}
#ncAiBtn:focus-visible {
    outline: 2px solid var(--nc-green-light, #74c69d);
    outline-offset: 2px;
}

/* 노란 펄스 뱃지 — overflow:hidden 때문에 절대위치를 안쪽으로 살짝 옮김 */
#ncAiBtn .nc-ai-badge {
    position: absolute;
    top: 4px;
    right: 7px;
    width: 8px;
    height: 8px;
    background: #d4a843;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(20, 29, 26, .9);   /* border 대신 box-shadow ring */
    animation: nc-pulse 2s infinite;
    pointer-events: none;
}
@keyframes nc-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .6; transform: scale(1.2); }
}

/* ── 채팅 패널 ───────────────────────────────────────────────────────────── */
#ncAiPanel {
    position: fixed;
    bottom: 80px;                          /* 버튼(28+44) + 8px 여백 */
    right: 22px;                           /* 화면 우측 기준 */
    z-index: 1039;
    width: 360px;
    max-height: 520px;
    background: #1e2a24;
    border: 1px solid #2d4a38;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;

    /* 초기 상태: 숨김 */
    opacity: 0;
    transform: translateY(12px) scale(.97);
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
}
#ncAiPanel.nc-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* 모바일 */
@media (max-width: 480px) {
    #ncAiPanel {
        width: calc(100vw - 32px);
        right: 16px;
        bottom: 80px;
        max-height: 60vh;
    }
    #ncAiBtn {
        right: 68px;                       /* 모바일: scroll-top 우측 간격 조정 */
        bottom: 28px;
    }
}

/* ── 패널 헤더 ───────────────────────────────────────────────────────────── */
.nc-ai-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px 12px;
    background: linear-gradient(90deg, #1a3328, #1e2a24);
    border-bottom: 1px solid #2d4a38;
    flex-shrink: 0;
}
.nc-ai-header-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2d6a4f, #40916c);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .9rem;
    color: #fff;
    flex-shrink: 0;
}
.nc-ai-header-text {
    flex: 1;
    min-width: 0;
}
.nc-ai-header-title {
    font-size: .82rem;
    font-weight: 600;
    color: #b7e4c7;
    line-height: 1.2;
}
.nc-ai-header-sub {
    font-size: .7rem;
    color: #74c69d;
    opacity: .8;
}
.nc-ai-close {
    background: none;
    border: none;
    color: #74c69d;
    font-size: 1rem;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    opacity: .7;
    transition: opacity .15s;
}
.nc-ai-close:hover { opacity: 1; }

/* ── 메시지 영역 ─────────────────────────────────────────────────────────── */
.nc-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
.nc-ai-messages::-webkit-scrollbar { width: 4px; }
.nc-ai-messages::-webkit-scrollbar-track { background: transparent; }
.nc-ai-messages::-webkit-scrollbar-thumb { background: #2d6a4f; border-radius: 4px; }

/* ── 메시지 버블 ─────────────────────────────────────────────────────────── */
.nc-msg {
    max-width: 86%;
    line-height: 1.5;
    font-size: .82rem;
    animation: nc-msg-in .18s ease;
}
@keyframes nc-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.nc-msg-ai {
    align-self: flex-start;
}
.nc-msg-ai .nc-msg-bubble {
    background: #243b2f;
    color: #d8f3dc;
    border-radius: 4px 14px 14px 14px;
    padding: 9px 12px;
}
.nc-msg-user {
    align-self: flex-end;
}
.nc-msg-user .nc-msg-bubble {
    background: #2d6a4f;
    color: #fff;
    border-radius: 14px 4px 14px 14px;
    padding: 9px 12px;
}

/* ── 타이핑 인디케이터 ───────────────────────────────────────────────────── */
.nc-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    background: #243b2f;
    border-radius: 4px 14px 14px 14px;
}
.nc-typing span {
    width: 6px;
    height: 6px;
    background: #74c69d;
    border-radius: 50%;
    animation: nc-dot .9s infinite;
}
.nc-typing span:nth-child(2) { animation-delay: .15s; }
.nc-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes nc-dot {
    0%, 80%, 100% { transform: scale(.7); opacity: .5; }
    40%           { transform: scale(1);  opacity: 1; }
}

/* ── 캠핑장 추천 카드 ────────────────────────────────────────────────────── */
.nc-camp-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}
.nc-camp-card {
    display: flex;
    gap: 10px;
    background: #1a3328;
    border: 1px solid #2d4a38;
    border-radius: 10px;
    padding: 10px;
    text-decoration: none;
    color: inherit;
    transition: border-color .15s, background .15s;
    cursor: pointer;
}
.nc-camp-card:hover {
    border-color: #40916c;
    background: #1e3d2f;
    color: inherit;
    text-decoration: none;
}
.nc-camp-card-img {
    width: 52px;
    height: 52px;
    border-radius: 7px;
    object-fit: cover;
    flex-shrink: 0;
    background: #243b2f;
}
.nc-camp-card-img.nc-no-img {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #40916c;
    font-size: 1.2rem;
}
.nc-camp-card-body {
    flex: 1;
    min-width: 0;
}
.nc-camp-card-name {
    font-size: .8rem;
    font-weight: 600;
    color: #b7e4c7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nc-camp-card-addr {
    font-size: .7rem;
    color: #74c69d;
    opacity: .8;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nc-camp-card-mood {
    display: inline-block;
    margin-top: 4px;
    font-size: .65rem;
    color: #d4a843;
    background: rgba(212,168,67,.12);
    border-radius: 4px;
    padding: 1px 5px;
}

/* ── 입력 영역 ───────────────────────────────────────────────────────────── */
.nc-ai-input-wrap {
    display: flex;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid #2d4a38;
    flex-shrink: 0;
    background: #1a2820;
}
.nc-ai-input {
    flex: 1;
    background: #243b2f;
    border: 1px solid #2d4a38;
    border-radius: 20px;
    color: #d8f3dc;
    font-size: .82rem;
    padding: 8px 14px;
    outline: none;
    resize: none;
    line-height: 1.4;
    max-height: 80px;
    overflow-y: auto;
    transition: border-color .15s;
}
.nc-ai-input::placeholder { color: #4d7a60; }
.nc-ai-input:focus { border-color: #40916c; }

.nc-ai-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #2d6a4f;
    border: none;
    color: #fff;
    font-size: .9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: flex-end;
    transition: background .15s, transform .1s;
}
.nc-ai-send:hover:not(:disabled) { background: #40916c; transform: scale(1.05); }
.nc-ai-send:disabled { opacity: .4; cursor: not-allowed; }
