/* CS Agent Test Chat — 카카오톡 스타일 */

.chat-wrap {
    max-width: 560px;
    margin: 1rem auto;
    background: #b2c7d9;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    min-height: 500px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

/* 헤더 */
.chat-header {
    background: #fff;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid hsl(var(--border));
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.chat-title {
    font-size: 1rem;
    font-weight: 700;
    color: #222;
}

.chat-subtitle {
    font-size: 0.7rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.125rem;
}

.chat-header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.chat-session {
    font-size: 0.7rem;
    color: hsl(var(--muted-foreground));
    font-family: ui-monospace, monospace;
}

.chat-reset-btn {
    padding: 0.25rem 0.6rem;
    font-size: 0.7rem;
    background: hsl(var(--muted));
    border: 1px solid hsl(var(--border));
    border-radius: 6px;
    cursor: pointer;
    color: hsl(var(--foreground));
}

.chat-reset-btn:hover {
    background: hsl(var(--border));
}

/* 메시지 영역 */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: #b2c7d9;
}

.chat-system {
    text-align: center;
    padding: 1rem;
    color: #476073;
    font-size: 0.8rem;
    background: rgba(255,255,255,0.4);
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.chat-system-sub {
    font-size: 0.7rem;
    margin-top: 0.25rem;
    opacity: 0.8;
}

/* 말풍선 공통 */
.msg-row {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.msg-row.user {
    align-self: flex-end;
    align-items: flex-end;
}

.msg-row.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.msg-bubble {
    padding: 0.6rem 0.85rem;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}

.msg-row.user .msg-bubble {
    background: #fef01b;  /* 카카오 노란색 */
    color: #222;
    border-bottom-right-radius: 4px;
}

.msg-row.assistant .msg-bubble {
    background: #fff;
    color: #222;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.msg-meta {
    font-size: 0.65rem;
    color: #476073;
    margin-top: 0.25rem;
    padding: 0 0.25rem;
}

/* 디버그 정보 */
.msg-debug {
    margin-top: 0.4rem;
    font-size: 0.7rem;
    font-family: ui-monospace, monospace;
    background: rgba(0,0,0,0.7);
    color: #d0f0d0;
    padding: 0.5rem 0.7rem;
    border-radius: 8px;
    max-width: 100%;
    line-height: 1.5;
}

.msg-debug .debug-label {
    color: #ffd27f;
    font-weight: 600;
}

.msg-debug .debug-value {
    color: #fff;
}

.msg-debug .debug-item {
    display: inline-block;
    margin-right: 0.75rem;
}

.msg-debug .debug-escalated {
    color: #ff8080;
    font-weight: 700;
}

/* 로딩 */
.chat-loading {
    align-self: flex-start;
    background: #fff;
    padding: 0.75rem 1rem;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 0.25rem;
}

.chat-loading span {
    width: 6px;
    height: 6px;
    background: #888;
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}

.chat-loading span:nth-child(2) { animation-delay: 0.15s; }
.chat-loading span:nth-child(3) { animation-delay: 0.3s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* 빠른 버튼 */
.quick-buttons {
    padding: 0.6rem 0.75rem;
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    background: #fff;
    border-top: 1px solid hsl(var(--border));
}

.quick-btn {
    flex-shrink: 0;
    padding: 0.4rem 0.85rem;
    background: hsl(var(--muted));
    border: 1px solid hsl(var(--border));
    border-radius: 9999px;
    font-size: 0.75rem;
    color: hsl(var(--foreground));
    cursor: pointer;
    white-space: nowrap;
}

.quick-btn:hover {
    background: hsl(var(--border));
}

.quick-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 입력창 */
.chat-input-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #fff;
    border-top: 1px solid hsl(var(--border));
}

#chat-input {
    flex: 1;
    padding: 0.65rem 0.9rem;
    border: 1px solid hsl(var(--input));
    border-radius: 9999px;
    font-size: 0.9rem;
    outline: none;
    background: hsl(var(--muted));
    color: hsl(var(--foreground));
}

#chat-input:focus {
    border-color: hsl(var(--primary));
    background: #fff;
}

.chat-send-btn {
    padding: 0.65rem 1.1rem;
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: none;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

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

@media (max-width: 640px) {
    .chat-wrap {
        margin: 0;
        border-radius: 0;
        height: calc(100vh - 60px);
    }
}
