/* Simple Chat UI - AI Kori Style */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans KR', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.5;
    min-height: 100vh;
}

/* Chat Wrapper */
.chat-wrapper {
    max-width: 900px;
    margin: 20px auto;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    background: #fff;
    box-shadow: 0 0 20px rgba(0,0,0,0.1);
    border-radius: 12px;
    overflow: hidden;
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, #1a365d 0%, #2c5282 100%);
    color: white;
    padding: 18px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

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

.header-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: white;
    object-fit: cover;
}

.header-title {
    font-size: 20px;
    font-weight: 700;
}

.lang-select {
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: transparent;
    color: white;
    font-size: 13px;
    cursor: pointer;
}

.lang-select option {
    color: #333;
    background: white;
}

/* Chat Area */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    background: linear-gradient(180deg, #e8f0f8 0%, #f5f7fa 100%);
}

/* Message Rows */
.message-row {
    display: flex;
    gap: 14px;
    margin-bottom: 20px;
}

.message-row.user {
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.message-row.user .msg-avatar {
    background: #2d6ed8;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 16px;
}

.msg-content {
    max-width: 75%;
    display: flex;
    flex-direction: column;
}

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

.msg-name {
    font-size: 13px;
    font-weight: 600;
    color: #555;
    margin-bottom: 4px;
}

.msg-bubble {
    background: white;
    border-radius: 16px;
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    font-size: 14px;
    line-height: 1.6;
}

.message-row.user .msg-bubble {
    background: #2d6ed8;
    color: white;
}

.msg-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* Welcome Message */
.welcome-text {
    margin-bottom: 8px;
}

.welcome-note {
    font-size: 13px;
    color: #666;
}

/* Input Area */
.input-area {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    background: #fff;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.chat-input {
    flex: 1;
    padding: 14px 20px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input:focus {
    border-color: #062e70;
}

.chat-input::placeholder {
    color: #aaa;
}

.send-btn {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    background: #062e70;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.send-btn:hover {
    background: #062e70;
}

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

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    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.6; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Scrollbar */
.chat-area::-webkit-scrollbar {
    width: 6px;
}

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

.chat-area::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* Response Formatting */
.msg-bubble h2, .msg-bubble h3, .msg-bubble h4 {
    color: #062e70;
    margin: 12px 0 8px 0;
    font-size: 15px;
}

.msg-bubble ul {
    margin: 8px 0;
    padding-left: 20px;
}

.msg-bubble li {
    margin: 4px 0;
}

.msg-bubble p {
    margin: 8px 0;
}

.msg-bubble strong {
    color: #062e70;
}

/* Tables */
.response-table-wrapper {
    overflow-x: auto;
    margin: 10px 0;
}

.response-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.response-table th {
    background: #062e70;
    color: white;
    padding: 8px;
    text-align: left;
}

.response-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #eee;
}

/* Mobile Responsive */
@media (max-width: 960px) {
    .chat-wrapper {
        max-width: 100%;
        height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    
    .msg-content {
        max-width: 85%;
    }
}

@media (min-width: 961px) {
    .msg-content {
        max-width: 70%;
    }
    
    .msg-bubble {
        font-size: 15px;
    }
    
    .chat-input {
        font-size: 15px;
    }
}

/* Source Tools Info */
.source-tools-info {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    font-size: 12px;
}

.source-tools-label {
    color: #666;
    margin-right: 4px;
}

.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    background: #f0f0f0;
    color: #555;
    font-size: 11px;
}

.source-badge.success {
    background: #e8f5e9;
    color: #2e7d32;
}

/* Citations */
.citations-section {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.citations-header {
    font-weight: 600;
    color: #062e70;
    font-size: 12px;
    margin-bottom: 6px;
}

.citations-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.citation-item {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    font-size: 11px;
    color: #666;
}

.citation-index {
    color: #062e70;
    font-weight: 600;
}

.citation-link {
    color: #062e70;
    text-decoration: none;
}

.citation-link:hover {
    text-decoration: underline;
}

/* Bot Answer in Bubble */
.msg-bubble .bot-answer {
    font-size: 14px;
    line-height: 1.6;
}

.msg-bubble .bot-answer p {
    margin: 6px 0;
}

.msg-bubble .bot-answer ul {
    margin: 8px 0;
    padding-left: 18px;
}

.msg-bubble .bot-answer li {
    margin: 3px 0;
}

.msg-bubble .bot-answer strong {
    color: #062e70;
}