/*
 * WP Chatbot by Prem - Frontend Styles
 * Version: 2.0.1
 */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* CSS Variables for customization */
:root {
    --wpcbp-primary-color: #8B5CF6;
    --wpcbp-primary-dark: #7C3AED;
    --wpcbp-text-color: #374151;
    --wpcbp-text-light: #6B7280;
    --wpcbp-bg-white: #FFFFFF;
    --wpcbp-bg-gray: #F9FAFB;
    --wpcbp-border-color: #E5E7EB;
    --wpcbp-shadow: 0 10px 25px rgba(0,0,0,0.15);
    --wpcbp-radius: 16px;
    --wpcbp-font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

/* Reset and base styles */
.wpcbp-chatbot * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Main chatbot container */
.wpcbp-chatbot {
    font-family: var(--wpcbp-font-family);
    position: fixed;
    z-index: 999999;
    font-size: 14px;
    line-height: 1.5;
}

/* Position variants */
.wpcbp-chatbot.bottom-right {
    bottom: 20px;
    right: 20px;
}

.wpcbp-chatbot.bottom-left {
    bottom: 20px;
    left: 20px;
}

.wpcbp-chatbot.top-right {
    top: 20px;
    right: 20px;
}

.wpcbp-chatbot.top-left {
    top: 20px;
    left: 20px;
}

/* Chat toggle button */
.wpcbp-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--wpcbp-primary-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--wpcbp-shadow);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.wpcbp-toggle-btn:hover {
    background: var(--wpcbp-primary-dark);
    transform: scale(1.1);
}

.wpcbp-toggle-btn svg {
    width: 24px;
    height: 24px;
    fill: white;
    transition: transform 0.3s ease;
}

.wpcbp-toggle-btn.active svg:first-child {
    transform: rotate(180deg);
}

/* Chat container */
.wpcbp-chat-container {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    max-width: calc(100vw - 40px);
    background: var(--wpcbp-bg-white);
    border-radius: var(--wpcbp-radius);
    box-shadow: var(--wpcbp-shadow);
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 600px;
}

.wpcbp-chat-container.open {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

.wpcbp-chat-container.wpcbp-visible {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

.wpcbp-chat-container.wpcbp-hidden {
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    visibility: hidden;
}

/* Chat header */
.wpcbp-chat-header {
    background: var(--wpcbp-primary-color);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wpcbp-chat-header .bot-info {
    display: flex;
    align-items: center;
}

.wpcbp-chat-header .bot-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
}

.wpcbp-chat-header .bot-avatar svg {
    width: 18px;
    height: 18px;
    fill: white;
}

.wpcbp-chat-header .bot-details h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.wpcbp-chat-header .bot-details p {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
}

.wpcbp-close-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.wpcbp-close-btn:hover {
    background: rgba(255,255,255,0.1);
}

.wpcbp-close-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Chat messages area */
.wpcbp-chat-messages {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
    background: var(--wpcbp-bg-gray);
    scroll-behavior: smooth;
}

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

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

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

/* Individual message */
.wpcbp-message {
    display: flex;
    margin-bottom: 16px;
    animation: wpcbp-fadeInUp 0.4s ease;
}

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

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

.wpcbp-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0 8px;
}

.wpcbp-message.bot .wpcbp-message-avatar {
    background: var(--wpcbp-primary-color);
    order: 1;
}

.wpcbp-message.user .wpcbp-message-avatar {
    background: var(--wpcbp-text-color);
    order: 2;
}

.wpcbp-message-avatar svg {
    width: 16px;
    height: 16px;
    fill: white;
}

.wpcbp-message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
}

.wpcbp-message.bot .wpcbp-message-content {
    background: var(--wpcbp-bg-white);
    color: var(--wpcbp-text-color);
    border-bottom-left-radius: 4px;
    order: 0;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.wpcbp-message.user .wpcbp-message-content {
    background: var(--wpcbp-primary-color);
    color: white;
    border-bottom-right-radius: 4px;
    order: 1;
}

/* Typing indicator */
.wpcbp-typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--wpcbp-bg-white);
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    max-width: 70%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.wpcbp-typing-dots {
    display: flex;
    gap: 4px;
}

.wpcbp-typing-dot {
    width: 8px;
    height: 8px;
    background: var(--wpcbp-text-light);
    border-radius: 50%;
    animation: wpcbp-typing 1.4s infinite ease-in-out;
}

