/* --- Enhanced Chat Widget Styles --- */

/* Floating Bubble Styles */
.anito-chat-bubble {
    position: fixed;
    width: 60px;
    height: 60px;
    background-color: #008080; /* Updated to match new theme */
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px; /* Placeholder for an icon */
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9998;
    transition: transform 0.2s ease-in-out, background-color 0.2s ease;
}

.anito-chat-bubble:hover {
    transform: scale(1.1);
    background-color: #006666; /* Darker teal on hover */
}

.anito-chat-bubble-bottom-right {
    bottom: 20px;
    right: 20px;
}

.anito-chat-bubble-bottom-left {
    bottom: 20px;
    left: 20px;
}

.anito-chat-bubble-top-right {
    top: 20px;
    right: 20px;
}

.anito-chat-bubble-top-left {
    top: 20px;
    left: 20px;
}

/* Chat Window Styles */
.anito-chat-window {
    width: 700px; /* Increased width */
    max-width: 95vw;
    height: 600px;
    max-height: 85vh;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    background-color: #fff;
    overflow: hidden;
    transition: width 0.3s ease, height 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

.anito-chat-window-floating {
    position: fixed;
    z-index: 9999;
    /* Default to bottom-right, JS can override based on options */
    bottom: 20px; 
    right: 20px;
}

/* Positioning for floating window - applied by JS based on options */
.anito-chat-window-bottom-right {
    bottom: 20px;
    right: 20px;
}

.anito-chat-window-bottom-left {
    bottom: 20px;
    left: 20px;
}

.anito-chat-window-top-right {
    top: 20px;
    right: 20px;
}

.anito-chat-window-top-left {
    top: 20px;
    left: 20px;
}

/* Styles for the main widget container, especially for inline mode */
.anito-chat-widget-inline {
    height: 100%; /* Ensure the widget itself fills its designated container */
    /* .anito-chat-window within this will take up 100% of this height */
}

.anito-chat-widget-inline .anito-chat-window {
    width: 100%; /* Take full width of inline container */
    height: 100%; /* Take full height of inline container */
    max-width: none;
    max-height: none;
    border-radius: 0; /* Often inline widgets don't need their own radius if container has it */
    box-shadow: none; /* Inline usually doesn't need its own shadow */
}

/* Chat Header */
.anito-chat-header {
    background-color: #008080; /* Dark Teal for header */
    color: white;
    padding: 18px 20px;
    font-size: 1.15em;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.anito-chat-close {
    font-size: 1.9em;
    font-weight: bold;
    color: #fff;
    opacity: 0.8;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0 5px;
}
.anito-chat-close:hover {
    opacity: 1;
}

/* Message Area */
.anito-chat-messages {
    padding: 20px;
    flex-grow: 1;
    overflow-y: auto;
    background-color: #f0f4f8; /* Very light blue-grey for message area */
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Input Area */
.anito-chat-input-area {
    padding: 15px 20px;
    border-top: 1px solid #dde3e9;
    background-color: #ffffff;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.anito-chat-input-area textarea {
    flex-grow: 1;
    padding: 12px 15px;
    border-radius: 20px;
    border: 1px solid #cdd5de;
    font-size: 1em;
    resize: none;
    min-height: 24px;
    max-height: 100px;
    line-height: 1.4;
    margin-right: 10px;
    font-family: inherit;
}
.anito-chat-input-area textarea:focus {
    outline: none;
    border-color: #008080;
    box-shadow: 0 0 0 0.2rem rgba(0, 128, 128, 0.25);
}

.anito-chat-input-area button {
    background-color: #008080; /* Teal send button */
    color: white;
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.anito-chat-input-area button:hover {
    background-color: #006666; /* Darker teal on hover */
}
.anito-chat-input-area button:disabled {
    background-color: #a0a0a0;
    cursor: not-allowed;
}

/* Message Styling Enhancements */
.anito-chat-message {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
}

.anito-chat-message-sender-info {
    display: flex;
    align-items: center;
    margin-bottom: 6px;
    font-size: 0.85em;
    color: #455a64;
}

.anito-chat-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    margin-right: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #ced4da;
    overflow: hidden;
}

.anito-chat-message-avatar-bot svg {
    width: 18px;
    height: 18px;
    fill: #495057;
}

.anito-chat-message-sender-name {
    font-weight: 600;
}

.anito-chat-message-content {
    padding: 10px 15px;
    border-radius: 15px;
    max-width: 75%;
    word-wrap: break-word;
    line-height: 1.5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* User Message Specific Styles */
.anito-chat-message-user {
    align-items: flex-end;
}

.anito-chat-message-user .anito-chat-message-sender-info {
    justify-content: flex-end;
}

.anito-chat-message-user .anito-chat-message-content {
    background-color: #008080; /* Dark Teal for user messages */
    color: white;
    border-top-right-radius: 5px;
}

/* Bot Message Specific Styles */
.anito-chat-message-bot {
    align-items: flex-start;
}

.anito-chat-message-bot .anito-chat-message-sender-info {
    justify-content: flex-start;
}

.anito-chat-message-bot .anito-chat-message-content {
    background-color: #ffffff; /* White for bot messages */
    color: #343a40;
    border: 1px solid #e0e6ed;
    border-top-left-radius: 5px;
}

/* Styling for HTML content within bot messages */
.anito-chat-message-bot .anito-chat-message-content p {
    margin-top: 0;
    margin-bottom: 0.6em;
}
.anito-chat-message-bot .anito-chat-message-content p:last-child {
    margin-bottom: 0;
}

.anito-chat-message-bot .anito-chat-message-content ul,
.anito-chat-message-bot .anito-chat-message-content ol {
    margin-top: 0;
    margin-bottom: 0.6em;
    padding-left: 22px;
}

.anito-chat-message-bot .anito-chat-message-content li {
    margin-bottom: 0.3em;
}

.anito-chat-message-bot .anito-chat-message-content strong,
.anito-chat-message-bot .anito-chat-message-content b {
    font-weight: 600;
}

.anito-chat-message-bot .anito-chat-message-content em,
.anito-chat-message-bot .anito-chat-message-content i {
    font-style: italic;
}

.anito-chat-message-bot .anito-chat-message-content a {
    color: #0056b3;
    text-decoration: underline;
}
.anito-chat-message-bot .anito-chat-message-content a:hover {
    color: #003d80;
}

/* Timestamp styling */
.anito-chat-message-timestamp {
    font-size: 0.7em;
    color: #78909c;
    margin-top: 5px;
}
.anito-chat-message-user .anito-chat-message-timestamp {
    text-align: right;
    margin-right: 5px;
}
.anito-chat-message-bot .anito-chat-message-timestamp {
    text-align: left;
    margin-left: 5px;
}

/* System Messages */
.anito-chat-message-system-info,
.anito-chat-message-system-error {
    font-style: italic;
    font-size: 0.9em;
    color: #6c757d;
    text-align: center;
    align-self: center;
    background-color: transparent;
    padding: 4px 8px;
    margin-top: 5px;
    margin-bottom: 10px;
    max-width: 90%;
}

.anito-chat-message-system-error {
    color: #dc3545;
    font-weight: bold;
}

/* Thinking Indicator Styles */

.anito-chat-thinking-indicator .anito-chat-message-content {
    background-color: #ffffff;
    color: #343a40;
    border: 1px solid #e0e6ed;
    padding: 10px 15px;
    border-radius: 15px;
    border-top-left-radius: 5px;
    display: flex;
    align-items: center;
    font-style: italic;
}

.anito-thinking-dot {
    animation: anito-dot-blink 1.4s infinite both;
    display: inline-block;
    margin-left: 2px;
}

.anito-thinking-dot:nth-child(1) {
    animation-delay: 0s;
}

.anito-thinking-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.anito-thinking-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes anito-dot-blink {
    0% {
        opacity: .2;
    }
    20% {
        opacity: 1;
    }
    100% {
        opacity: .2;
    }
}

/* HTML Content Modal Styles */
.anito-chat-html-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6); /* Darker backdrop */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
    box-sizing: border-box;
}

.anito-chat-html-modal-content {
    background-color: #fff;
    border-radius: 10px; /* More rounded modal */
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    width: 80%;
    max-width: 800px; /* Wider modal for content */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.anito-chat-html-modal-header {
    background-color: #008080; /* Match theme */
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #006666; /* Darker border */
}

.anito-chat-html-modal-title {
    font-size: 1.25em;
    font-weight: 600;
}

.anito-chat-html-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 2em;
    font-weight: bold;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

.anito-chat-html-modal-close:hover {
    opacity: 0.8;
}

.anito-chat-html-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex-grow: 1;
    background-color: #f8f9fa; /* Light background for modal body */
}

/* Basic styling for content within the modal body */
.anito-chat-html-modal-body h1,
.anito-chat-html-modal-body h2,
.anito-chat-html-modal-body h3 {
    margin-top: 0;
    margin-bottom: 0.75em;
    color: #212529;
}

.anito-chat-html-modal-body p {
    line-height: 1.65;
    color: #343a40;
    margin-bottom: 1em;
}

.anito-chat-html-modal-body a {
    color: #0069d9;
    text-decoration: none;
}
.anito-chat-html-modal-body a:hover {
    text-decoration: underline;
}

.anito-chat-html-modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin-top: 0.5em;
    margin-bottom: 1em;
}

.anito-chat-html-modal-body pre {
    background-color: #e9ecef;
    padding: 15px;
    border-radius: 5px;
    overflow-x: auto;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.anito-chat-html-modal-body code {
    font-family: 'Courier New', Courier, monospace;
    background-color: #e9ecef;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 0.9em;
}

.anito-chat-html-modal-body pre code {
    padding: 0;
    background-color: transparent;
    border-radius: 0;
}

/* Responsive adjustments */
@media (max-width: 768px) { 
    .anito-chat-window {
        width: 100%;
        height: 100%;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
    }

    .anito-chat-header,
    .anito-chat-window {
        border-top-left-radius: 0;
        border-top-right-radius: 0;
    }

    .anito-chat-message-content {
        max-width: 85%;
    }

    .anito-chat-html-modal-content {
        width: 95%;
        max-height: 95vh;
    }
}

/* --- Animations --- */
.anito-chat-bubble.thinking {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 6px 12px rgba(0,0,0,0.3);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    }
}
