/* ============================================================
   GG Agent Styles — Widget Flutuante + Modo Chat IA
   ============================================================ */

/* ── Wrapper principal ─────────────────────────────────────── */
#gg-agent-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse; /* Mantém a bolha na base e o painel expandindo para cima */
    align-items: flex-end;
    gap: 12px;
    font-family: 'Inter', 'Segoe UI', sans-serif;
}

/* ── Bolinha flutuante ─────────────────────────────────────── */
#gg-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    border: 2.5px solid rgba(255, 255, 255, 0.12);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
    overflow: hidden;
    position: relative;
    animation: gg-float 4s ease-in-out infinite;
    background: #1e1e2f;
}

#gg-bubble:hover {
    transform: scale(1.12);
    box-shadow: 0 12px 32px rgba(99, 102, 241, 0.4);
}

#gg-bubble img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Badge de notificação ──────────────────────────────────── */
.gg-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #ef4444, #dc2626);
    color: white;
    font-size: 9px;
    font-weight: 700;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.4);
    opacity: 0;
    transform: scale(0);
    transition: opacity 0.25s, transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 1.5px solid #0f0f1a;
}

.gg-has-unread .gg-badge {
    opacity: 1;
    transform: scale(1);
}

/* ── Painel principal ──────────────────────────────────────── */
#gg-panel {
    width: 360px;
    background: linear-gradient(160deg, #111827 0%, #1a1f2e 60%, #1e1b30 100%);
    color: #e2e8f0;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(99,102,241,0.08);
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    transform-origin: bottom right;
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    max-height: 520px;
}

#gg-panel.gg-expanded {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ── Header do painel ──────────────────────────────────────── */
.gg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px 8px;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
}

.gg-title {
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #f1f5f9;
}

.gg-icon-img-small {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255,255,255,0.15);
}

.gg-online-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 6px rgba(34,197,94,0.7);
    animation: gg-blink 2s ease-in-out infinite;
    flex-shrink: 0;
}

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

.gg-btn-close, .gg-btn-clear {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    font-size: 13px;
    padding: 4px 6px;
    border-radius: 6px;
    line-height: 1;
    transition: color 0.2s, background 0.2s;
}

.gg-btn-close:hover, .gg-btn-clear:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.gg-btn-clear {
    font-size: 10px;
    letter-spacing: 0.2px;
    border: 1px solid rgba(255,255,255,0.1);
}

/* ── Abas (Alertas / Chat) ─────────────────────────────────── */
.gg-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.gg-tab {
    flex: 1;
    padding: 8px 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.4px;
    text-align: center;
    cursor: pointer;
    color: rgba(255,255,255,0.4);
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s, background 0.2s;
    text-transform: uppercase;
    user-select: none;
    background: none;
    border-left: none;
    border-right: none;
    border-top: none;
}

.gg-tab:hover {
    color: rgba(255,255,255,0.75);
    background: rgba(255,255,255,0.04);
}

.gg-tab.active {
    color: #818cf8;
    border-bottom-color: #6366f1;
    background: rgba(99,102,241,0.06);
}

/* ── Aba de Alertas (comportamento original) ───────────────── */
.gg-tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.gg-tab-content.active {
    display: flex;
}

.gg-body {
    padding: 16px;
    font-size: 13px;
    line-height: 1.6;
    flex: 1;
    display: flex;
    align-items: flex-start;
}

.gg-message {
    margin: 0;
    white-space: pre-line;
    color: #cbd5e1;
}

/* ── Aba de Chat ───────────────────────────────────────────── */
.gg-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    min-height: 180px;
    max-height: 320px;
}

.gg-chat-messages::-webkit-scrollbar {
    width: 4px;
}
.gg-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.gg-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 4px;
}

/* Bolhas de mensagem */
.gg-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: gg-msg-in 0.2s ease;
}

.gg-msg.user {
    align-self: flex-end;
    align-items: flex-end;
}

.gg-msg.gg {
    align-self: flex-start;
    align-items: flex-start;
}

.gg-msg-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 12.5px;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
}

.gg-msg.user .gg-msg-bubble {
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(99,102,241,0.35);
}

.gg-msg.gg .gg-msg-bubble {
    background: rgba(255,255,255,0.07);
    color: #e2e8f0;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255,255,255,0.08);
}

.gg-msg-time {
    font-size: 9.5px;
    color: rgba(255,255,255,0.3);
    margin-top: 3px;
    padding: 0 4px;
}

/* Indicador "GG está digitando..." */
.gg-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    padding: 8px 13px;
    background: rgba(255,255,255,0.07);
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(255,255,255,0.08);
}

.gg-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.gg-typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #818cf8;
    display: block;
    animation: gg-dot-bounce 1.2s infinite;
}

.gg-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.gg-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

.gg-typing-label {
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    font-style: italic;
}

/* Mensagem de boas-vindas do chat */
.gg-chat-welcome {
    text-align: center;
    padding: 16px 12px;
    color: rgba(255,255,255,0.35);
    font-size: 12px;
    line-height: 1.6;
}

.gg-chat-welcome strong {
    display: block;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    margin-bottom: 6px;
}

.gg-chat-suggestions {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-top: 10px;
}

.gg-suggestion-btn {
    background: rgba(99,102,241,0.12);
    border: 1px solid rgba(99,102,241,0.25);
    color: #a5b4fc;
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s, color 0.2s;
    font-family: inherit;
}

.gg-suggestion-btn:hover {
    background: rgba(99,102,241,0.22);
    color: #c7d2fe;
}

/* ── Input do chat ─────────────────────────────────────────── */
.gg-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(255,255,255,0.06);
    background: rgba(0,0,0,0.2);
    flex-shrink: 0;
}

.gg-chat-input {
    flex: 1;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 10px;
    padding: 8px 12px;
    color: #e2e8f0;
    font-size: 12.5px;
    font-family: inherit;
    outline: none;
    resize: none;
    max-height: 80px;
    min-height: 36px;
    line-height: 1.4;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.gg-chat-input::placeholder {
    color: rgba(255,255,255,0.3);
}

.gg-chat-input:focus {
    border-color: rgba(99,102,241,0.5);
    box-shadow: 0 0 0 2px rgba(99,102,241,0.12);
}

.gg-chat-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.gg-chat-send {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(99,102,241,0.4);
}

.gg-chat-send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(99,102,241,0.55);
}

.gg-chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.gg-chat-send svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Estados de prioridade ─────────────────────────────────── */
.gg-priority-high #gg-bubble {
    border-color: rgba(239, 68, 68, 0.8);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.55);
    animation: gg-pulse-danger 2s infinite;
}

.gg-priority-high #gg-panel .gg-header {
    background: linear-gradient(to right, rgba(239, 68, 68, 0.2), rgba(0, 0, 0, 0.2));
}

/* ── Animações ─────────────────────────────────────────────── */
@keyframes gg-float {
    0%   { transform: translateY(0); }
    50%  { transform: translateY(-7px); }
    100% { transform: translateY(0); }
}

@keyframes gg-pulse-danger {
    0%   { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70%  { box-shadow: 0 0 0 14px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes gg-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.3; }
}

@keyframes gg-dot-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40%           { transform: translateY(-5px); opacity: 1; }
}

@keyframes gg-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsividade Mobile ─────────────────────────────────── */
@media (max-width: 480px) {
    #gg-agent-wrapper {
        bottom: 16px;
        right: 16px;
    }

    #gg-panel {
        width: calc(100vw - 32px);
        max-height: 480px;
    }

    .gg-chat-messages {
        max-height: 260px;
    }
}
