/* ========================================
   Syncle AI - Chat Messages Styles
   메시지, 웰컴 화면, 타이핑 인디케이터
   ======================================== */

/* Welcome Screen */
.welcome-screen {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.6s ease;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    z-index: 1; /* 입력창(z-index: 100)보다 낮게 설정 */
    background: transparent;
    will-change: opacity, visibility;
}

.welcome-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

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

.welcome-content {
    text-align: center;
    max-width: 500px;
    background: transparent;
    padding: 20px;
}

.welcome-title {
    font-size: 20px;
    font-weight: 600;
    color: #000;
    margin-bottom: 12px;
    letter-spacing: 0.5px;
    position: relative;
}

.welcome-description {
    font-size: var(--font-size-base);
    color: var(--color-text-tertiary);
    line-height: var(--line-height-relaxed);
    margin-bottom: 0;
    font-family: var(--font-family-mono);
    letter-spacing: var(--letter-spacing-normal);
    position: relative;
    opacity: 0;
    animation: fadeInUp 0.8s ease-out 0.3s forwards;
}

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

/* Typing Animation */
#typing-text {
    color: inherit;
    font-weight: 500;
}

.typing-cursor {
    color: inherit;
    font-weight: 300;
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Ripple Effect */
.ripple-container {
    pointer-events: none;
    position: absolute;
    inset: 0;
    overflow: visible;
    background: transparent;
}

.ripple-circle {
    position: absolute;
    border-radius: 50%;
    border: 2px solid transparent;
    background: radial-gradient(circle at center,
        rgba(107, 114, 128, 0.08) 0%,
        rgba(107, 114, 128, 0.04) 40%,
        transparent 70%);
    box-shadow:
        0 0 0 1px rgba(107, 114, 128, 0.2),
        0 0 40px rgba(107, 114, 128, 0.1),
        inset 0 0 30px rgba(107, 114, 128, 0.05);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    animation: ripple-pulse 4s cubic-bezier(0.4, 0, 0.6, 1) infinite;
    opacity: 0.9;
    mix-blend-mode: multiply;
    will-change: transform, opacity;
    transform: translateZ(0); /* GPU 가속 */
    backface-visibility: hidden;
}

.ripple-circle::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        transparent,
        rgba(107, 114, 128, 0.1),
        transparent,
        rgba(107, 114, 128, 0.1),
        transparent
    );
    animation: ripple-rotate 8s linear infinite;
    opacity: 0.5;
}

@keyframes ripple-pulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.9;
    }
    25% {
        transform: translate(-50%, -50%) scale(1.02);
        opacity: 0.7;
    }
    50% {
        transform: translate(-50%, -50%) scale(0.98);
        opacity: 0.8;
    }
    75% {
        transform: translate(-50%, -50%) scale(1.01);
        opacity: 0.75;
    }
}

@keyframes ripple-rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Hide suggestions */
.welcome-suggestions {
    display: none !important;
}

/* Message Styles - Minimal Modern Design */
.message-wrapper {
    margin-bottom: 24px;
    display: flex;
    align-items: flex-start;  /* 아바타와 텍스트를 상단 정렬 */
    gap: 12px;
    padding: 0 24px;
    width: 100%;
    max-width: 800px;
    margin: 0 auto 24px auto;
    animation: messageSlide 0.3s ease;
    will-change: transform, opacity;
}

/* User messages - left aligned */
.message-wrapper.user-message {
    flex-direction: row;
    justify-content: flex-start;
}

/* Bot messages - left aligned */
.message-wrapper.bot-message {
    flex-direction: row;
    justify-content: flex-start;
}

.message-wrapper.bot-message .message-content {
    max-width: 100%;  /* 제한 제거 */
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    font-size: 16px;
}

.bot-avatar {
    background: var(--color-bot-avatar-bg);
    color: var(--color-bot-avatar-text);
    box-shadow: var(--shadow-avatar);
}

.user-avatar {
    background: var(--color-user-avatar-bg);
    color: var(--color-user-avatar-text);
    box-shadow: var(--shadow-avatar);
}

.message-content {
    background: transparent;
    border-radius: 0;
    padding: 0;
    flex: 1;  /* 기본: 전체 너비 (봇 메시지용) */
}

