/* ==========================================================================
   爱农云联官网 - AI 助理挂件
   命名统一用 .aia- 前缀，避免影响站点既有样式（Bootstrap / 主题 CSS）。
   ========================================================================== */

.aia-root,
.aia-root * {
    box-sizing: border-box;
}

.aia-root {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9998;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #24252e;
    -webkit-font-smoothing: antialiased;
}

/* ---------------- 启动按钮 ---------------- */
.aia-launcher {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 20px 0 8px;
    border: 0;
    border-radius: 28px;
    background: linear-gradient(135deg, #a3c85e 0%, #7fb03c 100%);
    box-shadow: 0 10px 26px rgba(126, 168, 62, 0.38), 0 2px 6px rgba(0, 0, 0, 0.08);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.2px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.aia-launcher:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(126, 168, 62, 0.45), 0 3px 8px rgba(0, 0, 0, 0.1);
}

.aia-launcher:active {
    transform: translateY(0);
}

.aia-launcher-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.18);
    flex: 0 0 auto;
}

.aia-launcher-icon svg {
    width: 22px;
    height: 22px;
    display: block;
}

/* 呼吸光环：只在首次打开前提示一次，不高频闪动 */
.aia-launcher::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 0 0 0 rgba(163, 200, 94, 0.55);
    animation: aia-pulse 2.8s ease-out 3;
    pointer-events: none;
}

.aia-root.aia-seen .aia-launcher::after {
    display: none;
}

@keyframes aia-pulse {
    0% { box-shadow: 0 0 0 0 rgba(163, 200, 94, 0.5); }
    70% { box-shadow: 0 0 0 16px rgba(163, 200, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(163, 200, 94, 0); }
}

.aia-root.aia-open .aia-launcher {
    display: none;
}

/* ---------------- 面板 ---------------- */
.aia-panel {
    position: absolute;
    right: 0;
    bottom: 0;
    display: none;
    flex-direction: column;
    width: 384px;
    height: 580px;
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 28px 70px rgba(20, 32, 16, 0.26), 0 4px 12px rgba(20, 32, 16, 0.08);
    overflow: hidden;
}

.aia-root.aia-open .aia-panel {
    display: flex;
    animation: aia-in 0.22s cubic-bezier(0.22, 0.9, 0.3, 1);
}

@keyframes aia-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------------- 头部 ---------------- */
.aia-head {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 15px;
    background: linear-gradient(135deg, #24252e 0%, #333c35 100%);
    color: #fff;
    flex: 0 0 auto;
}

.aia-head::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, #a3c85e, rgba(163, 200, 94, 0.15));
}

.aia-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: linear-gradient(135deg, #a3c85e, #7fb03c);
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    flex: 0 0 auto;
}

.aia-head-text {
    flex: 1 1 auto;
    min-width: 0;
}

.aia-title {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.aia-sub {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.62);
    margin-top: 1px;
}

.aia-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a3c85e;
    box-shadow: 0 0 0 3px rgba(163, 200, 94, 0.18);
}

.aia-actions {
    display: flex;
    gap: 4px;
    flex: 0 0 auto;
}

.aia-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.aia-icon-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.aia-icon-btn svg {
    width: 17px;
    height: 17px;
    display: block;
}

/* ---------------- 消息区 ---------------- */
.aia-body {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 16px 8px;
    background:
        radial-gradient(circle at 100% 0, rgba(163, 200, 94, 0.07), transparent 45%),
        #f7f9f4;
}

.aia-body::-webkit-scrollbar {
    width: 6px;
}

.aia-body::-webkit-scrollbar-thumb {
    background: rgba(36, 37, 46, 0.16);
    border-radius: 3px;
}

.aia-msg {
    display: flex;
    margin-bottom: 14px;
    animation: aia-fade 0.18s ease;
}

@keyframes aia-fade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.aia-msg-user {
    justify-content: flex-end;
}

.aia-bubble {
    max-width: 84%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.65;
    word-break: break-word;
    white-space: normal;
}

.aia-msg-bot .aia-bubble {
    background: #fff;
    border: 1px solid #e6ecdd;
    border-bottom-left-radius: 5px;
    color: #2c2f28;
    box-shadow: 0 1px 2px rgba(36, 37, 46, 0.03);
}

