/* General Body and HTML styling */
html, body {
    height: 100%;
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden; /* Prevent scrollbars on body */
}

/* Chatbot Container */
.chatbot-container {
  width: 400px;
  height: 80vh;
  max-height: 720px;
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 2px; /* pour laisser apparaître la bordure dégradée */

  background-image: 
    linear-gradient(white, white), /* fond blanc interne */
    linear-gradient(to right, #0055A4, #FFFFFF, #EF4135); /* bleu, blanc, rouge */
  background-origin: border-box;
  background-clip: content-box, border-box;
  border: 4px solid transparent; /* bordure transparente pour laisser passer le dégradé */
}


/* Chatbot Header */
.chatbot-header {
    background-color: #00274B; /* Green header */
    color: white;
    padding: 15px;
    text-align: center;
    font-size: 1.1em;
    border-top-left-radius: 5px;
    border-top-right-radius: 5px;
}

/* Chatbot Body - Message display area */
.chatbot-body {
    flex-grow: 1;
    padding: 15px;
    overflow-y: auto; /* Enable scrolling for messages */
    display: flex;
    flex-direction: column;
    gap: 10px; /* Space between messages */
    scroll-behavior: smooth; /* Smooth scrolling */
}

/* Individual Message Styling */
.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 18px; /* More rounded corners */
    line-height: 1.4;
    word-wrap: break-word; /* Ensure long words break */
    white-space: pre-wrap; /* Preserve whitespace and allow wrapping */
}

.user-message {
    align-self: flex-end;
    background-color: #DCF8C6; /* Light green for user messages */
    color: #333;
    border-bottom-right-radius: 2px; /* Pointy corner for user */
}

.bot-message {
    align-self: flex-start;
    background-color: #E2E2E2; /* Light grey for bot messages */
    color: #333;
    border-bottom-left-radius: 2px; /* Pointy corner for bot */
}

/* Typing Indicator */
.typing-indicator {
    align-self: flex-start;
    background-color: #E2E2E2;
    border-radius: 18px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px; /* Fixed width for the indicator */
    height: 20px;
    margin-top: 5px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    margin: 0 2px;
    background-color: #999;
    border-radius: 50%;
    display: inline-block;
    animation: bounce 1.4s infinite ease-in-out both;
}

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

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Chatbot Input Area */
.chatbot-input {
    padding: 15px;
    background-color: #f0f0f0;
    display: flex;
    flex-wrap: wrap; /* Allow items to wrap to next line if needed */
    gap: 10px; /* Space between input elements/buttons */
    border-top: 1px solid #ddd;
    align-items: center; /* Align items vertically in the middle */
}

.chatbot-input input[type="email"],
.chatbot-input input[type="text"],
.chatbot-input input[type="tel"],
.chatbot-input textarea {
    flex-grow: 1; /* Allow inputs to take available space */
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1em;
    min-width: 150px; /* Ensure input fields aren't too small */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
    max-width: 100%; /* Prevent overflow on very long lines */
}

.chatbot-input textarea {
    resize: vertical; /* Allow vertical resizing for textareas */
    min-height: 40px; /* Minimum height for textarea */
}

.chatbot-input button {
    background-color: #38b6ff;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    white-space: normal; /* Allow text to wrap within the button */
    word-wrap: break-word; /* Break long words */
    flex-shrink: 0; /* Prevent buttons from shrinking if space is tight */
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
    min-width: auto; /* Allow button to shrink if text is short */
}

.chatbot-input button:hover {
    background-color: #5dcaf5;
}

/* Options container for multiple buttons */
.options-container {
    display: flex;
    flex-wrap: wrap; /* Allow buttons to wrap to next line */
    gap: 10px; /* Space between buttons */
    width: 100%; /* Take full width of the input area */
    justify-content: center; /* ALIGN BUTTONS TO THE CENTER */
}

.options-container button {
    flex-grow: 1; /* Allow buttons to grow and fill space */
    flex-basis: auto; /* Default basis, allows flex-grow to work */
    min-width: 120px; /* Minimum width for readability, adjust as needed */
    max-width: calc(50% - 5px); /* Max 2 buttons per line if space allows, with gap consideration */
    /* On smaller screens or with longer text, they will wrap thanks to flex-wrap */
    white-space: normal; /* Crucial: Allow text to wrap within the button */
    word-wrap: break-word; /* Ensure long words break */
    height: auto; /* Allow height to adjust based on content */
}

/* Media Queries for responsiveness */
@media (max-width: 600px) {
    .chatbot-container {
        width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .chatbot-header {
        border-radius: 0;
    }

    .options-container button {
        max-width: 100%; /* On small screens, make buttons take full width */
    }
}