/* ==========================================================================
   Clevdex Chatbot – Widget Styles
   Enqueued via wp_enqueue_style in class-widget-renderer.php.
   CSS custom-properties are injected dynamically via wp_add_inline_style:
     --ai-chatbot-primary-color
     --ai-chatbot-secondary-color
     --ai-chatbot-text-color
     --ai-chatbot-border-radius
   ========================================================================== */

/* ----------------------------- Reset / Base ------------------------------ */
.clevdex-chatbot-widget,
.clevdex-chatbot-widget *,
.clevdex-chatbot-widget *::before,
.clevdex-chatbot-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ----------------------------- Widget Root ------------------------------- */
.clevdex-chatbot-widget {
    position: fixed;
    z-index: 999999;
    /* display:none is set inline; JS removes it on boot */
}

/* Position modifiers */
.ai-chatbot-bottom-right { bottom: 20px; right: 20px; }
.ai-chatbot-bottom-left  { bottom: 20px; left: 20px; }
.ai-chatbot-top-right    { top: 20px;    right: 20px; }
.ai-chatbot-top-left     { top: 20px;    left: 20px; }

/* ----------------------------- Toggle Button ----------------------------- */
.ai-chatbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--ai-chatbot-primary-color, #435ebe);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    position: relative;
}

.ai-chatbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.22);
}

.ai-chatbot-toggle:active {
    transform: scale(0.96);
}

.ai-chatbot-icon {
    width: 28px;
    height: 28px;
}

/* Notification badge */
.ai-chatbot-notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    animation: ai-chatbot-badge-pulse 2s infinite;
}

