/* KMS (Knowledge RAG Platform) 전용 스타일 */

/******************************************************************/
/* Knowledge RAG Platform Web Interface 전용 스타일 */

.content-section {
    animation: fadeIn 0.3s;
}

/* 드래그앤드랍 업로드 영역 스타일 */
.upload-area {
    border: 2px dashed var(--bs-border-color);
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    background-color: var(--bs-secondary-bg);
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: var(--bs-primary);
    background-color: var(--bs-tertiary-bg);
}

.upload-area.dragover {
    border-color: var(--bs-success);
    background-color: var(--bs-success-bg-subtle);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* #chat-messages는 기본 폰트 상속 (Noto Sans KR) */

.message-user {
    background-color: #e3f2fd;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 0.25rem;
}

.message-assistant {
    background-color: #f1f8e9;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 0.25rem;
}

.source-item {
    border-left: 3px solid #0d6efd;
    padding-left: 0.5rem;
    margin-bottom: 0.5rem;
}

/* 출처 항목 넘버링 스타일 */
.step-number {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background-color: #cfe2ff;
    color: var(--bs-primary);
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-weight: bold;
    margin-right: 0.5rem;
}

/* LLM 질문 헤더 스타일 */
.llm-question-header {
    background-color: rgba(0, 0, 0, 0.05);
    border-left: 4px solid var(--bs-success);
    border-bottom: 2px solid var(--bs-border-color);
    padding-left: calc(1rem - 4px);
}

/* 다크 모드 지원 */
[data-bs-theme="dark"] .llm-question-header {
    background-color: rgba(255, 255, 255, 0.05);
    border-bottom-color: var(--bs-border-color);
}

/* ID 복사 버튼 스타일 (작은 크기, 테두리 없음) */
.id-copy-btn {
    padding: 0.125rem 0.25rem;
    font-size: 0.75rem;
    line-height: 1;
    border: none;
    min-width: auto;
    text-decoration: none;
    color: var(--bs-secondary);
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.id-copy-btn:hover {
    color: var(--bs-primary);
    text-decoration: none;
    background-color: transparent;
}

.id-copy-btn:focus {
    box-shadow: none;
    color: var(--bs-primary);
    background-color: transparent;
}

.id-copy-btn:active {
    background-color: transparent;
}

.id-copy-btn i {
    font-size: 0.75rem;
    line-height: 1;
    display: inline-block;
}

/* LLM 답변 바디 스타일 */
.llm-answer-body {
    border-left: 4px solid var(--bs-primary);
    padding-left: calc(1rem - 4px);
    background-color: var(--bs-body-bg);
}

/* 마크다운 렌더링 스타일 */
.rag-answer,
.summarize-result,
.llm-answer-body {
    line-height: 1.6;
}

.llm-answer-body h1,
.rag-answer h1,
.summarize-result h1 {
    font-size: 1.75rem;
    font-weight: bold;
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--bs-border-color);
}

.llm-answer-body h2,
.rag-answer h2,
.summarize-result h2 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.375rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.llm-answer-body h3,
.rag-answer h3,
.summarize-result h3 {
    font-size: 1.25rem;
    font-weight: bold;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.llm-content h4,
.rag-answer h4,
.summarize-result h4 {
    font-size: 1.125rem;
    font-weight: bold;
    margin-top: 0.875rem;
    margin-bottom: 0.5rem;
}

.llm-answer-body h5,
.rag-answer h5,
.summarize-result h5 {
    font-size: 1rem;
    font-weight: bold;
    margin-top: 0.75rem;
    margin-bottom: 0.5rem;
}

.llm-content h6,
.rag-answer h6,
.summarize-result h6 {
    font-size: 0.875rem;
    font-weight: bold;
    margin-top: 0.625rem;
    margin-bottom: 0.5rem;
}

.llm-answer-body p,
.rag-answer p,
.summarize-result p {
    margin-bottom: 1rem;
}

.llm-answer-body ul,
.llm-answer-body ol,
.rag-answer ul,
.rag-answer ol,
.summarize-result ul,
.summarize-result ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.llm-answer-body li,
.rag-answer li,
.summarize-result li {
    margin-bottom: 0.5rem;
}

.llm-content ul li,
.rag-answer ul li,
.summarize-result ul li {
    list-style-type: disc;
}

.llm-answer-body ol li,
.rag-answer ol li,
.summarize-result ol li {
    list-style-type: decimal;
}

.llm-content code,
.rag-answer code,
.summarize-result code {
    background-color: var(--bs-secondary-bg);
    color: var(--bs-emphasis-color);
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
}

.llm-answer-body pre,
.rag-answer pre,
.summarize-result pre {
    background-color: var(--bs-secondary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    padding: 1rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.llm-answer-body pre code,
.rag-answer pre code,
.summarize-result pre code {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    font-size: 0.875rem;
    display: block;
    white-space: pre;
}

.llm-answer-body blockquote,
.rag-answer blockquote,
.summarize-result blockquote {
    border-left: 4px solid var(--bs-primary);
    padding-left: 1rem;
    margin-left: 0;
    margin-bottom: 1rem;
    color: var(--bs-secondary-color);
    font-style: italic;
}

.llm-answer-body table,
.rag-answer table,
.summarize-result table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.llm-answer-body table th,
.llm-answer-body table td,
.rag-answer table th,
.rag-answer table td,
.summarize-result table th,
.summarize-result table td {
    border: 1px solid var(--bs-border-color);
    padding: 0.5rem;
    text-align: left;
}

.llm-answer-body table th,
.rag-answer table th,
.summarize-result table th {
    background-color: var(--bs-secondary-bg);
    font-weight: bold;
}

.llm-answer-body strong,
.rag-answer strong,
.summarize-result strong {
    font-weight: bold;
}

.llm-answer-body em,
.rag-answer em,
.summarize-result em {
    font-style: italic;
}

.llm-answer-body a,
.rag-answer a,
.summarize-result a {
    color: var(--bs-link-color);
    text-decoration: underline;
}

.llm-answer-body a:hover,
.rag-answer a:hover,
.summarize-result a:hover {
    color: var(--bs-link-hover-color);
}

.llm-answer-body hr,
.rag-answer hr,
.summarize-result hr {
    border: none;
    border-top: 1px solid var(--bs-border-color);
    margin: 1.5rem 0;
}

/* 알림 스타일 */
.alert {
    margin-bottom: 1rem;
}

/* 로딩 스피너 */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 0.15em;
}

/* 프로그레스바 부드러운 전환 효과 */
.progress-bar {
    transition: width 0.3s ease-out, background-color 0.3s ease-out;
}

.progress {
    height: 1.5rem;
    overflow: hidden;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
}

/* 유틸리티 클래스 */
.max-w-300 {
    max-width: 300px;
}

.scrollable-area {
    height: 400px;
    overflow-y: auto;
    max-height: 400px;
}

/* DataTables 테이블 상단 컨트롤 레이아웃 - KMS 전용 */
.dataTables_wrapper .row {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

/* site.css의 기본 스타일을 유지하면서 flexbox 레이아웃만 추가 */
.dataTables_wrapper .dataTables_length {
    flex: 0 0 auto;
    margin-right: auto;
    /* site.css의 padding, font-size, line-height는 상속됨 */
}

.dataTables_wrapper .dataTables_filter {
    flex: 0 0 auto;
    margin-left: auto;
    /* site.css의 padding, font-size, line-height는 상속됨 */
}

/* 파일 제거 버튼 스타일 */
.file-remove-btn {
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.file-remove-btn:hover {
    opacity: 1;
    color: var(--bs-danger) !important;
}

/******************************************************************/
/* 모달 헤더 높이 및 패딩 조정 */

.modal-header {
    padding: 0.5rem 1rem !important;
    min-height: auto;
}

.modal-header .modal-title {
    margin-bottom: 0;
    line-height: 1.5;
}

/******************************************************************/
/* DataTables Responsive 서브항목 텍스트 줄바꿈 처리 */

/* 서브항목 셀 스타일 */
/* site.css의 padding: 0 1.5rem; 스타일은 유지됨 */
tr.child td {
    white-space: normal !important;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* 서브항목 내부 요소들 */
tr.child td .dtr-title,
tr.child td .dtr-data {
    white-space: normal !important;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* 서브항목 데이터 영역 */
tr.child td .dtr-data {
    display: block;
    max-width: 100%;
    overflow-wrap: break-word;
}

/* 서브항목 전체 컨테이너 */
tr.child {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* 서브항목 내부 테이블이 있는 경우 */
tr.child table {
    width: 100%;
    table-layout: auto;
    word-wrap: break-word;
}

tr.child table td {
    white-space: normal !important;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
}

/******************************************************************/
/* 세션 메시지 모달 리사이즈 가능 설정 */

#view-session-messages-modal .modal-dialog {
    position: relative;
    width: 800px;
    height: 600px;
    min-width: 500px;
    min-height: 400px;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    margin: 1.75rem auto;
}

#view-session-messages-modal .modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

#view-session-messages-modal .modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#view-session-messages-modal #session-messages-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    height: auto !important;
    max-height: none !important;
}

/* 리사이즈 핸들 */
#view-session-messages-modal .modal-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    z-index: 1055;
    background-image: repeating-linear-gradient(
        -45deg,
        var(--bs-border-color),
        var(--bs-border-color) 1px,
        transparent 1px,
        transparent 4px
    );
    opacity: 0.6;
}

#view-session-messages-modal .modal-resize-handle:hover {
    opacity: 1;
    background-image: repeating-linear-gradient(
        -45deg,
        var(--bs-primary),
        var(--bs-primary) 1px,
        transparent 1px,
        transparent 4px
    );
}

/******************************************************************/
/* 문서관리 테이블 제목 컬럼 ellipsis 처리 */

.text-truncate-title {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* details/summary 커서 스타일 */
details summary {
    cursor: pointer;
    text-decoration: none;
}
details summary:hover {
    text-decoration: none;
}

/* 버전별 카테고리 키워드 테이블 텍스트 색상 및 헤더 배경 조정 */
table.table.text-muted th,
table.table.text-muted td {
    color: var(--bs-secondary-color) !important;
}

table.table.text-muted thead th {
    background-color: rgba(var(--bs-secondary-bg-rgb), 0.5) !important;
    border-color: var(--bs-border-color) !important;
}

/* 차트 요약 스타일 (개요와 비슷한 스타일) */
#summary-sentiment_distribution,
#summary-score_distribution,
#summary-category_distribution,
#summary-comprehensive_trend,
#summary-sentiment_trend,
#summary-score_trend,
#summary-category_trend,
#summary-urgency_trend,
#summary-category_bubble,
#summary-score_sentiment_scatter,
#summary-version_review_count,
#summary-version_category_compare {
    padding: 1rem;
    background-color: var(--bs-secondary-bg);
    border-radius: 0.375rem;
    margin-top: 1rem;
}

#summary-sentiment_distribution h3,
#summary-score_distribution h3,
#summary-category_distribution h3,
#summary-comprehensive_trend h3,
#summary-sentiment_trend h3,
#summary-score_trend h3,
#summary-category_trend h3,
#summary-urgency_trend h3,
#summary-category_bubble h3,
#summary-score_sentiment_scatter h3,
#summary-version_review_count h3,
#summary-version_category_compare h3 {
    color: var(--bs-heading-color);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

#summary-sentiment_distribution .text-muted,
#summary-score_distribution .text-muted,
#summary-category_distribution .text-muted,
#summary-comprehensive_trend .text-muted,
#summary-sentiment_trend .text-muted,
#summary-score_trend .text-muted,
#summary-category_trend .text-muted,
#summary-urgency_trend .text-muted,
#summary-category_bubble .text-muted,
#summary-score_sentiment_scatter .text-muted,
#summary-version_review_count .text-muted,
#summary-version_category_compare .text-muted {
    color: var(--bs-secondary-color);
    line-height: 1.6;
    font-size: 1rem;
}

/******************************************************************/
/* 테이블 내 드롭다운이 잘리지 않도록 설정 */

.table-responsive {
    overflow-x: auto;
    overflow-y: visible !important;
}

.card-body {
    overflow: visible;
}

/******************************************************************/
/* 앱 접근 권한 드롭다운 스타일 */

[id^="appAccessList"] {
    overflow-x: hidden !important;
}

[id^="appAccessList"] .form-check {
    display: flex !important;
    align-items: flex-start !important;
    margin-bottom: 0;
    gap: 0.5rem;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

[id^="appAccessList"] .form-check-input {
    margin-top: 0.25rem !important;
    flex-shrink: 0 !important;
    width: 1.25em !important;
    height: 1.25em !important;
    margin-right: 0 !important;
    margin-left: 0 !important;
    position: relative !important;
}

[id^="appAccessList"] .form-check-label {
    flex: 1 !important;
    min-width: 0 !important;
    word-break: break-word;
    overflow-wrap: break-word;
    margin-left: 0 !important;
    padding-left: 0 !important;
}

[id^="appAccessList"] .form-check-label strong {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

[id^="appAccessList"] .form-check-label small {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
