/* ==========================================================================
   TuBi - Assistente Inteligente & Widget de Suporte (TubeCalendar)
   ========================================================================== */

/* 1. Botão Flutuante (Launcher) */
.tc-tubi-launcher {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    width: 62px;
    height: 62px;
    border-radius: 50%;
    background: linear-gradient(135deg, #18181b, #09090b);
    border: 2px solid #ff1744;
    box-shadow: 0 8px 30px rgba(255, 23, 68, 0.4), 0 4px 12px rgba(0, 0, 0, 0.8);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    outline: none;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.tc-tubi-launcher:hover {
    transform: scale(1.08) translateY(-3px);
    box-shadow: 0 12px 35px rgba(255, 23, 68, 0.6), 0 6px 16px rgba(0, 0, 0, 0.9);
    border-color: #ff5252;
}

.tc-tubi-launcher:active {
    transform: scale(0.92);
}

.tc-tubi-launcher-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    pointer-events: none;
}

.tc-tubi-launcher-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: #10b981;
    border: 2px solid #09090b;
    border-radius: 50%;
    box-shadow: 0 0 10px #10b981;
    animation: tcTubiPulseDot 2s infinite;
}

.tc-tubi-launcher-alert {
    position: absolute;
    bottom: 68px;
    right: 0;
    background: rgba(18, 18, 20, 0.95);
    border: 1px solid rgba(255, 23, 68, 0.4);
    border-radius: 12px;
    padding: 8px 14px;
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(10px);
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
}

.tc-tubi-launcher:hover .tc-tubi-launcher-alert,
.tc-tubi-launcher.has-unread .tc-tubi-launcher-alert {
    opacity: 1;
    transform: translateY(0);
}

/* 2. Janela de Atendimento (Chat Window) */
.tc-tubi-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 99999;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 580px;
    max-height: calc(100vh - 120px);
    background: #09090b;
    border: 1px solid rgba(255, 23, 68, 0.3);
    border-radius: 20px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(255, 23, 68, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(20px);
}

.tc-tubi-window.is-open,
.tc-tubi-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
.tc-tubi-header {
    background: linear-gradient(135deg, #18181b, #09090b);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.tc-tubi-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tc-tubi-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1.5px solid #ff1744;
    object-fit: cover;
}

.tc-tubi-header-title {
    font-size: 14px;
    font-weight: 800;
    color: #ffffff;
    margin: 0;
    line-height: 1.2;
}

.tc-tubi-header-status {
    font-size: 11px;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 0;
}

.tc-tubi-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tc-tubi-btn-icon {
    background: transparent;
    border: none;
    color: #a1a1aa;
    font-size: 14px;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.tc-tubi-btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

/* User Account Quick Card */
.tc-tubi-account-card {
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: #a1a1aa;
    flex-wrap: wrap;
    gap: 6px;
}

.tc-tubi-account-pill {
    background: rgba(255, 23, 68, 0.12);
    border: 1px solid rgba(255, 23, 68, 0.3);
    color: #ff5252;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tc-tubi-credits-pill {
    background: rgba(251, 191, 36, 0.12);
    border: 1px solid rgba(251, 191, 36, 0.3);
    color: #fbbf24;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 10px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

/* Message Thread Body */
.tc-tubi-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.tc-tubi-messages::-webkit-scrollbar {
    width: 5px;
}

.tc-tubi-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}

/* Message Bubbles */
.tc-tubi-msg {
    display: flex;
    gap: 8px;
    max-width: 94%;
    animation: tcTubiMsgFadeIn 0.3s ease;
    scroll-margin-top: 12px;
}

.tc-tubi-msg.bot {
    align-self: flex-start;
    width: 100%;
}

.tc-tubi-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
    width: fit-content;
    max-width: 85%;
}

.tc-tubi-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-top: 2px;
    border: 1px solid rgba(255, 23, 68, 0.4);
}

.tc-tubi-bubble,
.tc-tubi-msg-bubble {
    padding: 12px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
    color: #f4f4f5;
    box-sizing: border-box;
    width: 100%;
}

