/**
 * WP ChatBot AI - Frontend Chat Widget Styles (v3.0)
 *
 * @package WP_ChatBot_AI
 */

/* Container */
.wp-chatbot-ai-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1d2327;
    bottom: 20px;
    right: 20px;
}

.wp-chatbot-ai-container.wpcai-position-bottom-left {
    right: auto;
    left: 20px;
}

/* Toggle Button */
.wp-chatbot-ai-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    z-index: 2;
}

.wp-chatbot-ai-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.wp-chatbot-ai-toggle:active {
    transform: scale(0.95);
}

/* Notification Badge */
.wp-chatbot-ai-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 20px;
    height: 20px;
    background: #dc2626;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: wpChatbotBadgePulse 2s infinite;
}

@keyframes wpChatbotBadgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chat Window */
.wp-chatbot-ai-window {
    position: absolute;
    bottom: 68px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15), 0 0 1px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    animation: wpChatbotSlideUp 0.3s ease;
}

.wpcai-position-bottom-left .wp-chatbot-ai-window {
    right: auto;
    left: 0;
}

@keyframes wpChatbotSlideUp {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.wp-chatbot-ai-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    flex-shrink: 0;
}

.wp-chatbot-ai-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.wp-chatbot-ai-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.wp-chatbot-ai-header-name {
    font-weight: 600;
    font-size: 14px;
}

.wp-chatbot-ai-header-status {
    font-size: 10px;
    opacity: 0.8;
    display: flex;
    align-items: center;
    gap: 4px;
}

.wp-chatbot-ai-header-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

.wp-chatbot-ai-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    transition: background 0.15s;
}

.wp-chatbot-ai-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Messages */
.wp-chatbot-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f9fafb;
}

.wp-chatbot-ai-messages::-webkit-scrollbar {
    width: 5px;
}

.wp-chatbot-ai-messages::-webkit-scrollbar-track {
    background: transparent;
}

.wp-chatbot-ai-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.wp-chatbot-ai-message {
    display: flex;
}

.wp-chatbot-ai-message-user {
    justify-content: flex-end;
}

.wp-chatbot-ai-message-assistant {
    justify-content: flex-start;
}

.wp-chatbot-ai-bubble {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 13px;
    line-height: 1.5;
    word-break: break-word;
    white-space: pre-wrap;
}

.wp-chatbot-ai-bubble-user {
    color: white;
    border-bottom-right-radius: 4px;
}

.wp-chatbot-ai-bubble-assistant {
    background: white;
    color: #1d2327;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.wp-chatbot-ai-bubble-name {
    font-size: 10px;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.7;
}

.wp-chatbot-ai-bubble-time {
    font-size: 9px;
    opacity: 0.5;
    margin-top: 4px;
    text-align: right;
}

/* Typing Indicator */
.wp-chatbot-ai-typing {
    display: flex;
    justify-content: flex-start;
    gap: 4px;
    padding: 12px 16px;
}

.wp-chatbot-ai-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: wpChatbotBounce 1.4s infinite ease-in-out;
}

.wp-chatbot-ai-typing span:nth-child(1) { animation-delay: 0s; }
.wp-chatbot-ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.wp-chatbot-ai-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes wpChatbotBounce {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* Footer */
.wp-chatbot-ai-footer {
    padding: 10px 14px;
    border-top: 1px solid #f0f0f1;
    background: white;
    flex-shrink: 0;
}

.wp-chatbot-ai-escalate {
    background: none;
    border: none;
    color: #d97706;
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 0;
    margin-bottom: 6px;
    transition: color 0.15s;
}

.wp-chatbot-ai-escalate:hover {
    color: #b45309;
}

.wp-chatbot-ai-input-form {
    display: flex;
    gap: 8px;
}

.wp-chatbot-ai-input {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.15s;
    font-family: inherit;
}

.wp-chatbot-ai-input:focus {
    border-color: var(--wpcai-primary, #10b981);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.1);
}

.wp-chatbot-ai-input::placeholder {
    color: #9ca3af;
}

.wp-chatbot-ai-send {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity 0.15s, transform 0.15s;
}

.wp-chatbot-ai-send:hover {
    opacity: 0.9;
}

.wp-chatbot-ai-send:active {
    transform: scale(0.95);
}

.wp-chatbot-ai-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Power badge */
.wp-chatbot-ai-powered {
    text-align: center;
    padding: 4px;
    font-size: 10px;
    color: #9ca3af;
    background: #f9fafb;
    border-top: 1px solid #f0f0f1;
}

.wp-chatbot-ai-powered a {
    color: #6b7280;
    text-decoration: none;
}

.wp-chatbot-ai-powered a:hover {
    color: #059669;
}

/* === Mobile responsive === */
@media (max-width: 480px) {
    .wp-chatbot-ai-container {
        bottom: 12px;
        right: 12px;
    }

    .wp-chatbot-ai-container.wpcai-position-bottom-left {
        left: 12px;
    }

    .wp-chatbot-ai-window {
        width: calc(100vw - 24px);
        height: calc(100vh - 80px);
        bottom: 62px;
        right: -6px;
        border-radius: 12px;
    }

    .wpcai-position-bottom-left .wp-chatbot-ai-window {
        left: -6px;
    }

    .wp-chatbot-ai-toggle {
        width: 50px;
        height: 50px;
    }

    .wp-chatbot-ai-bubble {
        max-width: 88%;
    }
}

/* Tablet adjustments */
@media (min-width: 481px) and (max-width: 768px) {
    .wp-chatbot-ai-window {
        width: 340px;
    }
}

/* Inline embed styles */
.wp-chatbot-ai-inline {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .wp-chatbot-ai-bubble-assistant {
        background: #374151;
        color: #f3f4f6;
    }

    .wp-chatbot-ai-messages {
        background: #1f2937;
    }

    .wp-chatbot-ai-footer {
        background: #1f2937;
        border-top-color: #374151;
    }

    .wp-chatbot-ai-input {
        background: #374151;
        border-color: #4b5563;
        color: #f3f4f6;
    }

    .wp-chatbot-ai-input::placeholder {
        color: #6b7280;
    }

    .wp-chatbot-ai-powered {
        background: #1f2937;
        color: #6b7280;
    }
}
