/* PC Gemini Chat — Frontend Widget */

.pc-chat-widget {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: var(--pc-chat-width, 480px);
    height: var(--pc-chat-height, 520px);
    max-height: 80vh;
    border-radius: var(--pc-chat-radius, 16px);
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: var(--pc-chat-font-size, 14px);
    box-sizing: border-box;
}

/* Avatar bot nei messaggi */
.pc-chat-msg--bot {
    align-items: flex-end;
    gap: 8px;
}
.pc-chat-bot-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    margin-bottom: 2px;
}

/* Topbar */
.pc-chat-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--pc-chat-primary, #172C84);
    color: #fff;
    flex-shrink: 0;
}
.pc-chat-topbar-identity {
    display: flex;
    align-items: center;
    gap: 10px;
}
.pc-chat-topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,.4);
    flex-shrink: 0;
}
.pc-chat-bot-name {
    font-weight: 600;
    font-size: calc(var(--pc-chat-font-size, 14px) + 1px);
    letter-spacing: .2px;
}
.pc-chat-topbar-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}
.pc-chat-reset-btn,
.pc-chat-tts-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,.75);
    cursor: pointer;
    padding: 5px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: color .2s, background .2s;
}
.pc-chat-reset-btn:hover,
.pc-chat-tts-btn:hover {
    color: #fff;
    background: rgba(255,255,255,.15);
}
.pc-chat-tts-btn.pc-chat-tts--active {
    color: #fff;
    background: rgba(255,255,255,.25);
}

/* Messaggi */
.pc-chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--pc-chat-bg, #f5f6fa);
}
.pc-chat-messages::-webkit-scrollbar { width: 4px; }
.pc-chat-messages::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }

.pc-chat-msg { display: flex; }
.pc-chat-msg--user { justify-content: flex-end; }
.pc-chat-msg--bot  { justify-content: flex-start; }

.pc-chat-bubble {
    max-width: 78%;
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    font-size: var(--pc-chat-font-size, 14px);
}
.pc-chat-msg--user .pc-chat-bubble {
    background: var(--pc-chat-user-bubble, var(--pc-chat-primary, #172C84));
    color: var(--pc-chat-user-text, #fff);
    border-bottom-right-radius: 4px;
}
.pc-chat-msg--bot .pc-chat-bubble {
    background: var(--pc-chat-bot-bubble, #fff);
    color: var(--pc-chat-bot-text, #1d2327);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

/* Typing indicator */
.pc-chat-typing .pc-chat-bubble {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 12px 16px;
}
.pc-chat-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #aab;
    animation: pc-chat-bounce .9s infinite ease-in-out;
}
.pc-chat-dot:nth-child(2) { animation-delay: .15s; }
.pc-chat-dot:nth-child(3) { animation-delay: .3s; }
@keyframes pc-chat-bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40%            { transform: translateY(-6px); }
}

/* Input area */
.pc-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.pc-chat-input {
    flex: 1;
    resize: none;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: var(--pc-chat-font-size, 14px);
    font-family: inherit;
    line-height: 1.5;
    max-height: 120px;
    overflow-y: auto;
    outline: none;
    transition: border-color .2s;
}
.pc-chat-input:focus {
    border-color: var(--pc-chat-primary, #172C84);
}
.pc-chat-send-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: var(--pc-chat-primary, #172C84);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .2s, transform .15s;
}
.pc-chat-send-btn:hover   { opacity: .88; }
.pc-chat-send-btn:active  { transform: scale(.94); }
.pc-chat-send-btn:disabled{ opacity: .45; cursor: not-allowed; }

/* Microfono */
.pc-chat-mic-btn {
    flex-shrink: 0 !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 10px !important;
    border: 1px solid #d1d5db !important;
    background: #fff !important;
    color: #6b7280 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background .2s, color .2s, border-color .2s;
    visibility: visible !important;
    opacity: 1 !important;
    padding: 0 !important;
    margin: 0 !important;
}
.pc-chat-mic-btn svg, .pc-chat-mic-btn { line-height: 1 !important; }
.pc-chat-mic-btn:hover {
    border-color: var(--pc-chat-primary, #172C84) !important;
    color: var(--pc-chat-primary, #172C84) !important;
}
.pc-chat-mic-btn.pc-chat-mic--active {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    color: #fff !important;
    animation: pc-chat-pulse 1s infinite;
}
@keyframes pc-chat-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); }
    50%       { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

/* Markdown base */
.pc-chat-bubble p  { margin: 0 0 6px; }
.pc-chat-bubble p:last-child { margin-bottom: 0; }
.pc-chat-bubble ul, .pc-chat-bubble ol { margin: 4px 0; padding-left: 18px; }
.pc-chat-bubble code { background: rgba(0,0,0,.07); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.pc-chat-bubble strong { font-weight: 600; }
