/* AI 채팅 모달 스타일 */

/* AI 상담 버튼 */
.btn-ai {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-ai:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-ai:active {
    transform: translateY(0);
}

.btn-ai svg {
    width: 20px;
    height: 20px;
}

/* AI 채팅 모달 */
.ai-chat-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
}

.ai-chat-modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-chat-container {
    width: 92%;
    max-width: 440px;
    height: 75vh;
    min-height: 400px;
    max-height: 680px;
    background: white;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.3s ease;
}

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

/* 채팅 헤더 */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
    color: white;
}

.ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ai-chat-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: 1.25rem;
}

.ai-chat-title {
    font-weight: 600;
    font-size: 1rem;
}

.ai-chat-subtitle {
    font-size: 0.75rem;
    opacity: 0.9;
}

.ai-chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 채팅 메시지 영역 */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: #F7FAFC;
}

/* 채팅 버블 */
.ai-chat-bubble {
    max-width: 85%;
    padding: 0.875rem 1rem;
    border-radius: 1rem;
    line-height: 1.5;
    font-size: 0.95rem;
    word-wrap: break-word;
    white-space: pre-wrap;
    animation: bubbleIn 0.3s ease;
}

@keyframes bubbleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ai-chat-bubble.ai {
    align-self: flex-start;
    background: white;
    color: #2D3748;
    border: 1px solid #E2E8F0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.ai-chat-bubble.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

/* 타이핑 인디케이터 */
.ai-typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    background: white;
    border: 1px solid #E2E8F0;
    border-radius: 1rem;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 80px;
}

.ai-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #A0AEC0;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.ai-typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.ai-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* 채팅 입력 영역 */
.ai-chat-input-area {
    padding: 1rem;
    background: white;
    border-top: 1px solid #E2E8F0;
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.ai-chat-input-wrapper {
    flex: 1;
    position: relative;
}

.ai-chat-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 1px solid #E2E8F0;
    border-radius: 1.5rem;
    font-size: 0.95rem;
    resize: none;
    min-height: 48px;
    max-height: 120px;
    line-height: 1.4;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ai-chat-input:focus {
    outline: none;
    border-color: #667EEA;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

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

.ai-chat-send-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

.ai-chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-chat-send-btn svg {
    width: 20px;
    height: 20px;
}

/* 액션 버튼 영역 */
.ai-chat-actions {
    padding: 0 1rem 1rem;
    background: white;
    display: none;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-chat-actions.visible {
    display: flex;
}

.ai-chat-action-btn {
    width: 100%;
    padding: 0.875rem 1rem;
    border: none;
    border-radius: 0.75rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.ai-chat-action-btn.primary {
    background: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.ai-chat-action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.ai-chat-action-btn.secondary {
    background: #F7FAFC;
    color: #4A5568;
    border: 1px solid #E2E8F0;
}

.ai-chat-action-btn.secondary:hover {
    background: #EDF2F7;
}

/* 견적 요약 카드 */
.ai-estimate-summary {
    background: linear-gradient(135deg, #F0FDF4 0%, #DCFCE7 100%);
    border: 1px solid #86EFAC;
    border-radius: 1rem;
    padding: 1rem;
    margin: 0.5rem 0;
    animation: bubbleIn 0.3s ease;
}

.ai-estimate-summary-title {
    font-weight: 700;
    font-size: 1rem;
    color: #166534;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-estimate-breakdown {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.ai-estimate-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: #374151;
    padding: 0.25rem 0;
}

.ai-estimate-row span:first-child {
    flex: 1;
    min-width: 0;
}

.ai-estimate-row span:last-child {
    font-weight: 500;
    white-space: nowrap;
    margin-left: 0.5rem;
    color: #1F2937;
}

.ai-estimate-multiplier {
    color: #6B7280;
    font-style: italic;
}

.ai-estimate-multiplier span:last-child {
    color: #7C3AED;
    font-weight: 600;
}

.ai-estimate-divider {
    height: 1px;
    background: #86EFAC;
    margin: 0.625rem 0;
}

.ai-estimate-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
}

.ai-estimate-total span:first-child {
    font-size: 0.9rem;
    font-weight: 600;
    color: #166534;
}

.ai-estimate-summary-price {
    font-size: 1.35rem;
    font-weight: 700;
    color: #15803D;
}

.ai-estimate-summary-period {
    font-size: 0.8rem;
    color: #16A34A;
    margin-top: 0.375rem;
    text-align: right;
}

/* 빠른 답변 버튼 */
.ai-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.5rem 0;
    animation: bubbleIn 0.3s ease;
}

.ai-quick-reply-btn {
    padding: 0.5rem 1rem;
    background: white;
    border: 1.5px solid #667EEA;
    border-radius: 2rem;
    font-size: 0.85rem;
    color: #667EEA;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, transform 0.2s, box-shadow 0.2s;
    white-space: nowrap;
}

.ai-quick-reply-btn:hover {
    background: #667EEA;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.ai-quick-reply-btn:active {
    transform: translateY(0);
}

/* 스크롤바 스타일 */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #CBD5E0;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #A0AEC0;
}

/* 태블릿 반응형 */
@media (min-width: 481px) and (max-width: 768px) {
    .ai-chat-container {
        width: 88%;
        max-width: 420px;
        height: 70vh;
        max-height: 600px;
    }

    .ai-chat-bubble {
        font-size: 0.9rem;
    }
}

/* 모바일 반응형 */
@media (max-width: 480px) {
    .ai-chat-container {
        width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .ai-chat-header {
        padding: 0.875rem 1rem;
    }

    .ai-chat-bubble {
        max-width: 88%;
        font-size: 0.9rem;
        padding: 0.75rem 0.875rem;
    }

    .ai-chat-messages {
        padding: 0.75rem;
        gap: 0.625rem;
    }

    .ai-chat-input-area {
        padding: 0.625rem 0.75rem;
        padding-bottom: calc(0.625rem + env(safe-area-inset-bottom, 0px));
    }

    .ai-chat-input {
        font-size: 16px; /* iOS 줌 방지 */
        padding: 0.75rem 0.875rem;
        min-height: 44px;
    }

    .ai-chat-send-btn {
        width: 44px;
        height: 44px;
    }

    .btn-ai {
        padding: 0.625rem 1rem;
        font-size: 0.9rem;
    }

    .ai-estimate-summary-price {
        font-size: 1.25rem;
    }
}

/* 작은 모바일 (SE 등) */
@media (max-width: 375px) {
    .ai-chat-bubble {
        max-width: 92%;
        font-size: 0.85rem;
    }

    .ai-chat-header {
        padding: 0.75rem;
    }

    .ai-chat-title {
        font-size: 0.9rem;
    }

    .ai-chat-subtitle {
        font-size: 0.7rem;
    }
}

/* 버튼 그룹에 AI 버튼 통합 */
.estimate-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.estimate-actions .btn-ai {
    width: 100%;
    justify-content: center;
}
