/* CSS do Chatbot Mestre das Alianças */

#chatbot-mestre-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Botão Flutuante e Tooltip */
.mestre-chat-trigger-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

/* Tooltip / Balão de boas-vindas flutuante */
.mestre-chat-tooltip {
    position: absolute;
    bottom: 100%;
    right: 0;
    margin-bottom: 12px;
    background: #ffffff;
    color: #451a03;
    padding: 8px 14px;
    border-radius: 12px;
    font-size: 12.5px;
    font-weight: 600;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.15), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #fde68a;
    white-space: nowrap;
    animation: mestreFloatTooltip 3s ease-in-out infinite;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.mestre-chat-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 24px;
    border-width: 6px;
    border-style: solid;
    border-color: #ffffff transparent transparent transparent;
}

@keyframes mestreFloatTooltip {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.mestre-chat-trigger {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: #ffffff;
    border: 2px solid #fcd34d;
    border-radius: 50px;
    padding: 10px 18px 10px 12px;
    box-shadow: 0 10px 25px -5px rgba(180, 83, 9, 0.4), 0 8px 10px -6px rgba(180, 83, 9, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    position: relative;
}

.mestre-chat-trigger::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50px;
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.5), rgba(217, 119, 6, 0.2));
    z-index: -1;
    animation: mestreGlowPulse 2s infinite;
}

@keyframes mestreGlowPulse {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.05); opacity: 0.2; }
    100% { transform: scale(1); opacity: 0.8; }
}

.mestre-chat-trigger:hover {
    transform: translateY(-2px) scale(1.04);
    background: linear-gradient(135deg, #b45309 0%, #92400e 100%);
    box-shadow: 0 15px 30px -5px rgba(180, 83, 9, 0.6);
}

.mestre-chat-trigger:active {
    transform: scale(0.97);
}

.mestre-chat-avatar-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mestre-chat-trigger img {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fef3c7;
}

.mestre-online-badge {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    background-color: #34d399;
    border: 2px solid #b45309;
    border-radius: 50%;
}

.mestre-chat-icon-badge {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
}

.mestre-chat-trigger-text {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.mestre-chat-trigger-title {
    font-size: 13px;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: 0.2px;
}

.mestre-chat-trigger-subtitle {
    font-size: 10px;
    color: #fef3c7;
    font-weight: 600;
}

/* Janela do Chat */
.mestre-chat-window {
    width: 340px;
    max-width: calc(100vw - 32px);
    background-color: #ffffff;
    border-radius: 18px;
    box-shadow: 0 20px 35px -5px rgba(0, 0, 0, 0.2), 0 10px 15px -5px rgba(0, 0, 0, 0.1);
    border: 1px solid #fde68a;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 12px;
    animation: mestreFadeInUp 0.3s ease-out forwards;
}

@keyframes mestreFadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Cabeçalho */
.mestre-chat-header {
    background: linear-gradient(135deg, #b45309 0%, #d97706 50%, #92400e 100%);
    color: #ffffff;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mestre-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mestre-chat-header-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #fcd34d;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.mestre-chat-title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
}

.mestre-chat-status {
    color: #fef3c7;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 3px;
}

.mestre-status-dot {
    width: 8px;
    height: 8px;
    background-color: #34d399;
    border-radius: 50%;
    display: inline-block;
    animation: mestrePulse 2s infinite;
}

@keyframes mestrePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

.mestre-chat-close-btn {
    background: transparent;
    border: none;
    color: #fef3c7;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background-color 0.2s;
}

.mestre-chat-close-btn:hover {
    color: #ffffff;
    background-color: rgba(255, 255, 255, 0.15);
}

/* Área de Mensagens */
.mestre-chat-messages {
    height: 380px;
    overflow-y: auto;
    padding: 16px;
    background-color: rgba(254, 243, 199, 0.25);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom Scrollbar */
.mestre-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.mestre-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.mestre-chat-messages::-webkit-scrollbar-thumb {
    background: #fcd34d;
    border-radius: 10px;
}

/* Balões de Mensagem */
.mestre-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.45;
    word-break: break-word;
    white-space: pre-wrap;
}

.mestre-msg-ia {
    background-color: #ffffff;
    border: 1px solid #fef3c7;
    color: #1f2937;
    align-self: flex-start;
    border-top-left-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.mestre-msg-usuario {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: #ffffff;
    align-self: flex-end;
    border-top-right-radius: 2px;
    box-shadow: 0 2px 4px rgba(180, 83, 9, 0.15);
}

.mestre-msg strong {
    font-weight: 700;
    color: #451a03;
}

.mestre-msg-usuario strong {
    color: #ffffff;
}

.mestre-msg a {
    color: #b45309;
    text-decoration: underline;
    font-weight: 600;
    transition: color 0.2s;
}

.mestre-msg a:hover {
    color: #78350f;
}

.mestre-msg-usuario a {
    color: #fef3c7;
}

/* Indicator Carregando */
.mestre-typing-indicator {
    background-color: #ffffff;
    border: 1px solid #fde68a;
    color: #d97706;
    align-self: flex-start;
    border-radius: 14px;
    border-top-left-radius: 2px;
    padding: 10px 14px;
    font-size: 13px;
    display: flex;
    gap: 4px;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.mestre-bounce {
    animation: mestreBounce 1.4s infinite ease-in-out both;
}

.mestre-bounce-1 { animation-delay: 0s; }
.mestre-bounce-2 { animation-delay: 0.2s; }
.mestre-bounce-3 { animation-delay: 0.4s; }

@keyframes mestreBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1.1); opacity: 1; }
}

/* Formulário de Envio */
.mestre-chat-form {
    padding: 10px 12px;
    background-color: #ffffff;
    border-top: 1px solid #fef3c7;
    display: flex;
    gap: 8px;
    align-items: center;
}

.mestre-chat-input {
    flex: 1;
    background-color: rgba(254, 243, 199, 0.3);
    border: 1px solid #fde68a;
    font-size: 13.5px;
    border-radius: 24px;
    padding: 9px 16px;
    outline: none;
    color: #1f2937;
    transition: all 0.2s ease;
}

.mestre-chat-input:focus {
    background-color: #ffffff;
    border-color: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
}

.mestre-chat-send-btn {
    background: #d97706;
    color: #ffffff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 2px 5px rgba(217, 119, 6, 0.3);
}

.mestre-chat-send-btn:hover:not(:disabled) {
    background: #b45309;
    transform: scale(1.05);
}

.mestre-chat-send-btn:disabled {
    background: #d1d5db;
    cursor: not-allowed;
    box-shadow: none;
}

/* Responsividade */
@media (max-width: 480px) {
    #chatbot-mestre-container {
        bottom: 16px;
        right: 16px;
    }
    .mestre-chat-window {
        width: calc(100vw - 32px);
    }
    .mestre-chat-trigger span {
        display: none;
    }
}
