/* Reset & Base */
body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: transparent;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: flex-end;
    height: 100vh;
    box-sizing: border-box;
}

/* Chat Button Container */
.chat-button-container {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 10px;
    transition: transform 0.2s ease;
}

.chat-button-container:hover {
    transform: scale(1.05);
}

.chat-label {
    background: white;
    color: #333;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.3s ease;
}

#chat-widget-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #1a237e;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(26, 35, 126, 0.3);
    cursor: pointer;
    position: relative;
    z-index: 10;
}

/* Chat Container */
#chat-widget-container {
    position: absolute;
    bottom: 90px;
    right: 10px;
    width: 350px;
    height: 500px;
    background: #f8f9fa; /* 전체 배경색 */
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.19, 1, 0.22, 1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

#chat-widget-container.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ★ 확대 기능 (Maximized) ★ */
/* ★ 확대 기능 (Maximized) - 기존 챗봇 방식 적용 ★ */
#chat-widget-container.maximized {
    /* 1. 뷰포트(화면) 기준으로 위치 고정 */
    position: fixed !important; 
    
    /* 2. 상하좌우 좌표를 강제로 지정하여 쫙 늘림 */
    top: 20px !important;        /* 화면 꼭대기에서 20px 띄움 (기존 코드와 동일) */
    bottom: 100px !important;    /* 화면 바닥 버튼 위까지 꽉 채움 */
    right: 20px !important;      /* 오른쪽 여백 */
    
    /* 3. 크기 설정 */
    width: 600px !important;     /* 너비 (기존 코드와 동일) */
    height: auto !important;     /* top과 bottom을 지정했으므로 높이는 자동으로 늘어남 */
    
    /* 4. 애니메이션 및 변환 효과 제거 (필수: 이게 있어야 위치가 안 꼬임) */
    transform: none !important;  
    
    /* 5. 레이어 최상단 및 기타 스타일 */
    z-index: 99999;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

/* 모바일 화면 대응 (모바일은 꽉 차게) */
@media (max-width: 768px) {
    #chat-widget-container.maximized {
        width: calc(100% - 20px) !important;
        top: 10px !important;
        bottom: 90px !important;
        right: 10px !important;
    }
}

/* Header */
#chat-widget-header {
    background: #1a237e;
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0; /* 크기 줄어들지 않음 */
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.widget-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}
.widget-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

/* ★ 상단 고정 버튼 영역 (Sticky Buttons) ★ */
#chat-mode-buttons {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: #fff; /* 흰색 배경으로 고정됨을 표시 */
    border-bottom: 1px solid #eee;
    flex-shrink: 0; /* 스크롤되지 않고 고정 */
}

.chat-mode-btn {
    flex: 1;
    padding: 8px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-mode-btn:hover {
    border-color: #1a237e;
    color: #1a237e;
    background: #f0f4ff;
}

.chat-mode-btn.active {
    background: #1a237e;
    color: white;
    border-color: #1a237e;
    font-weight: bold;
}

/* Body (Scrollable) */
#chat-widget-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ★ 메시지 스타일 (Bot vs User) ★ */
.bot-message {
    align-self: flex-start; /* 왼쪽 정렬 */
    background: white;
    padding: 12px 16px;
    border-radius: 12px;
    border-top-left-radius: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    color: #333;
    font-size: 14px;
    line-height: 1.5;
    max-width: 85%;
}

.bot-message strong {
    font-weight: 700;
    color: #1a237e;
}

.user-message {
    align-self: flex-end; /* 오른쪽 정렬 */
    background: #1a237e;  /* 사용자 배경색 (네이비) */
    color: white;         /* 글자색 흰색 */
    padding: 12px 16px;
    border-radius: 12px;
    border-top-right-radius: 2px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    font-size: 14px;
    line-height: 1.5;
    max-width: 85%;
}

.guide-message {
    background: #e8eaf6 !important; /* 가이드 메시지는 연한 배경 */
    border: 1px solid #c5cae9;
}

.loading-message {
    align-self: flex-start;
    color: #888;
    font-style: italic;
    font-size: 12px;
    margin-left: 10px;
}

.error-message {
    align-self: center;
    background: #ffebee;
    color: #c62828;
    padding: 10px;
    border-radius: 8px;
    font-size: 13px;
}

/* Footer */
#chat-widget-footer {
    padding: 16px;
    background: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

#chat-widget-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#chat-widget-input:focus {
    border-color: #1a237e;
}

#chat-widget-send {
    background: #1a237e;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* Utility */
.hidden-label .chat-label {
    opacity: 0;
    pointer-events: none;
}
