/* --- Hover Chat Bubble Button --- */
#that-ai-bot-trigger-button {
    position: fixed;
    bottom: 20px; /* <--- position from bottom of page */
    right: 20px;
    padding: 12px 18px;
    background-color: #0073aa;
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    z-index: 9998;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    font-size: 16px;
    transition: background-color 0.3s ease;
}

#that-ai-bot-trigger-button:hover {
    background-color: #005177;
}

/* --- CORE WIDGET LAYOUT (IMPROVED) --- */

/* Widget container - Now uses Flexbox for robust layout */
#that-ai-bot-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    height: 450px;
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: none; /* JS toggles this to 'flex' */
    flex-direction: column; /* Main axis is vertical */
    overflow: hidden;
}

/* Header styles - Stays at the top */
#that-ai-bot-header {
    padding: 12px 15px;
    background-color: #0073aa;
    color: white;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Prevents header from shrinking */
}

#that-ai-bot-header #that-ai-bot-title {
    font-size: 1em;
}

#that-ai-bot-close-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0 5px;
}

/* Messages area - Now grows and scrolls correctly */
#that-ai-bot-messages { /* Corrected ID */
    flex-grow: 1; /* Allows this element to take up all available space */
    padding: 15px;
    overflow-y: auto; /* Enables vertical scrollbar when content overflows */
    background-color: #f9f9f9;
}

/* Input area container - Stays at the bottom */
.input-container { /* Renamed from #that-ai-bot-input-area to match PHP */
    padding: 10px; /* Simplified padding */
    background-color: #ffffff;
    border-top: 1px solid #e0e0e0;
    flex-shrink: 0;
}

/* New wrapper for the textarea for better control */
.textarea-wrapper {
    position: relative;
    margin-bottom: 2px; /* <--- ADDS SPACING under the text box */
}

#that-ai-bot-input {
    width: 100%; /* <--- NEW: Make it take full width */
    box-sizing: border-box; /* <--- NEW: Ensure padding is included in width */
    padding: 10px 15px; /* <--- UPDATED: Left and right padding */
    border: 1px solid #dbdbdb; /* <--- UPDATED: Slight border */
    border-radius: 20px; /* <--- NEW: Pill shape for a modern look */
    resize: none;
    min-height: 40px;
    max-height: 100px;
    font-size: 0.95em;
    line-height: 1.4;
    transition: border-color 0.2s ease;
}

#that-ai-bot-input:focus {
    outline: none;
    border-color: #0073aa;
}

/* New wrapper for the send button for alignment */
.send-button-wrapper {
    text-align: right; /* <--- ALIGNS the button to the right */
}

#that-ai-bot-send-btn {
    padding: 8px 16px; /* <--- padding to make button smaller */
    background-color: #0073aa;
    color: white;
    border: none;
    border-radius: 20px; /* <--- modern pill shape */
    cursor: pointer;
    font-size: 0.9em; 
    font-weight: 500;
    transition: background-color 0.2s ease;
}

#that-ai-bot-send-btn:hover {
    background-color: #005177;
}

/* --- SPEECH BUBBLE STYLES --- */

.message-bubble,
.bot-response-block { /* A wrapper for consistent spacing */
    margin-bottom: 8px;
}

.message-bubble {
    display: flex;
}

.user-message, .bot-message {
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 85%;
    word-wrap: break-word;
    line-height: 1.4;
    font-size: 0.9em;
}

.user-message {
    background-color: #22b96e;
    color: #ffffff;
    margin-left: auto; /* Pushes to the right */
    border-bottom-right-radius: 5px;
}

.bot-message {
    background-color: #408de6;
    color: #ffffff;
    margin-right: auto; /* Pushes to the left */
    border-bottom-left-radius: 5px;
}

/* --- Product Card Styles --- */

.bot-products-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px; /* Add space above if it follows a text bubble */
}

.bot-product-card {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.bot-product-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.bot-product-card .product-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    padding: 10px;
}

.bot-product-card .product-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    margin-right: 12px;
}

.bot-product-card .product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.bot-product-card .product-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.bot-product-card .product-title {
    font-weight: bold;
    font-size: 0.9em;
    line-height: 1.3;
    margin-bottom: 4px;
    color: #1d2327;
}

.bot-product-card .product-price {
    font-size: 0.85em;
    color: #555;
    margin-bottom: 4px;
}

.bot-product-card .product-stock {
    font-size: 0.8em;
    font-weight: 500;
}

.bot-product-card .product-stock.in-stock {
    color: #28a745;
}

.bot-product-card .product-stock.out-of-stock {
    color: #dc3545;
}

/* --- Modern Rating Button Styles --- */

/* The container that holds the rating buttons */
.bot-rating-container {
    display: flex;
    justify-content: center; /* Center the buttons */
    gap: 15px; /* Add space between the buttons */
    margin-top: 10px;
    padding: 5px 0;
}

