/* ========================================
   왼쪽 분석 사이드바 스타일
   ======================================== */

/* 사이드바 메인 컨테이너 - 오버레이 방식 */
#analysis-sidebar {
    position: fixed;
    left: 0;
    top: 60px; /* 네비게이션 높이만큼 */
    width: 380px; /* 360px → 380px로 증가 */
    height: calc(100vh - 60px);
    background: #ffffff;
    border-right: 2px solid #e9ecef;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.15); /* 그림자 강화로 오버레이 효과 */
    z-index: 9998; /* chart(9999)보다 약간 낮게, wrapper(1000)보다 높게 */
    display: flex;
    flex-direction: column;
    transform: translateX(-380px); /* 380px로 조정 */
    transition: transform 0.3s ease;
}

/* 차트 섹션이 아닐 때는 사이드바 완전히 숨김 */
body:not(.chart-active) #analysis-sidebar {
    display: none !important;
}

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

/* 🎯 오버레이 방식: 사이드바가 열려도 차트를 밀지 않음 */
.wrapper {
    transition: none; /* 애니메이션 제거 */
    margin-left: 0 !important;
    width: 100% !important;
}

/* 사이드바가 열렸을 때도 wrapper는 그대로 유지 */
body.sidebar-open .wrapper {
    margin-left: 0 !important;
    width: 100% !important;
}

#content {
    transition: none; /* 애니메이션 제거 */
}

/* 사이드바 헤더 */
.sidebar-left-header {
    padding: 1rem;
    background: #495057; /* 세련된 짙은 회색 (Gray 700) */
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 60px;
    display: flex;
    align-items: center;
}

.sidebar-left-header h5 {
    font-size: 1rem;
    font-weight: 600;
    color: white;
}

.sidebar-left-header .btn-close-sidebar {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: rgba(255, 255, 255, 0.8);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-left-header .btn-close-sidebar:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    transform: scale(1.05);
}

/* 탭 메뉴 */
.sidebar-left-tabs {
    background: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.sidebar-left-tabs .nav-tabs {
    border: none;
    margin: 0;
}

.sidebar-left-tabs .nav-link {
    color: #6c757d;
    border: none;
    padding: 0.75rem 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s;
    background: transparent;
}

.sidebar-left-tabs .nav-link:hover {
    color: #495057;
    background: rgba(102, 126, 234, 0.1);
}

.sidebar-left-tabs .nav-link.active {
    color: #667eea;
    background: white;
    border-bottom: 3px solid #667eea;
    font-weight: 600;
}

.sidebar-left-tabs .nav-link i {
    font-size: 1rem;
}

/* 사이드바 바디 */
.sidebar-left-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f8f9fa;
}

/* 탭 컨텐츠 패널 */
.tab-content-pane {
    display: none;
    animation: fadeIn 0.3s ease-in-out;
}

.tab-content-pane.active {
    display: block;
}

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

/* 빈 플레이스홀더 */
.empty-placeholder {
    background: white;
    border-radius: 8px;
    margin: 1rem;
}

.empty-placeholder i {
    opacity: 0.5;
}

/* 분석 리스트 */
.analysis-list {
    padding: 0.5rem;
}

.analysis-card-mini {
    background: white;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border: 1px solid #e9ecef;
    cursor: pointer;
    transition: all 0.2s;
}

.analysis-card-mini:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
    transform: translateX(2px);
}

.analysis-card-mini .badge {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

.analysis-card-mini h6 {
    font-size: 0.875rem;
    margin: 0.5rem 0 0.25rem 0;
    color: #212529;
    font-weight: 600;
}

.analysis-card-mini small {
    font-size: 0.75rem;
    color: #6c757d;
}

/* 패턴 리스트 */
.pattern-list {
    padding: 0.5rem;
}

/* ================================
   AI 지표 카드 공통 스타일
   ================================ */
.ai-indicator-card {
    font-size: 0.85rem;
}

.ai-indicator-card h6 {
    font-size: 0.85rem;
    font-weight: 600;
}

.ai-indicator-card .badge {
    font-size: 0.72rem;
    padding: 0.25rem 0.5rem;
}

.indicator-visual {
    font-size: 0.82rem;
}

.indicator-visual .fw-bold,
.indicator-visual .fw-semibold {
    font-size: 0.9rem;
}

.indicator-visual small {
    font-size: 0.72rem;
}

.indicator-chart svg text {
    font-size: 5px;
}

.indicator-chart {
    max-height: 60px;
    overflow: hidden;
}

/* 패턴 카드 (기존 모달과 동일한 스타일) */
.pattern-card-sidebar {
    animation: slideInLeft 0.3s ease-out;
}

.pattern-card-sidebar .card {
    transition: all 0.2s;
}

.pattern-card-sidebar .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
}

/* Bootstrap 클래스 오버라이드 */
.pattern-card-sidebar .border-warning {
    border-color: #ff9800 !important;
    border-width: 2px !important;
}

