/**
 * Syncle AI - 채팅 사이드바 스타일
 * 오른쪽 추천 사이드바 및 히스토리 영역
 */

/* ========== 사이드바 컨테이너 ========== */
.syncleai-page .chat-sidebar {
    width: var(--syncleai-sidebar-width);
    background: var(--syncleai-color-sidebar-bg);
    border-left: none;
    display: flex;
    flex-direction: column;
    position: fixed; /* 화면 오른쪽에 고정 */
    top: var(--syncleai-header-height); /* 헤더 아래부터 */
    right: 0;
    bottom: 0;
    height: calc(100vh - var(--syncleai-header-height));
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.03);
    z-index: var(--syncleai-z-sidebar); /* Design Tokens 사용 - 메시지보다 위, 입력창보다 아래 */
    overflow-y: auto; /* 내용이 많을 때 스크롤 */
}

/* 그라디언트 분리선 */
.syncleai-page .chat-sidebar::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(to right,
        transparent 0%,
        rgba(0, 0, 0, 0.02) 30%,
        rgba(0, 0, 0, 0.03) 60%,
        rgba(0, 0, 0, 0.04) 100%
    );
    pointer-events: none;
    z-index: var(--syncleai-z-base);
}

/* ========== 새 채팅 버튼 ========== */
.syncleai-page .new-chat-button {
    margin: var(--syncleai-spacing-lg);
    padding: var(--syncleai-spacing-md) var(--syncleai-spacing-xl);
    background: linear-gradient(135deg, #1a1a1a 0%, #000000 100%);
    color: var(--syncleai-color-white);
    border: none;
    border-radius: 6px;
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: var(--syncleai-font-size-base);
    font-weight: var(--syncleai-font-weight-semibold);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--syncleai-spacing-sm);
    transition: all var(--syncleai-transition-normal);
    letter-spacing: 0.5px;
    box-shadow: var(--syncleai-shadow-sm);
}

