/**
 * AI Chat Assistant Styles
 *
 * @package MallorcaRenting
 * @since 1.0.0
 */

.ai-chat-container {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    position: relative;
    z-index: 9999;
}

/* Floating Chat Toggle */
.chat-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #007cba, #00a0d2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 124, 186, 0.4);
    transition: all 0.3s ease;
    z-index: 10000;
}

.chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 124, 186, 0.5);
}

.chat-toggle img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
}

.chat-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #ff4757;
    border-radius: 50%;
    display: none;
    animation: pulse 2s infinite;
}

.chat-notification.show {
    display: block;
}

/* Chat Window */
.chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10000;
    animation: slideInUp 0.3s ease;
}

.ai-chat-container[data-position="embedded"] .chat-window {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    max-width: 500px;
    height: 700px;
    margin: 0 auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #007cba, #00a0d2);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 16px 16px 0 0;
}

.chat-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.chat-info {
    flex: 1;
}

.chat-info h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
}

.chat-status {
    font-size: 12px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
}

.chat-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.message {
    display: flex;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
}

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    margin-right: 10px;
    flex-shrink: 0;
}

.user-message .message-avatar {
    margin-right: 0;
    margin-left: 10px;
    order: 1;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-content {
    max-width: 75%;
    position: relative;
}

.user-message .message-content {
    order: 0;
}

.message-content p {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    margin: 0 0 6px 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    line-height: 1.4;
    word-wrap: break-word;
}

.user-message .message-content p {
    background: linear-gradient(135deg, #007cba, #00a0d2);
    color: white;
    margin-left: auto;
}

.message-time {
    font-size: 11px;
    color: #666;
    margin-left: 16px;
}

.user-message .message-time {
    text-align: right;
    margin-left: 0;
    margin-right: 16px;
}

/* Product Cards in Messages */
.message-product-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    margin: 8px 0;
    max-width: 280px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.message-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.message-product-card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.product-card-content {
    padding: 12px;
}

.product-card-content h5 {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #333;
    line-height: 1.3;
}

.product-card-content .price {
    color: #28a745;
    font-weight: 600;
    font-size: 13px;
}

.product-card-actions {
    padding: 8px 12px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 8px;
}

.product-card-btn {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid #007cba;
    background: transparent;
    color: #007cba;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.product-card-btn:hover {
    background: #007cba;
    color: white;
}

.product-card-btn.primary {
    background: #007cba;
    color: white;
}

.product-card-btn.primary:hover {
    background: #005a87;
}

/* Chat Suggestions */
.chat-suggestions {
    padding: 15px 20px 0;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.suggestion-item {
    display: inline-block;
    background: white;
    border: 1px solid #007cba;
    color: #007cba;
    padding: 8px 16px;
    border-radius: 20px;
    margin: 0 8px 10px 0;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.suggestion-item:hover {
    background: #007cba;
    color: white;
    transform: translateY(-1px);
}

/* Chat Input */
.chat-input-container {
    background: white;
    border-top: 1px solid #e9ecef;
    padding: 15px 20px;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border-radius: 25px;
    padding: 4px;
    border: 1px solid #e9ecef;
    transition: border-color 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

#chat-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 16px;
    outline: none;
    font-size: 14px;
    color: #333;
}

#chat-input::placeholder {
    color: #999;
}

.send-button {
    width: 40px;
    height: 40px;
    border: none;
    background: #007cba;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    margin-right: 2px;
}

.send-button:hover:not(:disabled) {
    background: #005a87;
    transform: scale(1.05);
}

.send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.send-button svg {
    width: 18px;
    height: 18px;
}

/* Typing Indicator */
.chat-typing {
    padding: 10px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: #666;
}

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

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #007cba;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

/* Quick Actions */
.chat-quick-actions {
    padding: 10px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.quick-action {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    color: #666;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.quick-action:hover {
    background: #007cba;
    color: white;
    border-color: #007cba;
}

.quick-action svg {
    width: 14px;
    height: 14px;
}

/* Theme Variations */
.ai-chat-container[data-theme="dark"] .chat-window {
    background: #2c3e50;
    color: white;
}

.ai-chat-container[data-theme="dark"] .chat-messages {
    background: #34495e;
}

.ai-chat-container[data-theme="dark"] .message-content p {
    background: #3d566e;
    color: white;
}

.ai-chat-container[data-theme="minimal"] .chat-window {
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.ai-chat-container[data-theme="minimal"] .chat-header {
    background: #f8f9fa;
    color: #333;
    border-bottom: 1px solid #e9ecef;
}

/* Responsive Design */
@media (max-width: 768px) {
    .chat-window {
        width: 100%;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-height: none;
    }

    .chat-toggle {
        bottom: 15px;
        right: 15px;
        width: 50px;
        height: 50px;
    }

    .chat-toggle img {
        width: 28px;
        height: 28px;
    }

    .message-content {
        max-width: 85%;
    }

    .message-product-card {
        max-width: 240px;
    }

    .chat-suggestions {
        padding: 10px 15px 0;
    }

    .suggestion-item {
        margin: 0 5px 8px 0;
        padding: 6px 12px;
        font-size: 12px;
    }

    .chat-quick-actions {
        flex-wrap: wrap;
        padding: 8px 15px;
    }

    .quick-action {
        padding: 6px 10px;
        font-size: 11px;
    }
}

@media (max-width: 480px) {
    .chat-header {
        padding: 15px;
    }

    .chat-messages {
        padding: 15px;
    }

    .chat-input-container {
        padding: 10px 15px;
    }

    .message-product-card {
        max-width: 200px;
    }

    .product-card-actions {
        flex-direction: column;
    }

    .product-card-btn {
        flex: none;
    }
}

/* Animations */
@keyframes slideInUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.7;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Error States */
.chat-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 8px 0;
    font-size: 13px;
}

/* Loading States */
.chat-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #666;
}

.chat-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 10px;
}

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

/* Action Buttons in Messages */
.message-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.message-action-btn {
    background: #007cba;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.message-action-btn:hover {
    background: #005a87;
    transform: translateY(-1px);
    color: white;
    text-decoration: none;
}

.message-action-btn.secondary {
    background: transparent;
    color: #007cba;
    border: 1px solid #007cba;
}

.message-action-btn.secondary:hover {
    background: #007cba;
    color: white;
}