/* 사용자 메시지: 텍스트 길이만큼만 차지 */
.user-message .message-content {
    flex: 0 1 auto;  /* flex-grow: 0, flex-shrink: 1, flex-basis: auto */
    max-width: 70%;  /* 최대 너비 제한 (너무 길 경우 대비) */
}

.message-text {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: var(--font-size-md);          /* 14px → 16px */
    line-height: var(--line-height-relaxed);
    font-family: var(--font-family-base);    /* 모노 → 산세리프 */
    letter-spacing: var(--letter-spacing-normal);
    word-wrap: break-word;
}

.bot-message .message-text {
    background: var(--color-bot-bg);         /* 투명 배경 */
    color: var(--color-bot-text);
    border: none;
    box-shadow: none;
    padding: 0;                              /* ChatGPT 스타일: 완전 제거 */
    margin: 0;                               /* 마진도 제거 */
    border-radius: 0;                        /* 투명 배경이므로 radius 불필요 */
}

/* AI 메시지 내부 첫 번째 요소 여백 제거 */
.bot-message .message-text > *:first-child {
    margin-top: 0 !important;
}

.bot-message .message-text > *:last-child {
    margin-bottom: 0 !important;
}

.user-message .message-text {
    background: var(--color-user-bg);        /* 연한 회색 */
    color: var(--color-user-text);
    box-shadow: none;
    padding: 12px 16px;                      /* 말풍선처럼 여백 유지 */
}

.message-time {
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    margin-top: var(--space-1);
    font-family: var(--font-family-mono);
    letter-spacing: var(--letter-spacing-normal);
}

.message.user .message-time {
    text-align: right;
}

/* Bot Message Formatting Styles */
.bot-formatted {
    line-height: 1.8 !important;
}

.bot-formatted p {
    margin: 10px 0;
    line-height: 1.6;
}

.bot-formatted p:first-child {
    margin-top: 0 !important;  /* 첫 번째 p 태그 상단 여백 제거 */
}

.bot-formatted p:last-child {
    margin-bottom: 0 !important;
}

.bot-formatted br:last-child {
    display: none !important;
}

.bot-formatted h2 {
    font-size: 18px;
    font-weight: 700;
    margin: 20px 0 15px 0;
    color: #000;
    border-bottom: 2px solid #f0f0f0;
    padding-bottom: 8px;
}

.bot-formatted h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 18px 0 12px 0;
    color: #333;
}

.bot-formatted h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 15px 0 10px 0;
    color: #555;
}

.bot-formatted strong {
    font-weight: 700;
    color: #000;
    background: linear-gradient(to bottom, transparent 60%, #ffeb3b 60%);
    padding: 0 2px;
}

.bot-formatted ul {
    margin: 12px 0;
    padding-left: 25px;
    list-style: none;
}

.bot-formatted ul li {
    position: relative;
    margin: 8px 0;
    padding-left: 20px;
    line-height: 1.6;
}

.bot-formatted ul li::before {
    content: '▸';
    position: absolute;
    left: 0;
    color: #000;
    font-weight: bold;
}

.bot-formatted code {
    background: #f5f5f5;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    color: #e91e63;
}

.bot-formatted pre {
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    margin: 15px 0;
    overflow-x: auto;
}

.bot-formatted pre code {
    background: transparent;
    color: #333;
    padding: 0;
}

.bot-formatted hr {
    margin: 20px 0;
    border: none;
    border-top: 2px solid #e0e0e0;
}

.property-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    margin: 20px 0 0 0;
}

.property-number {
    display: inline-block;
    background: #000;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 8px;
}

.product-title-underline {
    font-weight: 700;
    color: #000;
    padding: 0 3px;
    display: inline-block;
    position: relative;
    transition: all 0.3s ease;
}

.product-title-underline:hover {
    color: #333;
}

