/* Recommendation Chat Plugin Styles */

.rcp-chat-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    max-width: 800px;
    margin: 0 auto;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    background: #fff;
}

.rcp-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px;
    text-align: center;
}

.rcp-chat-header h3 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
}

.rcp-chat-subtitle {
    margin: 0;
    opacity: 0.9;
    font-size: 14px;
}

.rcp-context-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.rcp-context-section {
    flex: 1;
    min-width: 200px;
}

.rcp-context-section h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #555;
    font-weight: 600;
}

.rcp-context-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    margin-bottom: 8px;
}

.rcp-context-btn {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.rcp-context-btn:hover {
    background: #45a049;
}

.rcp-active-contexts {
    flex: 2;
    min-width: 250px;
}

.rcp-active-contexts h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #555;
    font-weight: 600;
}

#rcp-active-contexts-list {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 12px;
    min-height: 40px;
    font-size: 14px;
    color: #666;
}

.rcp-preferences {
    padding: 20px;
    background: #f0f7ff;
    border-bottom: 1px solid #e0e0e0;
}

.rcp-preferences h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #555;
    font-weight: 600;
}

.rcp-preference-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.rcp-pref-input {
    flex: 1;
    min-width: 150px;
    padding: 10px 12px;
    border: 1px solid #b8d4ff;
    border-radius: 6px;
    font-size: 14px;
    background: white;
}

.rcp-pref-btn {
    background: #2196F3;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.rcp-pref-btn:hover {
    background: #0b7dda;
}

#rcp-current-preferences {
    background: white;
    border: 1px solid #b8d4ff;
    border-radius: 6px;
    padding: 12px;
    font-size: 14px;
    color: #666;
}

.rcp-chat-main {
    display: flex;
    flex-direction: column;
    height: 1000px;
}

.rcp-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fafafa;
    border-bottom: 1px solid #e0e0e0;
}

.rcp-message {
    margin-bottom: 16px;
    max-width: 80%;
    animation: fadeIn 0.3s ease-in;
}

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

.rcp-user-message {
    margin-left: auto;
}

.rcp-assistant-message {
    margin-right: auto;
}

.rcp-message-content {
    padding: 4px 16px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.5;
    position: relative;
}

.rcp-user-message .rcp-message-content {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.rcp-assistant-message .rcp-message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.rcp-message-content a {
    color: #007bff;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 123, 255, 0.3);
    transition: color 0.2s, border-color 0.2s;
}

.rcp-message-content a:hover {
    color: #0056b3;
    border-color: #0056b3;
}

.rcp-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

.rcp-user-message .rcp-message-time {
    text-align: right;
}

.rcp-assistant-message .rcp-message-time {
    text-align: left;
}

.rcp-chat-input-area {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.rcp-message-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 15px;
    resize: vertical;
    font-family: inherit;
    margin-bottom: 12px;
    transition: border 0.2s;
}

.rcp-message-input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.rcp-chat-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.rcp-send-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: background 0.2s;
    flex: 1;
    max-width: 150px;
}

.rcp-send-btn:hover {
    background: #0056b3;
}

.rcp-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.rcp-clear-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    transition: background 0.2s;
    flex: 1;
    max-width: 150px;
}

.rcp-clear-btn:hover {
    background: #545b62;
}

.rcp-debug-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    margin-left: auto;
}

.rcp-recommendations {
    padding: 20px;
    background: #f8f9fa;
    max-height: 200px;
    overflow-y: auto;
    border-bottom: 1px solid #e0e0e0;
}

.rcp-recommendation-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

.rcp-recommendation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.rcp-product-name {
    font-weight: 600;
    font-size: 16px;
    color: #333;
}

.rcp-product-score {
    background: #28a745;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.rcp-product-details {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.rcp-product-reasoning {
    font-size: 13px;
    color: #888;
    font-style: italic;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #007bff;
}

.rcp-chat-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #f8f9fa;
    font-size: 13px;
}

#rcp-status-message {
    color: #666;
    font-weight: 500;
}

.rcp-status-indicators {
    display: flex;
    gap: 16px;
}

.rcp-status-indicator {
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 500;
}

.rcp-status-api {
    background: #e7f3ff;
    color: #0066cc;
}

.rcp-status-context {
    background: #f0f9ff;
    color: #009688;
}

