/* CSAI LiveChat Widget */

/* Reset & Container */
#csai-chat-root * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Bubble */
.csai-bubble {
    position: fixed;
    bottom: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    z-index: 99999;
    transition: transform 0.3s ease, opacity 0.3s ease;
    animation: csai-pulse 2s infinite;
}

.csai-bubble:hover {
    transform: scale(1.1);
}

.csai-bubble.csai-hidden {
    transform: scale(0);
    opacity: 0;
    pointer-events: none;
}

.csai-pos-right {
    right: 24px;
}

.csai-pos-left {
    left: 24px;
}

@keyframes csai-pulse {

    0%,
    100% {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    }

    50% {
        box-shadow: 0 4px 24px rgba(0, 132, 255, 0.4);
    }
}

/* Panel */
.csai-panel {
    position: fixed;
    bottom: 96px;
    width: 380px;
    max-height: 560px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: csai-slideUp 0.3s ease;
}

.csai-panel.csai-pos-right {
    right: 24px;
}

.csai-panel.csai-pos-left {
    left: 24px;
}

@keyframes csai-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.csai-header {
    padding: 16px 18px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.csai-header-title {
    font-weight: 700;
    font-size: 16px;
}

.csai-header-status {
    font-size: 12px;
    opacity: 0.85;
}

.csai-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: background 0.2s;
}

.csai-close:hover {
    background: rgba(255, 255, 255, 0.35);
}

/* Messages */
.csai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
    max-height: 340px;
}

.csai-msg {
    max-width: 85%;
}

.csai-msg-user {
    align-self: flex-end;
}

.csai-msg-ai,
.csai-msg-admin {
    align-self: flex-start;
}

.csai-msg-label {
    font-size: 10px;
    color: #888;
    margin-bottom: 3px;
    font-weight: 600;
    text-transform: uppercase;
}

.csai-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.csai-msg-user .csai-msg-bubble {
    background: #0084ff;
    color: #fff;
    border-radius: 14px 14px 4px 14px;
}

.csai-msg-ai .csai-msg-bubble {
    background: #f0f2f5;
    color: #1a1a1a;
    border-radius: 14px 14px 14px 4px;
}

.csai-msg-admin .csai-msg-bubble {
    background: #fff3cd;
    color: #664d03;
    border-radius: 14px 14px 14px 4px;
    border: 1px solid #ffecb5;
}

/* Typing indicator */
.csai-typing {
    display: flex;
    gap: 4px;
    padding: 12px 18px !important;
}

.csai-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: csai-bounce 1.3s infinite;
    display: inline-block;
}

.csai-typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.csai-typing span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes csai-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-8px);
    }
}

/* Pre-chat form */
.csai-prechat {
    padding: 24px 20px;
    text-align: center;
}

.csai-prechat-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #1a1a1a;
}

.csai-prechat-desc {
    font-size: 13px;
    color: #666;
    margin-bottom: 18px;
}

.csai-input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 10px;
    outline: none;
    transition: border-color 0.2s;
}

.csai-input:focus {
    border-color: #0084ff;
}

.csai-start-btn {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 10px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 6px;
    transition: opacity 0.2s;
}

.csai-start-btn:hover {
    opacity: 0.9;
}

.csai-start-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Input area */
.csai-input-area {
    padding: 12px 14px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.csai-msg-input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.csai-msg-input:focus {
    border-color: #0084ff;
}

.csai-send-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.2s;
}

.csai-send-btn:hover {
    opacity: 0.85;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .csai-panel {
        width: calc(100vw - 16px);
        max-height: calc(100vh - 120px);
        bottom: 80px;
        right: 8px !important;
        left: 8px !important;
        border-radius: 12px;
    }

    .csai-messages {
        max-height: calc(100vh - 320px);
    }

    .csai-bubble {
        bottom: 16px;
        right: 16px !important;
        left: auto !important;
    }
}

/* Scrollbar  */
.csai-messages::-webkit-scrollbar {
    width: 4px;
}

.csai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.csai-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}