/* =========================================
   CHAT TRIPCOOKING
   ========================================= */

:root{
    --tc-chat-primary: #6f3cff;
    --tc-chat-primary-2: #8f63ff;
    --tc-chat-primary-dark: #5323d8;

    --tc-chat-received-bg: #e9fffa;
    --tc-chat-received-bg-2: #d7f8ef;
    --tc-chat-received-border: rgba(39, 179, 152, 0.18);
    --tc-chat-received-text: #21343f;

    --tc-chat-surface: rgba(255,255,255,0.97);
    --tc-chat-surface-soft: #fbf9ff;
    --tc-chat-border: rgba(111, 60, 255, 0.12);

    --tc-chat-text: #241f36;
    --tc-chat-text-soft: #6f6885;
    --tc-chat-text-muted: #9b95af;

    --tc-chat-shadow-lg: 0 24px 60px rgba(38, 25, 82, 0.22);
    --tc-chat-shadow-md: 0 14px 30px rgba(64, 43, 126, 0.12);
    --tc-chat-shadow-sm: 0 8px 18px rgba(64, 43, 126, 0.08);

    --tc-chat-radius-xl: 22px;
    --tc-chat-radius-lg: 18px;
    --tc-chat-radius-md: 16px;
    --tc-chat-radius-sm: 12px;
}

/* =========================================
   DOCK
   ========================================= */

#tcChatDock{
    position: fixed;
    right: 18px;
    bottom: 0;
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    gap: 14px;
    pointer-events: none;
}

#tcChatDock .tcChatWindow{
    pointer-events: auto;
}

/* =========================================
   FENETRE
   ========================================= */

.tcChatWindow{
    width: 360px;
    max-width: calc(100vw - 24px);
    height: 530px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 20px 20px 0 0;
    background: var(--tc-chat-surface);
    border: 1px solid var(--tc-chat-border);
    box-shadow: var(--tc-chat-shadow-lg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
}

.tcChatWindow.is-minimized{
    height: 72px;
}

.tcChatWindow.is-minimized .tcChatWindow__messages,
.tcChatWindow.is-minimized .tcChatWindow__form{
    display: none;
}

/* =========================================
   HEADER
   ========================================= */

.tcChatWindow__head{
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--tc-chat-primary) 0%, var(--tc-chat-primary-2) 100%);
    color: #fff;
    box-shadow: inset 0 -1px 0 rgba(255,255,255,0.10);
}

