/**
 * Enhanced Frontend CSS for PixelChefs Dealership Chatbot
 * 
 * @package PixelChefs_Chatbot
 */

:root {
    --chatbot-primary-color: #0073aa;
    --chatbot-secondary-color: #ffffff;
    --chatbot-text-color: #333333;
    --chatbot-window-width: 450px;
    --chatbot-window-height: 600px;
    --chatbot-border-radius: 12px;
    --chatbot-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    --chatbot-z-index: 999999;
    --chatbot-accent-color: #2271b1;
    --chatbot-success-color: #00a32a;
    --chatbot-warning-color: #dba617;
    --chatbot-error-color: #d63638;
}

/* Main Container */
#pixelchefs-chatbot-container {
    position: fixed;
    z-index: var(--chatbot-z-index);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.5;
    font-size: 14px;
}

/* Position Classes */
#pixelchefs-chatbot-container.pixelchefs-chatbot-bottom-right {
    bottom: 20px;
    right: 20px;
}

#pixelchefs-chatbot-container.pixelchefs-chatbot-bottom-left {
    bottom: 20px;
    left: 20px;
}

#pixelchefs-chatbot-container.pixelchefs-chatbot-top-right {
    top: 20px;
    right: 20px;
}

#pixelchefs-chatbot-container.pixelchefs-chatbot-top-left {
    top: 20px;
    left: 20px;
}

/* Chat Trigger Button */
.chatbot-trigger {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--chatbot-primary-color), var(--chatbot-accent-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--chatbot-shadow);
    transition: all 0.3s ease;
    border: none;
    position: relative;
}

.chatbot-trigger:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.chatbot-trigger svg {
    width: 28px;
    height: 28px;
    color: white;
}

.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--chatbot-error-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
}

/* Chat Window */
.chatbot-window {
    width: var(--chatbot-window-width);
    height: var(--chatbot-window-height);
    background: var(--chatbot-secondary-color);
    border-radius: var(--chatbot-border-radius);
    box-shadow: var(--chatbot-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 80px;
    right: 0;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

/* Header */
.chatbot-header {
    background: linear-gradient(135deg, var(--chatbot-primary-color), var(--chatbot-accent-color));
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
}

.chatbot-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-title-text {
    font-weight: 600;
    font-size: 16px;
}

.chatbot-controls {
    display: flex;
    gap: 8px;
}

.chatbot-control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    color: white;
}

.chatbot-control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Lead Capture Form */
.chatbot-lead-capture {
    padding: 24px;
    background: linear-gradient(135deg, #f8fafc, #e2e8f0);
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    /* Ensure it fits within the chatbot window height */
    max-height: calc(var(--chatbot-window-height) - 60px); /* Subtract header height */
}

.chatbot-lead-capture::-webkit-scrollbar {
    width: 6px;
}

.chatbot-lead-capture::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.chatbot-lead-capture::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chatbot-lead-capture::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.lead-capture-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: min-content;
}

.lead-capture-content h3 {
    margin: 0 0 12px 0;
    color: var(--chatbot-primary-color);
    font-size: 18px;
    font-weight: 600;
}

.lead-capture-content p {
    margin: 0 0 20px 0;
    color: #64748b;
    line-height: 1.6;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--chatbot-text-color);
    font-size: 13px;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: var(--chatbot-primary-color);
    box-shadow: 0 0 0 3px rgba(2, 115, 170, 0.1);
}

.form-actions {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

.start-chat-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--chatbot-primary-color), var(--chatbot-accent-color));
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 0;
}

.start-chat-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(2, 115, 170, 0.3);
}

.start-chat-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.privacy-notice {
    margin-top: 16px;
    text-align: center;
    padding-bottom: 10px;
}

.privacy-notice small {
    color: #64748b;
    font-size: 12px;
    line-height: 1.4;
}

/* Ensure form is always scrollable and submit button is accessible */
#lead-capture-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-grow: 1;
}

