/* 에이전트 챗봇 스타일 */

/* 플로팅 버튼 컨테이너 */
.agent-fab-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
}

/* 말풍선 */
.agent-bubble {
    position: absolute;
    bottom: 74px;
    right: 0;
    background: white;
    padding: 12px 16px;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    color: #1D1D1F;
    white-space: nowrap;
    animation: bubbleBounce 0.5s ease;
    cursor: pointer;
    display: none;
}

.agent-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 24px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 10px solid white;
}

.agent-bubble .close-bubble {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    background: #ccc;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 12px;
    line-height: 18px;
    color: white;
}

.agent-bubble .close-bubble:hover {
    background: #999;
}

@keyframes bubbleBounce {
    0% { opacity: 0; transform: translateY(10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* 플로팅 버튼 */
.agent-fab {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #FFD93D 0%, #FF9F43 100%);
    border: 3px solid white;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(255, 159, 67, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    font-size: 36px;
    padding: 0;
}

.agent-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(255, 159, 67, 0.5);
}

.agent-fab:active {
    transform: scale(0.95);
}

.agent-fab .agent-character {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.agent-fab .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #FF3B30;
    border-radius: 50%;
    font-size: 11px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* 채팅창 */
.agent-chat {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    height: 520px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 9999;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.agent-chat.open {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 채팅창 헤더 */
.agent-header {
    background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.agent-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.agent-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.agent-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.agent-header-info p {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.8;
}

.agent-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.agent-close:hover {
    opacity: 1;
}

/* 메시지 영역 */
.agent-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
}

.agent-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.agent-message.bot {
    background: white;
    color: #1D1D1F;
    align-self: flex-start;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.agent-message.user {
    background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 6px;
}

.agent-message.typing {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
}

.agent-message.typing span {
    width: 8px;
    height: 8px;
    background: #86868B;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.agent-message.typing span:nth-child(1) { animation-delay: 0s; }
.agent-message.typing span:nth-child(2) { animation-delay: 0.2s; }
.agent-message.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* 빠른 질문 버튼 */
.agent-quick-questions {
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    background: #f8f9fa;
    border-top: 1px solid #e8e8e8;
}

.quick-question-btn {
    padding: 8px 14px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 12px;
    color: #1D1D1F;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-question-btn:hover {
    background: #007AFF;
    color: white;
    border-color: #007AFF;
}

/* 입력 영역 */
.agent-input-area {
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e8e8e8;
    display: flex;
    gap: 10px;
    align-items: center;
}

.agent-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.agent-input:focus {
    border-color: #007AFF;
}

.agent-input::placeholder {
    color: #86868B;
}

.agent-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.agent-send:hover {
    transform: scale(1.05);
}

.agent-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.agent-send svg {
    width: 20px;
    height: 20px;
    color: white;
}

/* 모바일 대응 */
@media (max-width: 480px) {
    .agent-chat {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .agent-fab-container {
        bottom: 16px;
        right: 16px;
    }

    .agent-fab {
        width: 56px;
        height: 56px;
    }

    .agent-fab .agent-character {
        width: 40px;
        height: 40px;
        font-size: 28px;
    }

    .agent-bubble {
        right: -10px;
        font-size: 12px;
        padding: 10px 14px;
    }
}

/* 앱 모드에서 에이전트 버튼 위치 조정 (탭바 위로) */
body.app-mode .agent-fab-container {
    bottom: calc(56px + 16px + env(safe-area-inset-bottom));
}

body.app-mode .agent-chat {
    bottom: calc(56px + env(safe-area-inset-bottom));
    height: calc(100% - 56px - env(safe-area-inset-bottom));
}

@media (max-width: 480px) {
    body.app-mode .agent-fab-container {
        bottom: calc(56px + 12px + env(safe-area-inset-bottom));
        right: 12px;
    }
}
