/* ==========================================================================
   Otis — assistente de IA do ANT-Stock
   Usa exclusivamente tokens já definidos em variables.css (cores, radius,
   sombras, tipografia, motion) e as keyframes de animations.css.
   ========================================================================== */

.otis-root {
    position: relative;
    z-index: 900; /* abaixo do toast (1000), acima do restante da UI */
}

/* ── Bolha flutuante ─────────────────────────────────────────────────── */
.otis-bubble-btn {
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--green-400), var(--green-600));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-green);
    transition:
        transform var(--dur) var(--ease),
        box-shadow var(--dur) var(--ease);
    z-index: 900;
}
.otis-bubble-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 16px 36px rgba(16, 185, 129, 0.38);
}
.otis-bubble-btn:active {
    transform: scale(0.97);
}
.otis-bubble-btn .otis-star {
    width: 24px;
    height: 24px;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.12));
    transition: transform var(--dur) var(--ease);
}
.otis-bubble-btn:hover .otis-star {
    transform: scale(1.08) rotate(8deg);
}
.otis-bubble-btn-active .otis-star {
    transform: rotate(90deg) scale(0.94);
}
.otis-bubble-btn-active:hover .otis-star {
    transform: rotate(90deg) scale(1);
}

/* Anel discreto de "vivo" — reaproveita a keyframe pulseRing já existente. */
.otis-spinner-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
}
.otis-bubble-btn:not(.otis-bubble-btn-active) .otis-spinner-ring {
    animation: pulseRing 2.6s ease-out infinite;
}

/* Estado de processamento: leve rotação contínua da própria bolha. */
.otis-bubble-btn-processing {
    animation: otisProcessing 1.1s var(--ease) infinite;
}
@keyframes otisProcessing {
    0%,
    100% {
        box-shadow: var(--shadow-green);
    }
    50% {
        box-shadow: 0 12px 32px rgba(16, 185, 129, 0.55);
    }
}

@media (max-width: 640px) {
    .otis-bubble-btn {
        right: 16px;
        bottom: 16px;
        width: 52px;
        height: 52px;
    }
}

/* ── Painel do chat ──────────────────────────────────────────────────── */
.otis-panel {
    position: fixed;
    right: 24px;
    bottom: 92px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: min(600px, calc(100vh - 132px));
    max-height: 600px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 899;

    opacity: 0;
    transform: translateY(16px) scale(0.97);
    pointer-events: none;
    transform-origin: bottom right;
    transition:
        opacity var(--dur) var(--ease),
        transform var(--dur) var(--ease);
}
.otis-panel-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

@media (max-width: 640px) {
    .otis-panel {
        right: 12px;
        left: 12px;
        bottom: 84px;
        width: auto;
        max-width: none;
        height: min(72vh, 560px);
    }
}

/* Header */
.otis-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--sidebar-bg);
    color: #fff;
    flex-shrink: 0;
}
.otis-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
}
.otis-title-icon {
    display: inline-flex;
    color: var(--green-400);
}
.otis-header-actions {
    display: flex;
    align-items: center;
    gap: 2px;
}
.otis-icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.75);
    transition:
        background var(--dur-fast) var(--ease),
        color var(--dur-fast) var(--ease);
}
.otis-icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.otis-icon-btn i {
    width: 16px;
    height: 16px;
}

/* Área de mensagens */
.otis-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--bg);
}

.otis-empty {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 2px 2px;
    animation: fadeUp var(--dur) var(--ease) both;
}
.otis-empty-icon {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--green-50);
    color: var(--green-600);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}
.otis-empty-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 14.5px;
    color: var(--text);
}
.otis-empty-text {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}
.otis-suggestions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    margin-top: 6px;
}
.otis-suggestion {
    text-align: left;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 13px;
    transition:
        border-color var(--dur-fast) var(--ease),
        background var(--dur-fast) var(--ease);
}
.otis-suggestion:hover {
    border-color: var(--green-400);
    background: var(--green-50);
}

/* Mensagens */
.otis-msg {
    display: flex;
    animation: fadeUp var(--dur) var(--ease) both;
}
.otis-msg-user {
    justify-content: flex-end;
}
.otis-msg-assistant {
    justify-content: flex-start;
}
.otis-bubble {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13.5px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.otis-msg-user .otis-bubble {
    background: var(--green-500);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.otis-msg-assistant .otis-bubble {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

/* Indicador de digitação */
.otis-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 13px 16px;
}
.otis-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-soft);
    animation: otisDotBounce 1.2s ease-in-out infinite;
}
.otis-dot:nth-child(2) {
    animation-delay: 0.15s;
}
.otis-dot:nth-child(3) {
    animation-delay: 0.3s;
}
@keyframes otisDotBounce {
    0%,
    60%,
    100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-3px);
    }
}

/* Erro de comunicação */
.otis-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: var(--radius);
    background: #fde6e6;
    color: #b91c1c;
    font-size: 13px;
    animation: fadeUp var(--dur) var(--ease) both;
}
.otis-error i {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* Campo de mensagem */
.otis-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: #fff;
    flex-shrink: 0;
}
.otis-input {
    flex: 1;
    resize: none;
    max-height: 120px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-size: 13.5px;
    line-height: 1.4;
    background: var(--bg);
    transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.otis-input:focus {
    outline: none;
    border-color: var(--green-500);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
    background: #fff;
}
.otis-input:disabled {
    opacity: 0.7;
}
.otis-send-btn {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--green-500);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background var(--dur-fast) var(--ease),
        transform var(--dur-fast) var(--ease),
        opacity var(--dur) var(--ease);
}
.otis-send-btn:hover:not(:disabled) {
    background: var(--green-600);
}
.otis-send-btn:active:not(:disabled) {
    transform: scale(0.94);
}
.otis-send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.otis-send-btn i {
    width: 17px;
    height: 17px;
}

/* Scrollbar discreta na área de mensagens (mantém o resto do app como está) */
.otis-messages::-webkit-scrollbar {
    width: 6px;
}
.otis-messages::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: var(--radius-pill);
}
