* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* 헤더 */
.header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

/* 업로드 영역 */
.upload-area {
    background: white;
    border-radius: 20px;
    padding: 60px 40px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.15);
}

.upload-area.drag-over {
    background: #f0f4ff;
    border: 3px dashed #667eea;
}

.upload-content {
    pointer-events: none;
}

.upload-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 20px;
    color: #667eea;
}

.upload-text {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
}

.upload-subtext {
    font-size: 1rem;
    color: #888;
}

/* 메인 컨텐츠 */
.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    height: calc(100vh - 200px);
    min-height: 600px;
}

.main-content.hidden {
    display: none;
}

/* 사이드바 */
.sidebar {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.sidebar-header h2 {
    font-size: 1.3rem;
    color: #333;
    margin-bottom: 15px;
}

.search-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.sort-options {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.sort-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid #e0e0e0;
    background: white;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.sort-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.sort-btn.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* 대화 목록 */
.conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.conversation-item {
    padding: 15px;
    margin-bottom: 8px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.conversation-item:hover {
    background: #f8f9ff;
}

.conversation-item.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.conversation-name {
    font-weight: 600;
    font-size: 1rem;
    margin-bottom: 5px;
}

.conversation-id {
    font-weight: 400;
    font-size: 0.85rem;
    color: #888;
    opacity: 0.8;
}

.conversation-preview {
    font-size: 0.85rem;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item.active .conversation-preview {
    color: rgba(255, 255, 255, 0.8);
}

.conversation-item.active .conversation-id {
    color: rgba(255, 255, 255, 0.7);
}

.conversation-time {
    font-size: 0.75rem;
    color: #999;
    margin-top: 5px;
}

.conversation-item.active .conversation-time {
    color: rgba(255, 255, 255, 0.7);
}

/* 채팅 영역 */
.chat-area {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    padding: 20px 25px;
    border-bottom: 2px solid #f0f0f0;
    background: #fafbff;
}

.chat-header h2 {
    font-size: 1.4rem;
    color: #333;
    margin-bottom: 15px;
}

.message-search {
    display: flex;
    align-items: center;
    gap: 10px;
}

.search-navigation {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: #f0f0f0;
    border-radius: 8px;
}

.search-navigation.hidden {
    display: none;
}

.nav-btn {
    width: 30px;
    height: 30px;
    border: none;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    background: #667eea;
    color: white;
}

#matchCounter {
    font-size: 0.85rem;
    color: #666;
    min-width: 60px;
    text-align: center;
}

/* 메시지 컨테이너 */
.message-container {
    flex: 1;
    overflow-y: auto;
    padding: 25px;
    background: #f8f9fa;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    font-size: 1.2rem;
}

/* 메시지 */
.message {
    display: flex;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

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

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 60%;
    padding: 12px 18px;
    border-radius: 18px;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.message.sent .message-bubble {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
}

.message-sender {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.9;
}

.message.sent .message-sender {
    text-align: right;
}

.message-text {
    font-size: 0.95rem;
    line-height: 1.5;
}

.message-time {
    font-size: 0.75rem;
    margin-top: 6px;
    opacity: 0.7;
}

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

/* 하이라이트된 메시지 */
.message.highlight {
    animation: pulse 0.5s ease;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.message.highlight .message-bubble {
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.5);
}

/* 로딩 오버레이 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-overlay p {
    color: white;
    font-size: 1.2rem;
    margin-top: 20px;
}

/* 스크롤바 스타일 */
.conversation-list::-webkit-scrollbar,
.message-container::-webkit-scrollbar {
    width: 8px;
}

.conversation-list::-webkit-scrollbar-track,
.message-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.conversation-list::-webkit-scrollbar-thumb,
.message-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.conversation-list::-webkit-scrollbar-thumb:hover,
.message-container::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .sidebar.mobile-show {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        border-radius: 0;
    }
}
