/* 悬浮导航栏样式 */
/* 优化：统一使用现代CSS变量 */
:root {
    --primary-color: #007bff;
    --secondary-color: #1e90ff;
    --hover-color: #0066cc;
    --text-color: #333;
    --text-light: #666;
    --bg-color: #fff;
    --bg-light: #f5f5f5;
    --border-color: #e0e0e0;
    --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 3px 9px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 深色模式变量 */
@media (prefers-color-scheme: dark) {
    :root {
        --text-color: #e0e0e0;
        --text-light: #b0b0b0;
        --bg-color: #2c2c2c;
        --bg-light: #3a3a3a;
        --border-color: #444;
        --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 3px 9px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.3);
    }
}

/* 悬浮导航栏主容器 */
.floating-nav {
    position: fixed;
    right: 15px;
    bottom: 40%;
    transform: translateY(60%);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

/* 导航项基础样式 */
.floating-nav .nav-item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: 35px;
}

/* 确保提交工单按钮与其他按钮对齐 */
.floating-nav .nav-item:nth-child(2) {
    width: 28px;
    margin-right: 3px;
}

/* 导航链接基础样式 */
.floating-nav .nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    background: var(--bg-color);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    text-decoration: none;
    color: var(--text-color);
    position: relative;
    overflow: hidden;
}

/* 返回顶部按钮初始隐藏 */
.floating-nav .nav-item:last-child {
    opacity: 0;
    visibility: hidden;
    transform: translateX(20px);
    transition: var(--transition);
}

/* 返回顶部按钮显示状态 */
.floating-nav .nav-item:last-child.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* 导航链接 hover 效果 */
.floating-nav .nav-link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: var(--primary-color);
    color: #fff;
}

/* 图标样式 */
.floating-nav .nav-icon {
    width: 22px;
    height: 22px;
    margin-bottom: 2px;
    transition: var(--transition);
}

/* 图标 hover 效果 */
.floating-nav .nav-link:hover .nav-icon {
    filter: brightness(0) invert(1);
}

/* 文本标签样式 */
.floating-nav .nav-text {
    font-size: 10px;
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
}

/* 文本标签 hover 显示 */
.floating-nav .nav-link:hover .nav-text {
    opacity: 1;
    visibility: visible;
}

/* 提交工单按钮特殊样式 */
.floating-nav .nav-item:nth-child(2) .nav-link {
    background: var(--secondary-color);
    color: #fff;
    border-radius: 16px;
    width: 32px;
    height: 90px;
    box-shadow: 0 4px 12px rgba(30, 144, 255, 0.3);
}

/* 提交工单按钮文本样式 */
.floating-nav .nav-item:nth-child(2) .nav-text {
    opacity: 1;
    visibility: visible;
    position: static;
    transform: none;
    background: transparent;
    color: #fff;
    padding: 0;
    writing-mode: vertical-rl;
    text-orientation: upright;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 4px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 提交工单按钮 hover 效果 */
.floating-nav .nav-item:nth-child(2) .nav-link:hover {
    background: var(--hover-color);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(30, 144, 255, 0.4);
}

/* 提交工单按钮 active 效果 */
.floating-nav .nav-item:nth-child(2) .nav-link:active {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(30, 144, 255, 0.3);
}

/* 在线客服静态展示样式 */
.floating-nav .nav-item:nth-child(1) .nav-link {
    background: transparent;
    box-shadow: none;
    width: auto;
    height: auto;
    padding: 0;
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
    cursor: pointer;
}

/* 在线客服图标样式 */
.floating-nav .nav-item:nth-child(1) .nav-icon {
    width: 40px;
    height: 40px;
    margin-bottom: 0;
    border-radius: 50%;
}

/* 隐藏在线客服文本提示 */
.floating-nav .nav-item:nth-child(1) .nav-text {
    display: none;
}

/* 侧边栏样式 */
.nav-sidebar {
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    margin-right: 10px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    min-width: 280px;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 1001;
    pointer-events: auto;
}

/* 客服人员容器 */
.nav-sidebar .service-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

/* 侧边栏点击显示 */
.floating-nav .nav-item.active .nav-sidebar {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
    pointer-events: auto;
}

/* 侧边栏标题 */
.nav-sidebar h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    color: var(--text-color);
    font-weight: 600;
}

