* {
    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, #1e3c72 0%, #2a5298 50%, #7e8ba3 100%);
    height: 100vh;
    overflow: hidden;
}

.container {
    display: flex;
    height: 100vh;
    max-width: 1920px;
    margin: 0 auto;
    gap: 20px;
    padding: 20px;
}

/* PDF 뷰어 섹션 */
.pdf-viewer-section {
    flex: 0 0 65%;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.pdf-header {
    padding: 12px 16px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.pdf-header h2 {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
    min-width: 150px;
}

.pdf-controls {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.pdf-controls button {
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s;
    white-space: nowrap;
}

.pdf-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.page-info {
    display: flex;
    align-items: center;
    gap: 4px;
    color: white;
    font-weight: 500;
    font-size: 12px;
}

#current-page {
    width: 45px;
    padding: 4px 6px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border-radius: 4px;
    text-align: center;
    font-size: 12px;
}

/* PDF 메인 영역 */
.pdf-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* 사이드바 토글 버튼 */
.toggle-sidebar-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 100;
    padding: 8px 12px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(30, 60, 114, 0.3);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.toggle-sidebar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(30, 60, 114, 0.4);
}

/* 사이드바 */
.pdf-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 280px;
    background: white;
    border-right: 2px solid #e3f2fd;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.pdf-sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 15px;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-bottom: 2px solid #1e3c72;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 15px;
    color: #1e3c72;
    margin: 0;
}

.close-sidebar {
    background: transparent;
    border: none;
    font-size: 24px;
    color: #1e3c72;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.close-sidebar:hover {
    background: rgba(30, 60, 114, 0.1);
}

.page-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.page-thumbnail {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: white;
    border: 2px solid #e3f2fd;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s;
    font-size: 12px;
    color: #333;
    line-height: 1.4;
}

.page-thumbnail:hover {
    border-color: #2a5298;
    background: #f5f9ff;
    transform: translateX(5px);
}

.page-thumbnail.active {
    border-color: #1e3c72;
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    font-weight: 600;
    color: #1e3c72;
}

.page-thumbnail .page-number {
    display: block;
    font-size: 10px;
    color: #666;
    margin-bottom: 3px;
}

.page-thumbnail .page-title {
    display: block;
    font-size: 12px;
    font-weight: 500;
}

/* PDF 콘텐츠 */
.pdf-content {
    flex: 1;
    overflow: auto;
    padding: 20px;
    background: #fafafa;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#pdf-image {
    max-width: 100%;
    height: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
    color: #666;
}

/* 채팅 섹션 */
.chat-section {
    flex: 0 0 35%;
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.chat-header {
    padding: 12px 16px;
    background: linear-gradient(135deg, #1e88e5 0%, #1565c0 100%);
    color: white;
}

.chat-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.chat-subtitle {
    font-size: 12px;
    opacity: 0.9;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.message {
    margin-bottom: 20px;
    animation: slideIn 0.3s ease-out;
}

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

.message-content {
    padding: 12px 15px;
    border-radius: 10px;
    max-width: 90%;
    font-size: 13px;
}

.message.user .message-content {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    margin-left: auto;
}

.message.assistant .message-content {
    background: white;
    border: 1px solid #e0e0e0;
}

.message-content strong {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    opacity: 0.8;
}

.message-content p {
    line-height: 1.5;
    white-space: pre-wrap;
    font-size: 13px;
}

.sources {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
    font-size: 13px;
}

.source-item {
    margin: 5px 0;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.source-item:hover {
    background: #e3f2fd;
    color: #1e3c72;
}

.chat-input-area {
    padding: 20px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.input-container {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

#chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.3s;
}

#chat-input:focus {
    outline: none;
    border-color: #2a5298;
}

#send-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

#send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(30, 60, 114, 0.4);
}

#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.chat-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #666;
}

.status-ready {
    color: #28a745;
}

.status-processing {
    color: #ffc107;
}

.status-error {
    color: #dc3545;
}

/* 스크롤바 스타일 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #2a5298;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #1e3c72;
}

/* 반응형 */
@media (max-width: 1200px) {
    .container {
        flex-direction: column;
        padding: 10px;
        gap: 10px;
    }
    
    .pdf-viewer-section,
    .chat-section {
        flex: 1 1 50%;
    }
    
    .pdf-sidebar {
        width: 250px;
    }
}

@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
    
    .container {
        padding: 5px;
        gap: 5px;
    }
    
    .pdf-header {
        padding: 10px 12px;
    }
    
    .pdf-header h2 {
        font-size: 14px;
        width: 100%;
        margin-bottom: 8px;
    }
    
    .pdf-controls {
        width: 100%;
        justify-content: space-between;
    }
    
    .pdf-controls button {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .page-info {
        font-size: 11px;
    }
    
    #current-page {
        width: 40px;
        font-size: 11px;
    }
    
    .toggle-sidebar-btn {
        padding: 6px 10px;
        font-size: 11px;
        top: 8px;
        left: 8px;
    }
    
    .pdf-sidebar {
        width: 80%;
        max-width: 280px;
    }
    
    .chat-header h2 {
        font-size: 14px;
    }
    
    .chat-subtitle {
        font-size: 11px;
    }
    
    .chat-input-area {
        padding: 12px;
    }
    
    #chat-input {
        font-size: 13px;
        padding: 10px 12px;
    }
    
    #send-btn {
        padding: 10px 16px;
        font-size: 12px;
    }
    
    .message-content {
        font-size: 12px;
        padding: 10px 12px;
    }
    
    .message-content p {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .pdf-header h2 {
        font-size: 13px;
    }
    
    .pdf-controls button {
        padding: 5px 8px;
        font-size: 10px;
    }
    
    .page-info {
        font-size: 10px;
    }
    
    #current-page {
        width: 35px;
        padding: 3px 4px;
        font-size: 10px;
    }
    
    .toggle-sidebar-btn {
        padding: 5px 8px;
        font-size: 10px;
    }
    
    .pdf-sidebar {
        width: 90%;
    }
    
    .page-thumbnail {
        padding: 8px 10px;
        font-size: 11px;
    }
    
    .page-thumbnail .page-number {
        font-size: 9px;
    }
    
    .page-thumbnail .page-title {
        font-size: 11px;
    }
    
    .chat-header {
        padding: 10px 12px;
    }
    
    .chat-header h2 {
        font-size: 13px;
    }
    
    .message-content {
        font-size: 11px;
        padding: 8px 10px;
    }
    
    .message-content p {
        font-size: 11px;
    }
}
