/* ================================================================
   AI Chat Widget — aichat.css
   ================================================================ */
:root{
    --border-radius:16px;
}
/* ── コンテナ ──────────────────────────────────────────────────── */
#aichat {
    width: 100%;
    max-width: 480px;
    /* border: 1px solid #ddd; */
    border-radius: var(--border-radius);
    /* padding: 12px; */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    /* background: #fff; */
    box-sizing: border-box;
    margin: 0 auto;
    /* position: relative; */
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9998;
    /* display: none; */
}

/* ── ログエリア ────────────────────────────────────────────────── */
/* 2026-03-25 ADD START */
.aichat-title-group{
    padding: 24px 16px;
    /* background: linear-gradient(135deg, #4784ff, #4141cf); */
    background-image: url('https://miyoshi-doggs.com/wp-content/plugins/ai-controlled-chat/public/images/aichat-title-back.webp');
    background-size: cover;      /* 核心：确保图片铺满盒子且不失真 */
    background-position: center; /* 图片居中 */
    background-repeat: no-repeat;
    color: #fff;
    font-size: 14px;
    text-align: center;
    border-radius: 16px 16px 0 0;
    /* margin-bottom: 16px; */
    box-shadow: 0 12px 32px 0px rgba(0, 0, 0, 0.1);
}
.aichat-title{
    font-size: 20px;
    margin-bottom: 4px;
    font-weight: 600;
    letter-spacing: 1px;
}
.aichat-title span{
    color: #ffe5c8;
}

.aichat-close-group{
    width: 100%;
    text-align: right;
    position: relative;
    z-index: 9998;
    padding: 12px 0;
}
#aichat-close,
.close-btn{
    max-width: 64px;
    background: none;
    border: none;
    outline: none;
    padding: 0;
    box-shadow: none;
    font: inherit;
    color: inherit;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 100px;
    background-color: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 12px;
    padding: 4px 12px;
}

#aichat-mask {
    position: fixed;        /* ❗必须 fixed */
    top: 0;
    left: 0;
    width: 100vw;           /* 更严谨 */
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 9997;
    /* display: none; */          /* 默认隐藏 */
}

#aichat,
#aichat-mask {
    opacity: 0;
    pointer-events: none;
    transition: 0.3s;
}

#aichat.active,
#aichat-mask.active {
    opacity: 1;
    pointer-events: auto;
}
/* 2026-03-25 ADD END */

