/**
 * common-float-chat.css
 * 右下角浮动咨询组件样式
 */

/* ===== 容器（fixed 在右下角） ===== */
.lenet-float-chat-host {
    position: fixed;
    right: 24px;
    bottom: 80px;
    z-index: 999;
    font-family: "PingFang SC", "Microsoft YaHei", -apple-system, sans-serif;
}

.float-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

/* ===== 按钮通用 ===== */
.float-btn {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #e0e6ed;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    color: #1677ff;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.25s;
    padding: 0;
}

.float-btn:hover {
    background: #1677ff;
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(22, 119, 255, 0.3);
}

.float-btn .float-tip {
    position: absolute;
    right: 100%;
    margin-right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: #252525;
    color: #ffffff;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    pointer-events: none;
}

.float-btn .float-tip::after {
    content: "";
    position: absolute;
    left: 100%;
    top: 50%;
    margin-top: -4px;
    border: 4px solid transparent;
    border-left-color: #252525;
}

.float-btn:hover .float-tip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(-4px);
}

/* ===== 主按钮（蓝色） ===== */
.float-btn-primary {
    background: linear-gradient(135deg, #1677ff 0%, #4096ff 100%);
    color: #ffffff;
    border: none;
    box-shadow: 0 6px 20px rgba(22, 119, 255, 0.4);
    width: 60px;
    height: 60px;
}

.float-btn-primary:hover {
    background: linear-gradient(135deg, #0f5fd6 0%, #1677ff 100%);
    color: #ffffff;
}

.float-btn-primary.is-open {
    background: #ffffff;
    color: #1677ff;
    border: 1px solid #e0e6ed;
}

.float-btn-primary .float-text {
    font-size: 12px;
    margin-top: 2px;
}

/* ===== 按钮图标（CSS 绘制的简单图标） ===== */
.float-btn [class^="ico-"] {
    display: inline-block;
    width: 24px;
    height: 24px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    position: relative;
}

.ico-chat::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 22px;
    height: 18px;
    border: 2px solid currentColor;
    border-radius: 11px 11px 11px 4px;
}
.ico-chat::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 9px;
    width: 2px;
    height: 2px;
    background: currentColor;
    border-radius: 50%;
    box-shadow: 5px 0 0 currentColor, 10px 0 0 currentColor;
}

.ico-message::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 22px;
    height: 18px;
    border: 2px solid currentColor;
    border-radius: 3px;
}
.ico-message::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 16px;
    transform: translate(-50%, 0) rotate(45deg);
    width: 6px;
    height: 6px;
    background: currentColor;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
}

.ico-phone::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%) rotate(135deg);
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-radius: 3px 12px 3px 3px;
    border-bottom-color: transparent;
    border-left-color: transparent;
}

.ico-wechat::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 22px;
    height: 18px;
    border: 2px solid currentColor;
    border-radius: 11px 11px 11px 4px;
}
.ico-wechat::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 7px;
    width: 2px;
    height: 2px;
    background: currentColor;
    border-radius: 50%;
    box-shadow: 6px 0 0 currentColor;
}

.ico-top::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border-top: 2px solid currentColor;
    border-left: 2px solid currentColor;
    transform: translate(-50%, -30%) rotate(45deg);
}

/* 百度客服图标（双圆点+横线，仿客服） */
.ico-baidu::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid currentColor;
    border-radius: 50%;
}
.ico-baidu::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 12px;
    transform: translate(-50%, 0);
    width: 4px;
    height: 4px;
    background: currentColor;
    border-radius: 50%;
    box-shadow: -7px 0 0 currentColor, 7px 0 0 currentColor;
}

/* ===== 操作组（默认隐藏，展开后显示） ===== */
.float-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.float-actions[hidden] {
    display: none;
}

/* ===== 弹窗（留言 / 二维码） ===== */
.float-modal,
.float-qr {
    position: fixed;
    inset: 0;
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
}

.float-modal[hidden],
.float-qr[hidden] {
    display: none;
}

.float-modal-mask {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.float-modal-panel,
.float-qr-panel {
    position: relative;
    z-index: 1;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
    width: 420px;
    max-width: 90vw;
    animation: floatModalIn 0.2s ease-out;
}

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

.float-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #f0f0f0;
}
.float-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #252525;
    font-weight: 600;
}
.float-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: #f5f5f5;
    color: #999;
    font-size: 20px;
    cursor: pointer;
    line-height: 1;
}
.float-modal-close:hover {
    background: #ff4d4f;
    color: #ffffff;
}