/* Base style for both thumbs up and thumbs down buttons */
.rating-btn {
    width: 50px;           /* Larger width */
    height: 50px;          /* Larger height */
    font-size: 1.8rem;     /* Makes the emoji icon much bigger */
    border-radius: 50%;    /* Makes the button a perfect circle */
    border: 1px solid #dcdcdc; /* A slightly darker, subtle border */
    background-color: #f8f8f8; /* A very light grey to stand out on a white background */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease-in-out; /* Smooth transition for hover effects */
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05); /* A subtle shadow for a "lifted" look */
}

/* Style for hovering over any rating button */
.rating-btn:hover {
    transform: scale(1.1); /* Slightly enlarge the button on hover */
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); /* Enhance the shadow on hover */
}

/* Specific hover color for Thumbs Up */
.rating-btn.thumbs-up:hover {
    background-color: #e8f5e9; /* A light, modern green */
    border-color: #a5d6a7;
}

/* Specific hover color for Thumbs Down */
.rating-btn.thumbs-down:hover {
    background-color: #ffebee; /* A light, modern red */
    border-color: #ef9a9a;
}

/* Style for the "Thank you" feedback message after a rating is given */
.feedback-thanks {
    text-align: center;
    color: #888;
    font-style: italic;
    font-size: 0.9em;
    padding: 15px 0;
}

/* --- Dynamic Form Styles --- */

/* The main container for the form, styled as a bot message bubble */
.bot-form-container {
    background-color: #ECEFF1; /* A neutral, modern light grey */
    color: #37474F; /* Darker text for readability */
    padding: 18px;
    border-radius: 18px;
    border-bottom-left-radius: 5px; /* Matches other bot messages */
}

/* The form element itself */
.that-ai-bot-form {
    display: flex;
    flex-direction: column;
    gap: 15px; /* Spacing between form elements */
}

/* The title/prompt at the top of the form */
.form-prompt {
    font-size: 1.1em;
    font-weight: bold;
    margin: 0 0 5px 0; /* Remove default paragraph margin */
    text-align: center;
    color: #0073aa; /* Match the header color for consistency */
}

/* Wrapper for each label-input pair */
.form-field {
    display: flex;
    flex-direction: column;
}

/* Style for the input field labels */
.form-field label {
    font-size: 0.85em;
    font-weight: 500;
    margin-bottom: 5px;
    color: #546E7A;
}

/* Style for all input fields within the form */
.form-field input {
    width: 100%;
    padding: 5px 8px; 
    border: 1px solid #CFD8DC;
    border-radius: 6px;
    background-color: #ffffff;
    font-size: 0.95em;
    color: #37474F;
    box-sizing: border-box; /* Important width calculation */
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

/* Style for when an input field is focused */
.form-field input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.2); /* A soft blue glow */
}

/* Style for the form's submit button */
.form-submit-btn {
    width: 100%;
    padding: 12px;
    background-color: #22b96e; /* Using the user message green for a positive action */
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    margin-top: 5px; /* Add a little space above the button */
    transition: background-color 0.2s ease, transform 0.1s ease;
}

/* Hover effect for the submit button */
.form-submit-btn:hover {
    background-color: #1c9a5c;
}

/* Active (pressed) effect for the submit button */
.form-submit-btn:active {
    transform: scale(0.98);
}

/* Style for the button when it's disabled (e.g., during submission) */
.form-submit-btn:disabled {
    background-color: #90A4AE;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Style for the error message if form submission fails */
.form-error {
    background-color: #FFEBEE; /* Light red background */
    color: #C62828; /* Dark red text */
    padding: 10px;
    border-radius: 6px;
    font-size: 0.85em;
    text-align: center;
    border: 1px solid #EF9A9A;
    margin-bottom: 5px; /* Space it out if it appears */
}

/* --- "Start New Conversation" Button Styles --- */

/* This rule explicitly hides the OLD button that used to appear in the message area. */
.restart-btn {
    display: none;
}

/* This is the new container that replaces the text input area. */
.restart-container {
    padding: 10px;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

/* This is the new, blue, pill-shaped restart button. */
.restart-btn-main {
    width: auto; /* Let the button size itself */
    padding: 8px 16px;
    background-color: #007bff; /* A nice blue */
    color: white;
    border: none;
    border-radius: 20px; /* Pill shape */
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

/* This adds the hover effect for the new button. */
.restart-btn-main:hover {
    background-color: #0056b3; /* Darker blue on hover */
}

/* --- Service Card Styles --- */

.bot-services-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px; /* Add space above if it follows a text bubble */
}

.bot-service-card {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.bot-service-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.bot-service-card .service-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    padding: 10px;
}

.bot-service-card .service-image {
    flex-shrink: 0;
    width: 60px;
    height: 60px;
    margin-right: 12px;
}

.bot-service-card .service-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.bot-service-card .service-details {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.bot-service-card .service-title {
    font-weight: bold;
    font-size: 0.9em;
    line-height: 1.3;
    margin-bottom: 4px;
    color: #1d2327;
}

/* assets/css/chat-widget.css */

.bot-service-card .service-description {
    font-size: 0.85em;
    color: #555;
    margin-bottom: 4px;
    /* Truncate long descriptions */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2; /* Standard property */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.bot-service-card .service-price {
    font-size: 0.85em;
    color: #555;
    margin-top: auto; /* Pushes the price to the bottom if description is short */
}