/* =========================================================
   AI CHAT
   COMPLETE CHAT / SCROLL / COMPOSER
   ========================================================= */


/* =========================================================
   CHAT MESSAGES
   فقط این قسمت Scroll می‌شود
   ========================================================= */

.tc-ai-messages {
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    min-height: 0;
    height: auto;
    margin: 0;
    padding: 34px clamp(18px, 5vw, 75px) 25px;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(99,102,241,.28) transparent;
}


    /* scrollbar */

    .tc-ai-messages::-webkit-scrollbar {
        width: 7px;
    }

    .tc-ai-messages::-webkit-scrollbar-track {
        background: transparent;
    }

    .tc-ai-messages::-webkit-scrollbar-thumb {
        border-radius: 20px;
        background: linear-gradient( 180deg, rgba(99,102,241,.40), rgba(139,92,246,.35) );
    }


/* =========================================================
   WELCOME
   ========================================================= */

.tc-ai-welcome {
    display: block;
    width: min(760px, 100%);
    margin: 15px auto 35px;
    padding: 42px 28px;
    text-align: center;
    border: 1px solid rgba(99,102,241,.10);
    border-radius: 28px;
    background: linear-gradient( 145deg, rgba(255,255,255,.96), rgba(247,249,255,.92) );
    box-shadow: 0 22px 65px rgba(60,70,130,.09);
}

    .tc-ai-welcome[hidden] {
        display: none !important;
    }


/* =========================================================
   WELCOME ICON
   ========================================================= */