.product-link {
    font-weight: 700;
    color: #007bff;
    text-decoration: none;
    background: linear-gradient(to bottom, transparent 60%, #e3f2fd 60%);
    padding: 0 4px;
    display: inline;
    position: relative;
    transition: all 0.3s ease;
    border-bottom: 2px solid #007bff;
    cursor: pointer;
}

.product-link:hover {
    background: linear-gradient(to bottom, transparent 50%, #bbdefb 50%);
    color: #0056b3;
    border-bottom-color: #0056b3;
    text-decoration: none;
}

.product-link:active {
    color: #003d82;
}

.bot-formatted .property-card {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    margin: 15px 0;
    transition: all 0.3s ease;
}

.bot-formatted .property-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #a3a3a3;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Thinking Indicator Styles */
.thinking-wrapper {
    animation: fadeIn 0.3s ease;
}

.thinking-wrapper .message-content {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

/* ========== 반응형: 모바일 최적화 ========== */
@media (max-width: 767px) {
    .message-wrapper {
        padding: 0 16px;
        gap: 10px;
        margin-bottom: 20px;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .message-text {
        font-size: var(--font-size-md);  /* 16px 유지 (모바일 가독성) */
        padding: 10px 14px;
    }

    .bot-message .message-text {
        padding: 0;  /* ChatGPT 스타일: 완전 제거 */
    }

    .user-message .message-text {
        padding: 10px 14px;  /* 말풍선 스타일 유지 */
    }
}

/* ========== 반응형: 태블릿 최적화 ========== */
@media (min-width: 768px) and (max-width: 1024px) {
    .message-wrapper {
        padding: 0 20px;
        max-width: 720px;
    }

    .message-text {
        font-size: var(--font-size-md);  /* 16px */
    }
}

/* ========================================
   AI Option Buttons - 선택지 버튼 스타일
   ======================================== */
.ai-option-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    margin: 6px 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #fff 100%);
    border: 1.5px solid #e0e0e0;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
    font-family: var(--font-family-base);
    text-align: left;
    line-height: 1.4;
    /* 등장 애니메이션 */
    opacity: 0;
    transform: translateY(10px);
    animation: optionButtonFadeIn 0.4s ease forwards;
}

/* 순차적 등장 애니메이션 딜레이 */
.ai-option-button:nth-of-type(1) { animation-delay: 0.1s; }
.ai-option-button:nth-of-type(2) { animation-delay: 0.2s; }
.ai-option-button:nth-of-type(3) { animation-delay: 0.3s; }
.ai-option-button:nth-of-type(4) { animation-delay: 0.4s; }

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

.ai-option-button:hover {
    background: linear-gradient(135deg, #fff 0%, #f0f4ff 100%);
    border-color: #4a90d9;
    color: #1a73e8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 144, 217, 0.2);
}

.ai-option-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(74, 144, 217, 0.15);
}

/* 비활성화 상태 */
.ai-option-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
    background: #f5f5f5;
    border-color: #ddd;
    color: #999;
    transform: none;
    box-shadow: none;
}

.ai-option-button.disabled:hover {
    transform: none;
    box-shadow: none;
    background: #f5f5f5;
    border-color: #ddd;
}

/* 선택된 버튼 스타일 */
.ai-option-button.selected {
    opacity: 1;
    background: linear-gradient(135deg, #e8f4fd 0%, #d4e9fc 100%);
    border-color: #1a73e8;
    color: #1a73e8;
}

.ai-option-button.selected::after {
    content: ' ✓';
    font-weight: 700;
}

/* 버튼 내 이모지 스타일 */
.ai-option-button::first-letter {
    font-size: 1.2em;
}

/* 버튼 컨테이너 - 버튼들을 세로로 정렬 */
.bot-formatted .ai-option-button {
    display: block;
    width: fit-content;
    max-width: 100%;
}

/* 모바일 반응형 */
@media (max-width: 767px) {
    .ai-option-button {
        padding: 14px 18px;
        font-size: 14px;
        width: 100%;
        max-width: 100%;
        justify-content: flex-start;
    }

    .ai-option-button:hover {
        transform: none;
    }

    .ai-option-button:active {
        background: linear-gradient(135deg, #e8f0fe 0%, #d2e3fc 100%);
        border-color: #1a73e8;
    }
}

/* 태블릿 반응형 */
@media (min-width: 768px) and (max-width: 1024px) {
    .ai-option-button {
        padding: 12px 18px;
        font-size: 14px;
    }
}
