* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #10b981;
    --danger: #ef4444;
    --bg-light: #f9fafb;
    --bg-white: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans', sans-serif;
    background: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* 헤더 */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 2rem;
    text-align: center;
    box-shadow: var(--shadow);
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.header p {
    opacity: 0.9;
    font-size: 1.05rem;
}

/* 메인 콘텐츠 */
.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1rem;
    padding: 1rem;
    overflow: hidden;
    flex: 1;
}

/* 사이드바 */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.sidebar section {
    background: var(--bg-white);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.sidebar h2, .sidebar h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* 언어 선택기 */
.language-selector {
    padding: 1rem !important;
}

.language-selector label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.language-selector select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    cursor: pointer;
    background: var(--bg-white);
    color: var(--text-primary);
    transition: border-color 0.3s;
}

.language-selector select:hover {
    border-color: var(--primary);
}

.language-selector select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* PDF 업로드 */
.pdf-upload {
    padding: 1.5rem !important;
}

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 0.75rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--bg-light);
}

.upload-area:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.upload-area.drag-over {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.02);
}

.upload-icon {
    width: 3rem;
    height: 3rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.upload-area p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* 업로드 진행 상황 */
#uploadProgress {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-light);
    border-radius: 0.5rem;
}

#uploadProgress.hidden {
    display: none;
}

.progress-bar {
    width: 100%;
    height: 0.5rem;
    background: var(--border);
    border-radius: 0.25rem;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary), var(--primary));
    width: 0%;
    transition: width 0.3s;
}

#progressText {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

/* PDF 정보 */
.pdf-info {
    padding: 1rem !important;
}

.pdf-info h3 {
    margin-bottom: 1rem;
}

#fileDetails p {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
}

#fileDetails p:last-child {
    border-bottom: none;
}

#fileDetails strong {
    flex: 1;
    color: var(--text-secondary);
}

#fileDetails span {
    color: var(--text-primary);
    font-weight: 500;
}

/* 버튼 */
.btn-clear, .btn-send {
    width: 100%;
    padding: 0.75rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 1rem;
}

.btn-clear {
    background: var(--bg-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-clear:hover {
    background: var(--border);
    border-color: var(--text-secondary);
}

.btn-send {
    background: var(--primary);
    color: white;
    padding: 0.75rem;
    width: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-send:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-send svg {
    width: 1.25rem;
    height: 1.25rem;
}

/* 채팅 컨테이너 */
.chat-container {
    background: var(--bg-white);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 채팅 메시지 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-light);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

.message {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    align-items: flex-end;
}

.message.assistant {
    align-items: flex-start;
}

.message-content {
    max-width: 75%;
    padding: 1rem;
    border-radius: 0.75rem;
    word-wrap: break-word;
}

.message.user .message-content {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.assistant .message-content {
    background: var(--bg-light);
    color: var(--text-primary);
    border-bottom-left-radius: 0.25rem;
}

.message-content p {
    margin: 0;
}

.message-content p + p {
    margin-top: 0.5rem;
}

/* 참조 페이지 */
.reference-pages {
    margin-top: 0.5rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    font-size: 0.85rem;
}

.reference-pages strong {
    display: block;
    margin-bottom: 0.25rem;
}

.reference-pages span {
    display: inline-block;
    background: rgba(0, 0, 0, 0.05);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

.timestamp {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* 채팅 입력 영역 */
.chat-input-area {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    background: var(--bg-light);
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

#queryInput {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    min-height: 50px;
    transition: border-color 0.3s;
}

#queryInput:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#queryInput:disabled {
    background: var(--border);
    cursor: not-allowed;
    opacity: 0.6;
}

.input-hints {
    text-align: right;
    margin-top: 0.25rem;
}

.input-hints small {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* 로딩 오버레이 */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 3rem;
    height: 3rem;
    border: 4px 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);
    }
}

#loadingText {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .sidebar {
        display: none;
    }

    .message-content {
        max-width: 90%;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .header {
        padding: 1.5rem 1rem;
    }
}

.hidden {
    display: none !important;
}
