/**
 * 청약 매물 비교 기능 스타일 - 사이드바 버전
 * 버전: 2.1.0 (접기/펼치기 기능 추가)
 */

/* ========================================
   공통 접기/펼치기 위젯 스타일
======================================== */
.sidebar-widget-collapsible {
    transition: all 0.3s ease;
}

.sidebar-widget-header {
    cursor: pointer;
    user-select: none;
}

.sidebar-widget-header:hover {
    opacity: 0.9;
}

.sidebar-widget-toggle {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    transition: transform 0.3s ease;
}

.sidebar-widget-collapsible.expanded .sidebar-widget-toggle {
    transform: rotate(180deg);
}

.sidebar-widget-body {
    overflow: hidden;
    transition: all 0.3s ease;
}

/* ========================================
   사이드바 비교 위젯 (다크 테마)
======================================== */
.sidebar-compare-widget {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.sidebar-compare-widget.has-items {
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

.sidebar-compare-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.sidebar-compare-widget.expanded .sidebar-compare-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-compare-title {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-compare-count {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
}

/* 비교 아이템 목록 */
.sidebar-compare-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    max-height: 240px;
    overflow-y: auto;
}

.sidebar-compare-items::-webkit-scrollbar {
    width: 4px;
}

.sidebar-compare-items::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
}

.sidebar-compare-empty {
    text-align: center;
    color: #94a3b8;
    font-size: 11px;
    padding: 20px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px dashed rgba(255, 255, 255, 0.2);
}

/* 빈 슬롯 */
.sidebar-compare-slot {
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    color: #64748b;
    font-size: 11px;
}

/* 개별 비교 아이템 */
.sidebar-compare-item {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    transition: all 0.2s;
    position: relative;
}

.sidebar-compare-item:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(2px);
}

.sidebar-compare-item-content {
    flex: 1;
    min-width: 0;
}

