/* =========================================
   Simple Support Bot - Main Styles
   ========================================= */

/* 1. The Main Container 
   Fixed to the bottom right.
   Uses CSS variables to inherit the site's background color if available.
*/
#ssb-chat-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    z-index: 999999; /* Ultra high to sit on top of everything */
    
    /* Structure & visual pop */
    box-shadow: 0 5px 25px rgba(0,0,0,0.15);
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);

    /* INHERITANCE: Attempt to use theme background, fallback to white */
    background: var(--wp--preset--color--background, #ffffff);
    color: inherit; /* Inherit text color from body */
    
    /* INHERITANCE: Use the theme's default font */
    font-family: inherit; 
}

/* 2. Minimized State 
   When the class .ssb-closed is present (default)
*/
#ssb-chat-wrapper.ssb-closed {
    height: 50px;
    width: auto; /* Shrink to fit text */
    min-width: 140px;
    max-width: 200px;
    border-radius: 25px; /* Pill shape when closed */
    cursor: pointer;
}

#ssb-chat-wrapper.ssb-closed #ssb-chat-body {
    display: none; /* Hide the chat area */
}

/* 3. The Header (Title Bar)
   Uses the theme's "Primary" color.
*/
#ssb-chat-header {
    /* INHERITANCE: Use theme primary color, fallback to WordPress Blue */
    background: var(--wp--preset--color--primary, #0073aa);
    color: #ffffff; /* Always white text for contrast on the dark header */
    
    padding: 12px 20px;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

#ssb-toggle-btn {
    background: none;
    border: none;
    color: inherit;
    font-size: 12px;
    cursor: pointer;
    padding: 0;
    margin-left: 10px;
}

/* 4. The Chat Body 
   Flex container to hold messages and buttons.
*/
#ssb-chat-body {
    height: 450px; /* Max height of open window */
    display: flex;
    flex-direction: column;
}

/* 5. Message Area (Scrollable) 
*/
#ssb-messages {
    flex: 1; /* Takes up all available space */
    padding: 15px;
    overflow-y: auto;
    
    /* Subtle grey background for contrast against the white container */
    background: rgba(0,0,0,0.03); 
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ssb-msg {
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    line-height: 1.5;
    max-width: 85%;
    word-wrap: break-word;
}

/* Bot Message Bubble */
.ssb-msg.bot {
    background: #e5e5ea; /* iMessage grey */
    color: #000;
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

/* User Message Bubble */
.ssb-msg.user {
    /* INHERITANCE: Use theme primary color */
    background: var(--wp--preset--color--primary, #0073aa);
    color: #fff;
    align-self: flex-end;
    text-align: right;
    border-bottom-right-radius: 2px;
}

/* 6. Button / Options Area 
   Fixed at the bottom of the chat window
*/
#ssb-options {
    padding: 10px 15px;
    border-top: 1px solid rgba(0,0,0,0.05);
    background: var(--wp--preset--color--background, #ffffff);
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 180px;
    overflow-y: auto;
}

/* 7. The Choice Buttons 
   Designed to look clickable but inherit theme fonts
*/
.ssb-btn {
    display: block;
    width: 100%;
    padding: 10px 12px;
    text-align: left;
    
    /* Reset generic button styles */
    background: transparent;
    border: 1px solid var(--wp--preset--color--primary, #0073aa);
    color: var(--wp--preset--color--primary, #0073aa);
    
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    line-height: 1.4;
    transition: all 0.2s ease;
}

.ssb-btn:hover, .ssb-btn:focus {
    /* Flip colors on hover */
    background: var(--wp--preset--color--primary, #0073aa);
    color: #ffffff;
    outline: none;
}

.ssb-btn strong {
    font-weight: 700; /* Ensure category prefixes stand out */
}

/* 8. Citation Links 
*/
.citation-link {
    display: inline-block;
    margin-top: 8px;
    margin-right: 10px;
    font-size: 0.85em;
    color: var(--wp--preset--color--primary, #0073aa);
    text-decoration: underline;
}

/* 9. Scrollbar Polish 
   Makes the scrollbar look decent on Webkit browsers
*/
#ssb-messages::-webkit-scrollbar,
#ssb-options::-webkit-scrollbar {
    width: 6px;
}
#ssb-messages::-webkit-scrollbar-thumb,
#ssb-options::-webkit-scrollbar-thumb {
    background-color: rgba(0,0,0,0.2);
    border-radius: 3px;
}

.ssb-citation-block {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid rgba(0,0,0,0.1);
    font-size: 0.85em;
    color: #555;
    font-style: italic;
}

.ssb-citation-item {
    display: block;
    margin-bottom: 2px;
}

/* Loading Message Animation */
.ssb-msg.loading {
    color: #666;
    font-style: italic;
    background: transparent; /* clearer that it's temporary */
    padding-left: 0;
}

/* Simple pulse animation for the loader */
@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}
.ssb-msg.loading span {
    animation: pulse 1.5s infinite ease-in-out;
}
