/* shadow-ai.css */

/* Basic styling for the chat window */
html,
body {
    margin: 0;
    padding: 0;
    font-family: "Inter", sans-serif; /* Ensure Inter font is used */
    display: flex;
    flex-direction: column;
    height: 100vh; /* Full viewport height */
    overflow: hidden; /* Prevent scrolling in the iframe itself */
    background-color: transparent; /* Ensures the iframe itself is transparent */
    transition:
        background-color 0.3s ease,
        color 0.3s ease;
}

/* Base styles for HTML element inside iframe (light mode defaults) */
html {
    background-color: #f7fafc; /* Tailwind gray-100 for light mode */
    color: #1f2937; /* Default light mode text */
}

/* Dark mode styles directly applied to html.dark class inside iframe */
html.dark {
    background-color: #1a202c; /* Tailwind gray-900 for dark mode body */
    color: #f7fafc; /* Tailwind gray-100 for dark mode text */
}

#chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
    background-color: inherit; /* Inherit from html */
    font-size: 0.9rem; /* Slightly smaller default font size for messages */
    display: flex; /* Make it a flex container */
    flex-direction: column; /* Stack messages vertically */
    width: 100%; /* Ensure it takes full width of its parent */
    box-sizing: border-box; /* Include padding in the element's total width */
    align-items: flex-start; /* Default alignment for messages (left) */
}

#chat-input-container {
    padding: 1rem;
    border-top: 1px solid #e2e8f0; /* Light gray border */
    background-color: inherit; /* Inherit from html */
}

html.dark #chat-input-container {
    border-top-color: #4a5568; /* Dark gray border */
}

.user-message {
    display: flex; /* Make it a flex container */
    justify-content: flex-end; /* Align content to the right WITHIN this container */
    align-self: flex-end; /* Align the entire user-message block to the right within #chat-messages */
}

.ai-message {
    display: flex; /* Make it a flex container */
    justify-content: flex-start; /* Align content to the left WITHIN this container */
    align-self: flex-start; /* Align the entire ai-message block to the left within #chat-messages */
}

.message-bubble {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 1.25rem; /* More rounded corners */
    margin-bottom: 0.5rem;
    line-height: 1.4; /* Improve readability */
    font-size: 0.95rem; /* Adjust message bubble font size */
    word-wrap: break-word; /* Forces long words to break to the next line */
    overflow-wrap: break-word; /* Modern equivalent, use both for compatibility */
    white-space: normal; /* Ensures text wraps normally (overrides any nowrap) */
    min-width: 0; /* Prevents content from forcing a minimum width */
}

.user-message .message-bubble {
    background-color: #4299e1; /* Tailwind blue-500 */
    color: white;
}

.ai-message .message-bubble {
    background-color: #edf2f7; /* Tailwind gray-200 */
    color: #1f2937; /* Default text color */
}

html.dark .ai-message .message-bubble {
    background-color: #2d3748; /* Tailwind gray-700 */
    color: #f7fafc; /* Dark mode text color */
}

/* Input field specific font size and theme-aware colors */
#user-input {
    font-size: 0.95rem; /* Adjust input font size */
    background-color: #ffffff; /* Explicitly white for light mode */
    color: #1f2937; /* Explicitly dark text for light mode */
    /* Add transition for background and color for smooth theme changes */
    transition:
        background-color 0.3s ease,
        color 0.3s ease,
        border-color 0.3s ease;
}

html.dark #user-input {
    background-color: #2d3748; /* Tailwind gray-700 for dark mode */
    color: #f7fafc; /* Tailwind gray-200 for dark mode text */
}

/* Ensure input background stays dark when focused in dark mode */
html.dark #user-input:focus {
    background-color: #2d3748; /* Keep it the same dark gray as the unfocused state */
    color: #f7fafc; /* Ensure text remains readable */
}

/* Attempt to style browser autofill/autocomplete suggestions for dark mode */
/* Note: Direct styling of browser autofill dropdowns is limited and inconsistent across browsers. */

/* For WebKit/Blink browsers (Chrome, Safari, Edge) */
html.dark input:-webkit-autofill,
html.dark input:-webkit-autofill:hover,
html.dark input:-webkit-autofill:focus,
html.dark input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px #2d3748 inset !important; /* Corrected 0px to 0 */
    -webkit-text-fill-color: #f7fafc !important; /* Forces light text color */
    caret-color: #f7fafc !important; /* Cursor color */
}

/* For Firefox (using pseudo-element that might work for some aspects) */
html.dark input::-moz-placeholder {
    /* For placeholder text in Firefox */
    color: #a0aec0; /* Tailwind gray-500 equivalent */
}

/* General input styling for consistency */
html.dark input {
    color: #f7fafc; /* Ensure text color is light */
}
