/* ========================================
   개선된 사이드바 스타일 v1773562828
   - AI 분류 헤더: 텍스트 + ➕ + ▼ (한 줄)
   - 정렬: AI 분류 내부 (들여쓰기 + 작은 폰트)
   - 분류추가: 헤더 우측 아이콘만
   ======================================== */

/* 사이드바 구분선 */
.app-sidebar-divider {
    height: 1px;
    background: #E5E5E5;
    margin: 8px 0;
}

/* 옅은 구분선 (정렬 아래) */
.app-sidebar-divider-light {
    background: #F3F4F6;
    margin: 8px 20px;
}

/* AI 분류 헤더 (텍스트 + ➕ + ▼) */
.app-sidebar-ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 12px 20px;
    background: #F9FAFB;
    transition: background 0.2s ease;
}

.app-sidebar-ai-header:hover {
    background: #F3F4F6;
}

.app-sidebar-ai-header-text {
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    flex-shrink: 0;
}

.app-sidebar-ai-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-sidebar-ai-header-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.app-sidebar-ai-header-btn:hover {
    background: #E5E7EB;
}

.app-sidebar-ai-header-btn .icon {
    width: 16px;
    height: 16px;
    color: #6B7280;
    flex-shrink: 0;
}

.app-sidebar-ai-header-btn:hover .icon {
    color: #1E3A8A;
}

.app-sidebar-ai-header-btn .icon-arrow {
    transition: transform 0.3s ease;
}

.app-sidebar-ai-header-btn .icon-arrow.collapsed {
    transform: rotate(-90deg);
}

/* 분류추가 버튼 - 일반 사이드바 아이템 스타일 */
.app-sidebar-add-category {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 20px;
    background: transparent;
    border: none;
    color: #374151;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 12px;
}

.app-sidebar-add-category:hover {
    background: #F3F4F6;
    color: #1E3A8A;
}

.app-sidebar-add-category .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* 정렬 토글 버튼 (AI 분류 내부 - 들여쓰기) */
.app-sidebar-sort-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 10px 20px 10px 30px;  /* 왼쪽 들여쓰기 30px */
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 10px;
}

.app-sidebar-sort-toggle:hover {
    background: #F9FAFB;
}

.app-sidebar-sort-toggle .icon {
    width: 18px;  /* 약간 작게 */
    height: 18px;
    color: #9CA3AF;  /* 더 옅은 색상 */
    flex-shrink: 0;
}

.app-sidebar-sort-label {
    font-size: 13px;  /* 약간 작게 */
    font-weight: 400;
    color: #6B7280;  /* 약간 옅은 색상 */
    flex-shrink: 0;
}

.app-sidebar-sort-mode {
    margin-left: auto;
    font-size: 12px;  /* 약간 작게 */
    font-weight: 400;
    color: #9CA3AF;
    padding: 3px 8px;
    background: #F3F4F6;
    border-radius: 10px;
}

.app-sidebar-sort-toggle:hover .app-sidebar-sort-mode {
    background: #E5E7EB;
    color: #1E3A8A;
}

/* 접기/펼치기 토글 버튼 */
.app-sidebar-collapse-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 20px;
    background: #F9FAFB;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    gap: 8px;
    font-size: 14px;  /* 약간 크게 (정렬보다) */
    font-weight: 500;
    color: #374151;  /* 더 진한 색상 */
}

.app-sidebar-collapse-toggle:hover {
    background: #F3F4F6;
    color: #1E3A8A;
}

.app-sidebar-collapse-toggle .icon-arrow {
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
}

.app-sidebar-collapse-toggle .icon-arrow.collapsed {
    transform: rotate(-90deg);
}

