/* =========================================
   CSSPlayer Live Chat Widget
========================================= */

.cssp-live-chat {
    position: fixed;
    right: 20px;
    bottom: 90px;
    z-index: 99999;
    font-family: Arial, sans-serif;
}

/* Floating chat button */
#csspChatToggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: linear-gradient(135deg, #673ab7 0%, #2196f3 100%);
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(33, 150, 243, 0.30);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

#csspChatToggle:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(33, 150, 243, 0.38);
}

#csspChatToggle:focus-visible {
    outline: 3px solid rgba(33, 150, 243, 0.35);
    outline-offset: 3px;
}

/* Chat panel */
.cssp-chat-panel {
    display: none;
    position: absolute;
    right: 0;
    bottom: 72px;
    width: 360px;
    max-width: calc(100vw - 30px);
    height: 520px;
    max-height: calc(100vh - 180px);
    overflow: hidden;
    border: 1px solid #e7eaf1;
    border-radius: 18px;
    color: #252638;
    background: #fff;
    box-shadow: 0 18px 55px rgba(20, 25, 45, 0.22);
}

.cssp-chat-screen {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
    background: #fff;
}

.cssp-chat-screen[hidden] {
    display: none !important;
}

/* Header */
.cssp-chat-header {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 70px;
    box-sizing: border-box;
    padding: 15px 18px;
    color: #fff;
    background: linear-gradient(120deg, #673ab7 0%, #287fe0 58%, #2196f3 100%);
}

.cssp-chat-header strong {
    display: block;
    margin: 0;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.35;
}

.cssp-chat-status {
    display: block;
    margin-top: 5px;
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    line-height: 1.3;
}

.cssp-chat-header button {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    color: #fff;
    background: rgba(255, 255, 255, 0.12);
    font-family: Arial, sans-serif;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s ease;
}

.cssp-chat-header button:hover {
    background: rgba(255, 255, 255, 0.24);
}

/* Welcome and article body */
.cssp-chat-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 22px 20px;
    box-sizing: border-box;
}

.cssp-chat-body h3 {
    margin: 0 0 8px;
    color: #202235;
    font-size: 21px;
    font-weight: 600;
    line-height: 1.35;
}

.cssp-chat-body p {
    margin: 0 0 18px;
    color: #6b6d7c;
    font-size: 14px;
    line-height: 1.6;
}

.cssp-chat-body h4 {
    margin: 24px 0 12px;
    color: #303246;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
}

