/**
 * Frontend CSS for A1AI Chatbot Upgrade
 *
 * @package A1AI_Chatbot_Upgrade
 */

/* Contact Form Styles */
.a1ai-contact-form-wrapper {
    max-width: 600px;
    margin: 20px 0;
    padding: 20px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #fff;
}

.a1ai-form-title {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 24px;
    color: #333;
}

.a1ai-contact-form {
    display: flex;
    flex-direction: column;
}

.a1ai-form-field {
    margin-bottom: 15px;
}

.a1ai-form-field label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #555;
}

.a1ai-form-input,
.a1ai-form-textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 14px;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

/* AI-Enhanced Message Field Styles */
.a1ai-ai-message-container {
    position: relative;
}

.a1ai-form-textarea.a1ai-ai-enhanced {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none;
}

.a1ai-ai-chat-section {
    border: 1px solid #ccc;
    border-top: none;
    border-radius: 0 0 3px 3px;
    background-color: #f9f9f9;
    padding: 10px;
}

.a1ai-ai-chat-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.a1ai-ai-chat-toggle:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.a1ai-ai-chat-toggle .dashicons {
    font-size: 16px;
    margin-right: 5px;
}

/* AI Chat Widget */
.a1ai-ai-chat-widget {
    margin-top: 15px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    overflow: hidden;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.a1ai-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.a1ai-chat-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.a1ai-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 3px;
    transition: background-color 0.2s ease;
}

.a1ai-chat-close:hover {
    background-color: rgba(255,255,255,0.2);
}

/* Chat Messages Area */
.a1ai-chat-messages {
    height: 250px;
    overflow-y: auto;
    padding: 16px;
    background: #fafafa;
    border-bottom: 1px solid #eee;
}

.a1ai-chat-message {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
}

.a1ai-chat-message.a1ai-ai-message {
    align-items: flex-start;
}

.a1ai-chat-message.a1ai-user-message {
    align-items: flex-end;
}

.a1ai-message-content {
    max-width: 95%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.a1ai-ai-message .a1ai-message-content {
    background: #e3f2fd;
    color: #1565c0;
    border-bottom-left-radius: 4px;
}

.a1ai-user-message .a1ai-message-content {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.a1ai-message-time {
    font-size: 11px;
    color: #888;
    margin-top: 4px;
    padding: 0 14px;
}

/* Chat Input Area */
.a1ai-chat-input-area {
    display: flex;
    padding: 12px 16px;
    background: white;
    border-bottom: 1px solid #eee;
}

.a1ai-chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.a1ai-chat-input:focus {
    border-color: #667eea;
}

.a1ai-chat-send {
    margin-left: 8px;
    padding: 10px 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.a1ai-chat-send:hover {
    background: #5a67d8;
    transform: scale(1.05);
}

.a1ai-chat-send .dashicons {
    font-size: 16px;
}

/* Chat Actions */
.a1ai-chat-actions {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    background: #f8f9fa;
    justify-content: space-between;
}

.a1ai-chat-finalize {
    background: #28a745;
    border-color: #28a745;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 4px;
}

.a1ai-chat-finalize:hover {
    background: #218838;
    border-color: #1e7e34;
}

.a1ai-chat-clear {
    background: #6c757d;
    border-color: #6c757d;
    color: white;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 4px;
}

.a1ai-chat-clear:hover {
    background: #5a6268;
    border-color: #545b62;
}

/* Loading and Status Indicators */
.a1ai-chat-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #666;
    font-style: italic;
    padding: 8px 14px;
}

.a1ai-typing-dots {
    display: flex;
    gap: 3px;
}

.a1ai-typing-dots span {
    width: 6px;
    height: 6px;
    background: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.a1ai-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.a1ai-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Star Rating Styles */
.a1ai-stars {
    display: flex;
    gap: 5px;
    margin: 10px 0;
    user-select: none;
}

.a1ai-star {
    font-size: 24px;
    color: #ddd;
    cursor: pointer;
    transition: all 0.2s ease;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.a1ai-star:hover,
.a1ai-star.hover {
    color: #ffd700 !important;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
    transform: scale(1.1);
}

.a1ai-star.active,
.a1ai-stars .a1ai-star.active {
    color: #ffd700 !important;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.3) !important;
    opacity: 1 !important;
}

.a1ai-rating-input {
    margin: 15px 0;
}

.a1ai-rating-input label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

/* Scale Rating Styles */
.a1ai-rating-scale {
    width: 100%;
    margin: 10px 0;
}

#a1ai-scale-value {
    font-weight: bold;
    color: #ffd700;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .a1ai-ai-chat-widget {
        margin: 10px -10px 0 -10px;
    }

    .a1ai-chat-messages {
        height: 200px;
    }

    .a1ai-message-content {
        max-width: 98%;
    }

    .a1ai-chat-actions {
        flex-direction: column;
        gap: 8px;
    }

    .a1ai-chat-actions button {
        width: 100%;
    }
}

.a1ai-form-input:focus,
.a1ai-form-textarea:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 5px rgba(0, 124, 186, 0.3);
}

.a1ai-form-textarea {
    resize: vertical;
    min-height: 100px;
}

.a1ai-form-submit {
    margin-top: 10px;
}

.a1ai-submit-button {
    background-color: #007cba;
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s ease;
}

.a1ai-submit-button:hover {
    background-color: #005a87;
}

.a1ai-submit-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.a1ai-form-messages {
    margin-top: 15px;
}

.a1ai-form-success {
    padding: 10px;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 3px;
    color: #155724;
}

.a1ai-form-error {
    padding: 10px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 3px;
    color: #721c24;
}

/* Required field indicator */
.a1ai-form-field label:after {
    content: ' *';
    color: #dc3545;
}

.a1ai-form-field label[for*="phone"]:after,
.a1ai-form-field label[for*="company"]:after,
.a1ai-form-field label[for*="subject"]:after {
    content: '';
}

/* Responsive design */
@media (max-width: 768px) {
    .a1ai-contact-form-wrapper {
        padding: 15px;
        margin: 10px 0;
    }

    .a1ai-form-title {
        font-size: 20px;
    }

    .a1ai-submit-button {
        width: 100%;
    }
}

/* Chat Interface Styles */
.a1ai-chat-container {
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #f9f9f9;
    overflow: hidden;
}

.a1ai-chat-messages {
    height: 300px;
    overflow-y: auto;
    padding: 15px;
    background: white;
}

.a1ai-chat-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.a1ai-bot-message {
    align-items: flex-start;
}

.a1ai-user-message {
    align-items: flex-end;
}

.a1ai-chat-message .message-content {
    max-width: 95%;
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
}

.a1ai-bot-message .message-content {
    background: #e3f2fd;
    color: #1976d2;
}

.a1ai-user-message .message-content {
    background: #007cba;
    color: white;
}

.a1ai-chat-message .message-actions {
    margin-top: 8px;
}

.a1ai-form-trigger-button {
    background: #4caf50;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.3s ease;
}

.a1ai-form-trigger-button:hover {
    background: #45a049;
}

.a1ai-chat-input-container {
    padding: 15px;
    background: #f1f1f1;
    border-top: 1px solid #ddd;
}

.a1ai-chat-input-wrapper {
    display: flex;
    gap: 10px;
}

.a1ai-chat-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
}

