/* --- General Plugin Styles --- */
#my-chatbot-container,
#my-chatbot-context-editor-container,
.my-chatbot-context-editor-container-class, /* Common class for context editors */
.my-chatbot-container-class { /* Common class for chatbot containers */
    font-family: Arial, sans-serif !important;
    box-sizing: border-box !important;
    margin: 20px auto !important;
}

/* --- Context Editor Styles (Main and Simple) --- */
#my-chatbot-context-editor-container,
.my-chatbot-context-editor-container-class {
    border: 1px solid #daf1ff !important;
    padding: 20px !important;
    max-width: 600px !important;
    border-radius: 8px !important;
    background-color: #f5fafe !important; /* Default for main editor */
    box-shadow: 0 2px 5px rgba(0,0,0,0.05) !important;
}

/* Specific background for simple editor if desired for distinction */
#my-simple-context-editor-container.my-chatbot-context-editor-container-class {
    background-color: #f8f9fa !important;
}

#my-chatbot-context-editor-container h3,
.my-chatbot-context-editor-container-class h3 {
    margin-top: 0 !important;
    margin-bottom: 15px !important;
    color: #005a87 !important;
    font-size: 1.1em !important;
}

#my-chatbot-user-context-prompt, /* Main editor textarea */
.my-chatbot-context-editor-container-class textarea { /* Textarea in simple editor */
    width: 100% !important;
    padding: 10px !important;
    margin-bottom: 15px !important;
    border: 1px solid #a2d9ff !important; /* Default for main */
    border-radius: 4px !important;
    box-sizing: border-box !important;
    min-height: 100px !important;
    line-height: 1.5 !important;
    background-color: #fff !important;
    color: #333 !important;
}
#my-simple-context-prompt { /* Specific border for simple editor textarea if different */
    border: 1px solid #ced4da !important;
}


/* Button container for better layout (shared by both editors) */
.my-chatbot-context-buttons {
    margin-bottom: 15px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
}

/* Common style for main action buttons in context editors */
#my-chatbot-save-context,
#my-chatbot-download-context,
#my-chatbot-import-context,
#my-simple-save-context,
#my-simple-download-context,
#my-simple-import-context {
    padding: 10px 15px !important;
    color: white !important;
    border: none !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 0.95em !important;
    transition: background-color 0.2s ease-in-out !important;
    min-width: 120px; /* Example min-width */
    text-align: center !important;
}

/* Specific styles for main editor buttons */
#my-chatbot-save-context { background-color: #0073aa !important; }
#my-chatbot-save-context:hover { background-color: #005177 !important; }
#my-chatbot-import-context { background-color: #f0ad4e !important; }
#my-chatbot-import-context:hover { background-color: #ec971f !important; }
#my-chatbot-download-context { background-color: #5cb85c !important; }
#my-chatbot-download-context:hover { background-color: #4cae4c !important; }

/* Specific styles for simple editor buttons (can reuse or override) */
#my-simple-save-context { background-color: #0073aa !important; }
#my-simple-save-context:hover { background-color: #005177 !important; }
#my-simple-import-context { background-color: #f0ad4e !important; }
#my-simple-import-context:hover { background-color: #ec971f !important; }
#my-simple-download-context { background-color: #5cb85c !important; }
#my-simple-download-context:hover { background-color: #4cae4c !important; }


/* Description text in context editors */
#my-chatbot-context-editor-container .description,
.my-chatbot-context-editor-container-class .description {
    font-size: 0.9em !important;
    color: #555 !important;
    margin-top: 10px !important;
    line-height: 1.4 !important;
}

/* Status messages */
#my-chatbot-context-status,
#my-simple-context-status {
    padding: 8px 12px !important;
    margin-top: 10px !important; /* Ensure it has some top margin */
    border-radius: 4px !important;
    text-align: center !important;
    font-weight: bold;
    /* Color and background set by JS */
}


/* --- Styles for Predefined Persona Buttons (Frontend) --- */
#my-chatbot-predefined-personas-container {
    margin-bottom: 15px !important;
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
}
.my-chatbot-personas-title {
    width: 100%; /* Make title take full width */
    margin-bottom: 8px !important;
    font-size: 0.95em !important;
    color: #333 !important;
}
.my-chatbot-personas-title strong {
    color: #005a87 !important;
}
.my-chatbot-persona-button {
    background-color: #6c757d !important;
    color: white !important;
    border: none !important;
    padding: 8px 12px !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 0.9em !important;
    transition: background-color 0.2s ease-in-out !important;
}
.my-chatbot-persona-button:hover {
    background-color: #5a6268 !important;
}

