/* wiki.css - 위키피디아 스타일 지식베이스 */

/* 위키 활성화 시 app-container 오버플로우 해제 */
.app-container:has(.wiki-container[style*="display: block"]) {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
}

/* 위키 컨테이너 */
.wiki-container {
    flex-direction: row !important;
    min-height: 100% !important;
    height: auto !important;
    background: white;
    overflow: visible !important;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    margin-top: -12px;
}

/* 위키가 표시될 때만 flex 레이아웃 적용 */
.wiki-container[style*="display: block"] {
    display: flex !important;
}

/* 좌측 사이드바 */
.wiki-sidebar {
    width: 280px !important;
    min-width: 280px !important;
    max-width: 280px !important;
    background: white;
    border-right: 1px solid #e0e0e0;
    overflow-y: visible !important;
    overflow-x: visible !important;
    flex-shrink: 0 !important;
    height: auto !important;
    border-radius: 12px 0 0 12px;
}

.wiki-sidebar-header {
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    font-weight: 600;
    font-size: 16px;
    color: #333;
}

.wiki-search {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.wiki-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.wiki-search input:focus {
    outline: none;
    border-color: var(--brand-primary, #1428A0);
}

/* 검색창 + 추가 버튼 */
.wiki-search {
    display: flex;
    gap: 8px;
    align-items: center;
}

.wiki-search input {
    flex: 1;
}

.wiki-add-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: var(--brand-primary, #1428A0);
    color: white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.wiki-add-btn:hover {
    background: #0f1f85;
}

/* 트리 메뉴 */
.wiki-tree {
    padding: 8px 0;
}

.wiki-tree-item {
    position: relative;
    user-select: none;
}

.wiki-tree-item-content {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;
    transition: background 0.2s;
}

.wiki-tree-item-content:hover {
    background: #f0f0f0;
}

.wiki-tree-item-content.active {
    background: #e3f2fd;
    color: var(--brand-primary, #1428A0);
    font-weight: 600;
}

.wiki-tree-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    font-size: 12px;
    color: #666;
}

.wiki-tree-toggle.empty {
    visibility: hidden;
}

.wiki-tree-icon {
    margin-right: 6px;
    font-size: 14px;
}

.wiki-tree-label {
    flex: 1;
    font-size: 14px;
}

.wiki-inline-add-btn {
    margin-left: 4px;
    padding: 0 4px;
    font-size: 12px;
    color: var(--brand-primary, #1428A0);
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    font-weight: bold;
}

.wiki-tree-item-content:hover .wiki-inline-add-btn {
    opacity: 1;
}

.wiki-inline-add-btn:hover {
    transform: scale(1.3);
}

.wiki-delete-btn {
    margin-left: 4px;
    padding: 2px 6px;
    font-size: 14px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.wiki-tree-item-content:hover .wiki-delete-btn {
    opacity: 1;
}

.wiki-delete-btn:hover {
    transform: scale(1.2);
}

/* Inline Add Input */
.wiki-inline-input-container {
    margin: 4px 0;
}

.wiki-inline-add-form {
    background: #f8f9fa;
    border: 1px solid var(--brand-primary, #1428A0);
    border-radius: 4px;
    padding: 6px 12px !important;
}

.wiki-inline-input {
    flex: 1;
    border: none;
    background: white;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 14px;
    margin: 0 6px;
}

.wiki-inline-input:focus {
    outline: none;
    border: 1px solid var(--brand-primary, #1428A0);
}

.wiki-inline-save-btn,
.wiki-inline-cancel-btn {
    padding: 4px 8px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    margin-left: 4px;
    transition: all 0.2s;
}

.wiki-inline-save-btn {
    background: var(--brand-primary, #1428A0);
    color: white;
}

.wiki-inline-save-btn:hover {
    background: #0f1f85;
}

.wiki-inline-cancel-btn {
    background: #dc3545;
    color: white;
}

.wiki-inline-cancel-btn:hover {
    background: #c82333;
}

.wiki-tree-children {
    padding-left: 20px;
    display: none;
}

.wiki-tree-children.expanded {
    display: block;
}

/* 우측 콘텐츠 영역 */
.wiki-content {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    background: white;
    overflow: visible !important;
    min-width: 0 !important;
    height: auto !important;
}

.wiki-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
}

.wiki-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.wiki-actions {
    display: flex;
    gap: 8px;
}

.wiki-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.wiki-btn:hover {
    background: #f8f9fa;
}

.wiki-btn-primary {
    background: var(--brand-primary, #1428A0);
    color: white;
    border-color: var(--brand-primary, #1428A0);
}

.wiki-btn-primary:hover {
    background: #0f1f85;
}

.wiki-btn-danger {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.wiki-btn-danger:hover {
    background: #c82333;
}

/* 위키 본문 */
.wiki-body {
    flex: 1;
    overflow-y: visible !important;
    overflow-x: visible !important;
    padding: 24px;
    min-height: auto !important;
    height: auto !important;
}

.wiki-viewer {
    max-width: 900px;
    margin: 0 auto;
    line-height: 1.8;
    color: #333;
}

.wiki-viewer h1 {
    font-size: 28px;
    font-weight: 600;
    margin: 24px 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e0e0e0;
}

.wiki-viewer h2 {
    font-size: 22px;
    font-weight: 600;
    margin: 20px 0 12px;
}

.wiki-viewer h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 16px 0 8px;
}

.wiki-viewer p {
    margin: 12px 0;
}

.wiki-viewer ul, .wiki-viewer ol {
    margin: 12px 0;
    padding-left: 24px;
}

.wiki-viewer li {
    margin: 6px 0;
}

.wiki-viewer a {
    color: var(--brand-primary, #1428A0);
    text-decoration: underline;
    cursor: pointer;
}

.wiki-viewer a:hover {
    color: #0f1f85;
    text-decoration: underline;
}

.wiki-viewer .wiki-link {
    color: var(--brand-primary, #1428A0);
    cursor: pointer;
    border-bottom: 1px dotted var(--brand-primary, #1428A0);
}

.wiki-viewer .wiki-link:hover {
    background: #e3f2fd;
}

.wiki-viewer .wiki-link-new {
    color: #d73a49;
    border-bottom: 1px dotted #d73a49;
}

.wiki-viewer code {
    background: #f6f8fa;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.wiki-viewer pre {
    background: #f6f8fa;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 16px 0;
}

.wiki-viewer pre code {
    background: none;
    padding: 0;
}

.wiki-viewer blockquote {
    border-left: 4px solid #ddd;
    padding-left: 16px;
    margin: 16px 0;
    color: #666;
}

.wiki-viewer table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
}

/* 히스토리 섹션 스타일 */
.wiki-viewer hr {
    margin: 24px 0 8px;
    border: none;
    border-top: 1px solid #e0e0e0;
}

.wiki-viewer hr + p strong {
    font-size: 13px;
    color: #666;
}

.wiki-viewer hr ~ p {
    font-size: 12px;
    line-height: 1.1;
    margin: 2px 0;
}

.wiki-viewer hr ~ p a {
    font-size: 12px;
}

/* 히스토리 삭제 버튼 */
.wiki-history-delete-btn {
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 11px;
    color: #dc3545;
    cursor: pointer;
    border: 1px solid #dc3545;
    border-radius: 3px;
    background: white;
    font-weight: 500;
    transition: all 0.2s;
}

.wiki-history-delete-btn:hover {
    background: #dc3545;
    color: white;
}

.wiki-viewer th, .wiki-viewer td {
    border: 1px solid #ddd;
    padding: 8px 12px;
    text-align: left;
}

.wiki-viewer th {
    background: #f8f9fa;
    font-weight: 600;
}

/* 위키 에디터 */
.wiki-editor {
    max-width: 900px;
    margin: 0 auto;
}

.wiki-editor textarea {
    width: 100%;
    min-height: 400px;
    padding: 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
}

.wiki-editor textarea:focus {
    outline: none;
    border-color: var(--brand-primary, #1428A0);
}

.wiki-editor-help {
    margin-top: 16px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 13px;
    color: #666;
}

.wiki-editor-help h4 {
    margin: 0 0 8px;
    font-size: 14px;
    color: #333;
}

.wiki-editor-help ul {
    margin: 0;
    padding-left: 20px;
}

/* 빈 상태 */
.wiki-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #999;
    text-align: center;
}

.wiki-empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.wiki-empty-text {
    font-size: 18px;
    margin-bottom: 8px;
}

.wiki-empty-subtext {
    font-size: 14px;
    color: #bbb;
}

/* 위키 모달 */
.wiki-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.wiki-modal {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.wiki-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e0e0e0;
}

.wiki-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.wiki-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.wiki-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.wiki-modal-body {
    padding: 20px;
}

.wiki-form-group {
    margin-bottom: 16px;
}

.wiki-form-group:last-child {
    margin-bottom: 0;
}

.wiki-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.wiki-form-group input,
.wiki-form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.wiki-form-group input:focus,
.wiki-form-group select:focus {
    outline: none;
    border-color: var(--brand-primary, #1428A0);
}

.wiki-modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
}

/* 검색 결과 */
.wiki-search-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.wiki-empty-suggestion {
    margin-top: 24px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.wiki-empty-suggestion p {
    margin: 0 0 16px;
    color: #666;
    font-size: 15px;
}

.wiki-search-results {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

.wiki-search-title {
    font-size: 22px;
    font-weight: 600;
    margin: 0 0 24px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e0e0e0;
    color: #333;
}

.wiki-search-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.wiki-search-item {
    padding: 20px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.wiki-search-item:hover {
    border-color: var(--brand-primary, #1428A0);
    background: #f8f9fa;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.wiki-search-item-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 12px;
    color: var(--brand-primary, #1428A0);
}

.wiki-search-item-snippet {
    margin: 0;
    color: #666;
    font-size: 14px;
    line-height: 1.6;
}

.wiki-search-item-snippet mark {
    background: #fff3cd;
    color: #333;
    padding: 2px 4px;
    border-radius: 2px;
    font-weight: 600;
}

/* 히스토리 삭제 버튼 */
.wiki-history-delete-btn {
    margin-left: 8px;
    padding: 2px 8px;
    font-size: 11px;
    color: #dc3545;
    cursor: pointer;
    border: 1px solid #dc3545;
    border-radius: 3px;
    background: white;
    font-weight: 500;
    transition: all 0.2s;
}

.wiki-history-delete-btn:hover {
    background: #dc3545;
    color: white;
}

/* 모바일 반응형 */
@media (max-width: 480px) {
    .wiki-container {
        flex-direction: column !important;
    }

    .wiki-sidebar {
        width: 100% !important;
        min-width: 100% !important;
        max-width: 100% !important;
        height: auto;
        max-height: 350px;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
        overflow-y: auto !important;
    }

    .wiki-body {
        padding: 16px;
    }

    .wiki-header {
        padding: 12px 16px;
    }

    .wiki-title {
        font-size: 20px;
    }

    .wiki-actions {
        flex-wrap: wrap;
    }

    .wiki-btn {
        padding: 6px 12px;
        font-size: 13px;
    }

    .wiki-search-results {
        padding: 0 16px;
    }

    .wiki-search-title {
        font-size: 18px;
    }

    .wiki-search-item {
        padding: 16px;
    }

    .wiki-search-item-title {
        font-size: 16px;
    }
}