.tc-ai-welcome-icon {
    display: grid;
    place-items: center;
    width: 70px;
    height: 70px;
    margin: 0 auto 20px;
    border-radius: 22px;
    color: #fff;
    font-size: 29px;
    background: linear-gradient( 135deg, #6366f1, #8b5cf6, #ec4899 );
    box-shadow: 0 15px 35px rgba(99,102,241,.28);
}

.tc-ai-welcome h2 {
    margin: 0 0 12px;
    color: #202637;
    font-size: clamp(24px, 3vw, 32px);
    font-weight: 900;
}

.tc-ai-welcome p {
    max-width: 650px;
    margin: auto;
    color: #68748b;
    font-size: 14px;
    line-height: 2;
}


/* =========================================================
   MESSAGE
   ========================================================= */

.tc-ai-message {
    display: flex;
    align-items: flex-start;
    gap: 11px;
    width: min(850px, 100%);
    margin: 0 auto 17px;
    animation: aiMessageIn .25s ease both;
}

    .tc-ai-message.user {
        flex-direction: row-reverse;
    }


/* =========================================================
   AVATAR
   ========================================================= */

.tc-ai-avatar {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 13px;
    color: #fff;
    background: linear-gradient( 135deg, #6366f1, #8b5cf6 );
    box-shadow: 0 8px 20px rgba(99,102,241,.18);
}

.tc-ai-message.user .tc-ai-avatar {
    background: linear-gradient( 135deg, #06b6d4, #0ea5e9 );
}


/* =========================================================
   MESSAGE BUBBLE
   ========================================================= */

.tc-ai-bubble {
    width: auto;
    max-width: calc(100% - 52px);
    min-width: 0;
    padding: 14px 17px;
    border: 1px solid rgba(99,102,241,.08);
    border-radius: 18px;
    background: rgba(255,255,255,.96);
    box-shadow: 0 8px 28px rgba(50,60,110,.07);
    overflow-wrap: anywhere;
    word-break: break-word;
}

.tc-ai-message.user .tc-ai-bubble {
    background: linear-gradient( 135deg, #ecfeff, #eff6ff );
    border-color: rgba(6,182,212,.12);
}

.tc-ai-bubble p {
    margin: 0;
    color: #29334d;
    font-size: 14px;
    line-height: 2;
    white-space: pre-wrap;
}


/* =========================================================
   FEEDBACK
   ========================================================= */

.tc-ai-feedback {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 11px;
    padding-top: 9px;
    border-top: 1px solid rgba(99,102,241,.07);
    color: #94a3b8;
    font-size: 10px;
}

    .tc-ai-feedback button {
        display: grid;
        place-items: center;
        width: 30px;
        height: 30px;
        padding: 0;
        border: 0;
        border-radius: 9px;
        color: #94a3b8;
        background: #f2f4fa;
        cursor: pointer;
        transition: .2s ease;
    }

        .tc-ai-feedback button:hover {
            color: #6366f1;
            background: #eef2ff;
            transform: translateY(-1px);
        }

    .tc-ai-feedback.is-done {
        opacity: .45;
        pointer-events: none;
    }


/* =========================================================
   COMPOSER WRAPPER
   مهم:
   Composer بخشی از Main است و صفحه را بلند نمی‌کند
   ========================================================= */

.tc-ai-composer-wrap {
    position: relative;
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 10px clamp(18px, 5vw, 75px) max(13px, env(safe-area-inset-bottom));
    z-index: 30;
    background: linear-gradient( 180deg, rgba(245,247,255,0), rgba(245,247,255,.92) 22%, #f5f7ff 100% );
}


/* =========================================================
   HINT
   ========================================================= */

.tc-ai-composer-hint {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: min(850px, 100%);
    margin: 0 auto 7px;
    color: #8b95a9;
    font-size: 10px;
}

    .tc-ai-composer-hint span {
        min-width: 0;
    }

        .tc-ai-composer-hint span:first-child {
            display: flex;
            align-items: center;
            gap: 5px;
            color: #64748b;
        }


/* =========================================================
   COMPOSER
   ========================================================= */

.tc-ai-composer {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 5px;
    width: min(850px, 100%);
    max-width: 850px;
    min-width: 0;
    min-height: 62px;
    margin: 0 auto;
    padding: 8px;
    border: 1px solid rgba(99,102,241,.14);
    border-radius: 20px;
    background: rgba(255,255,255,.97);
    box-shadow: 0 14px 40px rgba(60,70,130,.10);
    transition: border-color .2s ease, box-shadow .2s ease;
}

    .tc-ai-composer:focus-within {
        border-color: rgba(99,102,241,.35);
        box-shadow: 0 16px 45px rgba(99,102,241,.15);
    }


/* =========================================================
   TEXTAREA
   ========================================================= */

#tcAiInput {
    display: block;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: auto;
    min-height: 44px;
    max-height: 180px;
    margin: 0;
    padding: 9px 12px;
    border: 0;
    outline: none;
    resize: none;
    overflow-x: hidden;
    overflow-y: auto;
    color: #1e293b;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.8;
    box-sizing: border-box;
}

    #tcAiInput::placeholder {
        color: #a1aabd;
    }

    #tcAiInput::-webkit-scrollbar {
        width: 4px;
    }

    #tcAiInput::-webkit-scrollbar-thumb {
        border-radius: 10px;
        background: rgba(99,102,241,.22);
    }


/* =========================================================
   SEND BUTTON
   ========================================================= */

.tc-ai-send {
    display: grid;
    place-items: center;
    width: 45px;
    height: 45px;
    min-width: 45px;
    flex: 0 0 45px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient( 135deg, #6366f1, #8b5cf6 );
    box-shadow: 0 8px 20px rgba(99,102,241,.25);
    cursor: pointer;
    transition: transform .2s ease, opacity .2s ease, box-shadow .2s ease;
}

    .tc-ai-send:not(:disabled):hover {
        transform: translateY(-2px);
        box-shadow: 0 12px 26px rgba(99,102,241,.34);
    }

    .tc-ai-send:disabled {
        opacity: .38;
        cursor: not-allowed;
        box-shadow: none;
    }


/* =========================================================
   COMPOSER FOOTER
   ========================================================= */

.tc-ai-composer-footer {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    width: min(850px, 100%);
    margin: 7px auto 0;
    color: #9aa3b5;
    font-size: 9px;
    line-height: 1.5;
}

    .tc-ai-composer-footer span {
        min-width: 0;
    }

        .tc-ai-composer-footer span:last-child {
            text-align: left;
        }


/* =========================================================
   CHAT MODE
   ========================================================= */

.tc-ai-main.is-chatting
.tc-ai-welcome {
    display: none;
}


/* =========================================================
   ANIMATION
   ========================================================= */

@keyframes aiMessageIn {

    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 1000px) {

    .tc-ai-messages {
        padding-left: 25px;
        padding-right: 25px;
    }

    .tc-ai-composer-wrap {
        padding-left: 25px;
        padding-right: 25px;
    }

    .tc-ai-message {
        width: min(800px, 100%);
    }
}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {

    .tc-ai-messages {
        padding: 20px 10px 15px;
    }

    .tc-ai-welcome {
        width: calc(100% - 10px);
        margin-top: 8px;
        padding: 30px 17px;
        border-radius: 22px;
    }

    .tc-ai-welcome-icon {
        width: 58px;
        height: 58px;
        margin-bottom: 16px;
        border-radius: 18px;
        font-size: 24px;
    }

    .tc-ai-welcome h2 {
        font-size: 22px;
    }

    .tc-ai-welcome p {
        font-size: 12px;
    }

    .tc-ai-message {
        width: 100%;
        gap: 7px;
        margin-bottom: 12px;
    }

    .tc-ai-avatar {
        width: 32px;
        height: 32px;
        min-width: 32px;
        border-radius: 10px;
    }

    .tc-ai-bubble {
        max-width: calc(100% - 40px);
        padding: 10px 12px;
        border-radius: 15px;
    }

        .tc-ai-bubble p {
            font-size: 13px;
            line-height: 1.9;
        }

    .tc-ai-composer-wrap {
        padding: 7px 9px max(9px, env(safe-area-inset-bottom));
    }

    .tc-ai-composer {
        width: 100%;
        min-height: 56px;
        padding: 6px;
        border-radius: 17px;
    }

    #tcAiInput {
        min-height: 42px;
        padding: 8px 10px;
        font-size: 13px;
    }

    .tc-ai-send {
        width: 41px;
        height: 41px;
        min-width: 41px;
        flex-basis: 41px;
        border-radius: 12px;
    }

    .tc-ai-composer-hint {
        width: 100%;
        font-size: 9px;
    }

    .tc-ai-composer-footer {
        width: 100%;
        font-size: 8px;
    }

        .tc-ai-composer-footer
        span:last-child {
            display: none;
        }
}


/* =========================================================
   SMALL MOBILE
   ========================================================= */

@media (max-width: 430px) {

    .tc-ai-messages {
        padding: 15px 7px 10px;
    }

    .tc-ai-composer-wrap {
        padding-left: 7px;
        padding-right: 7px;
    }

    .tc-ai-composer-hint
    span:first-child {
        max-width: 75%;
    }
}
