/* CSS Variables for theme customization */
:root {
    --chatbot-theme-color: #0073aa;
    --chatbot-width: 300px;
    --chatbot-height: 400px;
}

/* Base styles for all chatbot containers */
.chatbot-container, #chatbot-container {
    background: white;
    border: 1px solid #ccc;
    box-shadow: 0 0 15px rgba(0,0,0,0.2);
    border-radius: 10px;
    font-family: sans-serif;
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

/* Floating chatbot positioning */
#chatbot-container {
    position: fixed;
    width: var(--chatbot-width, 300px);
    max-width: 90vw; /* Limit width on small screens */
    max-height: 80vh;
}

/* Position classes */
.chatbot-bottom-right {
    bottom: 20px;
    right: 20px;
}

.chatbot-bottom-left {
    bottom: 20px;
    left: 20px;
}

.chatbot-top-right {
    top: 20px;
    right: 20px;
}

.chatbot-top-left {
    top: 20px;
    left: 20px;
}

/* Inline chatbot (for shortcode) */
.chatbot-inline {
    position: relative;
    width: 100%;
    height: 400px;
    margin: 20px 0;
    max-width: 100%; /* Ensure it doesn't overflow its container */
}

/* Chat bubble */
#chatbot-bubble {
    position: fixed;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--chatbot-theme-color, #0073aa);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 24px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    z-index: 9998;
    transition: transform 0.3s ease;
}

#chatbot-bubble:hover {
    transform: scale(1.1);
}

/* Header styles */
#chatbot-header, .chatbot-header {
    background: var(--chatbot-theme-color, #0073aa);
    color: white;
    padding: 10px 15px;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
}

#chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    margin: 0;
    line-height: 1;
}

/* Messages container */
#chatbot-messages, .chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    scroll-behavior: smooth;
    background-color: #f9f9f9;
    height: var(--chatbot-height, 400px);
}

/* Message styles */
.bot-message, .user-message {
    margin: 8px 0;
    padding: 10px 12px;
    border-radius: 10px;
    max-width: 80%;
    word-wrap: break-word;
    position: relative;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.bot-message {
    background: #f1f1f1;
    text-align: left;
    margin-right: auto;
    border-bottom-left-radius: 2px;
}

.user-message {
    background: #d1eaff;
    text-align: right;
    margin-left: auto;
    border-bottom-right-radius: 2px;
}

/* Controls area */
#chatbot-controls {
    display: flex;
    border-top: 1px solid #eee;
    padding: 10px;
    background-color: white;
    border-radius: 0 0 10px 10px;
    align-items: center;
}

/* Button container */
.chatbot-button-container {
    display: flex;
    align-items: center;
    margin-left: 10px;
}

/* Input styles */
#chatbot-input, .chatbot-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    height: 36px;
    box-sizing: border-box;
}

#chatbot-input:focus, .chatbot-input:focus {
    border-color: var(--chatbot-theme-color, #0073aa);
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* Button styles (common for send and clear) */
.chatbot-send-button, .chatbot-clear-button, #chatbot-clear {
    background: var(--chatbot-theme-color, #0073aa);
    border: none;
    color: white;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: 8px;
    transition: background-color 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.chatbot-send-button svg, .chatbot-clear-button svg, #chatbot-clear svg {
    width: 18px;
    height: 18px;
}

/* Send button specific styles */
.chatbot-send-button:hover {
    background-color: #005d87;
}

/* Clear button specific styles */
.chatbot-clear-button:hover, #chatbot-clear:hover {
    background-color: #d9534f;
}

/* Tooltip styles */
[title] {
    position: relative;
}

[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 10000;
    margin-bottom: 5px;
}

/* Loading animation */
.chatbot-loading {
    display: flex;
    padding: 10px;
}

.chatbot-loading span {
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background-color: #ccc;
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out both;
}

.chatbot-loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.chatbot-loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Skin Analysis Styles */
.skin-analysis-response {
    background-color: #f0f7ff !important;
    border-left: 3px solid var(--chatbot-theme-color, #0073aa);
    padding-left: 15px !important;
}

.skin-concern-button-container {
    margin: 10px 0;
    text-align: center;
    padding: 10px 0;
    border-top: 1px solid #eee;
}

.skin-concern-button {
    background-color: var(--chatbot-theme-color, #0073aa);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 14px;
    transition: opacity 0.2s ease;
}

.skin-concern-button:hover {
    opacity: 0.9;
}

/* Product Recommendation Styles */
.product-recommendation {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    margin: 12px 0;
    background-color: #f9f9f9;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    transition: transform 0.2s ease;
}

.product-recommendation:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.product-recommendation h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 16px;
}

.product-price {
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 5px;
    font-size: 15px;
}

.product-description {
    font-size: 14px;
    margin-bottom: 10px;
    color: #555;
    line-height: 1.4;
}

.product-link {
    display: inline-block;
    background-color: var(--chatbot-theme-color, #0073aa);
    color: white !important;
    padding: 6px 12px;
    border-radius: 4px;
    text-decoration: none !important;
    font-size: 14px;
    transition: background-color 0.2s ease;
}

.product-link:hover {
    opacity: 0.9;
    text-decoration: none !important;
}

/* Tablet Responsive Styles */
@media screen and (min-width: 481px) and (max-width: 768px) {
    /* Adjust floating chatbot size for tablets */
    #chatbot-container {
        width: 350px;
        max-width: 90vw;
    }
    
    /* Slightly larger chat bubble for tablets */
    #chatbot-bubble {
        width: 55px;
        height: 55px;
        font-size: 22px;
    }
    
    /* Adjust input field for tablets */
    #chatbot-input, .chatbot-input {
        padding: 11px 15px;
        font-size: 15px;
    }
}

/* Fix for mobile input focus - prevents unwanted zooming */
@media screen and (max-width: 768px) {
    #chatbot-input, .chatbot-input {
        font-size: 16px; /* Minimum 16px font size prevents iOS zoom on focus */
    }
}

/* Mobile Responsive Styles */
@media screen and (max-width: 480px) {
    /* Adjust chat bubble size for better touch target */
    #chatbot-bubble {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    /* Adjust header padding for mobile */
    #chatbot-header, .chatbot-header {
        padding: 12px 10px;
    }
    
    /* Increase input field height for better touch interaction */
    #chatbot-input, .chatbot-input {
        padding: 12px 15px;
        font-size: 16px; /* Minimum 16px font size prevents iOS zoom on focus */
    }
    
    /* Increase clear button size for better touch target */
    #chatbot-clear {
        font-size: 18px;
        padding: 0 12px;
    }
    
    /* Adjust message bubbles for mobile */
    .bot-message, .user-message {
        padding: 12px 14px;
        max-width: 85%;
    }
    
    /* Adjust skin concern button for mobile */
    .skin-concern-button {
        padding: 10px 16px;
        font-size: 16px;
    }
    
    /* Adjust product link for mobile */
    .product-link {
        padding: 8px 14px;
        font-size: 16px;
    }
}