.pattern-card-sidebar .border-info {
    border-color: #2196f3 !important;
    border-width: 2px !important;
}

.pattern-card-sidebar .border-purple {
    border-color: #9c27b0 !important;
    border-width: 2px !important;
}

/* 패턴 아이템 (간소화 버전 - 데모용) */
.pattern-item {
    background: white;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-left: 4px solid #ffc107;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
}

.pattern-item:hover {
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.2);
    transform: translateX(2px);
}

.pattern-item i {
    font-size: 1.5rem;
    width: 32px;
    text-align: center;
}

.pattern-item strong {
    display: block;
    font-size: 0.875rem;
    color: #212529;
    margin-bottom: 0.25rem;
}

.pattern-item small {
    display: block;
    font-size: 0.75rem;
    color: #6c757d;
}

.pattern-item .confidence-bar {
    width: 100%;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
    margin-top: 0.25rem;
}

.pattern-item .confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, #ffc107, #ff9800);
    transition: width 0.5s ease;
}

/* 신호 리스트 */
.signal-list {
    padding: 0.5rem;
}

/* AI 지표 카드 (사이드바용 큰 카드 - 모달과 동일) */
.ai-indicator-card {
    background: white;
    border: 2px solid #94a3b8 !important; /* 기본 테두리 색상을 진하게 변경 */
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
    animation: slideInLeft 0.3s ease-out;
    margin-bottom: 1.25rem;
    position: relative; /* 아이콘 배치 등을 위해 */
}

/* 상태별 테두리 색상 */
.ai-indicator-card.border-success {
    border-color: #28a745 !important;
}

.ai-indicator-card.border-danger {
    border-color: #dc3545 !important;
}

.ai-indicator-card.border-warning {
    border-color: #ffc107 !important;
}

.ai-indicator-card.border-secondary {
    border-color: #6c757d !important;
}

/* 카드 헤더 영역 스타일링 (배경 제거, 패딩 조정) */
.ai-indicator-card > div:first-child {
    background-color: transparent; /* 배경 제거 */
    padding: 0 0 0.75rem 0; /* 하단 패딩만 유지 */
    border-bottom: 1px solid #f1f5f9; /* 연한 구분선 */
    margin: 0 0 0.75rem 0; /* 마진 조정 */
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* 헤더 내 텍스트 스타일 조정 */
.ai-indicator-card > div:first-child h6 {
    margin-bottom: 0 !important;
    font-weight: 800; /* 폰트 두께 증가 */
    color: #1e293b;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
}

/* 헤더 아이콘 스타일 */
.ai-indicator-card > div:first-child h6 i {
    margin-right: 0.5rem;
    font-size: 1rem;
}

/* SVG 차트가 카드를 벗어나지 않도록 */
.ai-indicator-card svg {
    max-width: 100%;
    height: auto;
    margin-top: 0.5rem;
}

.ai-indicator-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* AI 지표 카드 (사이드바용 mini 버전) - 더 이상 사용 안함 */
.ai-indicator-card-mini {
    animation: slideInLeft 0.3s ease-out;
}

.ai-indicator-card-mini .card {
    transition: all 0.2s;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.ai-indicator-card-mini .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.ai-indicator-card-mini .progress {
    background-color: #e9ecef;
    border-radius: 3px;
}

.ai-indicator-card-mini .progress-bar {
    transition: width 0.6s ease;
}

.signal-item {
    background: white;
    border-radius: 8px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-left: 4px solid #28a745;
    animation: slideInLeft 0.3s ease-out;
}

.signal-item.signal-sell {
    border-left-color: #dc3545;
}

.signal-item.signal-neutral {
    border-left-color: #6c757d;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.signal-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.signal-item strong {
    font-size: 0.875rem;
    color: #212529;
}

.signal-item .badge {
    font-size: 0.7rem;
}

.signal-item-body {
    font-size: 0.75rem;
    color: #6c757d;
}

.signal-time {
    font-size: 0.7rem;
    color: #adb5bd;
    margin-top: 0.25rem;
}

/* 사이드바 열기 버튼 */
.sidebar-left-toggle {
    position: fixed;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    background: #495057;
    color: white;
    border: none;
    border-radius: 0 8px 8px 0;
    padding: 1rem 0.5rem;
    width: 40px;
    z-index: 10000; /* wrapper(1000)와 chart(9999)보다 높게 - 항상 최상위 */
    cursor: pointer;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

/* 사이드바 열렸을 때 토글 버튼 이동 */
#analysis-sidebar.open ~ .sidebar-left-toggle {
    transform: translate(380px, -50%); /* Y축 -50% 유지하면서 X축 이동 */
}

/* 차트 섹션이 아닐 때는 토글 버튼도 완전히 숨김 */
body:not(.chart-active) .sidebar-left-toggle {
    display: none !important;
}

.sidebar-left-toggle:hover {
    width: 50px;
    background: #343a40; /* 더 짙은 회색 */
    color: white;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.2);
}

.sidebar-left-toggle i {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

/* 사이드바 열렸을 때 아이콘 회전 */
#analysis-sidebar.open ~ .sidebar-left-toggle i {
    transform: rotate(180deg);
}

.sidebar-left-toggle .toggle-label {
    font-size: 0.75rem; /* 글자 크기 약간 키움 */
    text-align: center;
    line-height: 1.1;
    font-weight: 600;
    margin-top: 2px;
}

/* 스크롤바 스타일 */
.sidebar-left-body::-webkit-scrollbar {
    width: 6px;
}

.sidebar-left-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar-left-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.sidebar-left-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 반응형 디자인 - 오버레이 방식 유지 */
@media (max-width: 1200px) {
    #analysis-sidebar {
        width: 320px;
        transform: translateX(-320px);
    }
    
    /* 오버레이 방식: margin 제거 */
    body.sidebar-open .wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

@media (max-width: 768px) {
    #analysis-sidebar {
        width: 100%;
        max-width: 320px;
        transform: translateX(-100%);
    }
    
    /* 오버레이 방식: margin 제거 */
    body.sidebar-open .wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    /* 모바일에서는 오버레이 방식 + 그림자 강화 */
    #analysis-sidebar.open {
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }
}