.wpcbp-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.wpcbp-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* FAQ suggestions */
.wpcbp-faq-suggestions {
    margin: 10px 0;
}

.wpcbp-faq-item {
    background: var(--wpcbp-bg-white);
    border: 1px solid var(--wpcbp-border-color);
    border-radius: 8px;
    padding: 10px 12px;
    margin: 6px 0;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
}

.wpcbp-faq-item:hover {
    background: var(--wpcbp-primary-color);
    color: white;
    border-color: var(--wpcbp-primary-color);
}

/* Quick actions */
.wpcbp-quick-actions {
    display: flex;
    gap: 8px;
    margin: 10px 0;
    flex-wrap: wrap;
}

.wpcbp-quick-action {
    background: var(--wpcbp-bg-white);
    border: 1px solid var(--wpcbp-primary-color);
    color: var(--wpcbp-primary-color);
    padding: 6px 12px;
    border-radius: 16px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.wpcbp-quick-action:hover {
    background: var(--wpcbp-primary-color);
    color: white;
}

/* Chat input area */
.wpcbp-chat-input {
    padding: 16px 20px;
    background: var(--wpcbp-bg-white);
    border-top: 1px solid var(--wpcbp-border-color);
}

.wpcbp-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    position: relative;
}

.wpcbp-input-field {
    flex: 1;
    border: 1px solid var(--wpcbp-border-color);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: var(--wpcbp-font-family);
    outline: none;
    transition: border-color 0.2s ease;
    resize: none;
    min-height: 38px;
    max-height: 100px;
}

.wpcbp-input-field:focus {
    border-color: var(--wpcbp-primary-color);
}

.wpcbp-input-field::placeholder {
    color: var(--wpcbp-text-light);
}

.wpcbp-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--wpcbp-primary-color);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.wpcbp-send-btn:hover:not(:disabled) {
    background: var(--wpcbp-primary-dark);
    transform: scale(1.05);
}

.wpcbp-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wpcbp-send-btn svg {
    width: 16px;
    height: 16px;
    fill: white;
}

/* Status messages */
.wpcbp-status-message {
    text-align: center;
    padding: 20px;
    color: var(--wpcbp-text-light);
}

.wpcbp-status-message.success {
    color: #10B981;
}

.wpcbp-status-message.error {
    color: #EF4444;
}

.wpcbp-status-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpcbp-status-message.success .wpcbp-status-icon {
    background: #D1FAE5;
    color: #10B981;
}

.wpcbp-status-message.error .wpcbp-status-icon {
    background: #FEE2E2;
    color: #EF4444;
}

.wpcbp-status-icon svg {
    width: 24px;
    height: 24px;
}

/* Form elements */
.wpcbp-form-group {
    margin-bottom: 16px;
}

.wpcbp-form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--wpcbp-text-color);
    font-size: 13px;
}

.wpcbp-form-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--wpcbp-border-color);
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--wpcbp-font-family);
    transition: border-color 0.2s ease;
}

.wpcbp-form-input:focus {
    outline: none;
    border-color: var(--wpcbp-primary-color);
}

.wpcbp-form-textarea {
    min-height: 80px;
    resize: vertical;
}

