/**
 * AI 상담사 플로팅 위젯
 * - 오른쪽 하단 고정 아이콘 (첨부1 스타일)
 * - 클릭 시 채팅 오버레이 (첨부2 스타일: 그라데이션 테두리, 흰 배경)
 */

/* ========== 플로팅 버튼 (첨부1: 원형 청록/보라 아이콘) ========== */
.ai-chat-widget-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-main) 0%, #779da3 100%);
    box-shadow: 0 4px 20px rgba(0, 197, 197, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

.ai-chat-widget-trigger:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(0, 197, 197, 0.5);
}

.ai-chat-widget-trigger svg {
    width: 32px;
    height: 32px;
}

/* ========== 오버레이 배경 ========== */
.ai-chat-widget-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000000;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}

.ai-chat-widget-overlay.is-open {
    opacity: 1;
    visibility: visible;
    overscroll-behavior: contain;
    touch-action: none;
}

.ai-chat-widget-overlay.is-open .ai-chat-widget-messages {
    touch-action: pan-y;
}

/* ========== 채팅 패널 (첨부2: 둥근 모서리, 그라데이션 테두리) ========== */
.ai-chat-widget-panel {
    position: absolute;
    bottom: 24px;
    right: 24px;
    width: 450px;
    max-width: 100%;
    height: 60vh;
    max-height: 60vh;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.25s, transform 0.25s;
    border: 4px solid transparent;
    background-clip: padding-box;
    background-origin: padding-box;
}

.ai-chat-widget-overlay.is-open .ai-chat-widget-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* 그라데이션 외곽선 (두께 증가) */
.ai-chat-widget-panel::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 20px;
    padding: 8px;
    background: linear-gradient(120deg, #29d4c1 50%, #a855f7 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* 준비중: 패널 내부 전체 블러 + 중앙 문구 (푸터 링크 위까지 덮음) */
.ai-chat-widget-prep-overlay {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    box-sizing: border-box;
    pointer-events: auto;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    background: rgba(255, 255, 255, 0.42);
    border-radius: inherit;
}

.ai-chat-widget-prep-overlay__text {
    margin: 0;
    font-size: clamp(0.95rem, 2.8vw, 1.7rem);
    font-weight: 700;
    letter-spacing: 0.12em;
    color: rgb(53 53 53);
    text-align: center;
}

/* ========== 패널 헤더 (숨김) ========== */
.ai-chat-widget-header {
    display: none;
}

/* AI 메시지 왼쪽 로봇 프로필 */
.ai-chat-widget-msg__avatar {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #29d4c1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-widget-msg__avatar svg {
    width: 22px;
    height: 22px;
}

.ai-chat-widget-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 700;
    color: #000;
}

.ai-chat-widget-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: background 0.2s, color 0.2s;
}

.ai-chat-widget-close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #000;
}

/* ========== 메시지 영역 ========== */
.ai-chat-widget-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.ai-chat-widget-messages::-webkit-scrollbar {
    display: none;
}

.ai-chat-widget-msg {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    max-width: 90%;
}

.ai-chat-widget-msg--ai {
    align-self: flex-start;
}

.ai-chat-widget-msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.ai-chat-widget-msg__bubble {
    padding: 12px 16px;
    border-radius: 1.2rem;
    font-size: 0.9rem;
    line-height: 1.55;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.ai-chat-widget-msg--ai .ai-chat-widget-msg__bubble {
    background: #f3f4f6;
    color: #333;
}

.ai-chat-widget-msg--user .ai-chat-widget-msg__bubble {
    background: #29d4c1;
    color: #fff;
}

.ai-chat-widget-msg__suggestions {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.ai-chat-widget-msg__suggestions ol {
    margin: 0;
    padding-left: 18px;
    font-size: 0.85rem;
    color: #555;
    line-height: 1.8;
}

.ai-chat-widget-msg__suggestions li {
    cursor: pointer;
    transition: color 0.2s;
}

.ai-chat-widget-msg__suggestions li:hover {
    color: #29d4c1;
}

/* 타이핑 인디케이터 */
.ai-chat-widget-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
}

.ai-chat-widget-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    animation: ai-chat-widget-typing 1.2s ease-in-out infinite;
}

.ai-chat-widget-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.ai-chat-widget-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes ai-chat-widget-typing {
    0%, 60%, 100% { opacity: 0.35; transform: scale(0.9); }
    30% { opacity: 1; transform: scale(1); }
}

/* ========== 추천 질문 (첨부2 스타일) ========== */
.ai-chat-widget-quick {
    padding: 10px 16px 12px;
    flex-shrink: 0;
    background: transparent;
}

.ai-chat-widget-quick-label {
    display: none;
}

.ai-chat-widget-quick-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ai-chat-widget-quick-btn {
    padding: 8px 14px;
    font-size: 0.8rem;
    font-family: inherit;
    color: #333;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, color 0.2s;
}

.ai-chat-widget-quick-btn:hover {
    border-color: #29d4c1;
    background: rgba(41, 212, 193, 0.12);
    color: #29d4c1;
}

