/* ChatPop! Support Bot - Widget Styles */
#chatpop-widget-container * {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
}

/* Toggle Button */
#chatpop-toggle-btn {
    position: fixed;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    animation: chatpop-bounce 2s infinite;
}
#chatpop-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(0,0,0,0.3);
    animation: none;
}
#chatpop-toggle-btn.bottom-right { bottom: 24px; right: 24px; }
#chatpop-toggle-btn.bottom-left  { bottom: 24px; left: 24px; }

@keyframes chatpop-bounce {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-6px); }
}

/* Notification Badge */
#chatpop-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    background: #FF4757;
    border-radius: 50%;
    display: none;
}
#chatpop-badge.visible { display: block; }

/* Chat Window */
#chatpop-window {
    position: fixed;
    width: 360px;
    height: 500px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    z-index: 9998;
    transition: opacity 0.3s ease, transform 0.3s ease;
    background: #fff;
}
#chatpop-window.bottom-right { bottom: 100px; right: 24px; }
#chatpop-window.bottom-left  { bottom: 100px; left: 24px; }
#chatpop-window.chatpop-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95);
}

/* Header */
#chatpop-header {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
#chatpop-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
#chatpop-header-info { flex: 1; }
#chatpop-bot-name {
    font-weight: 700;
    font-size: 15px;
    margin: 0;
}
#chatpop-status {
    font-size: 12px;
    opacity: 0.85;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 4px;
}
#chatpop-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2ED573;
    display: inline-block;
}
#chatpop-close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: background 0.2s;
}
#chatpop-close-btn:hover { background: rgba(255,255,255,0.35); }

/* Messages Area */
#chatpop-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f8f9fa;
}
#chatpop-messages::-webkit-scrollbar { width: 4px; }
#chatpop-messages::-webkit-scrollbar-track { background: transparent; }
#chatpop-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

/* Message Bubbles */
.chatpop-msg {
    display: flex;
    gap: 8px;
    animation: chatpop-msg-in 0.25s ease;
}
@keyframes chatpop-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.chatpop-msg-bot { align-items: flex-start; }
.chatpop-msg-user { flex-direction: row-reverse; }

.chatpop-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

.chatpop-msg-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}
.chatpop-msg-bot .chatpop-msg-bubble {
    background: #fff;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    color: #333;
}
.chatpop-msg-user .chatpop-msg-bubble {
    border-bottom-right-radius: 4px;
    color: #fff;
}
.chatpop-msg-bubble a { color: inherit; text-decoration: underline; }

/* Contact Button in message */
.chatpop-contact-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: #fff !important;
    text-decoration: none !important;
    transition: opacity 0.2s;
}
.chatpop-contact-btn:hover { opacity: 0.85; }

/* Typing Indicator */
#chatpop-typing {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}
#chatpop-typing.visible { display: flex; }
.chatpop-typing-dots {
    background: #fff;
    border-radius: 18px;
    padding: 10px 16px;
    display: flex;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.chatpop-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ccc;
    animation: chatpop-typing 1.2s infinite;
}
.chatpop-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chatpop-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatpop-typing {
    0%, 60%, 100% { transform: translateY(0); background: #ccc; }
    30%            { transform: translateY(-6px); background: #aaa; }
}

/* Input Area */
#chatpop-input-area {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}
#chatpop-input {
    flex: 1;
    border: 2px solid #f0f0f0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    line-height: 1.4;
}
#chatpop-input:focus { border-color: #ddd; }
#chatpop-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s, opacity 0.2s;
    color: #fff;
}
#chatpop-send-btn:hover { transform: scale(1.1); }
#chatpop-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Powered By */
#chatpop-powered {
    text-align: center;
    font-size: 10px;
    color: #bbb;
    padding: 4px;
    background: #fff;
    flex-shrink: 0;
}
#chatpop-powered a { color: #bbb; text-decoration: none; }
#chatpop-powered a:hover { color: #999; }

/* Avatar Images */
.chatpop-btn-avatar-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.chatpop-header-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}
.chatpop-msg-avatar-img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* Mobile — bottom-sheet style */
@media (max-width: 480px) {
    /* チャットウィンドウ：下から引き上がるシート */
    #chatpop-window {
        width: 100vw !important;
        height: 65vh;
        max-height: 65vh;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        border-radius: 20px 20px 0 0;
        /* 閉じたときは下にスライドアウト */
        transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.32,0.72,0,1);
    }
    #chatpop-window.chatpop-hidden {
        opacity: 1;
        transform: translateY(100%);
        pointer-events: none;
    }

    /* ヘッダーに引っ張りインジケーター */
    #chatpop-header::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 36px;
        height: 4px;
        background: rgba(255,255,255,0.5);
        border-radius: 2px;
    }
    #chatpop-header { position: relative; padding-top: 20px; }

    /* チャット開いている間はフローティングボタンを隠す */
    #chatpop-toggle-btn.chatpop-btn-open {
        opacity: 0;
        pointer-events: none;
        transform: scale(0.5);
        transition: opacity 0.2s, transform 0.2s;
    }

    /* メッセージエリアのパディング調整 */
    #chatpop-messages { padding: 12px 14px; }

    /* 入力エリアに iOS セーフエリア対応 */
    #chatpop-input-area {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }
}