/* Start conversation button */
.cssp-chat-start {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    margin-top: 12px;
    padding: 13px 16px;
    border: 0;
    border-radius: 9px;
    color: #fff;
    background: linear-gradient(120deg, #673ab7 0%, #2196f3 100%);
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: opacity 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.cssp-chat-start:hover {
    opacity: 0.95;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(33, 150, 243, 0.20);
}

.cssp-chat-start:focus-visible {
    outline: 3px solid rgba(33, 150, 243, 0.30);
    outline-offset: 2px;
}

/* Popular articles */
.cssp-chat-articles {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.cssp-articles-loading {
    margin: 0;
    color: #777989;
    font-size: 13px;
}

/* Article links - title only */
.cssp-chat-article {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid #e8eaf1;
    border-radius: 9px;
    color: #34364a;
    background: #fff;
    font-family: Arial, sans-serif;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    text-align: left;
    text-decoration: none !important;
    overflow-wrap: anywhere;
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.cssp-chat-article strong {
    display: block;
    margin: 0;
    color: inherit;
    font-size: inherit;
    font-weight: 600;
    line-height: inherit;
}

.cssp-chat-article:hover {
    border-color: #2196f3;
    color: #1976d2;
    background: #f5faff;
    text-decoration: none !important;
    transform: translateX(2px);
}

.cssp-chat-article:focus-visible {
    outline: 2px solid #2196f3;
    outline-offset: 2px;
}

/* View all articles link */
.cssp-chat-view-all {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 14px;
    color: #287bd1;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s ease;
}

.cssp-chat-view-all:hover {
    color: #673ab7;
    text-decoration: underline;
}

/* Contact form */
.cssp-chat-form {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    box-sizing: border-box;
    padding: 20px;
}

.cssp-chat-form label {
    display: block;
    margin: 0 0 6px;
    color: #3d3f50;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
}

.cssp-chat-form input,
.cssp-chat-form textarea {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 0 0 16px;
    padding: 11px 12px;
    border: 1px solid #dfe1e8;
    border-radius: 8px;
    outline: none;
    color: #292b3b;
    background: #fff;
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cssp-chat-form input::placeholder,
.cssp-chat-form textarea::placeholder {
    color: #a0a3b1;
}

.cssp-chat-form input:focus,
.cssp-chat-form textarea:focus {
    border-color: #2196f3;
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.10);
}

.cssp-chat-form textarea {
    min-height: 90px;
    resize: vertical;
}

.cssp-chat-form .cssp-chat-start {
    margin-top: 4px;
}

/* Scrollbars */
.cssp-chat-body,
.cssp-chat-form {
    scrollbar-width: thin;
    scrollbar-color: #c9cbd5 transparent;
}

.cssp-chat-body::-webkit-scrollbar,
.cssp-chat-form::-webkit-scrollbar {
    width: 6px;
}

.cssp-chat-body::-webkit-scrollbar-thumb,
.cssp-chat-form::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: #c9cbd5;
}

/* Mobile */
@media (max-width: 480px) {
    .cssp-live-chat {
        right: 15px;
        bottom: 85px;
    }

    .cssp-chat-panel {
        position: fixed;
        right: 15px;
        bottom: 150px;
        width: calc(100vw - 30px);
        max-width: 380px;
        height: min(520px, calc(100dvh - 175px));
        max-height: calc(100dvh - 175px);
    }

    #csspChatToggle {
        width: 54px;
        height: 54px;
        font-size: 22px;
    }

    .cssp-chat-header {
        min-height: 64px;
        padding: 13px 16px;
    }

    .cssp-chat-body {
        padding: 18px 16px;
    }

    .cssp-chat-form {
        padding: 16px;
    }
}

@media (max-width: 360px) {
    .cssp-chat-panel {
        right: 10px;
        width: calc(100vw - 20px);
    }

    .cssp-chat-body {
        padding: 16px 14px;
    }
}



/* ==============================
   CSSPlayer AI Chat - Red Theme
================================ */

#csspChatAI {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: #ffffff;
    overflow: hidden;
}

/* Header */
#csspChatAI .cssp-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 16px;
    background: #ff0000;
    color: #ffffff;
}

#csspChatAI .cssp-chat-header strong {
    display: block;
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
}

#csspChatAI .cssp-chat-status {
    display: block;
    margin-top: 4px;
    color: #ffe5e5;
    font-size: 12px;
}

#csspChatAI .cssp-chat-header button {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

/* Message area */
#csspAIChatBody {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 18px 14px;
    overflow-y: auto;
    background: #fffafa;
}

#csspAIChatBody .cssp-chat-message {
    max-width: 85%;
    padding: 11px 14px;
    border-radius: 14px;
    font-family: Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

#csspAIChatBody .cssp-chat-message-bot {
    align-self: flex-start;
    border: 1px solid #ffe0e0;
    border-bottom-left-radius: 4px;
    background: #ffffff;
    color: #292929;
}

#csspAIChatBody .cssp-chat-message-user {
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    background: #ff0000;
    color: #ffffff;
}

/* Message input */
#csspAIChatForm {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #eeeeee;
    background: #ffffff;
}

#csspAIChatForm #csspAIChatMessage {
    flex: 1;
    min-width: 0;
    height: 44px;
    box-sizing: border-box;
    padding: 10px 13px;
    border: 1px solid #dddddd;
    border-radius: 9px;
    outline: none;
    background: #ffffff;
    color: #222222;
    font-family: Arial, sans-serif;
    font-size: 14px;
}

#csspAIChatForm #csspAIChatMessage:focus {
    border-color: #ff0000;
    box-shadow: 0 0 0 3px rgba(255, 0, 0, 0.08);
}

/* Send button */
#csspAIChatForm .cssp-chat-start {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: auto;
    min-width: 68px;
    min-height: 44px;
    margin: 0;
    padding: 10px 16px;
    border: 0;
    border-radius: 9px;
    background: #ff0000;
    color: #ffffff;
    font-family: Arial, sans-serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

#csspAIChatForm .cssp-chat-start:hover {
    background: #d90000;
}

#csspAIChatForm .cssp-chat-start:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Mobile adjustments */
@media (max-width: 480px) {
    #csspChatAI .cssp-chat-header {
        padding: 13px;
    }

    #csspAIChatBody {
        padding: 14px 10px;
    }

    #csspAIChatForm {
        gap: 6px;
        padding: 10px;
    }

    #csspAIChatForm .cssp-chat-start {
        min-width: 58px;
        padding: 10px 12px;
    }
}