/**
 * Multi-Source AI Chatbot - Styles
 */

/* ===========================================
   기본 스타일
   =========================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* ===========================================
   레이아웃
   =========================================== */
.container {
    display: flex;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
}

/* 좌측 컨텍스트 패널 */
.context-panel {
    width: 350px;
    min-width: 300px;
    background: #fff;
    border-right: 1px solid #ddd;
    padding: 20px;
    overflow-y: auto;
}

/* 우측 채팅 패널 */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    background: #fafafa;
}

/* ===========================================
   공통 컴포넌트
   =========================================== */
h2 {
    font-size: 1.3rem;
    margin-bottom: 20px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

h3 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: #34495e;
}

.section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.section:last-child {
    border-bottom: none;
}

/* 버튼 */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s, opacity 0.2s;
}

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

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #2980b9;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #7f8c8d;
}

.btn-small {
    padding: 5px 10px;
    font-size: 0.8rem;
}

/* 정보 박스 */
.info-box {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 12px;
    margin-top: 12px;
    font-size: 0.85rem;
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.summary-text {
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 200px;
    overflow-y: auto;
    color: #555;
}

/* 숨김 */
.hidden {
    display: none !important;
}

/* ===========================================
   엑셀 섹션
   =========================================== */
.file-upload {
    display: flex;
    gap: 10px;
    align-items: center;
}

.file-upload input[type="file"] {
    flex: 1;
    font-size: 0.85rem;
}

#excel-filename {
    font-weight: 600;
    color: #2c3e50;
}

/* ===========================================
   메일 섹션
   =========================================== */
.mail-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

#mail-result ul {
    margin: 10px 0 0 20px;
    padding: 0;
}

#mail-result li {
    margin-bottom: 5px;
}

#mail-result pre {
    background: #fff;
    padding: 10px;
    border-radius: 4px;
    overflow-x: auto;
    font-size: 0.8rem;
    max-height: 150px;
    overflow-y: auto;
}

/* 최근 메일 뷰어 */
#recent-mail-viewer {
    max-height: 400px;
    overflow-y: auto;
}

/* 폴더 탭 */
.folder-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.folder-tab {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f8f9fa;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.folder-tab:hover {
    background: #e9ecef;
}

.folder-tab.active {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.recent-mail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #ddd;
}

.recent-mail-nav {
    display: flex;
    gap: 8px;
}

.mail-detail h4 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1rem;
}

.mail-detail p {
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.mail-detail hr {
    border: none;
    border-top: 1px solid #eee;
    margin: 12px 0;
}

.mail-body {
    background: #fff;
    padding: 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
}

/* ===========================================
   옵션 섹션
   =========================================== */
.option-row {
    margin-bottom: 12px;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.toggle-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* ===========================================
   채팅 패널
   =========================================== */
.chat-log {
    flex: 1;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    overflow-y: auto;
    margin-bottom: 15px;
}

/* 메시지 */
.message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

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

.message.assistant {
    align-items: flex-start;
}

.role-label {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 4px;
    font-weight: 600;
}

.message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 16px;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.5;
}

.message.user .message-content {
    background: #3498db;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: #ecf0f1;
    color: #2c3e50;
    border-bottom-left-radius: 4px;
}

/* 상태 표시 */
.status {
    text-align: center;
    padding: 8px;
    color: #666;
    font-size: 0.9rem;
}

.status.error {
    color: #e74c3c;
    background: #fdeaea;
    border-radius: 4px;
}

/* 입력 영역 */
.chat-input-area {
    display: flex;
    gap: 10px;
}

#message-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    resize: none;
    font-family: inherit;
}

#message-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}

#send-btn {
    align-self: flex-end;
    min-width: 80px;
}

/* WebSocket 상태 */
.ws-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    font-size: 0.8rem;
    color: #666;
}

.indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.indicator.connected {
    background: #27ae60;
}

.indicator.disconnected {
    background: #e74c3c;
}

/* ===========================================
   반응형
   =========================================== */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .context-panel {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #ddd;
        max-height: 40vh;
    }

    .chat-panel {
        min-height: 60vh;
    }

    .message-content {
        max-width: 90%;
    }
}
