/* 店务会话页（conversation.html）专属样式，依赖 yjjcs.css 中的应用外壳 */

.store-tree,
.chat-stream {
    flex: 1;
    overflow: auto;
    min-height: 0;
}

.tree-item,
.tree-group-btn,
.conv-item,
.filter-tabs button {
    font-family: inherit;
}

.tree-all,
.tree-group-btn,
.tree-store {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
    color: var(--text);
    font-size: 13px;
}

.tree-store {
    padding: 7px 10px 7px 28px;
    align-items: flex-start;
}

.tree-all {
    padding: 7px 10px 7px 12px;
    margin: 8px 6px 4px;
    width: calc(100% - 12px);
    border-radius: 4px;
}

.tree-group {
    margin-top: 4px;
}

.tree-group-btn {
    padding: 7px 10px;
    font-weight: 600;
    color: var(--text-2);
}

.tree-chevron {
    width: 14px;
    color: var(--muted);
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.tree-group.is-collapsed .tree-chevron {
    transform: rotate(-90deg);
}

.tree-group.is-collapsed .tree-children {
    display: none;
}

.tree-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--blue);
    color: #fff;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tree-all:hover,
.tree-group-btn:hover,
.tree-store:hover {
    background: #ececec;
}

.tree-all.is-active,
.tree-group-btn.is-active,
.tree-store.is-active {
    background: var(--blue-soft);
    color: var(--blue-hover);
    font-weight: 600;
}

.tree-store-text {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 1px;
}

.tree-store-name {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-store-code {
    font-size: 11px;
    color: var(--muted);
    font-weight: 400;
}

.conv-item {
    width: 100%;
    display: block;
    border: 0;
    border-bottom: 1px solid #f0f0f0;
    background: var(--surface);
    text-align: left;
    padding: 10px 12px 10px 14px;
    cursor: pointer;
    position: relative;
}

.conv-item:hover {
    background: #f7f7f7;
}

.conv-item.is-active {
    background: var(--blue-softer);
}

.conv-item.is-unread {
    box-shadow: inset 3px 0 0 var(--blue);
}

.conv-item.is-high:not(.is-unread) {
    box-shadow: inset 3px 0 0 var(--danger);
}

.conv-top {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.conv-title {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conv-item.is-unread .conv-title {
    color: var(--blue-hover);
}

.conv-time {
    font-size: 11px;
    color: var(--muted);
    flex-shrink: 0;
}

.conv-preview {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.conv-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
}

.chat-stream {
    display: flex;
    flex-direction: column;
    padding: 16px 20px 8px;
    background: #fafafa;
}

.msg {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    max-width: 78%;
}

.msg.is-agent,
.msg.is-system {
    align-self: flex-start;
}

.msg.is-manager,
.msg.is-supervisor {
    margin-left: auto;
    flex-direction: row-reverse;
}

.msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
    background: var(--blue);
}

.msg.is-manager .msg-avatar {
    background: #5b5fc7;
}

.msg.is-supervisor .msg-avatar {
    background: var(--ok);
}

.msg-bubble {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 4px 12px 12px 12px;
    padding: 8px 12px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.msg.is-manager .msg-bubble,
.msg.is-supervisor .msg-bubble {
    border-radius: 12px 4px 12px 12px;
}

.msg.is-supervisor .msg-bubble {
    background: #eef8f1;
}

.msg.is-agent .msg-bubble {
    background: var(--blue-softer);
    border-color: #d3e7f8;
}

.msg-from {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
}

.msg-text {
    font-size: 13px;
    line-height: 1.55;
    white-space: pre-wrap;
    word-break: break-word;
}

.msg-time {
    margin-top: 6px;
    font-size: 11px;
    color: var(--muted);
}

/* 机会损失等带表格的消息：气泡放宽，表格横向滚动 */
.msg.msg--table {
    max-width: 96%;
}

.msg .msg-text + .msg-table-wrap {
    margin-top: 8px;
}

.msg-table-wrap + .msg-text {
    margin-top: 8px;
}

.msg-loss-stat {
    font-weight: 600;
}

.msg-table-wrap {
    overflow-x: auto;
    border: 1px solid #d3e7f8;
    border-radius: 8px;
    background: #fff;
}

.msg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    line-height: 1.5;
    white-space: nowrap;
}

.msg-table th,
.msg-table td {
    padding: 6px 10px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

/* 第 2 列是商品名（长文本），允许换行；编号/金额保持单行不被压断 */
.msg-table th:nth-child(2),
.msg-table td:nth-child(2) {
    white-space: normal;
    word-break: break-word;
}

/* 第 4 列是操作图标，收到最窄 */
.msg-table th:nth-child(4),
.msg-table td:nth-child(4) {
    width: 1%;
    text-align: center;
}

.msg-action {
    display: inline-flex;
    color: var(--blue);
}

.msg-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--line);
    font-size: 12px;
    color: var(--muted);
}

.msg-legend-title {
    font-weight: 600;
}

.msg-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.msg-legend-item .msg-action-icon {
    color: var(--blue);
}

@media (max-width: 768px) {
    .chat-stream {
        padding: 12px 10px 8px;
    }

    /* 消息不横向溢出：气泡占满可用宽度，表格放弃最小宽度改为换行 */
    .msg,
    .msg.msg--table {
        max-width: 100%;
    }

    .msg-bubble {
        flex: 1;
        min-width: 0;
    }

    .msg-table {
        font-size: 12px;
    }

    .msg-table th,
    .msg-table td {
        padding: 5px 6px;
    }
}

.msg-table thead th {
    background: var(--blue-softer);
    color: var(--muted);
    font-weight: 600;
}

.msg-table tbody tr:last-child td {
    border-bottom: none;
}

.msg-table tbody tr:hover td {
    background: #f5fbff;
}

.chat-composer {
    border-top: 1px solid var(--line);
    padding: 10px 14px 12px;
    background: var(--surface);
    flex-shrink: 0;
}

.composer-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
    color: var(--muted);
}

.role-switch {
    display: flex;
    align-items: center;
    gap: 8px;
}

.role-switch select {
    height: 26px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #fff;
    color: var(--text);
    font-size: 12px;
}

.composer-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.composer-row textarea {
    flex: 1;
    resize: none;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.45;
    outline: none;
}

.composer-row textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 1px var(--blue);
}

.filter-tabs {
    display: flex;
    gap: 4px;
}

.filter-tabs button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
}

.filter-tabs button:hover {
    background: #eee;
    color: var(--text);
}

.filter-tabs button.is-active {
    background: var(--blue-softer);
    color: var(--blue);
    font-weight: 600;
}