/* "Custom Prompt" button */
#my-chatbot-custom-prompt-button {
    background-color: #17a2b8 !important;
    color: white !important;
    border: none !important;
    padding: 10px 18px !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    font-size: 0.95em !important;
    transition: background-color 0.2s ease-in-out !important;
    margin-bottom: 15px !important;
    display: inline-block !important;
}
#my-chatbot-custom-prompt-button:hover {
    background-color: #138496 !important;
}

/* Active state for persona and custom prompt buttons */
.my-chatbot-persona-button.active,
#my-chatbot-custom-prompt-button.active {
    background-color: #004085 !important;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.2) !important;
}

/* Custom context textarea area */
#my-chatbot-custom-context-area {
    border: 1px dashed #0073aa;
    padding: 15px;
    margin-top: 0; /* Custom prompt button now has margin-bottom */
    margin-bottom: 15px;
    border-radius: 4px;
    background-color: #f0f8ff;
}
#my-chatbot-custom-context-area .my-chatbot-context-buttons {
    margin-top: 10px !important;
    margin-bottom: 0 !important;
}


/* --- Chatbot Interface Styles (Main and Simple) --- */
#my-chatbot-container,
.my-chatbot-container-class {
    border: 1px solid #ccc !important;
    padding: 15px !important; /* Reduced padding slightly for more content space */
    max-width: 500px !important;
    border-radius: 8px !important;
    background-color: #f9f9f9 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
    display: flex; /* Added for flex column layout */
    flex-direction: column; /* Stack messages and input area vertically */
    height: 450px; /* Example fixed height, or use min/max-height */
}

#my-chatbot-messages,
.my-chatbot-messages-class {
    flex-grow: 1; /* Messages area takes available vertical space */
    overflow-y: auto !important;
    border: 1px solid #e0e0e0 !important;
    padding: 10px !important; /* Reduced padding */
    margin-bottom: 10px !important; /* Reduced margin */
    background-color: #ffffff !important;
    border-radius: 4px !important;
    display: flex !important;
    flex-direction: column !important;
    /* scroll-behavior: auto !important; /* Ensure no smooth scroll interferes if set globally */
}

.my-chatbot-message {
    margin-bottom: 8px !important; /* Reduced margin */
    padding: 8px 12px !important; /* Reduced padding */
    border-radius: 15px !important; /* Slightly less rounded */
    line-height: 1.4 !important;
    word-wrap: break-word !important;
    max-width: 85% !important;
    box-shadow: 0 1px 1px rgba(0,0,0,0.05) !important; /* Softer shadow */
    color: #333 !important;
}
.my-chatbot-message.user {
    background-color: #0073aa !important;
    color: white !important;
    align-self: flex-end !important;
    margin-left: auto !important;
}
.my-chatbot-message.bot {
    background-color: #eef1f5 !important;
    color: #333 !important;
    align-self: flex-start !important;
    margin-right: auto !important;
}

/* Typing effect cursor */
.my-chatbot-message.bot.typing-effect::after {
    content: '▋';
    display: inline-block;
    animation: blink-caret 0.75s step-end infinite;
    font-weight: bold;
    margin-left: 2px;
    opacity: 1; /* Ensure it's visible */
}
@keyframes blink-caret {
    from, to { opacity: 1; }
    50% { opacity: 0; }
}


/* Input Area (Mobile Fix Incorporated) */
#my-chatbot-input-area,
.my-chatbot-input-area-class {
    display: flex !important;
    align-items: stretch; /* Ensure items are same height */
    /* margin-bottom: 10px !important; /* Removed, container handles its padding */
    border: 1px solid #aaa !important;
    border-radius: 22px !important;
    overflow: hidden; /* Crucial for rounded corners on children */
    background-color: #fff !important;
    margin-top: auto; /* Push input to bottom if chatbot container is flex column */
}

#my-chatbot-input,
.my-chatbot-input-area-class input[type="text"] {
    flex-grow: 1 !important;
    min-width: 0 !important; /* Allow input to shrink */
    padding: 10px 15px !important; /* Adjusted padding */
    border: none !important;
    box-sizing: border-box !important;
    font-size: 0.95em !important; /* Adjusted font size */
    line-height: 1.4 !important;
    background-color: transparent !important;
    color: #333 !important;
    outline: none !important;
}

