/* Menu: Trợ lý AI — khung chat 2 cột (danh sách hội thoại | luồng tin nhắn). */
.tl-wrap {
    display: flex;
    height: calc(100vh - 68px - 32px); /* header + padding dc-content */
    min-height: 420px;
    background: #fff;
    border: 1px solid var(--line-2);
    border-radius: 14px;
    overflow: hidden;
}

/* ---------- cột trái ---------- */
.tl-side {
    width: 260px;
    flex: none;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line-2);
    background: #fafbfc;
}
.tl-side-head {
    padding: 12px;
    border-bottom: 1px solid var(--line);
}
.tl-side-head .dc-btn {
    width: 100%;
}
.tl-list {
    flex: 1;
    overflow: auto;
    padding: 8px;
}
.tl-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 9px;
    cursor: pointer;
    font-size: 13.5px;
}
.tl-item:hover {
    background: #f1f3f6;
}
.tl-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}
.tl-item-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tl-item-time {
    font-size: 11px;
    color: var(--muted-2);
    font-weight: 400;
}
.tl-item-del {
    display: none;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--muted);
    border-radius: 6px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}
.tl-item-del svg {
    width: 15px;
    height: 15px;
}
.tl-item:hover .tl-item-del {
    display: inline-flex;
}
.tl-item-del:hover {
    background: #fee2e2;
    color: #dc2626;
}
.tl-side-empty {
    padding: 24px 12px;
    text-align: center;
    color: var(--muted-2);
    font-size: 13px;
}

/* ---------- cột chính ---------- */
.tl-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.tl-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--line);
    font-size: 13px;
    color: var(--muted);
}
.tl-head .dc-ic svg {
    width: 18px;
    height: 18px;
    color: var(--accent);
}
.tl-head-toggle {
    display: none;
}
.tl-messages {
    flex: 1;
    overflow: auto;
    padding: 20px 0;
}
.tl-inner {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* bubble */
.tl-msg {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.tl-msg.user {
    align-items: flex-end;
}
.tl-msg.model {
    align-items: flex-start;
}
.tl-bubble {
    max-width: 85%;
    padding: 11px 15px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}
.tl-msg.user .tl-bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 6px;
}
.tl-msg.model .tl-bubble {
    background: #f4f6f9;
    color: var(--ink);
    border-bottom-left-radius: 6px;
    white-space: normal;
}
.tl-msg.model .tl-bubble.error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}
.tl-tools {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 12px;
    color: var(--muted);
    padding-left: 4px;
}
.tl-tools span::before {
    content: '◆ ';
    color: var(--accent);
}
.tl-stopped {
    font-size: 12px;
    color: var(--muted-2);
    font-style: italic;
}
.tl-model-tag {
    font-size: 11px;
    color: var(--muted-2);
    padding-left: 4px;
}
.tl-retry {
    margin-top: 6px;
}

/* markdown trong bubble bot */
.tl-md p {
    margin: 0 0 8px;
}
.tl-md p:last-child {
    margin-bottom: 0;
}
.tl-md ul,
.tl-md ol {
    margin: 4px 0 8px 22px;
}
.tl-md h1,
.tl-md h2,
.tl-md h3 {
    font-size: 14.5px;
    margin: 10px 0 6px;
}
.tl-md code {
    background: #e9edf2;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12.5px;
}
.tl-md pre {
    background: #1f2937;
    color: #f9fafb;
    padding: 10px 12px;
    border-radius: 8px;
    overflow: auto;
    margin: 6px 0 10px;
}
.tl-md pre code {
    background: none;
    color: inherit;
    padding: 0;
}
.tl-md table {
    border-collapse: collapse;
    margin: 6px 0 10px;
    font-size: 13px;
    max-width: 100%;
    display: block;
    overflow: auto;
}
.tl-md th,
.tl-md td {
    border: 1px solid #d9dee5;
    padding: 5px 9px;
    text-align: left;
    white-space: nowrap;
}
.tl-md th {
    background: #e9edf2;
    font-weight: 600;
}

/* 3 chấm */
.tl-dots {
    display: inline-flex;
    gap: 4px;
    padding: 4px 0;
}
.tl-dots i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted-2);
    animation: tl-blink 1.2s infinite;
}
.tl-dots i:nth-child(2) {
    animation-delay: 0.2s;
}
.tl-dots i:nth-child(3) {
    animation-delay: 0.4s;
}
@keyframes tl-blink {
    0%,
    80%,
    100% {
        opacity: 0.25;
    }
    40% {
        opacity: 1;
    }
}

/* trống */
.tl-empty {
    margin: auto;
    max-width: 560px;
    text-align: center;
    padding: 20px;
}
.tl-empty .dc-ic svg {
    width: 40px;
    height: 40px;
    color: var(--accent);
}
.tl-empty h2 {
    font-size: 18px;
    margin: 10px 0 6px;
}
.tl-empty p {
    color: var(--muted);
    font-size: 13.5px;
    margin-bottom: 16px;
}
.tl-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.tl-chip {
    border: 1px solid #dce0e6;
    background: #fff;
    border-radius: 999px;
    padding: 7px 13px;
    font-size: 13px;
    cursor: pointer;
}
.tl-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ---------- ô nhập ---------- */
.tl-composer {
    border-top: 1px solid var(--line);
    padding: 12px 20px 14px;
}
.tl-composer-box {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    border: 1px solid #dce0e6;
    border-radius: 14px;
    padding: 8px 8px 8px 14px;
    background: #fff;
}
.tl-composer-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-ring);
}
.tl-textarea {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    font-size: 14px;
    line-height: 1.5;
    max-height: 144px; /* 6 dòng */
    padding: 6px 0;
    background: transparent;
}
.tl-send {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
}
.tl-send:disabled {
    background: #cbd5e1;
    cursor: default;
}
.tl-send.stop {
    background: #dc2626;
}
.tl-send svg {
    width: 18px;
    height: 18px;
}
.tl-hint {
    max-width: 800px;
    margin: 6px auto 0;
    font-size: 11.5px;
    color: var(--muted-2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}
.tl-model,
.tl-model-static {
    font-size: 11.5px;
    color: var(--muted);
    border: 1px solid #dce0e6;
    border-radius: 6px;
    padding: 2px 6px;
    background: #fff;
}
.tl-model:disabled {
    opacity: 0.6;
}
.tl-nokey {
    max-width: 800px;
    margin: 0 auto;
    padding: 12px 16px;
    border-radius: 10px;
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
    font-size: 13.5px;
}

@media (max-width: 900px) {
    .tl-side {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 5;
        transform: translateX(-100%);
        transition: transform 0.2s;
        box-shadow: 4px 0 16px rgba(0, 0, 0, 0.08);
    }
    .tl-wrap {
        position: relative;
    }
    .tl-wrap.side-open .tl-side {
        transform: none;
    }
    .tl-head-toggle {
        display: inline-flex;
    }
}
