/* ====================================
   MedCare IA - Chat APS Flutuante
   ==================================== */

/* Botão Flutuante */
.aps-chat-fab {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0f766e, #115e59);
    color: #fff;
    border: none;
    box-shadow: 0 6px 24px rgba(15, 118, 110, 0.45), 0 3px 10px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1050;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    animation: aps-fab-pulse 3s infinite;
}

.aps-chat-fab i {
    font-size: 34px;
}

.aps-chat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 32px rgba(15, 118, 110, 0.55);
    animation: none;
}

.aps-chat-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 16px;
    height: 16px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
}

@keyframes aps-fab-pulse {
    0%, 100% { box-shadow: 0 6px 24px rgba(15, 118, 110, 0.45); }
    50% { box-shadow: 0 6px 36px rgba(15, 118, 110, 0.65); }
}

/* Chat Panel */
.aps-chat-panel {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 520px;
    height: 720px;
    max-height: calc(100vh - 56px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 10px 48px rgba(0,0,0,0.16), 0 3px 14px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    z-index: 1060;
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.aps-chat-panel.open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Overlay */
.aps-chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.2);
    z-index: 1055;
    backdrop-filter: blur(2px);
    animation: aps-fade-in 0.2s ease;
}

@keyframes aps-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Header */
.aps-chat-header {
    background: linear-gradient(135deg, #0f766e, #115e59);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.aps-chat-avatar {
    width: 42px;
    height: 42px;
    background: rgba(255,255,255,0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aps-chat-avatar i {
    font-size: 24px;
    color: #fff;
}

.aps-chat-header h6 {
    font-size: 1rem;
}

.aps-chat-header small {
    font-size: 0.8rem;
}

.aps-chat-header-btn {
    background: rgba(255,255,255,0.1);
    border: none;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.aps-chat-header-btn:hover {
    background: rgba(255,255,255,0.2);
}

.aps-chat-header-btn i {
    font-size: 20px;
}

/* Messages Area */
.aps-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: #f8fafc;
    scroll-behavior: smooth;
}

.aps-chat-messages::-webkit-scrollbar {
    width: 5px;
}

.aps-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

/* Welcome */
.aps-chat-welcome {
    text-align: center;
    padding: 32px 20px;
}

.aps-chat-welcome h6 {
    font-size: 1.1rem;
}

.aps-chat-welcome p {
    font-size: 0.9rem;
}

.aps-chat-welcome-icon {
    width: 76px;
    height: 76px;
    background: linear-gradient(135deg, #f0fdfa, #ccfbf1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 14px;
    border: 2px solid #99f6e4;
}

.aps-chat-welcome-icon i {
    font-size: 38px;
    color: #0f766e;
}

/* Suggestions */
.aps-chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.aps-chat-suggestion {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 22px;
    padding: 8px 16px;
    font-size: 0.85rem;
    color: #475569;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.aps-chat-suggestion:hover {
    background: #f0fdfa;
    border-color: #0f766e;
    color: #0f766e;
}

.aps-chat-suggestion i {
    font-size: 16px;
}

/* Messages */
.aps-chat-msg {
    display: flex;
    gap: 10px;
    max-width: 92%;
    animation: aps-msg-in 0.3s ease;
}

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

.aps-chat-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.aps-chat-msg-ai {
    align-self: flex-start;
}

.aps-chat-msg-avatar {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background: linear-gradient(135deg, #0f766e, #115e59);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 2px;
}

.aps-chat-msg-avatar i {
    font-size: 16px;
    color: #fff;
}

.aps-chat-msg-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 0.92rem;
    line-height: 1.55;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.aps-chat-msg-user .aps-chat-msg-bubble {
    background: #0f766e;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.aps-chat-msg-ai .aps-chat-msg-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.aps-chat-msg-ai .aps-chat-msg-bubble h6 {
    font-size: 0.92rem;
    color: #0f766e;
}

.aps-chat-msg-ai .aps-chat-msg-bubble strong {
    color: #0f766e;
}

.aps-chat-msg-ai .aps-chat-msg-bubble ul {
    margin-bottom: 6px !important;
}

.aps-chat-msg-ai .aps-chat-msg-bubble li {
    font-size: 0.88rem;
    margin-bottom: 3px;
}

/* Typing indicator */
.aps-chat-typing {
    display: inline-flex;
    gap: 5px;
    padding: 5px 0;
}

.aps-chat-typing span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: aps-typing 1.4s infinite ease-in-out;
}

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

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

/* Input Area */
.aps-chat-input-area {
    padding: 14px 20px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.aps-chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: #f1f5f9;
    border-radius: 14px;
    padding: 5px 5px 5px 16px;
    border: 1px solid #e2e8f0;
    transition: border-color 0.2s;
}

.aps-chat-input-wrapper:focus-within {
    border-color: #0f766e;
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.08);
}

.aps-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-size: 0.95rem;
    max-height: 90px;
    line-height: 1.45;
    padding: 8px 0;
    color: #1e293b;
}

.aps-chat-input::placeholder {
    color: #94a3b8;
}

.aps-chat-send-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    background: #0f766e;
    color: #fff;
    border: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.aps-chat-send-btn:hover:not(:disabled) {
    background: #115e59;
    transform: scale(1.05);
}

.aps-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.aps-chat-send-btn i {
    font-size: 20px;
}

/* Mobile */
@media (max-width: 576px) {
    .aps-chat-panel {
        width: calc(100vw - 16px);
        height: calc(100vh - 16px);
        max-height: calc(100vh - 16px);
        bottom: 8px;
        right: 8px;
        border-radius: 14px;
    }

    .aps-chat-fab {
        bottom: 20px;
        right: 20px;
        width: 64px;
        height: 64px;
    }

    .aps-chat-fab i {
        font-size: 30px;
    }
}
