/**
 * DAE-A Electronics Back to Top Button Styles
 * 라이브 채팅과 조화된 Back to Top 버튼 스타일
 */

/* =================================
   Back to Top Button
   ================================= */
.back-to-top {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 15px rgba(44, 62, 80, 0.3);
    z-index: 9997; /* 라이브 채팅보다 낮은 z-index */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

.back-to-top:hover {
    background: linear-gradient(135deg, #34495e 0%, #2c3e50 100%);
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(44, 62, 80, 0.4);
}

.back-to-top:active {
    transform: translateY(0) scale(0.95);
    transition: all 0.1s ease;
}

.back-to-top i {
    font-size: 18px;
}

/* =================================
   라이브 채팅과의 조화
   ================================= */

/* 라이브 채팅이 있을 때 위치 조정 */
.livechat-widget ~ .back-to-top,
.back-to-top.with-livechat {
    bottom: 95px; /* 라이브 채팅 위로 이동 */
}

/* 라이브 채팅 창이 열려있을 때 */
.livechat-window:not(.hidden) ~ .back-to-top,
.back-to-top.with-livechat-open {
    bottom: 120px; /* 더 위로 이동 */
}

/* =================================
   애니메이션
   ================================= */

/* 나타나기 애니메이션 */
.back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* 펄스 효과 (선택적) */
.back-to-top.pulse {
    animation: backToTopPulse 2s infinite;
}

@keyframes backToTopPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* 바운스 효과 */
.back-to-top.bounce {
    animation: backToTopBounce 1s ease-in-out;
}

@keyframes backToTopBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* =================================
   반응형 디자인
   ================================= */

@media (max-width: 768px) {
    .back-to-top {
        width: 45px;
        height: 45px;
        font-size: 18px;
        bottom: 15px;
        right: 15px;
    }
    
    .back-to-top i {
        font-size: 16px;
    }
    
    /* 모바일에서 라이브 채팅과의 간격 */
    .livechat-widget ~ .back-to-top,
    .back-to-top.with-livechat {
        bottom: 90px;
    }
    
    .livechat-window:not(.hidden) ~ .back-to-top,
    .back-to-top.with-livechat-open {
        bottom: 110px;
    }
}

@media (max-width: 480px) {
    .back-to-top {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .back-to-top i {
        font-size: 14px;
    }
}

/* =================================
   접근성
   ================================= */

.back-to-top:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* 시각적 피드백 */
.back-to-top:focus-visible {
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
}

/* 고대비 모드 */
@media (prefers-contrast: high) {
    .back-to-top {
        background: #000;
        border: 2px solid #fff;
    }
    
    .back-to-top:hover {
        background: #333;
    }
}

/* 모션 감소 모드 */
@media (prefers-reduced-motion: reduce) {
    .back-to-top {
        transition: opacity 0.3s ease;
    }
    
    .back-to-top:hover {
        transform: none;
    }
    
    .back-to-top.pulse,
    .back-to-top.bounce {
        animation: none;
    }
}

/* =================================
   다크 모드 지원
   ================================= */

@media (prefers-color-scheme: dark) {
    .back-to-top {
        background: linear-gradient(135deg, #1a252f 0%, #2c3e50 100%);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    }
    
    .back-to-top:hover {
        background: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
    }
}

/* =================================
   특별한 상태들
   ================================= */

/* 스크롤 진행률 표시 (선택적) */
.back-to-top.with-progress {
    position: relative;
    overflow: hidden;
}

.back-to-top.with-progress::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--scroll-progress, 0%);
    background: linear-gradient(to bottom, 
        rgba(52, 152, 219, 0.3) 0%, 
        rgba(52, 152, 219, 0.1) 100%);
    transition: height 0.1s ease;
}

/* 로딩 상태 */
.back-to-top.loading {
    pointer-events: none;
}

.back-to-top.loading i {
    animation: spin 1s linear infinite;
}

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

/* =================================
   인쇄시 숨김
   ================================= */

@media print {
    .back-to-top {
        display: none !important;
    }
}