.a1ai-chat-input:focus {
    border-color: #007cba;
    box-shadow: 0 0 5px rgba(0, 124, 186, 0.3);
}

.a1ai-chat-send-button {
    background: #007cba;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.a1ai-chat-send-button:hover {
    background: #005a87;
}

.a1ai-chat-send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Hybrid Form Popup */
.a1ai-form-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.a1ai-form-popup-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.a1ai-form-popup-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.a1ai-form-popup-header h4 {
    margin: 0;
    color: #333;
}

.a1ai-form-popup-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.a1ai-form-popup-close:hover {
    color: #000;
}

.a1ai-form-popup-body {
    padding: 20px;
}

.a1ai-form-popup-body .a1ai-form-title {
    display: none;
}

/* Form Type Specific Styles */
.a1ai-organic-chat .a1ai-form-title {
    margin-bottom: 15px;
}

.a1ai-hybrid-form .a1ai-form-title {
    margin-bottom: 15px;
}

/* Hybrid Form Styles - Use existing chat widget but hide header */
.a1ai-contact-form-wrapper[data-form-type*="hybrid"] .a1ai-ai-chat-widget {
    margin-top: 0;
    border-radius: 8px;
}

.a1ai-contact-form-wrapper[data-form-type*="hybrid"] .a1ai-chat-header {
    display: none;
}

/* Loading States */
.a1ai-chat-loading {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 15px;
    color: #666;
    font-style: italic;
}

.a1ai-chat-loading::after {
    content: '...';
    animation: a1ai-dots 1.5s infinite;
}

@keyframes a1ai-dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Chat Scrollbar */
.a1ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.a1ai-chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.a1ai-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.a1ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* ==============================================
   REVIEW CHATBOT & ORGANIC CONTACT FORM STYLES
   ============================================== */

/* Organic Contact Form Interface */
.a1ai-organic-chat-interface {
    margin-top: 15px;
}

.a1ai-chatbot-container.a1ai-organic-contact-form {
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Collection Status Card */
.a1ai-organic-collection-status {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    padding: 20px;
    margin-top: 15px;
    border: 1px solid #dee2e6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.a1ai-collection-progress h4 {
    margin: 0 0 15px 0;
    color: #495057;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.a1ai-collection-progress h4::before {
    content: '📋';
    font-size: 18px;
}

/* Collection Fields Grid */
.a1ai-collection-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.a1ai-collection-field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.a1ai-collection-field:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.a1ai-collection-field .field-label {
    font-weight: 600;
    color: #495057;
    min-width: 80px;
}

.a1ai-collection-field .field-status {
    font-size: 13px;
    color: #6c757d;
    padding: 4px 10px;
    background: #f8f9fa;
    border-radius: 12px;
}

.a1ai-collection-field .field-value {
    flex: 1;
    text-align: right;
    color: #28a745;
    font-weight: 500;
    margin-left: 10px;
}

/* Field States */
.a1ai-collection-field.collected {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-color: #28a745;
}

.a1ai-collection-field.collected .field-status {
    background: #28a745;
    color: white;
}

.a1ai-collection-field.collecting {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeeba 100%);
    border-color: #ffc107;
    animation: pulse-collecting 1.5s infinite;
}