/* 侧边栏描述 */
.nav-sidebar p {
    margin: 0 0 15px 0;
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.4;
}

/* 侧边栏按钮 */
.nav-sidebar button {
    width: 100%;
    padding: 8px 0;
    background-color: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    outline: none;
}

/* 侧边栏按钮 hover 效果 */
.nav-sidebar button:hover {
    background-color: var(--hover-color);
}

/* 侧边栏按钮聚焦效果 */
.nav-sidebar button:focus {
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

/* 侧边栏箭头指示器 */
.nav-sidebar::after {
    content: '';
    position: absolute;
    right: -8px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 8px solid var(--bg-color);
}

/* 客服弹窗样式 */
.service-popup {
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    margin-right: 10px;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 1001;
}

/* 客服弹窗 hover 显示 */
.floating-nav .nav-link:hover .service-popup {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

/* 弹窗内容样式 */
.popup-content {
    background: var(--bg-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 16px;
    min-width: 200px;
    border: 1px solid var(--border-color);
}

/* 服务项样式 */
.service-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: none;
}

/* 服务容器中的服务项 */
.service-container .service-item {
    flex-direction: row;
    gap: 12px;
    align-items: center;
    text-align: left;
}

/* 客服热线容器 */
.nav-sidebar > .service-item {
    width: 100%;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    flex-direction: row;
    gap: 12px;
    align-items: center;
}

/* 服务图标样式 */
.service-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    display: flex;
    align-items: center;
    justify-content: center;
}

.service-icon svg {
    width: 24px;
    height: 24px;
}

/* 服务信息容器 */
.service-info {
    text-align: left;
    flex: 1;
}

/* 服务名称 */
.service-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 2px;
}

/* 服务描述 */
.service-desc {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 0;
}

/* 服务联系方式 */
.service-contact {
    font-size: 12px;
    color: var(--text-light);
}

/* 客服热线图标 */
.nav-sidebar > .service-item .service-icon {
    width: 28px;
    height: 28px;
}

/* 二维码容器 */
.qr-container {
    display: flex;
    justify-content: space-around;
    gap: 16px;
    padding: 8px;
}

/* 二维码项 */
.qr-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

/* 二维码图片 */
.qr-code {
    width: 100px;
    height: 100px;
    margin-bottom: 8px;
}

/* 二维码标签 */
.qr-label {
    font-size: 12px;
    color: var(--text-color);
    text-align: center;
}

/* 客服热线信息 */
.nav-sidebar > .service-item .service-info {
    text-align: left;
}

/* 客服热线标题 */
.nav-sidebar > .service-item .service-name {
    font-size: 14px;
    color: var(--text-color);
}

/* 客服热线电话 */
.nav-sidebar > .service-item .service-contact {
    font-size: 12px;
    color: var(--text-light);
}

/* 返回顶部按钮特殊样式 */
.nav-link.back-to-top {
    /* 基础样式与其他按钮一致 */
}

/* 动画定义 */
/* 循环放大缩小动画 */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* 火箭发射动画 */
@keyframes rocketLaunch {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: translateY(-10px) rotate(-5deg);
        opacity: 0.8;
    }
    100% {
        transform: translateY(-20px) rotate(-10deg);
        opacity: 0;
    }
}