.form-error {
    color: var(--chatbot-error-color);
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

/* Messages Container */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #fafbfc;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Individual Messages */
.chatbot-message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    margin-bottom: 4px;
}

.chatbot-message.user {
    align-self: flex-end;
}

.chatbot-message.bot {
    align-self: flex-start;
}

.message-content {
    background: white;
    border-radius: 16px;
    padding: 14px 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.chatbot-message.user .message-content {
    background: linear-gradient(135deg, var(--chatbot-primary-color), var(--chatbot-accent-color));
    color: white;
    border-radius: 16px 16px 4px 16px;
}

.chatbot-message.bot .message-content {
    background: white;
    border-radius: 16px 16px 16px 4px;
}

.message-text {
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-timestamp {
    font-size: 11px;
    margin-top: 8px;
    opacity: 0.7;
    text-align: right;
}

.chatbot-message.bot .message-timestamp {
    text-align: left;
    color: #64748b;
}

/* Intent Buttons */
.intent-buttons, .qualification-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.intent-btn, .qualification-btn {
    padding: 10px 12px;
    background: #f1f5f9;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    color: var(--chatbot-text-color);
}

.intent-btn:hover, .qualification-btn:hover {
    background: var(--chatbot-primary-color);
    color: white;
    border-color: var(--chatbot-primary-color);
    transform: translateY(-1px);
}

/* Boat Product Cards */
.chatbot-products {
    margin-top: 16px;
    background: #f8fafc;
    border-radius: 12px;
    padding: 16px;
    border: 1px solid #e2e8f0;
}

.products-header {
    font-weight: 600;
    color: var(--chatbot-primary-color);
    margin-bottom: 12px;
    font-size: 15px;
}

.products-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.boat-card {
    background: white;
    border-radius: 10px;
    padding: 16px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
}

.boat-card:hover {
    border-color: var(--chatbot-primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.product-image {
    width: 100%;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 12px;
    background: #f1f5f9;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--chatbot-text-color);
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.product-specs {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}

.spec {
    font-size: 13px;
    color: #64748b;
    line-height: 1.4;
}

.product-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--chatbot-success-color);
    margin-bottom: 12px;
}

.product-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.view-boat-btn, .check-availability-btn {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: inline-block;
}

.view-boat-btn {
    background: var(--chatbot-primary-color);
    color: white;
}

.view-boat-btn:hover {
    background: var(--chatbot-accent-color);
    color: white;
    text-decoration: none;
}

.check-availability-btn {
    background: #f1f5f9;
    color: var(--chatbot-text-color);
    border: 1px solid #e2e8f0;
}

.check-availability-btn:hover {
    background: var(--chatbot-success-color);
    color: white;
    border-color: var(--chatbot-success-color);
}

/* Contact Information */
.contact-info {
    background: #f8fafc;
    border-radius: 10px;
    padding: 16px;
    border: 1px solid #e2e8f0;
    margin-top: 12px;
}

.contact-info h4 {
    margin: 0 0 12px 0;
    color: var(--chatbot-primary-color);
    font-size: 15px;
}

.contact-details {
    margin-bottom: 12px;
}

.contact-item {
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--chatbot-text-color);
}

.contact-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}

.contact-btn {
    padding: 10px 12px;
    border-radius: 6px;
    border: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.contact-btn[data-action="request-callback"] {
    background: var(--chatbot-success-color);
    color: white;
}

.contact-btn[data-action="continue-chat"] {
    background: #f1f5f9;
    color: var(--chatbot-text-color);
    border: 1px solid #e2e8f0;
}

.contact-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Typing Indicator */
.chatbot-typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.02);
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--chatbot-primary-color);
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.typing-text {
    font-size: 13px;
    color: #64748b;
    font-style: italic;
}

