/* 챗봇 위젯 스타일 */
.moachat-widget {
    --moachat-primary: rgba(33, 136, 141, 1.0);
    --moachat-button-hover: rgba(26, 101, 112, 1.0);
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.moachat-right {
    right: 20px;
}

.moachat-left {
    left: 20px;
}

/* 토글 버튼 - 확장 가능한 캡슐 */
.moachat-toggle {
    width: 60px;
    height: 60px;
    background: var(--moachat-primary);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    padding: 0;
}

.moachat-toggle:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
    background: var(--moachat-button-hover);
    border-radius: 30px;
    width: auto;
    padding-right: 20px;
}

/* 토글 아이콘 래퍼 */
.moachat-toggle-icon {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* 토글 라벨 (봇 이름) */
.moachat-toggle-label {
    white-space: nowrap;
    color: white;
    font-weight: 600;
    font-size: 15px;
    max-width: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 왼쪽 위치일 때 */
.moachat-left .moachat-toggle {
    flex-direction: row-reverse;
}

.moachat-left .moachat-toggle:hover {
    padding-right: 0;
    padding-left: 20px;
}

/* 호버 시 위젯 확장 */
.moachat-widget:hover .moachat-toggle-label {
    max-width: 200px;
    opacity: 1;
    margin-left: 5px;
}

/* 채팅창이 열린 상태에서는 호버 비활성화 */
.moachat-widget.moachat-open:hover .moachat-toggle {
    width: 60px;
    border-radius: 50%;
    padding-right: 0;
    pointer-events: none;
}

.moachat-widget.moachat-open:hover .moachat-toggle-label {
    max-width: 0;
    opacity: 0;
    margin-left: 0;
}

.moachat-left:hover .moachat-toggle-label {
    margin-left: 0;
    margin-right: 5px;
}

/* 채팅창 열렸을 때 위젯 확장 유지 */
.moachat-widget.moachat-open .moachat-toggle-label {
    max-width: 0;
    opacity: 0;
}

.moachat-left.moachat-open .moachat-toggle-label {
    margin-left: 0;
    margin-right: 0;
}

/* 아이콘 흔들림 애니메이션 */
.moachat-shake {
    animation: moachat-shake 0.5s ease-in-out infinite alternate;
}

@keyframes moachat-shake {
    0% {
        transform: translateX(-5px) rotate(-5deg);
    }
    100% {
        transform: translateX(5px) rotate(5deg);
    }
}

.moachat-icon-default {
    font-size: 24px;
    color: white;
}

.moachat-icon-image {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}/* 채팅 창 */
.moachat-window {
    position: absolute;
    bottom: 70px;
    right: -15px;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 1000000;
    transform: translateY(10px);
    opacity: 0;
    transition: all 0.3s ease;
}

.moachat-widget.moachat-open .moachat-window {
    display: flex !important;
    transform: translateY(0);
    opacity: 1;
}

.moachat-left .moachat-window {
    right: auto;
    left: 0;
}

/* 헤더 */
.moachat-header {
    background: var(--moachat-primary);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.moachat-bot-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.moachat-bot-icon,
.moachat-bot-icon-default {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.moachat-bot-icon-default {
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.moachat-bot-name {
    font-weight: 600;
    font-size: 16px;
}

.moachat-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.moachat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 메시지 영역 */
.moachat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8fafc;
}

.moachat-message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.moachat-message.bot {
    justify-content: flex-start;
}

.moachat-message.user {
    align-items: flex-end;
}

.moachat-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
}

.moachat-message.bot .moachat-bubble {
    background: white;
    color: #374151;
    border: 1px solid #e5e7eb;
}

.moachat-message.user .moachat-bubble {
    background: var(--moachat-primary);
    color: white;
}

/* 입력 영역 */
.moachat-input-area {
    border-top: 1px solid #e5e7eb;
    background: white;
    padding: 16px;
}

.moachat-input-container {
    display: flex;
    gap: 8px;
}

.moachat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    transition: all 0.2s ease;
}

.moachat-input:focus {
    border-color: #667eea;
    background-color: white;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.moachat-send {
    padding: 12px 20px;
    background: var(--moachat-primary);
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.moachat-send:hover {
    background: var(--moachat-button-hover);
}

/* 버튼 스타일 */
.moachat-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    max-width: 85%;
}

.moachat-btn {
    padding: 8px 16px;
    background: var(--moachat-primary);
    color: white;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.2s ease;
}

.moachat-btn:hover {
    background: var(--moachat-button-hover);
}

/* 폼 스타일 */
.moachat-form {
    margin-top: 16px;
}

.moachat-form-group {
    margin-bottom: 12px;
}

.moachat-form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 4px;
}

.moachat-form-input,
.moachat-form-textarea,
.moachat-form-radio-group {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.moachat-form-input:focus,
.moachat-form-textarea:focus {
    border-color: #667eea;
    background-color: white;
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.moachat-form-textarea {
    resize: vertical;
    min-height: 80px;
}

.moachat-form-radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: none;
    padding: 0;
}

.moachat-form-radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
}

.moachat-form-radio-label input[type="radio"] {
    margin: 0;
}

.moachat-form-submit {
    width: 100%;
    padding: 12px;
    background: var(--moachat-primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.moachat-form-submit:hover {
    background: var(--moachat-button-hover);
}

/* 타이핑 애니메이션 */
.moachat-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    width: fit-content;
}

.moachat-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    animation: typing 1.4s infinite;
}

.moachat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.moachat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* 애니메이션 */
.moachat-window {
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.moachat-message {
    animation: fadeIn 0.3s ease-out;
}

/* 인사말 버블 */
.moachat-greeting-bubble {
    position: absolute;
    bottom: 70px;
    right: 0;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    padding: 12px 16px;
    max-width: 350px;
    min-width: 200px;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    transition: all 0.3s ease;
    cursor: pointer;
    z-index: 1000001;
    border: 1px solid #e5e7eb;
}

.moachat-greeting-bubble.show {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.moachat-greeting-content {
    font-size: 14px;
    line-height: 1.2;
    color: #374151;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.moachat-greeting-arrow {
    position: absolute;
    bottom: -9px;
    right: 20px;
    width: 16px;
    height: 9px;
    overflow: hidden;
}

.moachat-greeting-arrow::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
    top: -6px;
    left: 2px;
    box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.moachat-left .moachat-greeting-bubble {
    right: auto;
    left: 0;
}

.moachat-left .moachat-greeting-arrow {
    right: auto;
    left: 20px;
}

/* 모바일 반응형 */
@media (max-width: 480px) {
    .moachat-widget {
        bottom: 20px;
        left: 10px;
        right: auto;
    }
    
    .moachat-window {
        position: fixed !important;
        width: 100vw !important;
        height: 100vh !important;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        z-index: 1000001 !important;
        border-radius: 0 !important;
    }
    
    .moachat-widget.moachat-open .moachat-window {
        display: flex !important;
        transform: none !important;
        opacity: 1 !important;
    }
    
    .moachat-left .moachat-window {
        right: 0 !important;
        left: 0 !important;
    }
    
    /* 모바일에서 인사말 버블 스타일 */
    .moachat-greeting-bubble {
        bottom: 80px;
        max-width: 320px;
        min-width: 250px;
        left: 0;
        right: auto;
        transform: translateY(10px) scale(0.9);
    }
    
    .moachat-greeting-bubble.show {
        transform: translateY(0) scale(1);
    }
    
    .moachat-greeting-arrow {
        left: 20px;
        right: auto;
    }
    
    .moachat-greeting-arrow::before {
        left: -8px;
    }
}

/* ===== 1:1 채팅 상태 표시 ===== */
.moachat-bot-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.moachat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
}

.moachat-status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8; /* Gray - waiting */
    animation: pulse-waiting 2s ease-in-out infinite;
}

.moachat-status-indicator.connected {
    background: #22c55e; /* Green - connected */
    animation: pulse-connected 2s ease-in-out infinite;
}

.moachat-status-indicator.typing {
    background: #3b82f6; /* Blue - typing */
    animation: pulse-typing 1s ease-in-out infinite;
}

@keyframes pulse-waiting {
    0%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

@keyframes pulse-connected {
    0%, 100% {
        opacity: 0.8;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

@keyframes pulse-typing {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.9);
    }
}

.moachat-status-text {
    font-weight: 500;
}

/* 타이핑 인디케이터 애니메이션 개선 */
.moachat-typing span {
    animation: typing-bounce 1.4s infinite;
}

.moachat-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.moachat-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}