#my-chatbot-send,
.my-chatbot-input-area-class button {
    flex-shrink: 0 !important; /* Prevent button from shrinking */
    padding: 10px 15px !important;
    color: white !important;
    border: none !important;
    cursor: pointer !important;
    font-size: 0.9em !important; /* Adjusted font size */
    transition: background-color 0.2s ease-in-out !important;
    white-space: nowrap !important;
    display: flex;
    align-items: center;
    justify-content: center;
}

#my-chatbot-send { /* Specific for main chatbot */
    background-color: #0073aa !important;
}
#my-chatbot-send:hover {
    background-color: #005177 !important;
}

#my-simple-chatbot-input-area button { /* Specific for simple chatbot */
    background-color: #28a745 !important;
}
#my-simple-chatbot-input-area button:hover {
    background-color: #218838 !important;
}


/* Loading and Error messages */
#my-chatbot-loading, #my-chatbot-error,
#my-simple-chatbot-loading, #my-simple-chatbot-error {
    text-align: center !important;
    padding: 8px !important;
    margin-top: 5px !important;
    border-radius: 4px !important;
}
#my-chatbot-loading, #my-simple-chatbot-loading {
    color: #555 !important;
    font-style: italic !important;
}
#my-chatbot-error, #my-simple-chatbot-error {
    color: #d9534f !important;
    background-color: #f2dede !important;
    border: 1px solid #ebccd1 !important;
    font-weight: bold !important;
}


/* --- Modal Styles (Shared) --- */
.my-chatbot-modal {
    display: none;
    position: fixed !important;
    z-index: 1000 !important;
    left: 0;
    top: 0;
    width: 100% !important;
    height: 100% !important;
    overflow: auto !important;
    background-color: rgba(0,0,0,0.5) !important;
    padding-top: 60px;
}
.my-chatbot-modal-content {
    background-color: #fefefe !important;
    margin: 5% auto !important;
    padding: 25px !important;
    border: 1px solid #888 !important;
    width: 80% !important;
    max-width: 500px !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19) !important;
    position: relative !important;
}
.my-chatbot-modal-close {
    color: #aaa !important;
    float: right !important;
    font-size: 28px !important;
    font-weight: bold !important;
    line-height: 1 !important;
    padding: 0 5px;
}
.my-chatbot-modal-close:hover,
.my-chatbot-modal-close:focus {
    color: black !important;
    text-decoration: none !important;
    cursor: pointer !important;
}
.my-chatbot-modal h4 {
    margin-top: 0 !important;
    color: #005a87 !important;
}
.my-chatbot-modal p {
    font-size: 0.95em !important;
    line-height: 1.5 !important;
    margin-bottom: 15px !important;
}
#my-chatbot-context-file-input, /* For main editor modal */
#my-simple-context-file-input { /* For simple editor modal */
    display: block !important;
    width: 100% !important;
    padding: 8px !important;
    box-sizing: border-box !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    margin-bottom: 10px; /* Added margin for spacing */
}
#my-chatbot-import-file-feedback.error,
#my-simple-import-file-feedback.error {
    color: #d9534f !important;
    font-weight: bold;
}
#my-chatbot-import-file-feedback.success,
#my-simple-import-file-feedback.success {
    color: #5cb85c !important;
    font-weight: bold;
}

.clearfix::after {
    content: "" !important;
    clear: both !important;
    display: table !important;
}


/* Styles for [my_chatbot_user_full_history] Shortcode */
.my-chatbot-full-history-container-class {
    font-family: Arial, sans-serif;
    color: #333;
    background-color: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    max-width: 900px; /* Or your preferred max-width */
    margin: 20px auto;
}

.my-chatbot-full-history-container-class h2 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 25px;
    font-size: 1.8em;
}

.my-chatbot-full-history-controls {
    background-color: #fff;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.history-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 20px; /* Space between filter groups */
    margin-bottom: 15px;
    align-items: flex-end; /* Align items to the bottom */
}

.history-filter-group {
    display: flex;
    flex-direction: column; /* Stack label and input */
    flex-grow: 1;
}
.history-filter-group label {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.9em;
    color: #555;
}
.my-chatbot-history-search-input,
.my-chatbot-history-date-input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1em;
    box-sizing: border-box; /* Include padding and border in the element's total width and height */
}
.my-chatbot-history-search-input {
    width: 100%; /* Make search input take available space */
}
.my-chatbot-history-date-input {
     width: auto; /* Allow date input to size naturally or set a specific width */
}

