/* Cricket PEI Chatbot Styles */
#cpei-chatbot-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #1e3a8a;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(30, 58, 138, 0.4);
    transition: all 0.3s ease;
}
#cpei-chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(30, 58, 138, 0.55);
}
#cpei-chatbot-toggle svg {
    width: 28px;
    height: 28px;
    fill: #fff;
    transition: transform 0.3s ease;
}
#cpei-chatbot-toggle.open svg.chat-icon { display: none; }
#cpei-chatbot-toggle:not(.open) svg.close-icon { display: none; }

/* Chat Window */
#cpei-chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    z-index: 9998;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 1.5rem;
    box-shadow: 0 12px 48px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}
#cpei-chatbot-window.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Header */
.cpei-chat-header {
    background: #1e3a8a;
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.cpei-chat-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.cpei-chat-header-info h3 {
    font-size: 14px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}
.cpei-chat-header-info p {
    font-size: 11px;
    opacity: 0.75;
    margin: 2px 0 0;
}

/* Messages area */
.cpei-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f9fafb;
    -webkit-overflow-scrolling: touch;
}
.cpei-chat-messages::-webkit-scrollbar {
    width: 4px;
}
.cpei-chat-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

/* Message bubbles */
.cpei-msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 1rem;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    animation: cpei-msg-in 0.25s ease;
}
@keyframes cpei-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.cpei-msg.bot {
    background: #fff;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}
.cpei-msg.user {
    background: #1e3a8a;
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}
.cpei-msg a {
    color: #2563eb;
    text-decoration: underline;
    font-weight: 600;
}
.cpei-msg.user a {
    color: #93c5fd;
}

/* Quick replies */
.cpei-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 0 16px 8px;
    background: #f9fafb;
    flex-shrink: 0;
}
.cpei-quick-btn {
    background: #eff6ff;
    color: #1e3a8a;
    border: 1px solid #bfdbfe;
    padding: 6px 12px;
    border-radius: 1rem;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.cpei-quick-btn:hover {
    background: #1e3a8a;
    color: #fff;
    border-color: #1e3a8a;
}

/* Typing indicator */
.cpei-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
}
.cpei-typing span {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: cpei-bounce 1.2s infinite;
}
.cpei-typing span:nth-child(2) { animation-delay: 0.15s; }
.cpei-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cpei-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* Input area */
.cpei-chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}
.cpei-chat-input-area input {
    flex: 1;
    min-width: 0;
    border: 1px solid #e5e7eb;
    border-radius: 1rem;
    padding: 10px 16px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
    background: #f9fafb;
    font-family: inherit;
    -webkit-appearance: none;
    appearance: none;
}
.cpei-chat-input-area input:focus {
    border-color: #2563eb;
    background: #fff;
}
.cpei-chat-input-area button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #1e3a8a;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.cpei-chat-input-area button:hover {
    background: #1e40af;
}
.cpei-chat-input-area button svg {
    width: 18px;
    height: 18px;
    fill: #fff;
}

/* Notification badge on toggle button */
#cpei-chatbot-toggle .cpei-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #dc2626;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 800;
    color: #fff;
    border: 2px solid #fff;
    animation: cpei-badge-pulse 2s infinite;
}
@keyframes cpei-badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ── Tablet (≤768px) ────────────────────────────── */
@media (max-width: 768px) {
    #cpei-chatbot-window {
        width: 340px;
        max-width: calc(100vw - 24px);
        height: 480px;
        max-height: calc(100vh - 130px);
        bottom: 94px;
        right: 12px;
    }
    #cpei-chatbot-toggle {
        bottom: 20px;
        right: 20px;
    }
}

/* ── Mobile (≤480px) — compact floating widget ──── */
@media (max-width: 480px) {
    #cpei-chatbot-toggle {
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        right: 12px;
        width: 48px;
        height: 48px;
    }
    #cpei-chatbot-toggle svg {
        width: 22px;
        height: 22px;
    }

    #cpei-chatbot-window {
        width: calc(100vw - 24px);
        max-width: 320px;
        height: 380px;
        max-height: calc(100vh - 100px);
        bottom: 78px;
        right: 12px;
        border-radius: 1rem;
    }

    .cpei-chat-header {
        padding: 10px 14px;
    }
    .cpei-chat-header-avatar {
        width: 30px;
        height: 30px;
        font-size: 14px;
    }
    .cpei-chat-header-info h3 {
        font-size: 12px;
    }
    .cpei-chat-header-info p {
        font-size: 10px;
    }

    .cpei-chat-messages {
        padding: 10px;
        gap: 8px;
    }

    .cpei-msg {
        max-width: 90%;
        font-size: 12px;
        padding: 8px 11px;
    }

    .cpei-quick-replies {
        padding: 0 10px 6px;
        gap: 4px;
    }
    .cpei-quick-btn {
        padding: 5px 9px;
        font-size: 10px;
    }

    .cpei-chat-input-area {
        padding: 8px 10px;
        padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        gap: 6px;
    }
    .cpei-chat-input-area input {
        padding: 8px 12px;
        font-size: 16px;
    }
    .cpei-chat-input-area button {
        width: 34px;
        height: 34px;
    }
}
