/* ========== AI 客服浮窗样式 ========== */

#dscs-widget {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1e293b;
    z-index: 999999;
}

/* ===== 浮窗模式（右下角气泡） ===== */

/* 位置 */
#dscs-widget.dscs-float-mode.dscs-right {
    position: fixed;
    bottom: 24px;
    right: 24px;
}

#dscs-widget.dscs-float-mode.dscs-left {
    position: fixed;
    bottom: 24px;
    left: 24px;
}

/* 自定义头像按钮 */
.dscs-toggle-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    object-fit: cover;
}

.dscs-avatar img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* 消息中的头像 */
.dscs-msg-avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 6px;
    flex-shrink: 0;
    align-self: flex-end;
}

.dscs-msg-bot {
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

/* ===== 侧边悬浮模式 ===== */
#dscs-widget.dscs-sidebar-mode {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

#dscs-widget.dscs-sidebar-mode.dscs-right {
    right: 24px;
}

#dscs-widget.dscs-sidebar-mode.dscs-left {
    left: 24px;
}

.dscs-sidebar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.dscs-sidebar-panel {
    width: 720px;
    height: 850px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: height 0.3s ease, width 0.3s ease, box-shadow 0.3s ease;
    animation: dscs-slide-up 0.3s ease-out;
    position: relative;
    bottom: auto;
}

/* 头像下方品牌文字（绿色） */
.dscs-toggle-label {
    display: block;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #16a34a;
    white-space: nowrap;
    margin-top: 2px;
}

/* 切换按钮 */
.dscs-toggle-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--dscs-primary, #4F46E5);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.dscs-toggle-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
}

.dscs-toggle-btn:active {
    transform: scale(0.95);
}

.dscs-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
    animation: dscs-pulse 2s infinite;
}

@keyframes dscs-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* 聊天面板（浮窗模式） */
.dscs-float-mode .dscs-panel {
    position: fixed;
    bottom: 96px;
    width: 720px;
    max-width: calc(100vw - 48px);
    height: 980px;
    max-height: calc(100vh - 100px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: dscs-slide-up 0.3s ease-out;
}

#dscs-widget.dscs-float-mode.dscs-right .dscs-panel {
    right: 0;
}

#dscs-widget.dscs-float-mode.dscs-left .dscs-panel {
    left: 0;
}

@keyframes dscs-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 头部 */
.dscs-header {
    background: var(--dscs-primary, #4F46E5);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.dscs-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dscs-avatar {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dscs-title {
    font-weight: 600;
    font-size: 15px;
}

.dscs-close-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.dscs-close-btn:hover {
    color: #fff;
}

/* 消息区域 */
.dscs-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dscs-messages::-webkit-scrollbar {
    width: 5px;
}

.dscs-messages::-webkit-scrollbar-track {
    background: transparent;
}

.dscs-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

/* 消息气泡 */
.dscs-msg {
    display: flex;
    max-width: 85%;
    animation: dscs-fade-in 0.3s ease-out;
}

@keyframes dscs-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.dscs-msg-bot {
    align-self: flex-start;
}

.dscs-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.dscs-msg-content {
    padding: 10px 14px;
    border-radius: 12px;
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 14px;
}

.dscs-msg-bot .dscs-msg-content {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    color: #1e293b;
}

.dscs-msg-user .dscs-msg-content {
    background: var(--dscs-primary, #4F46E5);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* 打字指示器 */
.dscs-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.dscs-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #94a3b8;
    animation: dscs-typing-dot 1.4s infinite;
}

.dscs-typing span:nth-child(2) {
    animation-delay: 0.2s;
}

.dscs-typing span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dscs-typing-dot {
    0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
    30% { opacity: 1; transform: scale(1); }
}

/* 输入区域 */
.dscs-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.dscs-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.5;
    transition: border-color 0.2s;
}

.dscs-input:focus {
    border-color: var(--dscs-primary, #4F46E5);
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}

.dscs-input::placeholder {
    color: #94a3b8;
}

.dscs-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: var(--dscs-primary, #4F46E5);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.dscs-send-btn:hover {
    opacity: 0.9;
}

.dscs-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 底部 */
.dscs-footer {
    padding: 6px 16px;
    text-align: center;
    font-size: 11px;
    color: #94a3b8;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
    flex-shrink: 0;
}

/* 错误消息 */
.dscs-msg-error .dscs-msg-content {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

/* Markdown 基础样式 */
.dscs-msg-content p {
    margin: 0 0 8px;
}

.dscs-msg-content p:last-child {
    margin-bottom: 0;
}

.dscs-msg-content ul, .dscs-msg-content ol {
    margin: 4px 0;
    padding-left: 20px;
}

.dscs-msg-content code {
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 13px;
}

.dscs-msg-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}

.dscs-msg-content pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.dscs-msg-content a {
    color: var(--dscs-primary, #4F46E5);
    text-decoration: underline;
}

.dscs-msg-content strong {
    font-weight: 600;
}

/* 浮窗模式下的容器 */
.dscs-float-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

/* 响应式 */
@media (max-width: 480px) {
    .dscs-float-mode .dscs-panel {
        bottom: 0;
        left: 0 !important;
        right: 0 !important;
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    #dscs-widget.dscs-float-mode.dscs-right,
    #dscs-widget.dscs-float-mode.dscs-left {
        bottom: 16px;
        right: 16px;
        left: auto;
    }

    #dscs-widget.dscs-sidebar-mode {
        top: auto;
        bottom: 16px;
        transform: none;
    }

    .dscs-sidebar-panel {
        width: calc(100vw - 32px) !important;
        height: calc(100vh - 80px) !important;
        max-height: 480px !important;
    }

    #dscs-widget.dscs-sidebar-mode.dscs-right {
        right: 16px;
    }

    #dscs-widget.dscs-sidebar-mode.dscs-left {
        left: 16px;
    }

    .dscs-toggle-btn {
        width: 48px;
        height: 48px;
    }
}
