/* AI Smart Assistant — chat widget (v1.5.0 modern redesign) */
.asa-widget {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
    font-size: 14px;
    color: #1f2937;
    line-height: 1.5;
}

.asa-widget *,
.asa-widget *::before,
.asa-widget *::after {
    box-sizing: border-box;
}

/* ============================================
   Launcher bubble (bottom-right circle)
   ============================================ */
.asa-bubble {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22d3ee 0%, #06b6d4 60%, #0891b2 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow:
        0 8px 24px rgba(6, 182, 212, 0.4),
        0 2px 6px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
}

.asa-bubble:hover {
    transform: translateY(-2px) scale(1.04);
    box-shadow:
        0 12px 32px rgba(6, 182, 212, 0.5),
        0 4px 8px rgba(0, 0, 0, 0.1);
}

.asa-bubble:active {
    transform: translateY(0) scale(0.98);
}

.asa-bubble .asa-icon-chat,
.asa-bubble .asa-icon-close {
    position: absolute;
    width: 28px;
    height: 28px;
    transition: opacity 0.15s ease, transform 0.2s ease;
}

.asa-bubble .asa-icon-chat {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.asa-bubble .asa-icon-close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.6);
}

.asa-widget:not(.asa-closed) .asa-bubble .asa-icon-chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.6);
}

.asa-widget:not(.asa-closed) .asa-bubble .asa-icon-close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* "Contact us" tooltip on hover (only when closed) */
.asa-widget.asa-closed .asa-bubble::after {
    content: "Contact us";
    position: absolute;
    right: 76px;
    top: 50%;
    transform: translateY(-50%);
    background: #1f2937;
    color: #fff;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.asa-widget.asa-closed .asa-bubble::before {
    content: "";
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%);
    border: 6px solid transparent;
    border-left-color: #1f2937;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.asa-widget.asa-closed .asa-bubble:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(-4px);
}

.asa-widget.asa-closed .asa-bubble:hover::before {
    opacity: 1;
}

/* ============================================
   Chat panel
   ============================================ */
.asa-panel {
    position: absolute;
    right: 0;
    bottom: 80px;
    width: 380px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #ffffff;
    border-radius: 18px;
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.18),
        0 4px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(8px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.asa-widget:not(.asa-closed) .asa-panel {
    /* v1.6.0: panel inherits widget opacity (set by --asa-idle-opacity). */
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* v1.6.0: dim the widget when mouse leaves it (visitor is reading content elsewhere). */
.asa-widget {
    --asa-idle-opacity: 0.5;
    transition: opacity 0.25s ease;
}
.asa-widget:not(.asa-closed) {
    opacity: var(--asa-idle-opacity);
}
.asa-widget:hover {
    opacity: 1 !important;
}

/* ============================================
   Header
   ============================================ */
.asa-header {
    background: linear-gradient(135deg, #22d3ee 0%, #06b6d4 100%);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.asa-header::after {
    content: "";
    position: absolute;
    top: -50%;
    right: -10%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
    pointer-events: none;
}

.asa-title {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    position: relative;
    z-index: 1;
}

.asa-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.25);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, transform 0.15s ease;
    position: relative;
    z-index: 1;
}

.asa-close:hover {
    background: rgba(15, 23, 42, 0.4);
    transform: scale(1.05);
}

.asa-close:active {
    transform: scale(0.95);
}

.asa-close svg {
    width: 16px;
    height: 16px;
}

/* ============================================
   Messages area
   ============================================ */
.asa-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 18px 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.asa-messages::-webkit-scrollbar {
    width: 6px;
}

.asa-messages::-webkit-scrollbar-track {
    background: transparent;
}

.asa-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.asa-msg {
    max-width: 84%;
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
    animation: asa-msg-in 0.25s ease;
}

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

.asa-msg.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #22d3ee 0%, #06b6d4 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 6px rgba(6, 182, 212, 0.25);
}

.asa-msg.bot {
    align-self: flex-start;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.asa-msg.declined {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}

.asa-msg a {
    color: #0891b2;
    text-decoration: none;
    font-weight: 500;
}

.asa-msg.user a {
    color: #ecfeff;
    text-decoration: underline;
}

.asa-msg a:hover {
    text-decoration: underline;
}

/* Typing indicator */
.asa-typing {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 4px 0;
}

.asa-typing span {
    width: 7px;
    height: 7px;
    background: #94a3b8;
    border-radius: 50%;
    animation: asa-bounce 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-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40%           { transform: scale(1);   opacity: 1;   }
}

/* ============================================
   Input area
   ============================================ */
.asa-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 16px 16px;
    background: #fff;
    border-top: 1px solid #f1f5f9;
}

.asa-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    outline: none;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    background: #f8fafc;
    color: #1f2937;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

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

.asa-input:focus {
    border-color: #06b6d4;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}

.asa-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #22d3ee 0%, #06b6d4 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.35);
    transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.asa-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(6, 182, 212, 0.45);
}

.asa-send:active:not(:disabled) {
    transform: scale(0.95);
}

.asa-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.asa-send svg {
    width: 18px;
    height: 18px;
    transform: translateX(1px);
}

/* ============================================
   Footer
   ============================================ */
.asa-foot {
    text-align: center;
    padding: 8px 16px 10px;
    background: #fff;
    font-size: 11px;
    color: #94a3b8;
    border-top: 1px solid #f9fafb;
}

/* ============================================
   Responsive (mobile)
   ============================================ */
@media (max-width: 480px) {
    .asa-panel {
        right: -8px;
        bottom: 80px;
        width: calc(100vw - 24px);
        height: calc(100vh - 120px);
        border-radius: 14px;
    }
}

@media (max-width: 360px) {
    .asa-bubble {
        width: 56px;
        height: 56px;
    }
}