#my-chatbot-history-clear-date-filter {
    padding: 9px 15px; /* Adjust padding to align with input height */
    font-size: 0.9em;
    margin-left: 5px; /* Space from date input if on same conceptual line */
    height: 40px; /* Match input height approx */
    line-height: 1.5; /* Adjust for vertical centering of text */
    background-color: #e0e0e0;
    border-color: #ccc;
    color: #333;
}
#my-chatbot-history-clear-date-filter:hover {
    background-color: #d0d0d0;
    border-color: #bbb;
}


.my-chatbot-history-description {
    font-size: 0.85em;
    color: #666;
    margin-top: 10px;
    line-height: 1.5;
}

.my-chatbot-history-delete-controls {
    padding: 10px 0; /* Add some padding */
    border-top: 1px solid #eee; /* Separator */
    margin-top: 20px;
}

#my-chatbot-delete-selected-messages.button-danger {
    background-color: #d9534f; /* Red for danger */
    border-color: #d43f3a;
    color: white;
}
#my-chatbot-delete-selected-messages.button-danger:hover {
    background-color: #c9302c;
    border-color: #ac2925;
}


#my-chatbot-full-history-loading,
#my-chatbot-full-history-none {
    color: #777;
    font-style: italic;
}

.history-log-section {
    margin-top: 30px;
    background-color: #fff;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.history-log-section h3 {
    color: #34495e;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 10px;
    margin-bottom: 15px;
    font-size: 1.4em;
}

.history-date-header {
    font-size: 1.1em;
    color: #7f8c8d;
    margin: 20px 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 1px dashed #bdc3c7;
    font-weight: bold;
}
.history-date-header:first-child {
    margin-top: 0;
}

.history-messages .my-chatbot-message {
    margin-bottom: 12px;
    padding: 10px 15px;
    border-radius: 15px; /* More rounded corners for chat bubbles */
    line-height: 1.6;
    max-width: 85%; /* Prevent messages from taking full width */
    word-wrap: break-word; /* Ensure long words break */
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
    display: flex; /* For checkbox alignment */
    align-items: flex-start; /* Align checkbox with top of message content */
}

.history-messages .my-chatbot-message.user {
    background-color: #3498db; /* User message color */
    color: white;
    margin-left: auto; /* Align user messages to the right */
    border-bottom-right-radius: 5px; /* Tail effect */
}

.history-messages .my-chatbot-message.bot {
    background-color: #ecf0f1; /* Bot message color */
    color: #2c3e50;
    margin-right: auto; /* Align bot messages to the left */
    border-bottom-left-radius: 5px; /* Tail effect */
}

.history-message-meta {
    display: block; /* Or flex if you want time and checkbox on same line */
    font-size: 0.75em;
    color: #7f8c8d; /* Lighter color for meta */
    margin-bottom: 4px;
}
.history-messages .my-chatbot-message.user .history-message-meta {
    color: #e0f2fe; /* Lighter color for user meta */
    text-align: right; /* Align time to right for user */
}

.history-message-time {
    display: block; /* Time on its own line within meta, or inline-block */
}

.history-message-content-wrapper {
    display: flex;
    align-items: flex-start; /* Align checkbox with the start of the text block */
    width: 100%;
}

.history-message-delete-cb {
    margin-right: 10px; /* Space between checkbox and message content */
    margin-top: 3px; /* Align checkbox better with first line of text */
    flex-shrink: 0; /* Prevent checkbox from shrinking */
    accent-color: #3498db; /* Color the checkbox itself */
}

.history-message-content {
    flex-grow: 1;
}

.history-message-content p:first-child {
    margin-top: 0;
}
.history-message-content p:last-child {
    margin-bottom: 0;
}

/* Adjust checkbox position for user messages if they are right-aligned */
.history-messages .my-chatbot-message.user .history-message-content-wrapper {
    flex-direction: row-reverse; /* Checkbox on the left, content on the right for user */
}
.history-messages .my-chatbot-message.user .history-message-delete-cb {
    margin-left: 10px;
    margin-right: 0;
}
.history-messages .my-chatbot-message.user .history-message-content {
    text-align: left; /* Keep text within user bubble left-aligned */
}