/* =============================================
 * 企业 IM 客服聊天组件样式（单客服模式）
 * 左侧对话 + 右侧公司简介
 * ============================================= */

.yc-root,
.yc-root * {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
        "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* 主题变量：由 chat.js 按后台配置覆盖 */
.yc-root {
    --yc-primary: #4a7cf0;
    --yc-primary-rgb: 74, 124, 240;
    --yc-primary-dark: #3563d6;
    --yc-panel-width: 820px;
}

/* ---------- 悬浮按钮 ---------- */
.yc-fab {
    position: fixed;
    right: 24px;
    bottom: 80px;
    height: 56px;
    min-width: 56px;
    padding: 0;
    border-radius: 28px;
    background: linear-gradient(135deg, var(--yc-primary) 0%, var(--yc-primary-dark) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(var(--yc-primary-rgb), 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    z-index: 9998;
}
.yc-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(var(--yc-primary-rgb), 0.55);
}
.yc-fab svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}
/* 带文字标签时变成胶囊按钮 */
.yc-fab.yc-fab-pill {
    padding: 0 20px 0 16px;
}
.yc-fab-text {
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}
/* 左下角显示 */
.yc-root.yc-left .yc-fab {
    left: 24px;
    right: auto;
}
.yc-fab.badge::after {
    content: attr(data-count);
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: #ff4d4f;
    color: #fff;
    font-size: 12px;
    line-height: 20px;
    text-align: center;
    box-shadow: 0 2px 6px rgba(255, 77, 79, 0.5);
}

/* ---------- 主面板 ---------- */
.yc-panel {
    position: fixed;
    right: 24px;
    bottom: 150px;
    width: var(--yc-panel-width);
    max-width: calc(100vw - 48px);
    height: 620px;
    max-height: calc(100vh - 180px);
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    animation: yc-slide-up 0.25s ease;
}
/* 左下角显示 */
.yc-root.yc-left .yc-panel {
    left: 24px;
    right: auto;
}
@keyframes yc-slide-up {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 顶部标题栏 ---------- */
.yc-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px 14px;
    background: #fff;
}
.yc-header-title {
    font-size: 18px;
    font-weight: 700;
    color: #1f2430;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.yc-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.yc-lang-switch {
    border: none;
    background: #f5f6f8;
    color: #6b7280;
    padding: 4px 10px;
    border-radius: 10px;
    font-size: 12px;
    cursor: pointer;
    line-height: 1.4;
}
.yc-lang-switch:hover { background: #eef0f4; color: var(--yc-primary); }
.yc-close {
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    color: #b7bcc5;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    line-height: 1;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
}
.yc-close:hover { color: #6b7280; background: #f5f6f8; }

/* ---------- 主体：左聊天 + 右公司简介 ---------- */
.yc-body {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
}
.yc-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* ---------- 消息区 ---------- */
.yc-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 8px 24px 16px;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.yc-msg {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 78%;
}
.yc-msg.agent {
    align-self: flex-start;
    align-items: flex-start;
}
.yc-msg.visitor {
    align-self: flex-end;
    align-items: flex-end;
}
.yc-msg.system {
    align-self: center;
    align-items: center;
    max-width: 92%;
}
.yc-msg-bubble {
    padding: 13px 17px;
    border-radius: 12px;
    background: #f5f6f8;
    color: #333a45;
    font-size: 14px;
    line-height: 1.7;
    word-break: break-word;
    white-space: pre-wrap;
}
.yc-msg.visitor .yc-msg-bubble {
    background: var(--yc-primary);
    color: #fff;
}
.yc-msg.system .yc-msg-bubble {
    background: #f5f6f8;
    color: #9aa0aa;
    font-size: 12px;
    line-height: 1.6;
    padding: 7px 14px;
    border-radius: 10px;
    white-space: pre-wrap;
}
.yc-msg-time {
    font-size: 12px;
    color: #b9bec7;
    line-height: 1;
}

/* 图片消息 */
.yc-msg-bubble.yc-msg-image {
    padding: 4px;
    overflow: hidden;
    background: #f5f6f8;
}
.yc-chat-img {
    display: block;
    max-width: 220px;
    max-height: 220px;
    border-radius: 8px;
    cursor: zoom-in;
    object-fit: cover;
}
.yc-img-loading {
    color: #9aa0aa;
    font-size: 13px;
    font-style: italic;
}

/* ---------- FAQ ---------- */
.yc-faq-section {
    flex: 0 0 auto;
    padding: 4px 24px 10px;
    background: #fff;
}
.yc-faq-header {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
}
.yc-faq-title {
    font-size: 12px;
    color: #9aa0aa;
}
.yc-faq-arrow {
    font-size: 11px;
    color: #b7bcc5;
}
.yc-faq-refresh {
    margin-left: auto;
    font-size: 12px;
    color: var(--yc-primary);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}
.yc-faq-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 8px;
}
.yc-faq-list.yc-collapsed { display: none; }
.yc-faq-item {
    padding: 9px 12px;
    border-radius: 8px;
    background: #f7f8fa;
    color: #505763;
    font-size: 13px;
    line-height: 1.5;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.yc-faq-item:hover {
    background: rgba(var(--yc-primary-rgb), 0.08);
    color: var(--yc-primary);
}

/* ---------- 输入区 ---------- */
.yc-input-area {
    position: relative;
    flex: 0 0 auto;
    padding: 6px 24px 18px;
    background: #fff;
}
.yc-input-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.yc-input-tool {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: #f5f6f8;
    color: #8a8f99;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.yc-input-tool:hover {
    background: rgba(var(--yc-primary-rgb), 0.08);
    color: var(--yc-primary);
}
.yc-input-tool.yc-input-tool-active {
    background: rgba(var(--yc-primary-rgb), 0.14);
    color: var(--yc-primary);
}
.yc-input-tool svg { width: 17px; height: 17px; }

/* 表情面板 */
.yc-emoji-panel {
    position: absolute;
    bottom: 100%;
    left: 24px;
    right: 24px;
    max-height: 180px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #eceef2;
    border-radius: 10px;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08);
    padding: 8px;
    z-index: 20;
    margin-bottom: 4px;
}
.yc-emoji-panel::-webkit-scrollbar { width: 6px; }
.yc-emoji-panel::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
.yc-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}
.yc-emoji-item {
    font-size: 20px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: background 0.15s;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.yc-emoji-item:hover { background: #f0f4ff; }

/* 输入框 */
.yc-input-box {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #eceef2;
    border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    background: #fff;
    transition: border-color 0.2s;
}
.yc-input-box:focus-within { border-color: rgba(var(--yc-primary-rgb), 0.4); }
.yc-input-box textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 14px;
    line-height: 1.6;
    padding: 5px 2px;
    min-height: 24px;
    max-height: 110px;
    font-family: inherit;
    color: #333a45;
    background: transparent;
}
.yc-input-box textarea::placeholder { color: #b7bcc5; }
.yc-send-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--yc-primary);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.2s;
}
.yc-send-btn:hover { background: var(--yc-primary-dark); transform: scale(1.04); }
.yc-send-btn:disabled {
    background: #cdd5e3;
    cursor: not-allowed;
    transform: none;
}
.yc-send-btn svg { width: 17px; height: 17px; }

/* ---------- 右侧公司简介 ---------- */
.yc-side {
    flex: 0 0 300px;
    width: 300px;
    border-left: 1px solid #f0f1f4;
    padding: 22px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #fff;
}
.yc-side-title {
    position: relative;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: #1f2430;
    padding-bottom: 16px;
    border-bottom: 1px solid #f0f1f4;
}
.yc-side-title::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -2px;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    border-radius: 2px;
    background: var(--yc-primary);
}
.yc-side-logo {
    display: flex;
    justify-content: center;
    padding: 6px 0 2px;
}
.yc-side-logo img {
    width: 96px;
    height: 96px;
    object-fit: contain;
    border-radius: 8px;
}
.yc-side-logo-ph {
    width: 96px;
    height: 96px;
    border-radius: 8px;
    background: #f5f6f8;
    color: #9aa0aa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
}
.yc-side-desc-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.yc-side-desc {
    margin: 0;
    font-size: 13px;
    line-height: 1.9;
    color: #5f6673;
    white-space: pre-wrap;
    word-break: break-word;
}
.yc-side-desc.yc-clamped {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.yc-side-more {
    align-self: flex-end;
    font-size: 12px;
    color: var(--yc-primary);
    cursor: pointer;
}
.yc-side-empty {
    text-align: center;
    font-size: 13px;
    color: #b7bcc5;
    padding: 12px 0;
}
.yc-info-card {
    background: #f7f8fa;
    border-radius: 10px;
    padding: 14px 16px;
}
.yc-info-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #9aa0aa;
    margin-bottom: 7px;
}
.yc-info-label svg { width: 14px; height: 14px; }
.yc-info-value {
    font-size: 15px;
    font-weight: 600;
    color: #333a45;
    word-break: break-all;
    line-height: 1.5;
}

/* ---------- 滚动条 ---------- */
.yc-messages::-webkit-scrollbar,
.yc-side::-webkit-scrollbar {
    width: 6px;
}
.yc-messages::-webkit-scrollbar-thumb,
.yc-side::-webkit-scrollbar-thumb {
    background: #e5e7eb;
    border-radius: 3px;
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 900px) {
    .yc-panel {
        width: calc(100vw - 32px);
        right: 16px;
        max-width: none;
    }
    .yc-root.yc-left .yc-panel {
        left: 16px;
        right: auto;
    }
    .yc-side { display: none; }
}
@media (max-width: 480px) {
    .yc-panel {
        right: 0; left: 0;
        top: 0; bottom: 0;
        width: 100%;
        max-width: none;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    .yc-fab { right: 16px; bottom: 16px; }
    .yc-root.yc-left .yc-fab { left: 16px; right: auto; }
    .yc-header { padding: 14px 16px 10px; }
    .yc-header-title { font-size: 16px; }
    .yc-messages { padding: 6px 16px 12px; }
    .yc-faq-section { padding: 4px 16px 8px; }
    .yc-input-area { padding: 6px 16px 14px; }
    .yc-emoji-panel { left: 16px; right: 16px; }
}