/* 点击返回顶部时的动画 */
.floating-nav .back-to-top:active .nav-icon {
    animation: rocketLaunch 0.8s ease-out forwards;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .floating-nav {
        right: 8px;
        bottom: 30%;
        transform: translateY(50%);
        gap: 6px;
    }
    
    .floating-nav .nav-link {
        width: 30px;
        height: 30px;
    }
    
    .floating-nav .nav-item {
        width: 30px;
    }
    
    .floating-nav .nav-item:nth-child(1) .nav-icon {
        width: 34px;
        height: 34px;
    }
    
    .floating-nav .nav-item:nth-child(2) {
        width: 26px;
        margin-right: 2px;
    }
    
    .floating-nav .nav-item:nth-child(2) .nav-link {
        width: 26px;
        height: 70px;
    }
    
    .floating-nav .nav-item:nth-child(2) .nav-text {
        font-size: 11px;
        letter-spacing: 2px;
    }
    
    .popup-content {
        min-width: 160px;
        padding: 10px;
    }
    
    /* 侧边栏响应式优化 */
    .nav-sidebar {
        min-width: 240px;
        max-width: calc(100vw - 30px);
        padding: 8px;
        right: 100%;
        top: 50%;
        transform: translateY(-50%) translateX(8px);
        margin-right: 8px;
    }
    
    .nav-sidebar h4 {
        font-size: 13px;
        padding: 0 8px;
        margin-bottom: 8px;
    }
    
    #chatContainer {
        height: 140px;
        padding: 8px;
        margin: 0 8px 12px;
        gap: 8px;
    }
    
    #chatContainer p {
        font-size: 12px;
    }
    
    .nav-sidebar div[style*="display: flex; gap: 8px;"] {
        padding: 0 8px;
        gap: 6px;
    }
    
    #messageInput {
        padding: 6px 10px;
        font-size: 12px;
        border-radius: 16px;
    }
    
    #sendMessage {
        width: 32px;
        height: 32px;
    }
    
    #sendMessage svg {
        width: 16px;
        height: 16px;
    }
    
    .service-container {
        padding: 4px;
        gap: 8px;
    }
    
    .service-item {
        padding: 8px;
        margin-bottom: 6px;
        gap: 8px;
    }
    
    .service-container .service-item {
        gap: 10px;
    }
    
    .service-icon {
        width: 32px;
        height: 32px;
    }
    
    .service-icon svg {
        width: 18px;
        height: 18px;
    }
    
    .service-name {
        font-size: 13px;
    }
    
    .service-desc {
        font-size: 11px;
    }
    
    .footer-nav-item {
        font-size: 11px;
    }
    
    /* 客服热线服务项优化 */
    .nav-sidebar > .service-item {
        margin-top: 12px;
        padding-top: 12px;
        gap: 10px;
    }
    
    .nav-sidebar > .service-item .service-icon {
        width: 24px;
        height: 24px;
    }
    
    /* 侧边栏箭头指示器优化 */
    .nav-sidebar::after {
        right: -7px;
        border-top: 7px solid transparent;
        border-bottom: 7px solid transparent;
        border-left: 7px solid var(--bg-color);
    }
    
    /* 触摸友好优化 */
    .floating-nav .nav-link {
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    
    /* 文本标签优化 */
    .floating-nav .nav-text {
        right: 45px;
        padding: 3px 6px;
        font-size: 10px;
    }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    .floating-nav {
        right: 6px;
        gap: 5px;
    }
    
    .floating-nav .nav-link {
        width: 28px;
        height: 28px;
    }
    
    .floating-nav .nav-item {
        width: 28px;
    }
    
    .floating-nav .nav-item:nth-child(1) .nav-icon {
        width: 32px;
        height: 32px;
    }
    
    .floating-nav .nav-item:nth-child(2) .nav-link {
        width: 24px;
        height: 60px;
    }
    
    .floating-nav .nav-item:nth-child(2) .nav-text {
        font-size: 10px;
        letter-spacing: 1px;
    }
    
    .nav-sidebar {
        min-width: 220px;
        max-width: calc(100vw - 25px);
    }
    
    .service-name {
        font-size: 12px;
    }
    
    .service-desc {
        font-size: 10px;
    }
}

/* 深色模式下的特殊调整 */
@media (prefers-color-scheme: dark) {
    .floating-nav .nav-text {
        background: rgba(255, 255, 255, 0.1);
        color: var(--text-color);
    }
    
    .service-popup {
        background: transparent;
    }
}

/* 性能优化：硬件加速 */
.floating-nav, .nav-link, .nav-icon, .service-popup {
    will-change: transform;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* 可访问性优化 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 打印样式：隐藏悬浮导航 */
@media print {
    .floating-nav {
        display: none;
    }
}