#aichat-log {
    /* height: 400px; */
    max-height: 48vh;
    min-height: 80px;
    overflow-y: auto;
    /* border: 1px solid #e8e8e8; */
    /* border-radius: 6px; */
    padding: 24px;
    /* margin-bottom: 16px; */
    /* background: #f9f9f9; */
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: linear-gradient(#ffffff, #e6e6e6);
    box-shadow: 0 12px 32px 0px rgba(0, 0, 0, 0.1);
    position: relative;
}
/* #aichat-log::before{
    content: "";
    position: absolute;
    width: 100%;
    height: 30%;
    top: 0;
    left: 0;
    z-index: 1;
    background: linear-gradient(rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0));
} */
/* ── メッセージ共通 ────────────────────────────────────────────── */
/* 2026-03-25 ADD START */
.aichat-msg-group{
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.aichat-msg-img{
    width: 56px;
    height: 56px;
    border-radius: 100px;
}
/* 2026-03-25 ADD END */

.aichat-msg {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    word-break: break-word;
}

/* ── ユーザーメッセージ（右寄せ） ─────────────────────────────── */
.aichat-msg.user {
    /* background: #4784ff; */
    background: linear-gradient(135deg, #4784ff, #4141cf);
    color: #fff;
    align-self: flex-end;
    border-top-right-radius: 0;
}

/* ── AI メッセージ（左寄せ） ──────────────────────────────────── */
.aichat-msg.ai {
    max-width: calc(80% - 64px);
    background: #e2e2e2;
    color: #333;
    align-self: flex-start;
    border-top-left-radius: 0;
    margin-top: 4px;
}

/* ── 思考中インジケーター ─────────────────────────────────────── */
.aichat-thinking {
    /* color: #999; */
    /* font-size: 18px;
    letter-spacing: 4px; */
    /* animation: aichat-blink 1.2s ease-in-out infinite; */
}

/* 1. 基础消息气泡样式（确保定位，为流光留出空间） */
.aichat-msg.ai.aichat-thinking {
    position: relative;
    overflow: hidden; /* 裁剪旋转层 */
    background-color: #4784ff; /* 气泡背景色 */
    border: none;
    z-index: 1;
    /* 组合动画：流光旋转 + 整体呼吸闪烁 */
    animation: aichat-container-blink 1.5s ease-in-out infinite;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

/* 2. 容器内部的流光层 */
.aichat-thinking::before {
    content: "";
    position: absolute;
    width: 200%; /* 足够大的旋转层 */
    padding-bottom: 250%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(0deg);
    z-index: -1;
    
    /* 渐变流光色 */
    background: conic-gradient(
        transparent 30%, 
        #6a1be9 90%, 
        #a777e3 100%
    );
    
    /* 持续旋转 */
    animation: rotate-always 1.5s linear infinite;
    filter: blur(8px); /* 让边缘光晕更柔和 */
}

/* 3. 动画定义 */

/* 旋转：0到360度 */
@keyframes rotate-always {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 呼吸闪烁：控制整个气泡的透明度 */
@keyframes aichat-container-blink {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.8; transform: scale(0.99); } /* 稍微收缩增加动态感 */
}

/* ── 入力エリア ────────────────────────────────────────────────── */
.aichat-input {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 24px 16px;
    background-color: #e6e6e6;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 12px 32px 0px rgba(0, 0, 0, 0.1);
}

#aichat-message {
    width: 100%;
    height: 48px;
    padding: 8px 12px;
    /* border: 1px solid #fff; */
    /* --- 关键修复：显式去掉边框并设置背景色 --- */
    border: none;             /* 彻底去掉原生边框 */
    background-color: #fff;   /* 必须设置背景色，否则内阴影会发黑 */
    /* -------------------------------------- */
    border-radius: 12px;
    font-size: 14px;
    outline: none;
    /* transition: border-color 0.2s; */
    box-sizing: border-box;
    box-shadow: inset -2px 2px 12px rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 2;
}

/* 输入框本体：必须有背景色覆盖掉背后的旋转层 */
/* #aichat-message {
    outline: none;
    z-index: 2;
} */

#aichat-message:focus {
    /* border-color: #cacaca; */
    box-shadow: inset -2px 2px 12px rgba(0, 0, 0, 0.3);
}

/* 容器：必须设为 overflow: hidden 以裁剪旋转的圆圈 */
.aichat-message-group {
    position: relative;
    overflow: hidden; /* 核心：裁剪掉旋转层的多余部分 */
    z-index: 1;
    padding: 2px;
    flex: 1;
    box-shadow: 0 8px 16px 0px rgba(0, 0, 0, 0.1);
    border-radius: 12px;

    display: flex;
    align-items: center;
    /* background-color: #e68207; */
}

/* 兼容性最强的流光层：只在激活时出现 */
.aichat-message-group::before {
    content: "";
    position: absolute;
    /* 核心：设置一个远大于长方形容器的正方形 */
    width: 240%; 
    padding-bottom: 240%; /* 保持 1:1 比例 */
    top: 50%;
    left: 50%;
    /* 将中心点移至容器中心 */
    transform: translate(-50%, -50%) rotate(0deg); 
    z-index: -1;
    
    /* 圆锥渐变：控制光柱的长度和颜色 */
    background: conic-gradient(
        transparent 70%, 
        #4784ff 90%, 
        #a777e3 100%
    );
    
    opacity: 0;
    /* transition: opacity 0.3s; */
    filter: blur(8px); /* 增加一点虚化，让渐隐更柔和 */
}

/* 激活类：触发旋转 */
.glow-active::before {
    /* 播放1.2秒，执行一次，结束后保持最后一帧状态（透明度0） */
    animation: rotate-and-fade 1.2s ease-out forwards;
}

/* 定义复合动画：旋转的同时控制透明度 */
@keyframes rotate-and-fade {
    0% {
        /* 起始：改为 90deg 则从右侧开始跑 */
        transform: translate(-50%, -50%) rotate(90deg); 
    }
    15% {
        opacity: 1; /* 快速亮起 */
    }
    70% {
        opacity: 1; /* 保持一段时间流光 */
    }
    100% {
        /* 结束：450deg 表示转一圈后停在右侧 */
        transform: translate(-50%, -50%) rotate(450deg); 
    }
}

/* ── 送信ボタン ────────────────────────────────────────────────── */
#aichat-send {
    width: 48px;
    height: 48px;
    padding: 4px;
    /* background: #0073aa; */
    background: linear-gradient(135deg, #ffa538, #e78b1b);
    color: #fff;

    border: none;
    border-radius: 100px;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;

    transition: background 0.2s, opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* #aichat-send:hover:not(:disabled) {
    background: #005f8a;
} */

/* ── 送信中状態 ────────────────────────────────────────────────── */
#aichat-send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

/* ── CTA ボタン ────────────────────────────────────────────────── */
.aichat-cta {
    display: block;
    margin-top: 12px;
    padding: 16px;
    /* background: #e65c00; */
    background: linear-gradient(135deg, #ffa538, #e78b1b);
    color: #fff !important;
    text-align: center;
    border-radius: 100px;
    text-decoration: none !important;
    font-weight: bold;
    font-size: 18px;
    transition: background 0.2s;
    align-self: stretch;
}

.aichat-cta:hover {
    background: #e68207;
}

/* ── スクロールバー（Webkit） ──────────────────────────────────── */
#aichat-log::-webkit-scrollbar {
    width: 4px;
}
#aichat-log::-webkit-scrollbar-track {
    background: transparent;
}
#aichat-log::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}