/* 로딩 상태 */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem;
}

.loading-spinner i {
    font-size: 2rem;
    color: #667eea;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* 🎯 사이드바 오버레이 배경 (선택사항) */
.sidebar-overlay {
    position: fixed;
    top: 60px;
    left: 0;
    width: 100%;
    height: calc(100vh - 60px);
    background: rgba(0, 0, 0, 0.3);
    z-index: 9997; /* 사이드바(9998)보다 낮게 */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    pointer-events: none;
}

body.sidebar-open .sidebar-overlay {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}


/* ========================================
   Dark Mode Styles
   ======================================== */

body.theme-dark #analysis-sidebar {
    background: #1f2937;
    border-right-color: #374151;
}

body.theme-dark .sidebar-left-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

body.theme-dark .sidebar-left-tabs {
    background: #111827;
    border-bottom-color: #374151;
}

body.theme-dark .sidebar-left-tabs .nav-link {
    color: #9ca3af;
}

body.theme-dark .sidebar-left-tabs .nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #e5e7eb;
}

body.theme-dark .sidebar-left-tabs .nav-link.active {
    background: #1f2937;
    color: #e5e7eb;
    border-bottom-color: #667eea;
}

body.theme-dark .sidebar-left-body {
    background: #111827;
}

/* Cards & Items */
body.theme-dark .ai-indicator-card,
body.theme-dark .analysis-card-mini,
body.theme-dark .pattern-item,
body.theme-dark .signal-item {
    background: #1f2937;
    border-color: #4b5563; /* 다크모드 외곽선 더 밝게 */
    color: #e5e7eb;
}

body.theme-dark .ai-indicator-card > div:first-child {
    background-color: #111827;
    border-bottom-color: #374151;
}

body.theme-dark .ai-indicator-card > div:first-child h6 {
    color: #e5e7eb;
}

body.theme-dark .ai-indicator-card h6,
body.theme-dark .analysis-card-mini h6,
body.theme-dark .pattern-item strong,
body.theme-dark .signal-item strong {
    color: #e5e7eb;
}

body.theme-dark .ai-indicator-card small,
body.theme-dark .analysis-card-mini small,
body.theme-dark .pattern-item small,
body.theme-dark .signal-item-body,
body.theme-dark .signal-time {
    color: #9ca3af;
}

/* Hover Effects */
body.theme-dark .ai-indicator-card:hover,
body.theme-dark .analysis-card-mini:hover,
body.theme-dark .pattern-item:hover {
    background: #2d3748;
    border-color: #667eea;
}

/* Specific Component Fixes */
body.theme-dark .alert-info {
    background-color: #0c4a6e;
    border-color: #075985;
    color: #e0f2fe;
}

body.theme-dark .card {
    background-color: #1f2937;
    border-color: #374151;
}

body.theme-dark .card-header {
    background-color: #1f2937;
    border-bottom-color: #374151;
    color: #e5e7eb;
}

body.theme-dark .list-group-item {
    background-color: #1f2937;
    border-color: #374151;
    color: #e5e7eb;
}

body.theme-dark .empty-placeholder {
    background: #1f2937;
    color: #9ca3af;
}

/* Scrollbars */
body.theme-dark .sidebar-left-body::-webkit-scrollbar-track {
    background: #111827;
}

body.theme-dark .sidebar-left-body::-webkit-scrollbar-thumb {
    background: #4b5563;
}

body.theme-dark .sidebar-left-body::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}