.syncleai-page .new-chat-button:hover {
    background: linear-gradient(135deg, #2a2a2a 0%, #0a0a0a 100%);
    transform: translateY(-1px);
    box-shadow: var(--syncleai-shadow-md);
}

.syncleai-page .new-chat-button:active {
    transform: translateY(0);
}

/* 키보드 포커스 (접근성) */
.syncleai-page .new-chat-button:focus-visible {
    outline: 2px solid var(--syncleai-color-focus);
    outline-offset: 2px;
}

.syncleai-page .new-chat-button:focus:not(:focus-visible) {
    outline: none;
}

/* ========== 히스토리 섹션 ========== */
.syncleai-page .history-section {
    padding: 0 var(--syncleai-spacing-lg) 2px var(--syncleai-spacing-lg);
    flex-shrink: 0;
    margin-bottom: 0;
    background: var(--syncleai-color-sidebar-bg);
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.syncleai-page .history-section .section-title:hover {
    color: #525252;
}

.syncleai-page .history-toggle-arrow {
    flex-shrink: 0;
}

.syncleai-page .history-list-wrapper {
    position: relative;
    overflow: hidden;
}

.syncleai-page .history-list-wrapper.expanded {
    max-height: 250px;
}

/* 섹션 타이틀 공통 스타일 */
.syncleai-page .section-title {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: var(--syncleai-font-size-sm);
    font-weight: var(--syncleai-font-weight-semibold);
    color: var(--syncleai-color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: var(--syncleai-spacing-md);
    padding-bottom: var(--syncleai-spacing-sm);
    border-bottom: 1px solid #f0f0f0;
}

.syncleai-page .history-section .section-title {
    margin-bottom: var(--syncleai-spacing-xs);
    padding-bottom: var(--syncleai-spacing-xs);
}

.syncleai-page .recommendations-section .section-title {
    margin-bottom: var(--syncleai-spacing-sm);
    padding-bottom: 6px;
}

/* ========== 히스토리 리스트 ========== */
.syncleai-page .history-list {
    display: flex;
    flex-direction: column;
    gap: var(--syncleai-spacing-xs);
    max-height: 200px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    scrollbar-gutter: stable;
}

/* 접근성: 키보드 포커스 */
.syncleai-page .history-list:focus:not(:focus-visible) {
    outline: none;
}

.syncleai-page .history-list:focus-visible {
    outline: 2px solid var(--syncleai-color-focus);
    outline-offset: 2px;
}

/* Remove accent colors */
.syncleai-page .history-list * {
    accent-color: transparent;
}

/* ========== 히스토리 아이템 ========== */
.syncleai-page .history-item {
    padding: 12px 14px;
    background: var(--syncleai-color-white);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--syncleai-transition-fast);
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: var(--syncleai-font-size-sm);
    color: var(--syncleai-color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    border: 1px solid var(--syncleai-color-border-light);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    margin-right: var(--syncleai-spacing-xs);
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    line-height: 1.4;
}

.syncleai-page .history-item::before {
    display: none;
}

.syncleai-page .history-item::selection {
    background: transparent;
}

.syncleai-page .history-item::-moz-selection {
    background: transparent;
}

.syncleai-page .history-item:hover {
    background: #f7f7f7;
    border-color: var(--syncleai-color-border-medium);
    transform: translateX(2px);
}

/* 키보드 포커스 */
.syncleai-page .history-item:focus:not(:focus-visible) {
    outline: none;
}

.syncleai-page .history-item:focus-visible {
    outline: 2px solid var(--syncleai-color-focus);
    outline-offset: 2px;
    border-color: var(--syncleai-color-focus);
}

.syncleai-page .history-item.active {
    background: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
    color: var(--syncleai-color-text-primary);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transform: translateX(2px);
}

.syncleai-page .history-item.active div {
    color: var(--syncleai-color-text-primary);
}

.syncleai-page .history-item.active:hover {
    background: linear-gradient(135deg, #fafafa 0%, #f0f0f0 100%);
}

/* 히스토리 제목 (첫 번째 div) */
.syncleai-page .history-item > div:first-child {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.syncleai-page .history-time {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: var(--syncleai-font-size-xs);
    color: #999;
    margin-top: 0;
    flex-shrink: 0;
    white-space: nowrap;
}

.syncleai-page .history-item.active .history-time {
    color: var(--syncleai-color-text-tertiary);
}

/* ========== 추천 섹션 ========== */
.syncleai-page .recommendations-section {
    flex: 1;
    padding: var(--syncleai-spacing-lg);
    padding-top: var(--syncleai-spacing-sm);
    overflow-y: auto;
    background: transparent;
    margin-top: 0;
}

.syncleai-page .property-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--syncleai-spacing-md);
}

/* ========== 속성 카드 ========== */
.syncleai-page .property-card {
    background: var(--syncleai-color-white);
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    padding: var(--syncleai-spacing-md);
    cursor: pointer;
    transition: border-color 0.15s ease;
    position: relative;
}

.syncleai-page .property-card:hover {
    border-color: #000000;
}

/* 키보드 포커스 */
.syncleai-page .property-card:focus-visible {
    outline: 2px solid var(--syncleai-color-focus);
    outline-offset: 2px;
}

.syncleai-page .property-card:focus:not(:focus-visible) {
    outline: none;
}

.syncleai-page .property-type {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: 10px;
    font-weight: var(--syncleai-font-weight-semibold);
    color: var(--syncleai-color-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.syncleai-page .property-title {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: var(--syncleai-font-size-base);
    font-weight: var(--syncleai-font-weight-semibold);
    color: var(--syncleai-color-text-primary);
    margin-bottom: var(--syncleai-spacing-sm);
    line-height: var(--syncleai-line-height-tight);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.syncleai-page .property-price {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: var(--syncleai-font-size-md);
    font-weight: var(--syncleai-font-weight-bold);
    color: var(--syncleai-color-text-primary);
    margin-bottom: var(--syncleai-spacing-xs);
}

.syncleai-page .property-location {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: var(--syncleai-font-size-sm);
    color: var(--syncleai-color-text-tertiary);
    display: flex;
    align-items: center;
    gap: var(--syncleai-spacing-xs);
}

.syncleai-page .property-features {
    display: flex;
    gap: var(--syncleai-spacing-sm);
    margin-top: var(--syncleai-spacing-sm);
    padding-top: var(--syncleai-spacing-sm);
    border-top: 1px solid var(--syncleai-color-border-light);
}

.syncleai-page .property-feature {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    font-size: var(--syncleai-font-size-xs);
    color: var(--syncleai-color-text-tertiary);
    display: flex;
    align-items: center;
    gap: 2px;
}

/* ========== 이미지 썸네일 ========== */
.syncleai-page .property-thumbnail {
    width: 100%;
    height: 90px;
    margin-bottom: var(--syncleai-spacing-sm);
    border-radius: 4px;
    overflow: hidden;
    background: var(--syncleai-color-border-light);
}

.syncleai-page .property-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

.syncleai-page .property-card:hover .property-thumbnail img {
    transform: scale(1.05);
}

/* ========== AI 배지 ========== */
.syncleai-page .ai-badge {
    position: absolute;
    top: var(--syncleai-spacing-sm);
    right: var(--syncleai-spacing-sm);
    background: var(--syncleai-color-black);
    color: var(--syncleai-color-white);
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: var(--syncleai-font-weight-semibold);
    letter-spacing: 0.5px;
    z-index: 1;
}

/* ========== 스크롤바 스타일링 ========== */
.syncleai-page .history-list::-webkit-scrollbar,
.syncleai-page .recommendations-section::-webkit-scrollbar {
    width: 4px;
}

.syncleai-page .history-list::-webkit-scrollbar-track,
.syncleai-page .recommendations-section::-webkit-scrollbar-track {
    background: var(--syncleai-scrollbar-track);
    border-radius: 2px;
}

.syncleai-page .history-list::-webkit-scrollbar-thumb,
.syncleai-page .recommendations-section::-webkit-scrollbar-thumb {
    background: var(--syncleai-scrollbar-thumb);
    border-radius: 2px;
}

.syncleai-page .history-list::-webkit-scrollbar-thumb:hover,
.syncleai-page .recommendations-section::-webkit-scrollbar-thumb:hover {
    background: var(--syncleai-scrollbar-thumb-hover);
}

/* ========== 로딩 카드 애니메이션 ========== */
.syncleai-page .loading-card {
    background: #f8f8f8;
    border: 1px solid var(--syncleai-color-border-dark);
    border-radius: var(--syncleai-radius-lg);
    padding: var(--syncleai-spacing-md);
    height: 120px;
    position: relative;
    overflow: hidden;
}

.syncleai-page .loading-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: -150%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: loading-shimmer 2s infinite;
}

@keyframes loading-shimmer {
    0% { left: -150%; }
    100% { left: 150%; }
}

/* ========== 반응형: 태블릿 (사이드바 숨김) ========== */
@media (max-width: 1024px) {
    .syncleai-page .chat-sidebar {
        display: none;
    }
}

/* ========== 반응형: 모바일 (사이드바 숨김) ========== */
@media (max-width: 767px) {
    .syncleai-page .chat-sidebar {
        display: none;
    }
}