/* ========== 입력 영역 ========== */
.ai-chat-widget-input-wrap {
    padding: 12px 16px 16px;
    background: transparent;
    flex-shrink: 0;
}

.ai-chat-widget-input-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f5f5f5;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 8px 12px;
}

.ai-chat-widget-input-inner:focus-within {
    border-color: var(--color-main);
    box-shadow: 0 0 0 2px rgba(0, 197, 197, 0.2);
}

.ai-chat-widget-input {
    flex: 1;
    min-width: 0;
    height: 36px;
    padding: 0 8px;
    font-size: 0.9rem;
    font-family: inherit;
    color: #000;
    background: transparent;
    border: none;
}

.ai-chat-widget-input::placeholder {
    color: #999;
}

.ai-chat-widget-input:focus {
    outline: none;
}

.ai-chat-widget-send {
    width: 36px;
    height: 36px;
    border: none;
    background: #666;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background 0.2s;
}

.ai-chat-widget-send:hover {
    background: #29d4c1;
}

.ai-chat-widget-send svg {
    width: 18px;
    height: 18px;
}

/* ========== 전체 화면 링크 ========== */
.ai-chat-widget-fullscreen {
    display: block;
    padding: 20px 16px;
    font-size: 0.9rem;
    color: #29d4c1;
    text-align: center;
    text-decoration: none;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    transition: background 0.2s;
}

.ai-chat-widget-fullscreen:hover {
    background: rgba(41, 212, 193, 0.08);
}

/* ========== 반응형 ========== */

/* 태블릿 (768px ~ 1199px) */
@media (max-width: 1199px) {
    .ai-chat-widget-trigger {
        bottom: 20px;
        right: 20px;
        width: 52px;
        height: 52px;
    }

    .ai-chat-widget-trigger svg {
        width: 28px;
        height: 28px;
    }

    .ai-chat-widget-panel {
        bottom: 20px;
        right: 20px;
        width: min(400px, calc(100vw - 40px));
        max-width: calc(100vw - 40px);
        height: calc(100vh - 500px);
        max-height: calc(100vh - 200px);
        border-radius: 16px;
    }

    .ai-chat-widget-panel::before {
        border-radius: 18px;
    }

    .ai-chat-widget-messages {
        padding: 16px;
        gap: 12px;
    }

    .ai-chat-widget-msg__avatar {
        width: 36px;
        height: 36px;
    }

    .ai-chat-widget-msg__avatar svg {
        width: 20px;
        height: 20px;
    }

    .ai-chat-widget-msg__bubble {
        padding: 10px 14px;
        font-size: 0.875rem;
    }

    .ai-chat-widget-quick {
        padding: 8px 14px 10px;
    }

    .ai-chat-widget-quick-btn {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .ai-chat-widget-input-wrap {
        padding: 10px 14px 14px;
    }

    .ai-chat-widget-input-inner {
        padding: 6px 10px;
    }

    .ai-chat-widget-input {
        height: 32px;
        font-size: 0.875rem;
    }

    .ai-chat-widget-send {
        width: 32px;
        height: 32px;
    }

    .ai-chat-widget-send svg {
        width: 16px;
        height: 16px;
    }

    .ai-chat-widget-fullscreen {
        padding: 14px 12px;
        font-size: 0.8125rem;
    }
}

/* 모바일 (768px 이하) */
@media (max-width: 768px) {
    .ai-chat-widget-trigger {
        bottom: 16px;
        right: 16px;
        width: 48px;
        height: 48px;
    }

    .ai-chat-widget-trigger svg {
        width: 26px;
        height: 26px;
    }

    .ai-chat-widget-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 98%;
        height: 70vh;
        max-height: 70vh;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.15);
    }

    .ai-chat-widget-panel::before {
        border-radius: 22px 22px 0 0;
        inset: -3px -3px 0 -3px;
    }

    .ai-chat-widget-messages {
        padding: 14px 12px;
        gap: 10px;
    }

    .ai-chat-widget-msg {
        max-width: 95%;
    }

    .ai-chat-widget-msg__avatar {
        width: 32px;
        height: 32px;
    }

    .ai-chat-widget-msg__avatar svg {
        width: 18px;
        height: 18px;
    }

    .ai-chat-widget-msg__bubble {
        padding: 10px 12px;
        font-size: 0.8125rem;
    }

    .ai-chat-widget-msg__suggestions ol {
        font-size: 0.8125rem;
    }

    .ai-chat-widget-quick {
        padding: 8px 12px 10px;
    }

    .ai-chat-widget-quick-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .ai-chat-widget-input-wrap {
        padding: 10px 12px 12px;
    }

    .ai-chat-widget-input-inner {
        padding: 6px 10px;
    }

    .ai-chat-widget-input {
        height: 36px;
        font-size: 0.875rem;
    }

    .ai-chat-widget-send {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
    }

    .ai-chat-widget-send svg {
        width: 18px;
        height: 18px;
    }

    .ai-chat-widget-fullscreen {
        padding: 12px 10px;
        font-size: 0.8125rem;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
