/* WP AI Chat Buddy - Frontend Chatbot Styles */

/* Reset & Base */
.waicb-chatbot-widget,
.waicb-chatbot-widget *,
.waicb-chatbot-embedded,
.waicb-chatbot-embedded * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* =============================================
   FLOATING WIDGET
   ============================================= */

/* Default position: bottom-right */
.waicb-chatbot-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
}

/* Position: bottom-left */
.waicb-chatbot-widget.waicb-pos-bottom-left {
    right: auto;
    left: 24px;
}

.waicb-pos-bottom-left .waicb-chat-panel {
    right: auto;
    left: 0;
}

/* Position: middle-right */
.waicb-chatbot-widget.waicb-pos-middle-right {
    bottom: auto;
    top: 50%;
    transform: translateY(-50%);
}

.waicb-pos-middle-right .waicb-chat-panel {
    bottom: auto;
    top: -200px;
}

/* Position: middle-left */
.waicb-chatbot-widget.waicb-pos-middle-left {
    bottom: auto;
    right: auto;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
}

.waicb-pos-middle-left .waicb-chat-panel {
    bottom: auto;
    right: auto;
    left: 0;
    top: -200px;
}

/* Toggle Button */
.waicb-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    color: #fff;
    position: relative;
}

.waicb-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(102, 126, 234, 0.55);
}

.waicb-chat-toggle:active {
    transform: scale(0.95);
}

/* Chat Panel */
.waicb-chat-panel {
    position: absolute;
    bottom: 76px;
    right: 0;
    width: 380px;
    max-height: 560px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: waicb-slideUp 0.3s ease;
}

@keyframes waicb-slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Header */
.waicb-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.waicb-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.waicb-chat-avatar {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.waicb-chat-avatar svg {
    color: #fff;
}

.waicb-chat-title {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    line-height: 1.3;
}

.waicb-chat-subtitle {
    font-size: 12px;
    opacity: 0.85;
}

.waicb-chat-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    cursor: pointer;
    color: #fff;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.waicb-chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Area */
.waicb-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    min-height: 300px;
    max-height: 380px;
    scroll-behavior: smooth;
    background: #f7f8fc;
}

.waicb-chat-messages-embedded {
    min-height: 350px;
    max-height: 450px;
}

/* Message Bubbles */
.waicb-message {
    display: flex;
    margin-bottom: 12px;
    animation: waicb-fadeIn 0.3s ease;
}

@keyframes waicb-fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.waicb-message-bot {
    justify-content: flex-start;
}

.waicb-message-user {
    justify-content: flex-end;
}

.waicb-message-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.waicb-message-bot .waicb-message-content {
    background: #fff;
    color: #1a1a2e;
    border: 1px solid #e8eaf0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.waicb-message-user .waicb-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Links in bot messages */
.waicb-message-bot .waicb-message-content a {
    color: #667eea;
    text-decoration: underline;
    word-break: break-all;
}

.waicb-message-bot .waicb-message-content a:hover {
    color: #764ba2;
}

/* Typing Indicator */
.waicb-typing-indicator {
    padding: 8px 16px;
    background: #f7f8fc;
}

.waicb-typing-dots {
    display: flex;
    gap: 4px;
    padding: 8px 16px;
    background: #fff;
    border-radius: 18px;
    border: 1px solid #e8eaf0;
    width: fit-content;
}

.waicb-typing-dots span {
    width: 8px;
    height: 8px;
    background: #a0a3b1;
    border-radius: 50%;
    display: inline-block;
    animation: waicb-bounce 1.4s infinite ease-in-out;
}

.waicb-typing-dots span:nth-child(1) {
    animation-delay: 0s;
}

.waicb-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.waicb-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes waicb-bounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Input Area */
.waicb-chat-input-area {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid #e8eaf0;
    background: #fff;
    gap: 8px;
    flex-shrink: 0;
}

.waicb-chat-input {
    flex: 1;
    border: 1px solid #dcdfe6;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f7f8fc;
    color: #1a1a2e;
}

.waicb-chat-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
    background: #fff;
}

.waicb-chat-input::placeholder {
    color: #a0a3b1;
}

.waicb-chat-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    transition: transform 0.2s, opacity 0.2s;
}