@keyframes ai-chatbot-badge-pulse {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* ----------------------------- Container -------------------------------- */
.ai-chatbot-container {
    position: absolute;
    bottom: 72px;          /* sits above toggle */
    right: 0;
    width: 380px;
    max-height: 560px;
    background: #fff;
    border-radius: var(--ai-chatbot-border-radius, 12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: ai-chatbot-slide-up 0.3s ease;
}

/* Position adjustments */
.ai-chatbot-bottom-left .ai-chatbot-container { right: auto; left: 0; }
.ai-chatbot-top-right   .ai-chatbot-container { bottom: auto; top: 72px; animation-name: ai-chatbot-slide-down; }
.ai-chatbot-top-left    .ai-chatbot-container { bottom: auto; top: 72px; right: auto; left: 0; animation-name: ai-chatbot-slide-down; }

/* Size modifiers */
.ai-chatbot-small  .ai-chatbot-container { width: 320px; max-height: 460px; }
.ai-chatbot-medium .ai-chatbot-container { width: 380px; max-height: 560px; }
.ai-chatbot-large  .ai-chatbot-container { width: 440px; max-height: 640px; }

@keyframes ai-chatbot-slide-up {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes ai-chatbot-slide-down {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ----------------------------- Header ----------------------------------- */
.ai-chatbot-header {
    background: var(--ai-chatbot-primary-color, #435ebe);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-chatbot-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-chatbot-avatar svg {
    width: 22px;
    height: 22px;
    fill: #fff;
}

.ai-chatbot-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
}

.ai-chatbot-subtitle {
    font-size: 12px;
    opacity: 0.85;
    line-height: 1.2;
}

.ai-chatbot-minimize {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.ai-chatbot-minimize:hover {
    background: rgba(255, 255, 255, 0.2);
}

.ai-chatbot-minimize svg {
    width: 20px;
    height: 20px;
}

/* ----------------------------- Messages --------------------------------- */
.ai-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--ai-chatbot-secondary-color, #f8f9fa);
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.ai-chatbot-messages::-webkit-scrollbar {
    width: 5px;
}
.ai-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}
.ai-chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

/* Individual message */
.ai-chatbot-message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    animation: ai-chatbot-msg-in 0.25s ease;
}

@keyframes ai-chatbot-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ai-chatbot-message-content {
    padding: 10px 14px;
    border-radius: var(--ai-chatbot-border-radius, 12px);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    max-width: 85%;
}

.ai-chatbot-message-content a {
    color: var(--ai-chatbot-primary-color, #435ebe);
    text-decoration: underline;
}

.ai-chatbot-message-content code {
    background: rgba(0, 0, 0, 0.06);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 13px;
    font-family: "SF Mono", Menlo, Consolas, monospace;
}

/* Bot message */
.ai-chatbot-message-bot .ai-chatbot-message-content {
    background: #fff;
    color: var(--ai-chatbot-text-color, #333);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Visitor message */
.ai-chatbot-message-visitor {
    align-items: flex-end;
}

.ai-chatbot-message-visitor .ai-chatbot-message-content {
    background: var(--ai-chatbot-primary-color, #435ebe);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-chatbot-message-visitor .ai-chatbot-message-content a {
    color: #fff;
}

/* System message */
.ai-chatbot-message-system .ai-chatbot-message-content {
    background: transparent;
    color: #999;
    font-size: 12px;
    text-align: center;
    max-width: 100%;
    padding: 4px 8px;
}

/* Timestamp */
.ai-chatbot-message-time {
    font-size: 10px;
    color: #999;
    margin-top: 3px;
    padding: 0 4px;
}

.ai-chatbot-message-visitor .ai-chatbot-message-time {
    text-align: right;
}

/* ----------------------------- Typing Indicator ------------------------- */
.ai-chatbot-typing-indicator {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    background: var(--ai-chatbot-secondary-color, #f8f9fa);
}

.ai-chatbot-typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.ai-chatbot-typing-dots span {
    width: 7px;
    height: 7px;
    background: #b0b0b0;
    border-radius: 50%;
    animation: ai-chatbot-dot-bounce 1.4s infinite ease-in-out both;
}

.ai-chatbot-typing-dots span:nth-child(1) { animation-delay: 0s; }
.ai-chatbot-typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.ai-chatbot-typing-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes ai-chatbot-dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40%            { transform: scale(1);   opacity: 1; }
}

/* ----------------------------- Input Area ------------------------------- */
.ai-chatbot-input-area {
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

.ai-chatbot-input-container {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: var(--ai-chatbot-border-radius, 12px);
    padding: 6px 8px;
    transition: border-color 0.2s;
}

.ai-chatbot-input-container:focus-within {
    border-color: var(--ai-chatbot-primary-color, #435ebe);
    box-shadow: 0 0 0 2px rgba(67, 94, 190, 0.12);
}

.ai-chatbot-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    min-height: 22px;
    max-height: 100px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--ai-chatbot-text-color, #333);
    outline: none;
    padding: 4px 0;
    font-family: inherit;
}

.ai-chatbot-input::placeholder {
    color: #aaa;
}

/* File upload button */
.ai-chatbot-file-button {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #888;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    flex-shrink: 0;
}

.ai-chatbot-file-button:hover {
    color: var(--ai-chatbot-primary-color, #435ebe);
    background: rgba(0, 0, 0, 0.05);
}

.ai-chatbot-file-button svg {
    width: 18px;
    height: 18px;
}

/* Send button */
.ai-chatbot-send-button {
    background: var(--ai-chatbot-primary-color, #435ebe);
    border: none;
    color: #fff;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.15s;
    flex-shrink: 0;
}

.ai-chatbot-send-button:disabled {
    opacity: 0.4;
    cursor: default;
}

.ai-chatbot-send-button:not(:disabled):hover {
    opacity: 0.85;
}

.ai-chatbot-send-button:not(:disabled):active {
    transform: scale(0.9);
}

.ai-chatbot-send-button svg {
    width: 16px;
    height: 16px;
}

/* ----------------------------- File Preview ----------------------------- */
.ai-chatbot-file-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin: 0 12px 4px;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    font-size: 12px;
    color: #4338ca;
}

.ai-chatbot-file-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-chatbot-file-remove {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #6366f1;
    line-height: 1;
    padding: 0 2px;
}

.ai-chatbot-file-remove:hover {
    color: #ef4444;
}

/* ----------------------------- Footer ----------------------------------- */
.ai-chatbot-footer {
    text-align: center;
    padding: 6px 12px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
}

.ai-chatbot-footer small {
    font-size: 11px;
    color: #aaa;
}

.ai-chatbot-footer a {
    color: var(--ai-chatbot-primary-color, #435ebe);
    text-decoration: none;
}

.ai-chatbot-footer a:hover {
    text-decoration: underline;
}

/* ----------------------------- Visitor Info Form ------------------------ */
.ai-chatbot-visitor-form {
    padding: 0 0 4px;
}

.ai-chatbot-form-fields {
    padding: 12px 0 0;
}

.ai-chatbot-field {
    margin-bottom: 10px;
}

.ai-chatbot-field input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: var(--ai-chatbot-border-radius, 8px);
    font-size: 14px;
    color: var(--ai-chatbot-text-color, #333);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    font-family: inherit;
}

.ai-chatbot-field input:focus {
    border-color: var(--ai-chatbot-primary-color, #435ebe);
    box-shadow: 0 0 0 2px rgba(67, 94, 190, 0.12);
}

.ai-chatbot-field input::placeholder {
    color: #aaa;
}

.ai-chatbot-visitor-submit {
    width: 100%;
    padding: 11px 16px;
    background: var(--ai-chatbot-primary-color, #435ebe);
    color: #fff;
    border: none;
    border-radius: var(--ai-chatbot-border-radius, 8px);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    font-family: inherit;
}

.ai-chatbot-visitor-submit:hover {
    opacity: 0.9;
}

.ai-chatbot-visitor-submit:disabled {
    opacity: 0.5;
    cursor: default;
}

.ai-chatbot-form-error {
    margin-top: 8px;
    color: #ef4444;
    font-size: 13px;
    text-align: center;
}

/* ----------------------------- Quick Replies ---------------------------- */
.ai-chatbot-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0 8px;
}

.ai-chatbot-quick-reply-btn {
    padding: 6px 14px;
    background: #fff;
    color: var(--ai-chatbot-primary-color, #435ebe);
    border: 1px solid var(--ai-chatbot-primary-color, #435ebe);
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    font-family: inherit;
}

.ai-chatbot-quick-reply-btn:hover {
    background: var(--ai-chatbot-primary-color, #435ebe);
    color: #fff;
}

/* ----------------------------- Welcome ---------------------------------- */
.ai-chatbot-welcome-message {
    margin-bottom: 4px;
}

/* ----------------------------- Responsive ------------------------------- */
@media (max-width: 480px) {
    .ai-chatbot-container {
        width: calc(100vw - 24px) !important;
        max-height: calc(100vh - 100px) !important;
        right: 0;
        left: 0;
        margin: 0 auto;
        border-radius: var(--ai-chatbot-border-radius, 12px) var(--ai-chatbot-border-radius, 12px) 0 0;
    }

    .ai-chatbot-bottom-right .ai-chatbot-container,
    .ai-chatbot-bottom-left .ai-chatbot-container {
        bottom: 72px;
        position: fixed;
        left: 12px;
        right: 12px;
    }

    .ai-chatbot-toggle {
        width: 54px;
        height: 54px;
    }

    .ai-chatbot-icon {
        width: 24px;
        height: 24px;
    }
}