/* AI 분류 목록 컨테이너 */
.ai-categories-container {
    max-height: 2000px;
    overflow: hidden;
    opacity: 1;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.ai-categories-container.collapsed {
    max-height: 0 !important;
    opacity: 0;
    padding: 0 !important;
}

/* 중요 항목 스타일 (별표) */
.app-sidebar-item[data-filter="STARRED"] .icon {
    color: #FCD34D;
}

.app-sidebar-item[data-filter="STARRED"]:hover .icon {
    color: #F59E0B;
}

.app-sidebar-item[data-filter="STARRED"].active {
    background: #FEF3C7;
}

.app-sidebar-item[data-filter="STARRED"].active .icon {
    color: #F59E0B;
}

/* 모바일 최적화 */
@media (max-width: 768px) {
    .app-sidebar-ai-header {
        padding: 10px 16px;
    }
    
    .app-sidebar-ai-header-text {
        font-size: 13px;
    }
    
    .app-sidebar-ai-header-btn {
        width: 26px;
        height: 26px;
    }
    
    .app-sidebar-ai-header-btn .icon {
        width: 14px;
        height: 14px;
    }
    
    .app-sidebar-add-category,
    .app-sidebar-collapse-toggle {
        padding: 10px 16px;
        font-size: 13px;
    }
    
    .app-sidebar-sort-toggle {
        padding: 9px 16px 9px 26px;  /* 모바일 들여쓰기 */
        font-size: 12px;
    }
    
    .app-sidebar-add-category .icon {
        width: 18px;
        height: 18px;
    }
    
    .app-sidebar-sort-toggle .icon {
        width: 16px;
        height: 16px;
    }
    
    .app-sidebar-collapse-toggle .icon-arrow {
        width: 14px;
        height: 14px;
    }
    
    .app-sidebar-sort-label {
        font-size: 12px;
    }
    
    .app-sidebar-sort-mode {
        font-size: 11px;
        padding: 2px 6px;
    }
    
    .app-sidebar-divider-light {
        margin: 6px 16px;
    }
}

/* ========================================
   폴더 관리 기능 스타일 (v1773562828)
   ======================================== */

/* 폴더 아이템에 메뉴 버튼 공간 확보 */
.app-sidebar-item {
    position: relative;
    display: flex;
    align-items: center;
}

/* [2026-06-18] 복제 폴더 배지 — 원본명 뒤에 작은 📋, 호버 시 네이티브 툴팁 */
.app-sidebar-clone-badge {
    display: inline-flex;
    align-items: center;
    margin-left: 5px;
    font-size: 11px;
    line-height: 1;
    opacity: 0.65;
    cursor: help;
    flex-shrink: 0;
    transition: opacity 0.15s ease, transform 0.15s ease;
}
.app-sidebar-item:hover .app-sidebar-clone-badge {
    opacity: 1;
    transform: scale(1.12);
}

/* 카운트 숫자 위치 조정 (삼점 버튼과 겹치지 않도록) */
.app-sidebar-item-count {
    margin-left: auto;
    margin-right: 32px; /* 삼점 버튼 공간 확보 (24px + 8px 여유) */
    font-size: 12px;
    color: #9CA3AF;
    transition: margin-right 0.2s ease;
}

/* 호버 시 카운트 숫자 더 왼쪽으로 이동 */
.app-sidebar-item:hover .app-sidebar-item-count {
    margin-right: 36px;
}

/* 삼점 메뉴 버튼 */
.app-sidebar-item-menu-btn {
    position: absolute;
    right: 8px;
    display: none; /* 기본 숨김, 호버 시 표시 */
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10; /* 카운트 숫자 위에 표시 */
}

.app-sidebar-item:hover .app-sidebar-item-menu-btn {
    display: flex;
    opacity: 1;
}

.app-sidebar-item-menu-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}

.app-sidebar-item-menu-btn .icon {
    width: 16px;
    height: 16px;
    color: #6B7280;
}

.app-sidebar-item-menu-btn:hover .icon {
    color: #374151;
}

/* 폴더 메뉴 드롭다운 */
.app-sidebar-folder-menu {
    position: absolute;
    right: 8px;
    top: 100%;
    margin-top: 4px;
    min-width: 160px;
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    z-index: 1000;
    overflow: hidden;
}

.app-sidebar-folder-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.folder-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s ease;
    white-space: nowrap;
}

.folder-menu-item:hover {
    background: #F3F4F6;
}

.folder-menu-item-danger {
    color: #DC2626;
}

.folder-menu-item-danger:hover {
    background: #FEE2E2;
}

/* 폴더 삭제 모달 */
.folder-delete-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.folder-delete-modal.show {
    opacity: 1;
}

.folder-delete-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
}

.folder-delete-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 480px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.folder-delete-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #E5E7EB;
}

.folder-delete-modal-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #DC2626;
}

.folder-delete-modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 24px;
    color: #6B7280;
    cursor: pointer;
    transition: all 0.2s ease;
}

.folder-delete-modal-close:hover {
    background: #F3F4F6;
    color: #374151;
}

.folder-delete-modal-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.folder-delete-modal-body p {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #374151;
    line-height: 1.6;
}

.folder-delete-note-info {
    padding: 8px 12px;
    background: #F3F4F6;
    border-radius: 6px;
    font-size: 13px;
    color: #6B7280;
    margin-bottom: 20px !important;
}

.folder-delete-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.folder-delete-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border: 2px solid #E5E7EB;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.folder-delete-option:hover {
    border-color: #667eea;
    background: #F9FAFB;
}

.folder-delete-option input[type="radio"] {
    margin-top: 2px;
    flex-shrink: 0;
    cursor: pointer;
}

.folder-delete-option input[type="radio"]:checked + .folder-delete-option-content {
    color: #1E3A8A;
}

.folder-delete-option:has(input[type="radio"]:checked) {
    border-color: #667eea;
    background: #EEF2FF;
}

.folder-delete-option-content {
    flex: 1;
}

.folder-delete-option-content strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

.folder-delete-option-content p {
    margin: 0;
    font-size: 13px;
    color: #6B7280;
    line-height: 1.4;
}

.danger-text {
    color: #DC2626 !important;
    font-weight: 500;
}

.folder-delete-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #E5E7EB;
}

.btn-cancel,
.btn-delete {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.btn-cancel {
    background: #F3F4F6;
    color: #374151;
}

.btn-cancel:hover {
    background: #E5E7EB;
}

.btn-delete {
    background: #DC2626;
    color: white;
}

.btn-delete:hover:not(:disabled) {
    background: #B91C1C;
}

.btn-delete:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* 고정된 폴더 아이콘 */
.app-sidebar-item[data-is-pinned="1"]::before {
    content: "📌";
    position: absolute;
    left: 4px;
    font-size: 10px;
    opacity: 0.7;
}

/* 모바일 대응 */
@media (max-width: 768px) {
    .app-sidebar-item-menu-btn {
        display: flex;
        opacity: 1;
    }
    
    .folder-delete-modal-content {
        width: 95%;
        max-height: 95vh;
    }
    
    .folder-delete-modal-header,
    .folder-delete-modal-body,
    .folder-delete-modal-footer {
        padding: 16px;
    }
    
    .folder-delete-option {
        padding: 12px;
    }
}
