/* ============================================================
 * 招生问答悬浮组件 - 样式（完全独立，不影响宿主页面）
 *
 * 使用方式：在任意页面底部引入本CSS即可
 *   <link rel="stylesheet" href="enrollment/css/floating-widget.css">
 *
 ============================================================ */

/* ==================== 悬浮触发器（小机器人 + 提示文字） ==================== */
.enroll-float-trigger {
    position: fixed;
    right: 24px;
    bottom: 28px;
    z-index: 99998;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.3s ease;
    /* 隐藏状态（对话框打开时） */
}
.enroll-float-trigger.hidden { display: none !important; }

.enroll-float-trigger:hover {
    transform: scale(1.08) translateY(-3px);
}

/* 提示气泡文字 "点我咨询" */
.enroll-float-hint {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: 16px;
    margin-bottom: 6px;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(37,99,235,0.35);
    animation: hintBounce 2s ease-in-out infinite;
    pointer-events: none;
}
@keyframes hintBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* 小机器人头像 */
.enroll-float-avatar {
    width: 60px;
    height: 64px;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(37,99,235,0.35), 0 0 0 3px rgba(255,255,255,0.9);
    animation: robotFloat 3s ease-in-out infinite;
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    display: flex;
    align-items: center;
    justify-content: center;
}
@keyframes robotFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
.enroll-float-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}


/* ==================== 悬浮对话窗口 ==================== */

/* 窗口容器 */
.enroll-float-window {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 380px;
    height: 540px;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15), 0 0 0 1px rgba(0,0,0,0.05);
    z-index: 99997;
    display: none;           /* 默认隐藏 */
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;

    /* 入场动画 */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.25s ease, transform 0.25s ease, width 0.3s ease, height 0.3s ease;
}

/* 显示状态 */
.enroll-float-window.show {
    display: flex;
}

.enroll-float-window.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* 展开状态（大尺寸） */
.enroll-float-window.expanded {
    width: min(720px, calc(100vw - 40px));
    height: min(80vh, calc(100vh - 80px));
    right: 50%;
    bottom: 30px;
    transform: translateX(50%) scale(1);
}


/* ===== 窗口头部栏 ===== */
.enroll-float-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    flex-shrink: 0;
    user-select: none;
}

.enroll-float-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.enroll-float-header-avatar {
    width: 34px; height: 36px;
    border-radius: 10px; overflow: hidden;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
}
.enroll-float-header-avatar img {
    width: 100%; height: 100%; object-fit: contain;
}

.enroll-float-header-info {
    display: flex;
    flex-direction: column;
}
.enroll-float-header-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
}
.enroll-float-header-status {
    font-size: 11px;
    color: rgba(255,255,255,0.75);
    line-height: 1.2;
}
.enroll-float-status-dot {
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #4ade80;
    margin-right: 4px;
    vertical-align: middle;
    animation: statusPulse 2s infinite;
}
@keyframes statusPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.enroll-float-header-actions {
    display: flex;
    gap: 4px;
}

.enroll-float-btn-icon {
    width: 30px; height: 30px;
    border: none; background: rgba(255,255,255,0.15);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    transition: background 0.2s;
    line-height: 1;
}
.enroll-float-btn-icon:hover {
    background: rgba(255,255,255,0.3);
}


/* ===== 消息区域 ===== */
.enroll-float-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 18px;
    background: #f8fafc;
    min-height: 0;
}
.enroll-float-messages::-webkit-scrollbar { width: 4px; }
.enroll-float-messages::-webkit-scrollbar-track { background: transparent; }
.enroll-float-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