.aia-msg-user .aia-bubble {
    background: linear-gradient(135deg, #a3c85e, #8fba49);
    color: #fff;
    border-bottom-right-radius: 5px;
    box-shadow: 0 2px 8px rgba(143, 186, 73, 0.24);
}

.aia-bubble a {
    color: #6f9c2c;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.aia-msg-user .aia-bubble a {
    color: #fff;
}

.aia-bubble strong {
    font-weight: 600;
}

.aia-bubble ul {
    margin: 6px 0 2px;
    padding-left: 18px;
}

.aia-bubble li {
    margin: 2px 0;
}

.aia-tag {
    display: inline-block;
    margin-top: 6px;
    padding: 1px 7px;
    border-radius: 6px;
    background: rgba(163, 200, 94, 0.14);
    color: #749a30;
    font-size: 11px;
    line-height: 1.7;
}

/* 欢迎态 */
.aia-welcome-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 6px;
    color: #24252e;
}

.aia-welcome-desc {
    font-size: 13px;
    color: #5e6459;
    margin-bottom: 10px;
}

.aia-capabilities {
    margin: 0;
    padding: 0;
    list-style: none;
}

.aia-capabilities li {
    position: relative;
    padding-left: 20px;
    margin: 4px 0;
    font-size: 13px;
    color: #3f453b;
}

.aia-capabilities li::before {
    content: "";
    position: absolute;
    left: 4px;
    top: 8px;
    width: 6px;
    height: 6px;
    border-radius: 2px;
    background: #a3c85e;
}

/* 快捷问题 */
.aia-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 16px 12px;
    background: #f7f9f4;
    flex: 0 0 auto;
}

.aia-chips:empty {
    display: none;
}

.aia-chip {
    padding: 6px 12px;
    border: 1px solid #d9e4c6;
    border-radius: 14px;
    background: #fff;
    color: #55702a;
    font-size: 12.5px;
    line-height: 1.4;
    cursor: pointer;
    transition: all 0.15s ease;
    font-family: inherit;
}

.aia-chip:hover {
    background: #f0f6e5;
    border-color: #a3c85e;
}

/* 输入中 */
.aia-typing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 20px;
}

.aia-typing i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a3c85e;
    display: block;
    animation: aia-bounce 1.1s infinite ease-in-out;
}

.aia-typing i:nth-child(2) { animation-delay: 0.15s; }
.aia-typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes aia-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* 错误条 */
.aia-error {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 16px 10px;
    padding: 8px 12px;
    border-radius: 10px;
    background: #fff5f5;
    border: 1px solid #f3d2d2;
    color: #a34a4a;
    font-size: 12.5px;
    flex: 0 0 auto;
}

.aia-retry {
    border: 0;
    background: transparent;
    color: #a34a4a;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
    font-size: 12.5px;
    flex: 0 0 auto;
}

/* ---------------- 输入区 ---------------- */
.aia-composer {
    flex: 0 0 auto;
    padding: 10px 14px 6px;
    background: #fff;
    border-top: 1px solid #eef1e8;
}

.aia-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 6px 6px 6px 12px;
    border: 1px solid #e0e6d7;
    border-radius: 14px;
    background: #fafbf8;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.aia-input-row:focus-within {
    border-color: #a3c85e;
    box-shadow: 0 0 0 3px rgba(163, 200, 94, 0.14);
    background: #fff;
}

.aia-input {
    flex: 1 1 auto;
    min-height: 24px;
    max-height: 96px;
    padding: 4px 0;
    border: 0;
    outline: none;
    resize: none;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.55;
    color: #24252e;
}

.aia-input::placeholder {
    color: #9aa093;
}

.aia-send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, #a3c85e, #8ab944);
    color: #fff;
    cursor: pointer;
    flex: 0 0 auto;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.aia-send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.aia-send:not(:disabled):hover {
    transform: translateY(-1px);
}

.aia-send svg {
    width: 17px;
    height: 17px;
    display: block;
}

.aia-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 2px 2px;
    font-size: 11px;
    color: #9aa093;
    line-height: 1.5;
}

.aia-foot a {
    color: #7d9c46;
    text-decoration: none;
    white-space: nowrap;
}

.aia-foot a:hover {
    text-decoration: underline;
}

/* ---------------- 移动端 ---------------- */
@media (max-width: 640px) {
    .aia-root {
        right: 14px;
        bottom: 14px;
    }

    .aia-launcher {
        height: 50px;
        padding: 0 16px 0 7px;
        font-size: 13px;
    }

    .aia-launcher-icon {
        width: 36px;
        height: 36px;
    }

    .aia-panel {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }

    .aia-head {
        padding-top: max(14px, env(safe-area-inset-top));
    }

    .aia-composer {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}

@media (prefers-reduced-motion: reduce) {
    .aia-launcher::after,
    .aia-typing i {
        animation: none;
    }

    .aia-root.aia-open .aia-panel,
    .aia-msg {
        animation: none;
    }
}