.waicb-chat-send:hover {
    transform: scale(1.05);
}

.waicb-chat-send:active {
    transform: scale(0.95);
}

.waicb-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Error message styling */
.waicb-message-error .waicb-message-content {
    background: #fff0f0;
    border-color: #ffd0d0;
    color: #cc3333;
}

/* =============================================
   EMBEDDED CHATBOT (Shortcode)
   ============================================= */

.waicb-chatbot-embedded {
    max-width: 600px;
    margin: 20px auto;
}

.waicb-chat-panel-embedded {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    max-height: none;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
    background: #fff;
}

/* =============================================
   SCROLLBAR
   ============================================= */

.waicb-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.waicb-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.waicb-chat-messages::-webkit-scrollbar-thumb {
    background: #d0d3dc;
    border-radius: 3px;
}

.waicb-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0a3b1;
}

/* =============================================
   RESPONSIVE
   ============================================= */

@media screen and (max-width: 480px) {
    .waicb-chatbot-widget {
        bottom: 16px;
        right: 16px;
    }

    /* On mobile, reset all positions to bottom-right */
    .waicb-chatbot-widget.waicb-pos-bottom-left {
        right: auto;
        left: 16px;
    }

    .waicb-chatbot-widget.waicb-pos-middle-right,
    .waicb-chatbot-widget.waicb-pos-middle-left {
        top: auto;
        bottom: 16px;
        transform: none;
    }

    .waicb-chatbot-widget.waicb-pos-middle-left {
        right: auto;
        left: 16px;
    }

    .waicb-chat-toggle {
        width: 52px;
        height: 52px;
    }

    .waicb-chat-panel {
        width: calc(100vw - 32px);
        max-height: calc(100vh - 120px);
        bottom: 68px;
        right: -8px;
        border-radius: 12px;
    }

    .waicb-pos-bottom-left .waicb-chat-panel,
    .waicb-pos-middle-left .waicb-chat-panel {
        right: auto;
        left: -8px;
    }

    .waicb-pos-middle-right .waicb-chat-panel,
    .waicb-pos-middle-left .waicb-chat-panel {
        top: auto;
        bottom: 68px;
    }

    .waicb-chat-messages {
        min-height: 250px;
        max-height: calc(100vh - 280px);
    }

    .waicb-message-content {
        max-width: 90%;
        font-size: 13px;
    }
}

@media screen and (max-width: 380px) {
    .waicb-chat-panel {
        width: calc(100vw - 16px);
        right: -12px;
    }

    .waicb-pos-bottom-left .waicb-chat-panel,
    .waicb-pos-middle-left .waicb-chat-panel {
        right: auto;
        left: -12px;
    }
}

/* =============================================
   PRODUCT CARD IN CHAT
   ============================================= */

.waicb-product-card {
    background: #f7f8fc;
    border: 1px solid #e8eaf0;
    border-radius: 8px;
    padding: 10px;
    margin-top: 8px;
}

.waicb-product-card-title {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
}

.waicb-product-card-price {
    color: #667eea;
    font-weight: 600;
    font-size: 14px;
}

.waicb-product-card-link {
    display: inline-block;
    margin-top: 6px;
    font-size: 12px;
    color: #667eea;
}

/* =============================================
   LEAD CAPTURE FORM
   ============================================= */

.waicb-lead-form {
    padding: 24px 20px;
    background: #f7f8fc;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.waicb-lead-form-inner {
    text-align: center;
    width: 100%;
}

.waicb-lead-form-inner h4 {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0 0 8px;
}

.waicb-lead-form-inner > p {
    font-size: 13px;
    color: #646970;
    margin: 0 0 20px;
}

.waicb-lead-field {
    margin-bottom: 12px;
}

.waicb-lead-field input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #dcdfe6;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    color: #1a1a2e;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.waicb-lead-field input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.waicb-lead-field input::placeholder {
    color: #a0a3b1;
}

.waicb-lead-submit {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 4px;
}

.waicb-lead-submit:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.waicb-lead-submit:active {
    transform: scale(0.98);
}

.waicb-lead-skip {
    margin-top: 12px;
    font-size: 12px;
}

.waicb-lead-skip a {
    color: #667eea;
    text-decoration: none;
}

.waicb-lead-skip a:hover {
    text-decoration: underline;
}