.sidebar-compare-item-name {
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.sidebar-compare-item-info {
    font-size: 10px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-compare-item-status {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

.sidebar-compare-item-status.ongoing {
    background: #10b981;
    color: white;
}

.sidebar-compare-item-status.upcoming {
    background: #f59e0b;
    color: white;
}

.sidebar-compare-item-remove {
    background: rgba(239, 68, 68, 0.8);
    border: none;
    color: #fff;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-compare-item-remove:hover {
    background: #ef4444;
    transform: scale(1.1);
}

/* 액션 버튼들 */
.sidebar-compare-actions {
    display: flex;
    gap: 8px;
}

.sidebar-compare-btn-start {
    flex: 1;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.sidebar-compare-btn-start:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.sidebar-compare-btn-start:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.sidebar-compare-btn-clear {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    width: 38px;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.sidebar-compare-btn-clear:hover {
    background: rgba(239, 68, 68, 0.3);
    border-color: rgba(239, 68, 68, 0.5);
}

/* ========================================
   비교 모달
======================================== */
.compare-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 200000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.compare-modal-overlay.show {
    display: flex;
    animation: fadeIn 0.3s ease;
}

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

.compare-modal {
    background: #fff;
    border-radius: 20px;
    width: 900px;
    max-width: 95vw;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.4);
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    position: relative;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.compare-modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.compare-modal-title {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.compare-modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.compare-modal-close:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.05);
}

.compare-modal-body {
    padding: 0;
    overflow-x: auto;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

/* 비교 테이블 */
.compare-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
}

.compare-table th,
.compare-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13px;
}

.compare-table th {
    background: #f8fafc;
    color: #475569;
    font-weight: 600;
    position: sticky;
    left: 0;
    z-index: 1;
    width: 120px;
    min-width: 120px;
}

.compare-table td {
    color: #1e293b;
    min-width: 180px;
}

.compare-table tr:hover td {
    background: #f1f5f9;
}

/* 매물명 헤더 */
.compare-header-cell {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%) !important;
    text-align: center !important;
    vertical-align: top !important;
}

.compare-property-name {
    font-size: 14px;
    font-weight: 700;
    color: #1e3a5f;
    margin-bottom: 6px;
}

.compare-property-type {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

/* 상태 배지 */
.compare-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.compare-status.ongoing {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
}

.compare-status.upcoming {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
}

.compare-status.ended {
    background: #f3f4f6;
    color: #6b7280;
}

/* 모달 푸터 */
.compare-modal-footer {
    padding: 16px 24px;
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.compare-tip {
    color: #64748b;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.compare-footer-actions {
    display: flex;
    gap: 10px;
}

.btn-compare-export {
    background: #fff;
    border: 1px solid #e5e7eb;
    color: #475569;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-compare-export:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

/* 비교 버튼 (인포윈도우용) */
.btn-compare-add {
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-compare-add:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-compare-add.added {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.btn-compare-add.added::before {
    content: '✓ ';
}

/* ========================================
   v2.0 비교 분석 스타일
======================================== */

/* 스피너 */
.cmp-spinner {
    width: 36px;
    height: 36px;
    border: 4px solid #e0f2fe;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: cmpSpin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes cmpSpin { to { transform: rotate(360deg); } }

/* 섹션 */
.cmp-section {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    padding: 20px;
    margin-bottom: 16px;
}

.cmp-section-title {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* 종합 점수 헤더 */
.cmp-score-header {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 16px;
    color: #fff;
}
.cmp-score-header .cmp-section-title {
    color: #fff;
}
.cmp-score-cards {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.cmp-score-card {
    flex: 1;
    min-width: 140px;
    background: rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    position: relative;
    border: 2px solid transparent;
    transition: all 0.3s;
}
.cmp-score-card.winner {
    background: rgba(245,158,11,0.15);
    border-color: #f59e0b;
    box-shadow: 0 4px 20px rgba(245,158,11,0.3);
}
.cmp-winner-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
}
.cmp-rank-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #475569;
    color: #fff;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
}
.cmp-score-name {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,0.9);
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cmp-score-value {
    font-size: 32px;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    margin-bottom: 8px;
}
.cmp-score-unit {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255,255,255,0.5);
    margin-left: 2px;
}
.cmp-score-bar-bg {
    height: 6px;
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 10px;
}
.cmp-score-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.8s ease;
}
.cmp-wdl {
    display: flex;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
}
.cmp-w { color: #10b981; }
.cmp-d { color: #94a3b8; }
.cmp-l { color: #ef4444; }

/* 섹션별 점수 바 */
.cmp-section-scores {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
    background: #f8fafc;
    border-radius: 8px;
    padding: 10px 12px;
}
.cmp-sec-score-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.cmp-sec-score-name {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    min-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cmp-sec-score-bar-bg {
    flex: 1;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}
.cmp-sec-score-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s ease;
}
.cmp-sec-score-val {
    font-size: 12px;
    font-weight: 700;
    min-width: 50px;
    text-align: right;
}

/* 우위 배지 */
.cmp-best-badge {
    display: inline-block;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    vertical-align: middle;
}

/* AI 분석 콘텐츠 */
.cmp-ai-content {
    font-size: 13px;
    line-height: 1.8;
    color: #1e293b;
}
.cmp-ai-content br {
    margin-bottom: 4px;
}

/* 비교 모달 body 패딩 (v2.0 오버라이드) */
.compare-modal-body {
    padding: 16px !important;
    overflow-x: auto;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    background: #f1f5f9;
}

/* ========================================
   헤더 버튼 그룹
======================================== */
.compare-modal-header-btns {
    display: flex;
    align-items: center;
    gap: 6px;
}
.cmp-hdr-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.cmp-hdr-btn:hover {
    background: rgba(255,255,255,0.35);
    transform: scale(1.05);
}

/* ========================================
   전체화면 모드
======================================== */
.compare-modal.cmp-fullscreen {
    max-width: 100vw !important;
    max-height: 100vh !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    margin: 0 !important;
}
.compare-modal.cmp-fullscreen .compare-modal-body {
    max-height: calc(100vh - 140px) !important;
}

/* ========================================
   드래그 이동 모드
======================================== */
.compare-modal.cmp-dragged {
    position: fixed !important;
    transform: none !important;
    transition: none !important;
}

/* ========================================
   숨김(최소화) 모드
======================================== */
.compare-modal-overlay.cmp-hidden {
    display: none !important;
}

/* 미니바 (숨김 상태에서 표시) */
.compare-minibar {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 200001;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-radius: 12px;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 20px rgba(102,126,234,0.4);
    cursor: pointer;
    animation: minibarSlideIn 0.3s ease;
    user-select: none;
}
@keyframes minibarSlideIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.compare-minibar-title {
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}
.compare-minibar-btns {
    display: flex;
    gap: 4px;
}
.compare-minibar-btns button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.compare-minibar-btns button:hover {
    background: rgba(255,255,255,0.4);
}

/* ========================================
   드래그 핸들 시각 피드백
======================================== */
#compare-modal-drag-handle {
    user-select: none;
}
#compare-modal-drag-handle:active {
    cursor: grabbing !important;
}

/* 반응형 */
@media (max-width: 768px) {
    .compare-modal {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        margin-top: auto;
    }
    
    .compare-table th,
    .compare-table td {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .cmp-score-cards {
        flex-direction: column;
    }
    .cmp-score-card {
        min-width: unset;
    }
    .cmp-score-value {
        font-size: 24px;
    }
    .cmp-section {
        padding: 14px;
    }
}