/* 欢迎消息 */
.ef-welcome {
    text-align: left;
    margin-bottom: 16px;
}
.ef-welcome-bubble {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 16px 18px;
    font-size: 13.5px;
    line-height: 1.7;
    color: #475569;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.ef-welcome-bubble p { margin: 4px 0; }
.ef-welcome-bubble p:first-child { margin-top: 0; }
.ef-welcome-bubble p:last-child { margin-bottom: 0; }
.ef-welcome-bubble strong { color: #2563eb; }
.ef-welcome-tags {
    list-style: none; padding: 0; margin: 10px 0 4px;
}
.ef-welcome-tags li { padding: 2px 0; font-size: 13px; }

/* 消息行 */
.ef-msg-row {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    animation: efSlideIn 0.22s ease-out;
}
.ef-msg-row.user { flex-direction: row-reverse; }
@keyframes efSlideIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.ef-avatar {
    width: 30px; height: 30px;
    border-radius: 10px;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px;
    overflow: hidden;
    background: linear-gradient(135deg, #7dd3fc, #38bdf8);
}
.ef-avatar img { width: 100%; height: 100%; object-fit: contain; }
.ef-msg-row.user .ef-avatar { background: linear-gradient(135deg, #fbbf24, #f59e0b); }

.ef-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.68;
    word-break: break-word;
}
.ef-msg-row:not(.user) .ef-bubble {
    background: #fff;
    color: #475569;
    border: 1px solid #eef2f7;
    border-radius: 0 14px 14px 14px;
}
.ef-msg-row.user .ef-bubble {
    background: #2563eb;
    color: #fff;
    border-radius: 14px 0 14px 14px;
}
.ef-bubble .ef-md-body { line-height: 1.68; }
.ef-bubble .ef-md-body p { margin: 4px 0; }
.ef-bubble .ef-md-body p:first-child { margin-top: 0; }
.ef-bubble .ef-md-body p:last-child { margin-bottom: 0; }

/* 打字动画 */
.ef-typing {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}
.ef-typing span {
    width: 6px; height: 6px;
    background: #3b82f6;
    border-radius: 50%;
    animation: efTypeBounce 1.3s infinite both;
}
.ef-typing span:nth-child(2) { animation-delay: 0.15s; }
.ef-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes efTypeBounce {
    0%, 80%, 100% { transform: scale(0.55); opacity: 0.35; }
    40% { transform: scale(1); opacity: 1; }
}

/* 表格样式 */
.ef-bubble table {
    width: 100%; border-collapse: collapse;
    margin: 10px 0; font-size: 12.5px;
    border-radius: 8px; overflow: hidden;
    display: block; overflow-x: auto;
}
.ef-bubble thead { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.ef-bubble thead th {
    padding: 8px 10px; color: #fff; font-weight: 600;
    font-size: 12px; text-align: left; white-space: nowrap;
}
.ef-bubble tbody tr:nth-child(even) { background: #f1f5f9; }
.ef-bubble tbody tr:hover { background: #e0e7ff; }
.ef-bubble td { padding: 7px 10px; color: #475569; border-bottom: 1px solid #eef2f7; word-break: break-word; }

/* 图片样式 */
.ef-bubble .ef-img {
    max-width: 100%; max-height: 260px;
    border-radius: 8px;
    margin: 6px 0; cursor: pointer;
    display: block;
}
.ef-bubble .ef-img:hover { transform: scale(1.02); }


/* ===== 输入区域 ===== */
.enroll-float-input-area {
    flex-shrink: 0;
    padding: 12px 14px 14px;
    border-top: 1px solid #eef2f7;
    background: #fff;
}

.enroll-float-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f1f5f9;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 8px 12px 8px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.enroll-float-input-wrap:focus-within {
    border-color: #3b82f6;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.enroll-float-textarea {
    flex: 1;
    border: none; outline: none; resize: none;
    font-size: 14px; line-height: 1.5;
    color: #1e293b; background: transparent;
    font-family: inherit;
    min-height: 22px; max-height: 90px;
}
.enroll-float-textarea::placeholder { color: #94a3b8; }

.enroll-float-send-btn {
    width: 34px; height: 34px;
    border: none; background: #2563eb;
    color: #fff; border-radius: 10px;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}
.enroll-float-send-btn:not(:disabled):hover {
    background: #1d4ed8;
    transform: scale(1.06);
}
.enroll-float-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }


/* ===== 错误消息 ===== */
.ef-error { background: #fef2f2 !important; color: #dc2626 !important; border-color: #fecaca !important; }


/* ===== 图片预览遮罩 ===== */
.ef-img-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.85); z-index: 99999;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; animation: efOverlayIn 0.2s ease;
}
.ef-img-overlay img {
    max-width: 92vw; max-height: 88vh;
    border-radius: 12px; object-fit: contain;
}
@keyframes efOverlayIn { from { opacity: 0; } to { opacity: 1; } }


/* ==================== 响应式 ==================== */
@media screen and (max-width: 480px) {
    .enroll-float-window {
        width: calc(100vw - 16px);
        right: 8px; bottom: 8px;
        height: calc(100vh - 120px);
        border-radius: 14px;
    }
    .enroll-float-window.expanded {
        width: 100vw;
        height: 100vh;
        right: 0; bottom: 0;
        border-radius: 0;
        transform: translateX(0) scale(1) !important;
    }
    .enroll-float-trigger { right: 12px; bottom: 12px; }
    .enroll-float-avatar { width: 52px; height: 56px; }
}