/* Input Area */
.chatbot-input-container {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.chatbot-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    resize: none;
    font-size: 14px;
    line-height: 1.4;
    min-height: 20px;
    max-height: 100px;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

.chatbot-input:focus {
    outline: none;
    border-color: var(--chatbot-primary-color);
    box-shadow: 0 0 0 3px rgba(2, 115, 170, 0.1);
}

.chatbot-send-btn {
    width: 44px;
    height: 44px;
    background: var(--chatbot-primary-color);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: white;
}

.chatbot-send-btn:hover:not(:disabled) {
    background: var(--chatbot-accent-color);
    transform: translateY(-1px);
}

.chatbot-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

.chatbot-send-btn svg {
    width: 20px;
    height: 20px;
}

/* Footer */
.chatbot-footer {
    padding: 12px 20px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    text-align: center;
}

.powered-by {
    font-size: 11px;
    color: #94a3b8;
}

.powered-by a {
    color: var(--chatbot-primary-color);
    text-decoration: none;
    font-weight: 500;
}

.powered-by a:hover {
    text-decoration: underline;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    :root {
        --chatbot-window-width: calc(100vw - 40px);
        --chatbot-window-height: calc(100vh - 120px);
    }
    
    .chatbot-window {
        right: 20px;
        left: 20px;
        bottom: 80px;
        width: calc(100vw - 40px);
        max-height: calc(100vh - 120px);
    }
    
    .intent-buttons, .qualification-buttons {
        grid-template-columns: 1fr;
    }
    
    .product-actions {
        grid-template-columns: 1fr;
    }
    
    .contact-actions {
        grid-template-columns: 1fr;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .chatbot-window {
        border: 2px solid var(--chatbot-text-color);
    }
    
    .message-content {
        border: 1px solid var(--chatbot-text-color);
    }
    
    .intent-btn, .qualification-btn {
        border: 2px solid var(--chatbot-text-color);
    }
}

/* Focus styles for keyboard navigation */
.chatbot-trigger:focus,
.chatbot-control-btn:focus,
.intent-btn:focus,
.qualification-btn:focus,
.contact-btn:focus,
.view-boat-btn:focus,
.check-availability-btn:focus,
.start-chat-btn:focus,
.chatbot-send-btn:focus {
    outline: 2px solid var(--chatbot-primary-color);
    outline-offset: 2px;
}

.form-group input:focus {
    outline: 2px solid var(--chatbot-primary-color);
    outline-offset: 1px;
}

.chatbot-input:focus {
    outline: 2px solid var(--chatbot-primary-color);
    outline-offset: 1px;
}

/* Mobile and Responsive Design */
@media (max-width: 768px) {
    #pixelchefs-chatbot-container.pixelchefs-chatbot-bottom-right,
    #pixelchefs-chatbot-container.pixelchefs-chatbot-bottom-left {
        bottom: 10px;
        left: 10px;
        right: 10px;
    }
    
    .chatbot-window {
        width: 100%;
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
    }
    
    .chatbot-lead-capture {
        max-height: calc(100vh - 160px); /* Account for header and padding */
        padding: 16px;
    }
    
    .chatbot-messages {
        max-height: calc(100vh - 220px);
    }
}

@media (max-width: 480px) {
    :root {
        --chatbot-window-width: 100%;
        --chatbot-window-height: calc(100vh - 80px);
    }
    
    .chatbot-window {
        border-radius: 12px 12px 0 0;
        height: calc(100vh - 80px);
    }
    
    .chatbot-lead-capture {
        max-height: calc(100vh - 140px);
        padding: 12px;
    }
    
    .lead-capture-content h3 {
        font-size: 16px;
    }
    
    .form-group {
        margin-bottom: 12px;
    }
    
    .form-actions {
        margin-top: 16px;
        padding-top: 16px;
        position: sticky;
        bottom: 0;
        background: linear-gradient(135deg, #f8fafc, #e2e8f0);
        margin-left: -12px;
        margin-right: -12px;
        padding-left: 12px;
        padding-right: 12px;
    }
}