/* ===== 留言表单 ===== */
.float-form {
    padding: 20px 24px 24px;
}

.float-form-row {
    margin-bottom: 14px;
}
.float-form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.float-form input,
.float-form textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e0e6ed;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
    transition: border-color 0.2s;
}
.float-form input:focus,
.float-form textarea:focus {
    outline: none;
    border-color: #1677ff;
}

.float-form-actions {
    margin-top: 16px;
}

.float-btn-submit {
    width: 100%;
    height: 44px;
    background: #1677ff;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}
.float-btn-submit:hover {
    background: #0f5fd6;
}
.float-btn-submit:disabled {
    background: #91b9ff;
    cursor: not-allowed;
}

.float-form-alt {
    margin: 12px 0 0;
    text-align: center;
    color: #999;
    font-size: 12px;
}
.float-form-alt a {
    color: #1677ff;
    text-decoration: none;
    margin-left: 4px;
}
.float-form-alt a:hover {
    text-decoration: underline;
}

/* ===== 二维码面板 ===== */
.float-qr-panel {
    padding: 32px 24px 24px;
    text-align: center;
}
.float-qr-panel img {
    width: 160px;
    height: 160px;
    margin: 0 auto 16px;
    display: block;
}
.float-qr-panel p {
    margin: 0;
    color: #6a7787;
    font-size: 14px;
    line-height: 1.6;
}
.float-qr-panel .float-modal-close {
    position: absolute;
    right: 12px;
    top: 12px;
}

/* ===== 嵌入式聊天窗口（绝对定位悬浮在按钮上方） ===== */
.float-chat-window {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    width: 380px;
    height: 550px;
    max-height: calc(100vh - 200px);
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.16);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    animation: floatChatIn 0.2s ease-out;
}
.float-chat-window[hidden] {
    display: none;
}

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

.float-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: rgb(0, 156, 255);
    color: #ffffff;
    flex-shrink: 0;
    user-select: none;
    position: relative;
    z-index: 2;
}

.float-chat-title {
    font-size: 13px;
    font-weight: 500;
}

.float-chat-tools {
    display: flex;
    align-items: center;
    gap: 4px;
}

.float-chat-tool {
    width: 30px;
    height: 24px;
    border: none;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    border-radius: 4px;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.2s;
}

.float-chat-tool:hover {
    background: rgba(255, 255, 255, 0.2);
}

.float-chat-iframe {
    flex: 1;
    width: 630px;
    min-width: 630px;
    height: 500px;
    margin-top: -110px;
    border: none;
    display: block;
    background: #ffffff;
    flex-shrink: 0;
}

/* ===== 最小化后的悬浮标签 ===== */
.float-chat-minimized {
    position: absolute;
    right: 0;
    bottom: calc(100% + 12px);
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgb(0, 156, 255);
    color: #ffffff;
    border-radius: 24px;
    cursor: pointer;
    font-size: 13px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
    transition: all 0.25s;
    z-index: 1000;
    user-select: none;
    white-space: nowrap;
}

.float-chat-minimized[hidden] {
    display: none;
}

.float-chat-minimized:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 156, 255, 0.4);
}

.float-chat-minimized-icon {
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
}

.float-chat-minimized-icon::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 3px;
    height: 3px;
    background: currentColor;
    border-radius: 50%;
}

/* ===== 响应式 ===== */
@media (max-width: 767px) {
    .lenet-float-chat-host {
        right: 12px;
        bottom: max(60px, env(safe-area-inset-bottom) + 16px);
    }
    .float-btn { width: 48px; height: 48px; }
    .float-btn-primary { width: 52px; height: 52px; }
    .float-chat-window {
        width: calc(100vw - 24px);
        max-width: 320px;
        max-height: calc(100vh - 160px);
    }
    .float-chat-iframe {
        width: calc((100vw - 24px) * 1.67);
        min-width: calc((100vw - 24px) * 1.67);
        height: 700px;
        margin-top: -100px;
    }
    .float-chat-minimized {
        font-size: 12px;
        padding: 6px 12px;
    }
}