/* 浮动横幅样式 */
.floating-banner {
    position: fixed;
    bottom: 24px;
    right: 24px;
    /* left: 50%;
    transform: translateX(-50%); */
    z-index: 9999;
    width: 100%;
    max-width: 480px;
    padding-top: 40px;
    transition: opacity 0.5s ease, transform 0.5s ease;
    opacity: 0;
    /* transform: translateX(-50%) translateY(20px); */
    transform: translateY(20px);
    visibility: hidden;
    
    /* background:
        url(https://chico-online.com/wp-content/uploads/2025/05/promo-back.png) no-repeat bottom right / 306px auto,
        linear-gradient(120deg, #f1e9da, #ffe9c1);
    background-repeat: no-repeat;
    background-position: bottom right; */
    /* border-radius: 12px; */
    /* box-shadow: 0 8px 16px rgba(70, 60, 43, 0.15);  */
}
/* 当横幅可见时的样式 */
.floating-banner.visible {
    opacity: 1;
    /* transform: translateX(-50%) translateY(0); */
    transform: translateY(0);
    visibility: visible;
}
.floating-banner-group{
    /* padding: 16px; */
    border-radius: var(--border-radius);
    background-color: #fff;
}
.floating__content,
.floating__button-group{
    width: 64%;
    padding: 16px;
    margin-left: auto;
    position: relative;
    z-index: 2;
}
.floating__content-group{
    background-image: url('https://miyoshi-doggs.com/wp-content/plugins/ai-controlled-chat/public/images/aichat-title-back.webp');
    background-size: cover;      /* 核心：确保图片铺满盒子且不失真 */
    background-position: center; /* 图片居中 */
    background-repeat: no-repeat;
    border-radius: 16px 16px 0 0;
}
.floating__content{
    font-size: 18px;
    display: grid;
    gap: 4px;
    /* background-color: rgba(0, 0, 255, 0.5); */
    color: #fff;
}
.floating__title{
    font-weight: 600;
    letter-spacing: 0.5px;
}
.floating__title span{
    color: #ffe5c8;
}
.floating__subtitle{
    font-size: 14px;
}
/* .floating__button-group{
    padding-top: 0;
} */
.floating__button{
    width: 100%;
    /* height: 48px; */
    padding: 16px;
    background: linear-gradient(135deg, #ffa538, #e78b1b);
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 1px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;

    border: none;
    border-radius: 100px;
    /* font-size: 14px; */
    cursor: pointer;
    white-space: nowrap;
}
.floating__button span{
    flex: 1;
}

.floating__media-group{
    position: absolute;
    bottom: 0;
    left: 0;
    z-index: 1;
    width: 46%;
    height: 100%;
    /* overflow-x: hidden; */
    /* background-color: rgba(0, 0, 255, 0.6); */
    border-radius: var(--border-radius);
    clip-path: inset(0 0 0 0 round 16px);
}
.floating__media{
    width: 100%;
    height: 100%;
    position: relative;
    border-radius: var(--border-radius);
}
.floating__media img{
    width: 100%;
    height: auto;
    position: absolute;
    bottom: -2px;
    left: 0;
    transform: translateX(-24px);
    border-radius: var(--border-radius);
}

/* 关闭按钮 */
.close-btn {
    position: absolute;
    top: 4px;
    right: 0;
    /* width: 16px;
    height: 16px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s; */
}
.close-btn:hover {opacity: 1;}
/* .close-btn:before, 
.close-btn:after {
    content: '';
    position: absolute;
    width: 100%;
    height: 2px;
    background-color: #291e0d;
    top: 50%;
    left: 0;
}
.close-btn:before {transform: rotate(45deg);}
.close-btn:after {transform: rotate(-45deg);} */



/* ── レスポンシブ（狭い画面） ────────────────────────────────── */
@media (max-width: 480px) {
    #aichat {
        /* max-width: 100%; */
        /* border-radius: 0; */
        border-left: none;
        border-right: none;
    }
    #aichat-log {
        padding: 12px;
    }
    .aichat-msg {
        max-width: 84%;
    }
    .aichat-msg.ai {
        max-width: calc(84% - 64px);
    }
    .aichat-input {
        padding: 12px 8px;
    }
    #aichat,
    .floating-banner {
        left: 50%;
        /* transform: translateX(-50%); */
        transform: translateX(-50%) translateY(20px);
    }
    #aichat.visible,
    .floating-banner.visible {
        transform: translateX(-50%) translateY(0);
    }
}