.wpcbp-form-button {
    background: var(--wpcbp-primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.wpcbp-form-button:hover:not(:disabled) {
    background: var(--wpcbp-primary-dark);
}

.wpcbp-form-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    /* Chat container full screen on mobile */
    .wpcbp-chat-container {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        z-index: 999999 !important;
    }
    
    .wpcbp-chat-container.wpcbp-hidden {
        transform: translateY(100%) !important;
    }
    
    .wpcbp-chat-container.wpcbp-visible {
        transform: translateY(0) !important;
    }
    
    /* Chat button positioning */
    .wpcbp-chat-button {
        position: fixed !important;
        bottom: 20px !important;
        right: 20px !important;
        width: 60px !important;
        height: 60px !important;
        font-size: 24px !important;
        z-index: 999998 !important;
        box-shadow: 0 4px 20px rgba(0,0,0,0.3) !important;
    }
    
    /* Header with close button */
    .wpcbp-chat-header {
        position: relative !important;
        padding: 20px !important;
        font-size: 18px !important;
        background: var(--wpcbp-primary-color) !important;
        color: white !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }
    
    .wpcbp-chat-header::after {
        content: '×' !important;
        position: absolute !important;
        top: 50% !important;
        right: 20px !important;
        transform: translateY(-50%) !important;
        font-size: 28px !important;
        font-weight: 300 !important;
        cursor: pointer !important;
        opacity: 0.8 !important;
        transition: opacity 0.2s ease !important;
        width: 30px !important;
        height: 30px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        border-radius: 50% !important;
        background: rgba(255,255,255,0.1) !important;
    }
    
    .wpcbp-chat-header::after:hover {
        opacity: 1 !important;
        background: rgba(255,255,255,0.2) !important;
    }
    
    /* Messages area */
    .wpcbp-chat-messages {
        flex: 1 !important;
        height: auto !important;
        max-height: none !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
        padding: 20px !important;
    }
    
    /* Input area */
    .wpcbp-chat-input {
        padding: 20px !important;
        background: #f9f9f9 !important;
        border-top: 1px solid #e0e0e0 !important;
    }
    
    .wpcbp-input-field {
        font-size: 16px !important;
        padding: 15px !important;
        border-radius: 8px !important;
        -webkit-appearance: none !important;
    }
    
    .wpcbp-send-btn {
        width: 44px !important;
        height: 44px !important;
        margin-left: 10px !important;
    }
    
    /* Form elements */
    .wpcbp-form-input {
        font-size: 16px !important;
        padding: 15px !important;
        -webkit-appearance: none !important;
    }
    
    .wpcbp-form-button {
        padding: 15px 20px !important;
        font-size: 16px !important;
        margin-top: 10px !important;
    }
    
    /* Messages styling */
    .wpcbp-message {
        margin-bottom: 15px !important;
        font-size: 16px !important;
        line-height: 1.4 !important;
    }
    
    .wpcbp-message-content {
        max-width: 85% !important;
        padding: 12px 16px !important;
        font-size: 16px !important;
    }
    
    /* FAQ items */
    .wpcbp-faq-item {
        padding: 15px !important;
        margin-bottom: 12px !important;
        font-size: 16px !important;
        line-height: 1.4 !important;
        border-radius: 8px !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
    }
    
    /* Prevent body scroll when chat is open */
    body.wpcbp-chat-open {
        overflow: hidden !important;
        position: fixed !important;
        width: 100% !important;
    }
    
    /* Position variations for mobile */
    .wpcbp-chatbot.bottom-right .wpcbp-chat-button,
    .wpcbp-chatbot.bottom-left .wpcbp-chat-button,
    .wpcbp-chatbot.top-right .wpcbp-chat-button,
    .wpcbp-chatbot.top-left .wpcbp-chat-button {
        bottom: 20px !important;
        right: 20px !important;
        top: auto !important;
        left: auto !important;
    }
}

/* Smaller mobile screens */
@media (max-width: 480px) {
    .wpcbp-chat-header {
        padding: 15px !important;
        font-size: 16px !important;
    }
    
    .wpcbp-chat-messages {
        padding: 15px !important;
    }
    
    .wpcbp-chat-input {
        padding: 15px !important;
    }
    
    .wpcbp-chat-button {
        width: 56px !important;
        height: 56px !important;
        font-size: 22px !important;
    }
}

/* Animations */
@keyframes wpcbp-fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes wpcbp-typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

@keyframes wpcbp-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root {
        --wpcbp-text-color: #F3F4F6;
        --wpcbp-text-light: #9CA3AF;
        --wpcbp-bg-white: #1F2937;
        --wpcbp-bg-gray: #111827;
        --wpcbp-border-color: #374151;
    }
}

/* Accessibility improvements */
.wpcbp-chatbot button:focus,
.wpcbp-chatbot input:focus,
.wpcbp-chatbot textarea:focus {
    outline: 2px solid var(--wpcbp-primary-color);
    outline-offset: 2px;
}

.wpcbp-chatbot button:focus:not(:focus-visible) {
    outline: none;
}

/* Screen reader only text */
.wpcbp-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Print styles */
@media print {
    .wpcbp-chatbot {
        display: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .wpcbp-chatbot {
        --wpcbp-border-color: #000000;
        --wpcbp-text-color: #000000;
        --wpcbp-bg-white: #FFFFFF;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .wpcbp-chatbot *,
    .wpcbp-chatbot *::before,
    .wpcbp-chatbot *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}