@keyframes pulse-collecting {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(255, 193, 7, 0); }
}

/* Send Button */
.a1ai-send-collected-info {
    width: 100%;
    margin-top: 20px;
    padding: 14px 24px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.a1ai-send-collected-info:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(40, 167, 69, 0.4);
}

.a1ai-send-collected-info:active {
    transform: translateY(0);
}

.a1ai-send-collected-info:disabled {
    background: #6c757d;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Review Form Styles (standalone form, not inside chatbot) */
.a1ai-contact-form-wrapper.a1ai-review-form {
    border: 1px solid #ddd;
    border-radius: 8px;
}

.a1ai-review-form .a1ai-form-title {
    color: #333;
    border-bottom: 2px solid #ffd700;
    padding-bottom: 15px;
}

/* Rating Section - Initial View */
.a1ai-rating-section {
    text-align: center;
    padding: 30px 20px;
}

.a1ai-rating-prompt {
    font-size: 18px;
    color: #333;
    margin: 0 0 20px 0;
    font-weight: 500;
}

/* Review Form Panel - Expands after rating */
.a1ai-review-form-panel {
    border-top: 1px solid #e9ecef;
    padding: 25px;
    background: #fafafa;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Rating Field */
.a1ai-rating-field {
    text-align: center;
    padding: 15px;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-radius: 8px;
    margin-bottom: 20px;
}

.a1ai-rating-field label {
    display: block;
    margin-bottom: 10px;
    text-align: left;
}

.a1ai-rating-field label::after {
    content: '' !important; /* Remove required asterisk for rating label */
}

.a1ai-rating-label {
    margin-top: 8px;
    font-size: 14px;
    color: #b45309;
    font-weight: 500;
}

/* Star Rating in Reviews */
.a1ai-review-stars {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-radius: 12px;
    margin: 15px 0;
}

.a1ai-review-stars .a1ai-star {
    font-size: 32px;
    color: #d1d5db;
    cursor: pointer;
    transition: all 0.2s ease;
}

.a1ai-review-stars .a1ai-star:hover,
.a1ai-review-stars .a1ai-star.hover {
    color: #fbbf24;
    transform: scale(1.2);
}

.a1ai-review-stars .a1ai-star.active {
    color: #f59e0b;
    text-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

/* Thank You Message Card */
.a1ai-review-thank-you {
    text-align: center;
    padding: 30px;
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-radius: 12px;
    border: 1px solid #28a745;
}

.a1ai-review-thank-you h3 {
    color: #155724;
    margin: 0 0 10px 0;
    font-size: 24px;
}

.a1ai-review-thank-you p {
    color: #155724;
    margin: 0;
    font-size: 16px;
}

.a1ai-review-thank-you::before {
    content: '🎉';
    font-size: 48px;
    display: block;
    margin-bottom: 15px;
}

/* Organic Chat Enhanced Messages */
.a1ai-organic-contact-form .a1ai-chatbot-messages,
.a1ai-organic-contact-form .a1ai-chat-messages {
    background: linear-gradient(180deg, #fafafa 0%, #f5f5f5 100%);
}

.a1ai-organic-contact-form .a1ai-bot-message .message-content,
.a1ai-organic-contact-form .a1ai-ai-message .a1ai-message-content {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 1px solid #90caf9;
}

.a1ai-organic-contact-form .a1ai-user-message .message-content,
.a1ai-organic-contact-form .a1ai-user-message .a1ai-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Info Extracted Badge */
.a1ai-info-extracted-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 8px;
}

.a1ai-info-extracted-badge::before {
    content: '✓';
}

/* Responsive chat */
@media (max-width: 768px) {
    .a1ai-chat-messages {
        height: 250px;
    }

    .a1ai-chat-message .message-content {
        max-width: 98%;
        font-size: 13px;
    }

    .a1ai-form-popup-content {
        width: 95%;
        max-height: 90vh;
    }

    .a1ai-chat-input-wrapper {
        flex-direction: column;
        gap: 8px;
    }

    .a1ai-chat-send-button {
        align-self: flex-end;
        padding: 8px 16px;
    }

    /* Responsive Review/Organic Form Styles */
    .a1ai-organic-collection-status {
        padding: 15px;
    }

    .a1ai-collection-field {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .a1ai-collection-field .field-value {
        text-align: left;
        margin-left: 0;
    }

    .a1ai-review-stars .a1ai-star {
        font-size: 28px;
    }

    .a1ai-send-collected-info {
        padding: 12px 20px;
        font-size: 14px;
    }
}
