/* ===== AI Sales Agent Chat Widget ===== */
#ai-sales-agent-chat,
#ai-sales-agent-chat * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

#ai-sales-agent-chat {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
}

/* ===== Action buttons (WA / Room / AI) ===== */
.asa-actions {
    position: absolute;
    bottom: 76px;
    right: 6px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px) scale(0.9);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.asa-actions.asa-actions-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.asa-action {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-radius: 50px;
    padding: 8px 14px 8px 8px;
    cursor: pointer;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.asa-action:hover {
    transform: translateX(-4px) scale(1.03);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.asa-action-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.asa-action-icon svg {
    width: 20px;
    height: 20px;
}

.asa-action-wa .asa-action-icon {
    background: #25D366;
    color: #ffffff;
}

.asa-action-room .asa-action-icon {
    background: #2563eb;
    color: #ffffff;
}

.asa-action-ai .asa-action-icon {
    background: linear-gradient(135deg, #7c3aed, #db2777);
    color: #ffffff;
}

/* ===== Main toggle button ===== */
.asa-main-toggle {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #7c3aed, #db2777);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.asa-main-toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 10px 30px rgba(124, 58, 237, 0.55);
}

.asa-main-icon {
    position: absolute;
    width: 26px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease, transform 0.25s ease;
}

.asa-main-icon svg {
    width: 100%;
    height: 100%;
}

.asa-main-icon.asa-icon-close {
    opacity: 0;
    transform: rotate(-90deg);
}

.asa-main-toggle.asa-open .asa-icon-open {
    opacity: 0;
    transform: rotate(90deg);
}

.asa-main-toggle.asa-open .asa-icon-close {
    opacity: 1;
    transform: rotate(0);
}

/* Pulse animation */
.asa-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(124, 58, 237, 0.5);
    animation: asa-pulse 2s infinite;
    pointer-events: none;
}

@keyframes asa-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    70% { transform: scale(1.35); opacity: 0; }
    100% { transform: scale(1.35); opacity: 0; }
}

/* ===== Chat panel ===== */
.asa-chat-panel {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: asa-slide-up 0.25s ease;
}

@keyframes asa-slide-up {
    from { opacity: 0; transform: translateY(15px); }
    to   { opacity: 1; transform: translateY(0); }
}

.asa-panel-header {
    background: linear-gradient(135deg, #7c3aed, #db2777);
    color: #ffffff;
    padding: 12px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.asa-panel-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.asa-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.asa-avatar svg {
    width: 20px;
    height: 20px;
}

.asa-panel-header h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
}

.asa-panel-header p {
    margin: 2px 0 0;
    font-size: 11px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.asa-panel-header p::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

.asa-panel-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.asa-panel-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages */
.asa-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.asa-message {
    padding: 10px 14px;
    border-radius: 16px;
    max-width: 82%;
    word-wrap: break-word;
    line-height: 1.45;
    font-size: 14px;
    animation: asa-fade-in 0.2s ease;
}

@keyframes asa-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.asa-user {
    background: linear-gradient(135deg, #7c3aed, #db2777);
    color: #ffffff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.asa-assistant {
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.asa-assistant a {
    color: #7c3aed;
    text-decoration: underline;
    word-break: break-all;
}

.asa-assistant img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    margin-top: 6px;
    display: block;
}

.asa-media {
    margin-top: 8px;
}

.asa-pdf-link {
    display: inline-flex;
    align-items: center;
    background: #f1f5f9;
    padding: 6px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: #2563eb;
    font-weight: 600;
    margin-top: 5px;
    font-size: 13px;
}

.asa-pdf-link:hover {
    background: #e2e8f0;
}

/* Typing indicator */
.asa-typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 4px 2px;
}

.asa-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #9ca3af;
    animation: asa-typing 1.2s infinite ease-in-out;
}

.asa-typing span:nth-child(2) { animation-delay: 0.15s; }
.asa-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes asa-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* Form */
.asa-form {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
}

.asa-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    background: #f8fafc;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border 0.2s ease, background 0.2s ease;
}

.asa-input:focus {
    border-color: #7c3aed;
    background: #ffffff;
}

.asa-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #7c3aed, #db2777);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    flex-shrink: 0;
}

.asa-send:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.4);
}

.asa-send svg {
    width: 18px;
    height: 18px;
}

/* Responsive */
@media (max-width: 480px) {
    #ai-sales-agent-chat {
        bottom: 16px;
        right: 16px;
    }

    .asa-action-label {
        display: none;
    }

    .asa-action {
        padding: 6px;
        border-radius: 50%;
    }

    .asa-action-icon {
        width: 38px;
        height: 38px;
    }

    .asa-action:hover {
        transform: scale(1.08);
    }

    .asa-chat-panel {
        width: calc(100vw - 32px);
        height: calc(100vh - 160px);
        bottom: 72px;
    }
}