/**
 * Heaven Four Chatbot Widget - Mobile Fullscreen
 */

/* Widget Container */
#h4-chatbot-widget {
    position: fixed;
    bottom: 15px;
    left: 15px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Toggle Button */
#h4-chatbot-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e3967e 0%, #d4836b 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(227, 150, 126, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#h4-chatbot-toggle:hover {
    transform: scale(1.1);
}

#h4-chatbot-toggle .h4-chat-icon,
#h4-chatbot-toggle .h4-close-icon {
    font-size: 20px;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#h4-chatbot-toggle .h4-close-icon {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg);
    color: white;
    font-size: 18px;
}

.h4-chatbot-open #h4-chatbot-toggle .h4-chat-icon {
    opacity: 0;
    transform: rotate(90deg);
}

.h4-chatbot-open #h4-chatbot-toggle .h4-close-icon {
    opacity: 1;
    transform: rotate(0deg);
}

/* Chat Window - FULLSCREEN on mobile */
#h4-chatbot-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: white;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(100%);
    transition: all 0.3s ease;
    z-index: 100000;
}

.h4-chatbot-open #h4-chatbot-window {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Minimized state */
.h4-chatbot-minimized #h4-chatbot-window {
    top: auto;
    bottom: 70px;
    left: 15px;
    right: auto;
    width: 280px;
    height: 50px;
    border-radius: 25px;
    transform: translateY(0);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.h4-chatbot-minimized #h4-chatbot-messages,
.h4-chatbot-minimized #h4-chatbot-form,
.h4-chatbot-minimized .h4-chatbot-disclaimer {
    display: none;
}

.h4-chatbot-minimized .h4-chatbot-header {
    border-radius: 25px;
    cursor: pointer;
}

/* Header with controls */
.h4-chatbot-header {
    background: linear-gradient(135deg, #e3967e 0%, #d4836b 100%);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    flex-shrink: 0;
}

.h4-chatbot-avatar {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.h4-chatbot-title {
    flex: 1;
}

.h4-chatbot-title strong {
    display: block;
    font-size: 14px;
}

.h4-chatbot-title span {
    font-size: 11px;
    opacity: 0.9;
}

/* Header buttons */
.h4-chatbot-controls {
    display: flex;
    gap: 8px;
}

.h4-chatbot-controls button {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.h4-chatbot-controls button:hover {
    background: rgba(255, 255, 255, 0.3);
}

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

/* Message Bubbles */
.h4-chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    font-size: 15px;
    animation: h4-message-appear 0.3s ease;
    word-wrap: break-word;
}

@keyframes h4-message-appear {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.h4-chat-message.bot {
    background: white;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.h4-chat-message.user {
    background: linear-gradient(135deg, #e3967e 0%, #d4836b 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.h4-chat-message.error {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
    align-self: center;
    text-align: center;
    font-size: 13px;
}

/* Typing Indicator */
.h4-typing-indicator {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.h4-typing-indicator span {
    width: 8px;
    height: 8px;
    background: #e3967e;
    border-radius: 50%;
    animation: h4-typing-bounce 1.4s infinite ease-in-out;
}

.h4-typing-indicator span:nth-child(1) { animation-delay: 0s; }
.h4-typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.h4-typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

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

/* Disclaimer */
.h4-chatbot-disclaimer {
    padding: 8px 16px;
    background: #f1f1f1;
    font-size: 10px;
    color: #888;
    text-align: center;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

/* Input Form */
#h4-chatbot-form {
    display: flex;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: white;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
    flex-shrink: 0;
}

#h4-chatbot-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s ease;
    min-width: 0;
}

#h4-chatbot-input:focus {
    border-color: #e3967e;
}

#h4-chatbot-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

#h4-chatbot-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #e3967e 0%, #d4836b 100%);
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

#h4-chatbot-send:hover {
    transform: scale(1.05);
}

#h4-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* TABLET & DESKTOP - Not fullscreen */
@media (min-width: 600px) {
    #h4-chatbot-widget {
        bottom: 20px;
        left: 20px;
    }
    
    #h4-chatbot-toggle {
        width: 56px;
        height: 56px;
    }
    
    #h4-chatbot-window {
        position: absolute;
        top: auto;
        left: 0;
        right: auto;
        bottom: 70px;
        width: 380px;
        height: 550px;
        border-radius: 16px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
        transform: translateY(20px) scale(0.95);
    }
    
    .h4-chatbot-open #h4-chatbot-window {
        transform: translateY(0) scale(1);
    }
    
    .h4-chatbot-minimized #h4-chatbot-window {
        width: 300px;
        bottom: 75px;
    }
    
    #h4-chatbot-form {
        padding-bottom: 12px;
    }
}

/* Scrollbar */
#h4-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#h4-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#h4-chatbot-messages::-webkit-scrollbar-thumb {
    background: #e3967e;
    border-radius: 3px;
}

/* Clickable links in chat */
.h4-chat-message a {
    color: #c17a5f;
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.2s ease;
}

.h4-chat-message a:hover {
    color: #a05d42;
    text-decoration: none;
}

.h4-chat-message.bot a {
    color: #c17a5f;
}

.h4-chat-message.error a {
    color: #9b2c2c; font-weight: 600;
    text-decoration: underline;
}

.h4-chat-message.error a:hover {
    color: #742a2a;
}