.tc-tubi-msg.bot .tc-tubi-bubble,
.tc-tubi-msg.bot .tc-tubi-msg-bubble {
    background: #18181b;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top-left-radius: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    word-break: break-word;
}

.tc-tubi-msg.user .tc-tubi-bubble,
.tc-tubi-msg.user .tc-tubi-msg-bubble {
    background: linear-gradient(135deg, #ff1744, #c62828);
    color: #ffffff;
    border-top-right-radius: 4px;
    font-weight: 500;
    width: fit-content;
    min-width: 36px;
    max-width: 100%;
    box-shadow: 0 4px 14px rgba(255, 23, 68, 0.25);
    word-break: normal;
    overflow-wrap: break-word;
    white-space: normal;
    text-align: left;
}

/* Quick Action Options (Buttons/Pills) */
.tc-tubi-options-box,
.tc-tubi-options {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 12px;
    width: 100%;
}

.tc-tubi-option-btn,
.tc-tubi-option-chip {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 10px 12px;
    color: #f4f4f5;
    font-size: 12.5px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
    line-height: 1.35;
}

.tc-tubi-option-btn:hover,
.tc-tubi-option-chip:hover {
    background: rgba(255, 23, 68, 0.16);
    border-color: rgba(255, 23, 68, 0.45);
    color: #ffffff;
    transform: translateX(3px);
    box-shadow: 0 3px 12px rgba(255, 23, 68, 0.2);
}

.tc-tubi-option-btn:active,
.tc-tubi-option-chip:active {
    transform: scale(0.98);
}

/* Interactive Action Buttons inside responses */
.tc-tubi-action-btn {
    background: linear-gradient(135deg, #ff1744, #d50000);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 14px rgba(255, 23, 68, 0.35);
}

.tc-tubi-action-btn:hover {
    background: linear-gradient(135deg, #ff5252, #ff1744);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 23, 68, 0.5);
}

.tc-tubi-action-btn:active {
    transform: scale(0.98);
}

.tc-tubi-action-btn.secondary {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e4e4e7;
    box-shadow: none;
}

.tc-tubi-action-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
}

/* Attachment button */
.tc-tubi-attach-btn,
#tcTubiAttachBtn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #a1a1aa;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.tc-tubi-attach-btn:hover,
#tcTubiAttachBtn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    border-color: rgba(255, 23, 68, 0.5);
    transform: scale(1.05);
}

/* Typing Indicator */
.tc-tubi-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    background: #18181b;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    border-top-left-radius: 4px;
    width: fit-content;
}

.tc-tubi-typing-dot {
    width: 6px;
    height: 6px;
    background: #a1a1aa;
    border-radius: 50%;
    animation: tcTubiBlink 1.4s infinite both;
}

.tc-tubi-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.tc-tubi-typing-dot:nth-child(3) { animation-delay: 0.4s; }

/* Input Footer */
.tc-tubi-footer {
    background: #121215;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tc-tubi-input {
    flex: 1;
    background: #09090b;
    border: 1px solid #27272a;
    border-radius: 12px;
    padding: 10px 14px;
    color: #ffffff;
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
    resize: none;
    height: 40px;
    line-height: 20px;
    box-sizing: border-box;
}

.tc-tubi-input:focus {
    border-color: #ff1744;
    box-shadow: 0 0 10px rgba(255, 23, 68, 0.2);
}

.tc-tubi-send-btn {
    background: #ff1744;
    color: #ffffff;
    border: none;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.tc-tubi-send-btn:hover {
    background: #ff5252;
    transform: scale(1.05);
}

.tc-tubi-send-btn:active {
    transform: scale(0.92);
}

/* Animations */
@keyframes tcTubiPulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.25); opacity: 0.8; }
}

@keyframes tcTubiMsgFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes tcTubiBlink {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.1); }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .tc-tubi-launcher {
        bottom: 16px;
        right: 16px;
        width: 54px;
        height: 54px;
    }

    .tc-tubi-launcher-avatar {
        width: 46px;
        height: 46px;
    }

    .tc-tubi-window {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 90vh;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
    }
}
