/*
 * =========================================
 * CSS RESET FOR OPTIBOT
 * =========================================
 */
#wordpress-chat-widget div,
#wordpress-chat-widget h4,
#wordpress-chat-widget p,
#wordpress-chat-widget form,
#wordpress-chat-widget textarea,
#wordpress-chat-widget button,
#wordpress-chat-widget i {
    margin: 0;
    padding: 0;
    border: 0;
    font-size: 100%;
    font: inherit;
    vertical-align: baseline;
    box-sizing: border-box;
    background: none;
    color: inherit;
}

#wordpress-chat-widget button,
#wordpress-chat-widget textarea {
    font-family: inherit;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}


/*
 * =========================================
 * MAIN WIDGET LAYOUT
 * =========================================
 */

#wordpress-chat-widget {
    width: 100%;
}

/* The main container provides the overall padding. */
#wordpress-chat-widget .chat-wrapper {
    background-color: #454654;
    border-radius: 8px;
    width: 100%;
    border: 1px #000 solid;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    max-height: 500px;
    padding: 15px; /* UNIFIED PADDING for top, left, and right. */
    overflow: hidden; /* Failsafe to prevent overflow. */
}

#wordpress-chat-widget .chat-intro {
    height: 35px; /* Adjusted height since parent handles top padding. */
    display: flex;
    align-items: center; /* Vertically center the title. */
    flex-shrink: 0;
}

#wordpress-chat-widget .chat-intro h4 {
    color: #ffffff;
    font-family: sans-serif;
    font-size: 16px;
    font-weight: bold;
}

#wordpress-chat-widget .chat-history {
    flex-grow: 1; /* Makes the history take up all available vertical space. */
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    margin-bottom: 15px; /* Space between history and form. */
    padding-right: 5px; /* Space for the scrollbar so it doesn't overlap content. */
}

/*
 * =========================================
 * MESSAGE BUBBLE STYLES
 * =========================================
 */
#wordpress-chat-widget .message-block {
    box-sizing: border-box;
    padding: 10px;
    border-radius: 5px;
    max-width: 90%; /* Prevent bubbles from taking the full width. */
}

#wordpress-chat-widget .message-block p {
    font-family: sans-serif;
    font-size: 14px;
    white-space: pre-wrap; /* Respects newlines from the server. */
    word-wrap: break-word; /* Breaks long words. */
}

#wordpress-chat-widget .message-block.user {
    background-color: #343541;
    color: #ffffff;
    align-self: flex-end;
}

#wordpress-chat-widget .message-block.assistant {
    background-color: #4f505e; /* Slightly different for contrast. */
    color: #ffffff;
    align-self: flex-start;
}


/*
 * =========================================
 * CHAT INPUT FORM & BUTTON
 * =========================================
 */

/* The form container has NO PADDING. It fits perfectly inside the wrapper. */
#wordpress-chat-widget .chat-form {
    height: 45px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
}

#wordpress-chat-widget .chat-form textarea {
    padding: 10px;
    flex-grow: 1;
    height: 100%;
    resize: none;
    border-radius: 5px;
    border: 1px solid #3B2C35;
    background-color: #343541;
    color: #ffffff;
    font-family: sans-serif;
    font-size: 14px;
    min-width: 0; /* Critical fix for flexbox shrinking. */
}

#wordpress-chat-widget .chat-form button[type=submit] {
    height: 100%;
    width: 45px;
    padding: 0;
    border-radius: 5px;
    border: none;
    background-color: #3B2C35;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
}

#wordpress-chat-widget .chat-form button[type=submit] i.material-icons {
    font-family: 'Material Icons' !important;
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'liga';
    color: #ffffff;
}

/*
 * =========================================
 * LOADING SPINNER ANIMATION (Unchanged)
 * =========================================
 */
#wordpress-chat-widget .sk-chase {
    display: inline-block;
    width: 20px;
    height: 20px;
    position: relative;
    animation: sk-chase 2.5s infinite linear both;
}

#wordpress-chat-widget .sk-chase-dot {
    width: 100%;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
    animation: sk-chase-dot 2.0s infinite ease-in-out both;
}

#wordpress-chat-widget .sk-chase-dot:before {
    content: '';
    display: block;
    width: 25%;
    height: 25%;
    background-color: #F6D6D6;
    border-radius: 100%;
    animation: sk-chase-dot-before 2.0s infinite ease-in-out both;
}

#wordpress-chat-widget .sk-chase-dot:nth-child(1) { animation-delay: -1.1s; }
#wordpress-chat-widget .sk-chase-dot:nth-child(2) { animation-delay: -1.0s; }
#wordpress-chat-widget .sk-chse-dot:nth-child(3) { animation-delay: -0.9s; }
#wordpress-chat-widget .sk-chase-dot:nth-child(4) { animation-delay: -0.8s; }
#wordpress-chat-widget .sk-chase-dot:nth-child(5) { animation-delay: -0.7s; }
#wordpress-chat-widget .sk-chase-dot:nth-child(6) { animation-delay: -0.6s; }
#wordpress-chat-widget .sk-chase-dot:nth-child(1):before { animation-delay: -1.1s; }
#wordpress-chat-widget .sk-chase-dot:nth-child(2):before { animation-delay: -1.0s; }
#wordpress-chat-widget .sk-chase-dot:nth-child(3):before { animation-delay: -0.9s; }
#wordpress-chat-widget .sk-chase-dot:nth-child(4):before { animation-delay: -0.8s; }
#wordpress-chat-widget .sk-chase-dot:nth-child(5):before { animation-delay: -0.7s; }
#wordpress-chat-widget .sk-chase-dot:nth-child(6):before { animation-delay: -0.6s; }

@keyframes sk-chase { 100% { transform: rotate(360deg); } }
@keyframes sk-chase-dot { 80%, 100% { transform: rotate(360deg); } }
@keyframes sk-chase-dot-before { 50% { transform: scale(0.4); } 100%, 0% { transform: scale(1.0); } }