/* =========================================================
   SofIA Publica — Widget flutuante para paginas publicas
   ========================================================= */

/* ── Botao flutuante ──────────────────────────────────────── */
@keyframes pgcRingPulse {
    0%   { transform: scale(1);    opacity: 0.55; }
    60%  { transform: scale(1.55); opacity: 0;    }
    100% { transform: scale(1.55); opacity: 0;    }
}

#pgcBtn {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 9998;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, #29707D 0%, #1b6e7a 100%);
    color: #fff;
    border: 3px solid rgba(255,255,255,0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow:
        0 4px 18px rgba(0,0,0,0.28),
        0 6px 28px rgba(41,112,125,0.4);
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.25s ease;
    user-select: none;
}

.pgc-btn-icon {
    font-size: 1.4rem;
    line-height: 1;
}

/* Anel pulsante */
#pgcBtn::before {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2.5px solid rgba(41,112,125,0.55);
    animation: pgcRingPulse 2.4s ease-out infinite;
    pointer-events: none;
}

#pgcBtn:hover {
    transform: scale(1.08);
    box-shadow:
        0 8px 24px rgba(0,0,0,0.3),
        0 10px 36px rgba(41,112,125,0.5);
}
#pgcBtn.pgc-open {
    transform: rotate(15deg) scale(0.9);
}
#pgcBtn.pgc-open::before { animation: none; opacity: 0; }

/* ── Painel ───────────────────────────────────────────────── */
#pgcPanel {
    position: fixed;
    bottom: 95px;
    right: 28px;
    z-index: 9999;
    width: 360px;
    height: 520px;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 16px 56px rgba(0,0,0,0.16), 0 4px 16px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: pgcSlideIn 0.22s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes pgcSlideIn {
    from { opacity: 0; transform: scale(0.85) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.pgc-hidden { display: none !important; }

/* ── Cabecalho ────────────────────────────────────────────── */
.pgc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, #29707D, #1b6e7a);
    color: #fff;
    flex-shrink: 0;
}

.pgc-header-info {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.pgc-header-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.pgc-header-title {
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.2;
}

.pgc-header-sub {
    font-size: 0.68rem;
    opacity: 0.8;
    margin-top: 1px;
}

.pgc-close {
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: background 0.18s;
    flex-shrink: 0;
}
.pgc-close:hover { background: rgba(255,255,255,0.28); }

/* ── Welcome ──────────────────────────────────────────────── */
.pgc-sofia-welcome {
    text-align: center;
    padding: 1.5rem 1rem 1rem;
}

.pgc-sofia-welcome-icon {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #29707D, #1b6e7a);
    color: #fff;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem;
}

.pgc-sofia-welcome h4 {
    margin: 0 0 0.4rem;
    font-size: 1rem;
    color: #0e4d56;
}

.pgc-sofia-welcome p {
    font-size: 0.78rem;
    color: #6b7280;
    line-height: 1.5;
    margin: 0 0 1rem;
}

.pgc-sofia-suggestions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pgc-sofia-suggestion {
    background: rgba(41,112,125,.06);
    border: 1px solid rgba(41,112,125,.18);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 0.76rem;
    color: #1b6e7a;
    cursor: pointer;
    text-align: left;
    transition: background 0.15s, border-color 0.15s;
}
.pgc-sofia-suggestion:hover {
    background: rgba(41,112,125,.12);
    border-color: #29707D;
}

/* ── Mensagens ────────────────────────────────────────────── */
.pgc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #f8fafc;
    min-height: 120px;
}

.pgc-msg {
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 14px;
    font-size: 0.8rem;
    line-height: 1.5;
    word-break: break-word;
}

.pgc-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #29707D, #1b6e7a);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.pgc-msg-bot {
    align-self: flex-start;
    background: #fff;
    color: #1f2937;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border: 1px solid #e5e7eb;
}

.pgc-msg-time {
    font-size: 0.6rem;
    opacity: 0.5;
    text-align: right;
    margin-top: 4px;
}

/* Bot message formatting */
.pgc-msg-bot strong { font-weight: 700; }
.pgc-msg-bot pre {
    background: #0e4d56;
    color: #e2e8f0;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 0.72rem;
    overflow-x: auto;
    margin: 6px 0;
}
.pgc-msg-bot code {
    background: #f1f5f9;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.74rem;
}
.pgc-msg-bot table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.72rem;
    margin: 6px 0;
}
.pgc-msg-bot th, .pgc-msg-bot td {
    border: 1px solid #e5e7eb;
    padding: 4px 6px;
    text-align: left;
}
.pgc-msg-bot th,
[data-theme="dark"] .pgc-msg-bot th {
    background: #29707D !important;
    background-color: #29707D !important;
    color: #fff !important;
    font-weight: 600;
}
.pgc-msg-bot ul {
    margin: 4px 0;
    padding-left: 18px;
}
.pgc-msg-bot li {
    margin-bottom: 2px;
}

/* ── Typing ───────────────────────────────────────────────── */
.pgc-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
    background: #fff;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    border: 1px solid #e5e7eb;
}

.pgc-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #1b6e7a;
    animation: pgcTypingBounce 1.2s ease-in-out infinite;
}
.pgc-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.pgc-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes pgcTypingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Input area ───────────────────────────────────────────── */
.pgc-input-area {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}

.pgc-clear-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}
.pgc-clear-btn:hover {
    color: #ef4444;
    background: #fef2f2;
}

.pgc-form-inline {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    flex: 1;
}

.pgc-textarea {
    flex: 1;
    resize: none;
    padding: 7px 10px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.8rem;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.18s;
    max-height: 80px;
    background: #f9fafb;
    font-family: inherit;
}
.pgc-textarea:focus { border-color: #29707D; background: #fff; }

.pgc-send-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #29707D, #1b6e7a);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.18s, transform 0.15s;
}
.pgc-send-btn:hover:not(:disabled) { opacity: 0.9; transform: scale(1.05); }
.pgc-send-btn:disabled { background: #d1d5db; cursor: not-allowed; }

/* ── Responsivo ───────────────────────────────────────────── */
@media (max-width: 480px) {
    #pgcPanel {
        right: 12px;
        bottom: 85px;
        width: calc(100vw - 24px);
        height: 70vh;
    }
    #pgcBtn { right: 16px; bottom: 20px; }
}
