/* Chatbot Styles */
.chatbot-container {
    position: fixed;
    bottom: 90px; /* Moved up above Buy Me A Coffee button */
    right: 20px; /* Aligned with Buy Me A Coffee button */
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.chatbot-toggle {
    width: 70px; /* Larger button */
    height: 70px; /* Larger button */
    border-radius: 50%;
    background-color: transparent; /* Transparent background for image */
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 1001;
    position: relative;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2); /* Add shadow for better visibility */
}

.chatbot-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.chatbot-toggle-icon {
    display: none; /* Hide the text icon */
}

.chatbot-toggle-image {
    width: 70px; /* Larger image */
    height: 70px; /* Larger image */
    border-radius: 50%;
}

.chatbot-window {
    position: fixed; /* Changed from absolute to fixed for better mobile positioning */
    bottom: 20px;
    right: 20px;
    width: 350px;
    height: 500px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    max-width: calc(100vw - 40px); /* Prevent overflow on small screens */
}

.chatbot-window.active {
    transform: scale(1);
    opacity: 1;
}

.chatbot-header {
    background-color: var(--primary-color, #2c3e50);
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.chatbot-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 20px;
    margin-left: 8px;
}

.chatbot-messages {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
}

.chat-message {
    max-width: 85%;
    padding: 10px 15px;
    border-radius: 18px;
    animation: fadeIn 0.3s;
    word-wrap: break-word;
    line-height: 1.4;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-message {
    align-self: flex-end;
    background-color: var(--secondary-color, #3498db);
    color: white;
    border-bottom-right-radius: 5px;
}

.bot-message {
    align-self: flex-start;
    background-color: #f1f1f1;
    color: #333;
    border-bottom-left-radius: 5px;
}

.message-content p {
    margin: 0;
    line-height: 1.4;
}

.message-content code {
    font-family: monospace;
    background-color: rgba(0, 0, 0, 0.1);
    padding: 2px 4px;
    border-radius: 4px;
    word-break: break-all;
}

.chatbot-input-container {
    display: flex;
    padding: 10px 15px;
    border-top: 1px solid #eee;
    align-items: center;
}

.chatbot-input {
    flex-grow: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 15px 15px; /* Increased padding for larger input */
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
    min-height: 24px; /* Ensure minimum height */
    -webkit-appearance: none; /* Fix for iOS styling */
}

.chatbot-input:focus {
    border-color: var(--secondary-color, #3498db);
    box-shadow: 0 0 3px rgba(52, 152, 219, 0.3);
}

.chatbot-send {
    background-color: var(--secondary-color, #3498db);
    color: white;
    border: none;
    border-radius: 50%;
    width: 29px; /* Smaller button */
    height: 29px; /* Smaller button */
    margin-left: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
    flex-shrink: 0; /* Prevent shrinking */
    -webkit-appearance: none; /* Fix for iOS styling */
}

.chatbot-send:hover {
    background-color: var(--primary-color, #2c3e50);
}

.send-icon {
    font-size: 12px;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background-color: #f1f1f1;
    border-radius: 18px;
    border-bottom-left-radius: 5px;
    max-width: 80px;
    align-self: flex-start;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    border-radius: 50%;
    background-color: #666;
    display: inline-block;
    margin-right: 5px;
    animation: bounce 1.3s linear infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.3s;
    margin-right: 0;
}

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Responsive design */
@media (max-width: 576px) {
    .chatbot-window {
        width: calc(100% - 40px);
        height: 80vh; /* Use viewport height for better mobile sizing */
        max-height: 500px;
        bottom: 10px;
        right: 10px;
        left: 10px;
        margin: 0 auto;
    }
    
    .chatbot-toggle {
        width: 60px;
        height: 60px;
    }

    .chatbot-toggle-image {
        width: 60px;
        height: 60px;
    }

    /* Position buttons with appropriate spacing */
    .chatbot-container {
        bottom: 80px;
    }

    .chatbot-input {
        padding: 10px 12px;
        font-size: 16px;
    }
    
    .chatbot-send {
        width: 30px;
        height: 30px;
        margin-left: 8px;
    }

    .send-icon {
        font-size: 14px;
    }
    
    /* Fix for iOS keyboard issues */
    .chatbot-messages {
        height: calc(80vh - 120px);
    }
}

/* Additional adjustments for very small screens */
@media (max-width: 350px) {
    .chatbot-header h3 {
        font-size: 14px;
    }
    
    .chatbot-input {
        padding: 8px 10px;
    }
    
    .chat-message {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* Fix for devices with notches */
@supports (padding: max(0px)) {
    .chatbot-window {
        padding-bottom: env(safe-area-inset-bottom);
    }
}