/* Loading animation */
.rcp-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .rcp-context-selector {
        flex-direction: column;
    }
    
    .rcp-context-section, .rcp-active-contexts {
        min-width: 100%;
    }
    
    .rcp-chat-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .rcp-send-btn, .rcp-clear-btn {
        max-width: 100%;
    }
    
    .rcp-debug-toggle {
        margin-left: 0;
        justify-content: center;
    }
    
    .rcp-chat-status {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
    
    .rcp-status-indicators {
        justify-content: center;
    }
}

/* Typing indicator */
.rcp-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 18px;
    width: fit-content;
    margin-bottom: 16px;
    border-bottom-left-radius: 4px;
}

.rcp-typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.rcp-typing-dot:nth-child(1) { animation-delay: -0.32s; }
.rcp-typing-dot: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; }
}

/* Enhanced recommendation styles */
.rcp-recommendation {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.rcp-recommendation:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.rcp-recommendation-with-image {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.rcp-recommendation-image {
    flex-shrink: 0;
    width: 120px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.rcp-recommendation-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.rcp-recommendation:hover .rcp-recommendation-image img {
    transform: scale(1.05);
}

.rcp-recommendation-content {
    flex: 1;
    min-width: 0; /* Prevent flex item from overflowing */
}

.rcp-recommendation-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 10px;
}

.rcp-recommendation-header strong {
    font-size: 16px;
    color: #333;
    flex: 1;
    margin-right: 10px;
    line-height: 1.4;
}

.rcp-recommendation-score {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.rcp-recommendation-rating {
    color: #ffc107;
    font-size: 13px;
    margin: 5px 0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.rcp-recommendation-description {
    font-size: 14px;
    color: #666;
    line-height: 1.5;
    margin: 10px 0;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #007bff;
}

.rcp-recommendation-reasoning {
    font-size: 13px;
    color: #6c757d;
    font-style: italic;
    margin: 10px 0;
    padding: 10px;
    background: #f0f7ff;
    border-radius: 6px;
    border-left: 3px solid #17a2b8;
}

.rcp-recommendation-link {
    margin-top: 12px;
    text-align: right;
}

.rcp-recommendation-link a {
    display: inline-block;
    background: #007bff;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.rcp-recommendation-link a:hover {
    background: #0056b3;
    text-decoration: none;
}

/* Responsive adjustments for product images */
@media (max-width: 768px) {
    .rcp-recommendation-with-image {
        flex-direction: column;
    }
    
    .rcp-recommendation-image {
        width: 100%;
        height: 180px;
    }
    
    .rcp-recommendation-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .rcp-recommendation-score {
        align-self: flex-start;
    }
}

/* Questionnaire styles */
.rcp-questionnaire-question {
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e0e0e0;
}

.rcp-question-text {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 15px;
    line-height: 1.4;
}

.rcp-question-options {
    display: flex;
    flex-direction: column;
    gap: 0px;
}

.rcp-question-option {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 4px 16px;
    margin: 4px 0;
    cursor: pointer;
    transition: all 0.2s ease;
    background-color: #ffffff;
    font-size: 15px;
    color: #333;
    position: relative;
    overflow: hidden;
}

.rcp-question-option:hover {
    border-color: #007bff;
    background-color: #e7f3ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.1);
}

.rcp-question-option.rcp-option-selected {
    border-color: #28a745;
    background-color: #d4edda;
    color: #155724;
}

.rcp-question-option.rcp-option-selected:hover {
    border-color: #1e7e34;
    background-color: #c3e6cb;
}

.rcp-question-option.rcp-option-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f8f9fa;
}

.rcp-question-option.rcp-option-disabled:hover {
    border-color: #e0e0e0;
    background-color: #f8f9fa;
    transform: none;
    box-shadow: none;
}

.rcp-question-text-input {
    margin-top: 15px;
}

.rcp-question-textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    margin-bottom: 10px;
    transition: border-color 0.2s;
}

.rcp-question-textarea:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.rcp-question-submit-text {
    background: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.rcp-question-submit-text:hover {
    background: #0056b3;
}

/* Markdown styles in messages */
.rcp-message-content strong {
    font-weight: 600;
    color: #333;
}

.rcp-message-content em {
    font-style: italic;
    color: #555;
}

.rcp-message-content code {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #e83e8c;
}

.rcp-message-content a {
    color: #007bff;
    text-decoration: none;
    border-bottom: 1px solid rgba(0, 123, 255, 0.3);
    transition: color 0.2s, border-color 0.2s;
}

.rcp-message-content a:hover {
    color: #0056b3;
    border-color: #0056b3;
}
