/**
 * Rentmax Sleepcoach - Chat Widget with Popup
 * Includes floating button and modal styling
 */

/* Floating Button */
.rentmax-floating-button {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
    animation: slideUp 0.3s ease-out;
}

.rentmax-floating-button.rentmax-button-hidden {
    display: none;
}

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

.rentmax-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.2s;
    white-space: nowrap;
}

.rentmax-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
}

.rentmax-toggle-btn:active {
    transform: translateY(0);
}

.rentmax-btn-icon {
    font-size: 18px;
    display: inline-block;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

/* Modal Container */
.rentmax-chat-modal {
    position: fixed;
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: 9999;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    transition: all 0.3s ease;
    pointer-events: none;
}

.rentmax-chat-modal.rentmax-modal-open {
    background: rgba(0, 0, 0, 0.3);
    pointer-events: auto;
}

.rentmax-modal-content {
    width: 100%;
    max-width: 420px;
    height: 600px;
    background: white;
    border-radius: 16px 16px 0 0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    pointer-events: auto;
}

.rentmax-chat-modal.rentmax-modal-open .rentmax-modal-content {
    transform: translateY(0);
}

/* Modal Header */
.rentmax-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 16px 16px 0 0;
    flex-shrink: 0;
}

.rentmax-modal-title-area {
    flex: 1;
}

.rentmax-modal-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.rentmax-modal-subtitle {
    margin: 4px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.rentmax-close-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    padding: 0;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    font-size: 24px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.rentmax-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Container */
.rentmax-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f9fafb;
}

/* Message Bubbles */
.rentmax-message {
    display: flex;
    animation: slideIn 0.3s ease-out;
}

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

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

.rentmax-message-assistant,
.rentmax-message-system {
    justify-content: flex-start;
}

.rentmax-message-error {
    justify-content: flex-start;
}

.rentmax-message-content {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
    font-size: 14px;
}

.rentmax-message-user .rentmax-message-content {
    background: #667eea;
    color: white;
    border-radius: 12px 4px 12px 12px;
}

.rentmax-message-assistant .rentmax-message-content,
.rentmax-message-system .rentmax-message-content {
    background: white;
    color: #1f2937;
    border: 1px solid #e5e7eb;
    border-radius: 4px 12px 12px 12px;
}

.rentmax-message-error .rentmax-message-content {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

/* Images in Messages */
.rentmax-message-images {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.rentmax-message-images img {
    max-width: 120px;
    max-height: 120px;
    border-radius: 8px;
    object-fit: cover;
}

/* Typing Indicator */
.rentmax-typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px 4px 12px 12px;
    width: fit-content;
}

.rentmax-typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9ca3af;
    animation: bounce 1.4s infinite;
}

.rentmax-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.rentmax-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    0%, 60%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-10px);
    }
}

/* Input Area */
.rentmax-chatbot-input-area {
    border-top: 1px solid #e5e7eb;
    background: #ffffff;
    padding: 12px;
    flex-shrink: 0;
}

.rentmax-image-preview {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
    min-height: 0;
}

.rentmax-image-item {
    position: relative;
    width: 60px;
    height: 60px;
}

.rentmax-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #e5e7eb;
}

.rentmax-image-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.rentmax-image-remove:hover {
    background: #dc2626;
}

/* Input Controls */
.rentmax-input-controls {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.rentmax-btn-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: #f3f4f6;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rentmax-btn-icon:hover {
    background: #e5e7eb;
}

.rentmax-message-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    outline: none;
    transition: border-color 0.2s;
}

.rentmax-message-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.rentmax-btn-send {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: #667eea;
    color: white;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rentmax-btn-send:hover:not(:disabled) {
    background: #5568d3;
}

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

/* Responsive - Mobile */
@media (max-width: 768px) {
    .rentmax-modal-content {
        max-width: 100%;
        height: 70vh;
        border-radius: 16px 16px 0 0;
    }

    .rentmax-toggle-btn {
        padding: 10px 14px;
        font-size: 13px;
    }

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

    .rentmax-message-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Scrollbar Styling */
.rentmax-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

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

.rentmax-chatbot-messages::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.rentmax-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Embedded Widget Container */
#rentmax-sleepcoach-embedded-widget {
    width: 100%;
    max-width: 100%;
}

#rentmax-sleepcoach-embedded-widget .rentmax-chatbot-container {
    max-height: 600px;
}

.rentmax-chatbot-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.rentmax-chatbot-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom: 1px solid #e5e7eb;
}

.rentmax-chatbot-header-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.rentmax-chatbot-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.rentmax-chatbot-subtitle {
    margin: 4px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}
