/* ==========================================================
   Tafiti Assistant - conversation styles
   Append to the widget's <style> block, or load as a file
   ========================================================== */


.tf-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
    font-size: .84rem;
}

.tf-text th,
.tf-text td {
    padding: 6px 8px;
    border-bottom: 1px solid #e6ebf3;
    text-align: left;
}

.tf-text th {
    font-size: .72rem;
    text-transform: uppercase;
    color: #7a869a;
}

.tf-text h4 {
    font-size: .92rem;
    font-weight: 700;
    margin: 10px 0 6px;
}

.tf-text ul,
.tf-text ol {
    margin: 6px 0 9px;
    padding-left: 20px;
}

.tf-text li {
    margin-bottom: 3px;
}

.tf-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 16px;
    background: #eef3fa;
    border-bottom: 1px solid #dde6f2;
    font-size: .74rem;
    color: #6b7789;
    flex-shrink: 0;
}

.tf-toolbar i {
    margin-right: 5px;
}

.tf-clear {
    border: 0;
    background: transparent;
    color: #003d82;
    font-weight: 600;
    font-size: .74rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
}

.tf-clear:hover {
    background: #dce7f6;
}

/* ---------- rows ---------- */

.tf-row {
    display: flex;
    gap: 9px;
    margin-bottom: 14px;
    align-items: flex-start;
    animation: tfIn .26s ease both;
}

@keyframes tfIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

.tf-row-user {
    justify-content: flex-end;
}

.tf-ava {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: linear-gradient(135deg, #003d82, #0a5aa8);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: .82rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.tf-ava-bad {
    background: linear-gradient(135deg, #a33, #c0392b);
}

/* ---------- bubbles ---------- */

.tf-bubble {
    max-width: 84%;
    border-radius: 16px;
    padding: 11px 14px;
    font-size: .9rem;
    line-height: 1.62;
}

.tf-bubble-user {
    background: #003d82;
    color: #fff;
    border-bottom-right-radius: 5px;
}

.tf-bubble-bot {
    background: #fff;
    border: 1px solid #e6ebf3;
    color: #16202f;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 8px rgba(16, 24, 40, .04);
}

.tf-bubble-bad {
    background: #fdeceb;
    border: 1px solid #f5cdc9;
    color: #8c2f24;
    border-bottom-left-radius: 5px;
}

.tf-text p {
    margin: 0 0 9px;
}

.tf-text p:last-child {
    margin-bottom: 0;
}

.tf-text a {
    color: #0a5aa8;
    word-break: break-word;
}

.tf-bubble-user .tf-text a {
    color: #cfe4ff;
}

.tf-text code {
    background: #eef2f7;
    padding: 1px 5px;
    border-radius: 5px;
    font-size: .86em;
    font-family: ui-monospace, Menlo, Consolas, monospace;
}

/* ---------- typing caret ---------- */

.tf-text.tf-typing p:last-child::after {
    content: "";
    display: inline-block;
    width: 2px;
    height: 1em;
    background: #003d82;
    margin-left: 2px;
    vertical-align: -2px;
    animation: tfCaret .9s steps(1) infinite;
}

@keyframes tfCaret {

    0%,
    49% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0;
    }
}

/* ---------- thinking dots ---------- */

.tf-dots {
    display: flex;
    gap: 4px;
    padding: 4px 2px;
}

.tf-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #b9c4d4;
    animation: tfBounce 1.3s infinite ease-in-out;
}

.tf-dots span:nth-child(2) {
    animation-delay: .18s;
}

.tf-dots span:nth-child(3) {
    animation-delay: .36s;
}

@keyframes tfBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: .5;
    }

    30% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

/* ---------- message actions ---------- */

.tf-actions {
    display: flex;
    gap: 6px;
    margin-top: 9px;
    padding-top: 8px;
    border-top: 1px solid #eef1f6;
}

.tf-bubble-bad .tf-actions {
    border-top-color: #f5cdc9;
}

.tf-mini {
    border: 0;
    background: transparent;
    color: #7a869a;
    font-size: .74rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 7px;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.tf-mini:hover {
    background: #eef3fa;
    color: #003d82;
}

.tf-bubble-bad .tf-mini {
    color: #a3453a;
}

.tf-bubble-bad .tf-mini:hover {
    background: #f8dcd8;
    color: #8c2f24;
}

/* ---------- follow-up chips ---------- */

.tf-followups {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: -6px 0 14px 39px;
    animation: tfIn .3s ease both;
}

.tf-followup {
    border: 1px solid #cfdcef;
    background: #fff;
    color: #003d82;
    font-size: .79rem;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}

.tf-followup:hover {
    background: #eef3fa;
    border-color: #a9c4e6;
}

/* ---------- stop button ---------- */

.tf-stop {
    display: block;
    margin: 0 auto 10px;
    border: 1px solid #e6ebf3;
    background: #fff;
    color: #46536b;
    font-size: .78rem;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(16, 24, 40, .06);
}

.tf-stop:hover {
    background: #f4f7fb;
    color: #c0392b;
}

/* ---------- send spinner ---------- */

.tf-spin {
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #fff;
    border-radius: 50%;
    display: inline-block;
    animation: tfSpin .7s linear infinite;
}

@keyframes tfSpin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {

    .tf-row,
    .tf-followups {
        animation: none;
    }

    .tf-dots span {
        animation: none;
    }
}