.tcChatWindow__user{
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.tcChatWindow__user img{
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 2px solid rgba(255,255,255,0.38);
    background: rgba(255,255,255,0.16);
}

.tcChatWindow__userMeta{
    min-width: 0;
}

.tcChatWindow__name{
    font-size: .98rem;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tcChatWindow__status{
    margin-top: 2px;
    font-size: .8rem;
    color: rgba(255,255,255,0.84);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tcChatWindow__actions{
    display: flex;
    align-items: center;
    gap: 8px;
}

.tcChatWindow__actions button{
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 12px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: transform .18s ease, background .18s ease, opacity .18s ease;
}

.tcChatWindow__actions button:hover{
    background: rgba(255,255,255,0.24);
    transform: scale(1.05);
}

.tcChatWindow__actions button:active{
    transform: scale(.98);
}

/* =========================================
   ZONE MESSAGES
   ========================================= */

.tcChatWindow__messages{
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background:
        radial-gradient(circle at top left, rgba(111,60,255,0.05), transparent 30%),
        linear-gradient(180deg, #fcfbff 0%, #f6f3ff 100%);
}

.tcChatWindow__messages::-webkit-scrollbar{
    width: 8px;
}

.tcChatWindow__messages::-webkit-scrollbar-track{
    background: transparent;
}

.tcChatWindow__messages::-webkit-scrollbar-thumb{
    background: rgba(111,60,255,0.18);
    border-radius: 999px;
}

.tcChatWindow__loading,
.tcChatWindow__empty,
.tcChatWindow__error{
    padding: 14px 16px;
    border-radius: 16px;
    font-size: .94rem;
    line-height: 1.5;
    box-shadow: var(--tc-chat-shadow-sm);
}

.tcChatWindow__loading,
.tcChatWindow__empty{
    background: rgba(111, 60, 255, 0.06);
    color: #61547f;
    border: 1px solid rgba(111,60,255,0.08);
}

.tcChatWindow__error{
    background: rgba(220, 74, 110, 0.08);
    color: #c43d65;
    border: 1px solid rgba(220, 74, 110, 0.12);
}

/* =========================================
   MESSAGE
   ========================================= */

.tcChatMessage{
    display: flex;
    align-items: flex-end;
    gap: 10px;
    max-width: 92%;
}

.tcChatMessage--sent{
    align-self: flex-end;
    justify-content: flex-end;
}

.tcChatMessage--received{
    align-self: flex-start;
    justify-content: flex-start;
}

.tcChatMessage__avatar{
    flex: 0 0 36px;
}

.tcChatMessage__avatar img{
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    background: #ece9f8;
    border: 2px solid rgba(255,255,255,0.9);
    box-shadow: 0 6px 16px rgba(44, 27, 93, 0.10);
}

.tcChatMessage__content{
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.tcChatMessage--sent .tcChatMessage__content{
    align-items: flex-end;
}

.tcChatMessage--received .tcChatMessage__content{
    align-items: flex-start;
}

/* =========================================
   META
   ========================================= */
.tcChatMessage__meta{
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 4px;
    font-size: .78rem;
}

.tcChatMessage__author{
    font-weight: 800;
    color: #2e2547;
}

.tcChatMessage__time{
    color: #9b95af;
    font-weight: 600;
    font-size: .72rem;
}

/* =========================================
   BULLE
   ========================================= */

.tcChatMessage__bubble{
    padding: 12px 14px;
    border-radius: 18px;
    font-size: .94rem;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: var(--tc-chat-shadow-sm);
}

/* Envoyé */
.tcChatMessage--sent .tcChatMessage__bubble{
    background: linear-gradient(135deg, var(--tc-chat-primary) 0%, var(--tc-chat-primary-2) 100%);
    color: #fff;
    border-bottom-right-radius: 6px;
}

/* Reçu */
.tcChatMessage--received .tcChatMessage__bubble{
    background: linear-gradient(135deg, var(--tc-chat-received-bg) 0%, var(--tc-chat-received-bg-2) 100%);
    color: var(--tc-chat-received-text);
    border: 1px solid var(--tc-chat-received-border);
    border-bottom-left-radius: 6px;
}

/* =========================================
   FORMULAIRE
   ========================================= */

.tcChatWindow__form{
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 12px;
    background: rgba(255,255,255,0.96);
    border-top: 1px solid rgba(111, 60, 255, 0.08);
}

.tcChatWindow__form textarea{
    flex: 1;
    min-height: 46px;
    max-height: 120px;
    resize: none;
    padding: 12px 14px;
    border-radius: 16px;
    border: 1.5px solid rgba(111,60,255,0.14);
    outline: none;
    background: #fff;
    color: var(--tc-chat-text);
    font-size: .94rem;
    line-height: 1.45;
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.tcChatWindow__form textarea::placeholder{
    color: #a89fbc;
}

.tcChatWindow__form textarea:hover{
    border-color: rgba(111,60,255,0.22);
}

.tcChatWindow__form textarea:focus{
    border-color: rgba(111,60,255,0.45);
    box-shadow: 0 0 0 4px rgba(111,60,255,0.10);
    background: #fff;
}

.tcChatWindow__form button{
    min-width: 94px;
    height: 46px;
    padding: 0 16px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--tc-chat-primary) 0%, var(--tc-chat-primary-2) 100%);
    color: #fff;
    font-size: .92rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(111,60,255,0.18);
    transition: transform .18s ease, box-shadow .2s ease, filter .2s ease, opacity .2s ease;
}

.tcChatWindow__form button:hover{
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(111,60,255,0.24);
    filter: brightness(1.02);
}

.tcChatWindow__form button:active{
    transform: translateY(0);
}

.tcChatWindow__form button:disabled{
    opacity: .72;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 8px 18px rgba(111,60,255,0.12);
}

/* =========================================
   PETITS ETATS EN PLUS
   ========================================= */

.tcChatWindow__typing{
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(111,60,255,0.06);
    color: var(--tc-chat-text-soft);
    font-size: .84rem;
    font-weight: 700;
}

.tcChatWindow__typingDot{
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--tc-chat-primary);
    animation: tcChatPulse 1.2s infinite ease-in-out;
}

.tcChatWindow__typingDot:nth-child(2){
    animation-delay: .15s;
}

.tcChatWindow__typingDot:nth-child(3){
    animation-delay: .3s;
}

@keyframes tcChatPulse{
    0%, 100%{
        transform: translateY(0);
        opacity: .35;
    }
    50%{
        transform: translateY(-3px);
        opacity: 1;
    }
}

/* =========================================
   MOBILE
   ========================================= */

@media (max-width: 900px){
    #tcChatDock{
        right: 10px;
        left: 10px;
        gap: 10px;
        justify-content: flex-end;
    }

    .tcChatWindow{
        width: 100%;
        max-width: 100%;
        height: 72vh;
    }
}

@media (max-width: 640px){
    #tcChatDock{
        right: 0;
        left: 0;
        bottom: 0;
        gap: 0;
    }

    .tcChatWindow{
        width: 100%;
        max-width: 100%;
        height: 78vh;
        border-radius: 18px 18px 0 0;
    }

    .tcChatWindow__head{
        padding: 12px 14px;
    }

    .tcChatWindow__messages{
        padding: 12px;
    }

    .tcChatMessage{
        max-width: 97%;
    }

    .tcChatWindow__form{
        padding: 10px;
    }

    .tcChatWindow__form button{
        min-width: 82px;
    }
}