/**
 * Public-facing styles for the A1AI Chatbot plugin
 *
 * @package    A1AI
 * @subpackage A1AI/public/css
 */

/* Common chatbot styling */
.a1ai-chatbot-container {
    display: flex;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    background-color: #fff;
    max-width: 100%;
    margin: 0 auto;
    position: relative !important;
    /* Ensure proper positioning context for GDPR overlay */
    color: #000000 !important;
}

.a1ai-chatbot-header {
    padding: 12px 16px;
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.a1ai-chatbot-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.a1ai-chatbot-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background-color: #f9f9f9;
}

.a1ai-message {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    position: relative;
}

.a1ai-message-user {
    align-self: flex-end;
    background-color: #e3f2fd;
    border-bottom-right-radius: 4px;
    color: #000000 !important;
}

.a1ai-message-ai {
    align-self: flex-start;
    background-color: #fff;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    color: #000000 !important;
}

.a1ai-message-time {
    font-size: 10px;
    color: #757575;
    margin-top: 4px;
    text-align: right;
}

.a1ai-message-content {
    word-break: break-word;
    color: #000000 !important;
}

.a1ai-message-content a {
    color: #0073aa !important;
    text-decoration: underline;
}

.a1ai-message-content a:hover {
    color: #005a87 !important;
}

.a1ai-message-content p {
    margin: 0 0 8px 0;
}

.a1ai-message-content p:last-child {
    margin-bottom: 0;
}

.a1ai-message-content ul,
.a1ai-message-content ol {
    margin: 4px 0 8px 0;
    padding-left: 20px;
}

.a1ai-message-content ul:last-child,
.a1ai-message-content ol:last-child {
    margin-bottom: 0;
}

.a1ai-message-content li {
    margin: 0 0 4px 0;
    line-height: 1.45;
}

.a1ai-message-content li:last-child {
    margin-bottom: 0;
}

.a1ai-message-content strong {
    font-weight: 600;
}

/* A reply a person wrote during a live takeover: the AI bubble with their name on top. */
.a1ai-agent-label {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 3px;
    color: #00775f !important;
}

/* Status line such as "Sam from the team has joined the chat". */
.a1ai-chat-notice {
    align-self: center;
    max-width: 90%;
    padding: 4px 12px;
    border-radius: 12px;
    background-color: rgba(0, 0, 0, 0.06);
    color: #4a4a4a !important;
    font-size: 12px;
    line-height: 1.4;
    text-align: center;
}

.a1ai-chatbot-input {
    padding: 12px;
    border-top: 1px solid #eaeaea;
    background-color: #fff;
}

.a1ai-chatbot-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.a1ai-chatbot-input-field {
    flex-grow: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 16px;
    font-size: 14px;
    font-family: inherit;
    color: #000000 !important;
    background-color: #ffffff !important;
    resize: none;
    overflow-y: auto;
    min-height: 72px;
    max-height: 120px;
    line-height: 1.4;
}

.a1ai-review-confirm p {
    margin: 0 0 8px 0;
}

.a1ai-review-confirm-btn {
    background-color: #2271b1;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.a1ai-review-confirm-btn:hover {
    background-color: #135e96;
}

.a1ai-chatbot-input-field:focus {
    outline: none;
    border-color: #0073aa;
    color: #000000 !important;
    background-color: #ffffff !important;
}

.a1ai-chatbot-input-field::placeholder {
    color: #666666 !important;
    opacity: 1;
}

.a1ai-chatbot-submit {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.a1ai-chatbot-submit svg {
    width: 18px;
    height: 18px;
}

.a1ai-chatbot-powered-by {
    padding: 6px;
    font-size: 11px;
    text-align: center;
    color: #757575;
    background-color: #f9f9f9;
    border-top: 1px solid #eaeaea;
}

.a1ai-chatbot-powered-by a {
    color: #0073aa;
    text-decoration: none;
}

/* Global chatbot specific styling */
.a1ai-global-chatbot-container {
    position: fixed !important;
    z-index: 9999;
}

.a1ai-global-chatbot-container.a1ai-position-br {
    bottom: 20px !important;
    right: 20px !important;
    left: auto !important;
}

.a1ai-global-chatbot-container.a1ai-position-bl {
    bottom: 20px !important;
    left: 20px !important;
    right: auto !important;
}

.a1ai-global-chatbot-toggle {
    border: none;
    border-radius: 50px;
    color: white;
    padding: 12px 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.a1ai-toggle-icon svg {
    width: 20px;
    height: 20px;
}

.a1ai-icon-close {
    display: none;
}

.a1ai-global-chatbot-container.a1ai-active .a1ai-icon-chat {
    display: none;
}

.a1ai-global-chatbot-container.a1ai-active .a1ai-icon-close {
    display: block;
}

.a1ai-global-chatbot-dialog {
    position: absolute;
    bottom: 80px;
    width: 350px;
    height: 500px;
    max-width: 90vw;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    background-color: #fff;
    color: #000000 !important;
}

.a1ai-position-br .a1ai-global-chatbot-dialog {
    right: 0;
}

.a1ai-position-bl .a1ai-global-chatbot-dialog {
    left: 0;
}

.a1ai-chatbot-close {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
}

.a1ai-chatbot-close svg {
    width: 18px;
    height: 18px;
}

/* Loading state */
.a1ai-message-loading {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.a1ai-loading-dot {
    width: 8px;
    height: 8px;
    background-color: #bbb;
    border-radius: 50%;
    animation: a1ai-dot-pulse 1.4s infinite ease-in-out both;
}

.a1ai-loading-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.a1ai-loading-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes a1ai-dot-pulse {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Accessibility & screen reader text */
.screen-reader-text {
    border: 0;
    clip: rect(1px, 1px, 1px, 1px);
    clip-path: inset(50%);
    height: 1px;
    margin: -1px;
    overflow: hidden;
    padding: 0;
}

/* Force text colors to prevent theme inheritance */
.a1ai-chatbot-container *,
.a1ai-global-chatbot-dialog * {
    color: inherit;
}

.a1ai-chatbot-container,
.a1ai-global-chatbot-dialog {
    color: #000000 !important;
}

/* The inherit rule above also reached the header and cancelled its white, so titles
   printed black on the bot colour. */
.a1ai-chatbot-container .a1ai-chatbot-header,
.a1ai-global-chatbot-dialog .a1ai-chatbot-header {
    color: #fff;
}

/* Themes fill a hovered button pink (Hello Elementor's button:hover). */
.a1ai-chatbot-header .a1ai-chatbot-close,
.a1ai-chatbot-header .a1ai-chatbot-close:hover,
.a1ai-chatbot-header .a1ai-chatbot-close:focus {
    background: transparent;
    border: none;
    color: inherit;
    padding: 0;
}

.a1ai-message,
.a1ai-message-content,
.a1ai-message-content * {
    color: #000000 !important;
}

.a1ai-chatbot-input-field,
.a1ai-chatbot-input-field::placeholder {
    color: #000000 !important;
}

.a1ai-chatbot-input-field::placeholder {
    color: #666666 !important;
}

/* Font Size Classes
   (1.7.0: an orphaned declaration fragment used to sit just above this comment.
   Browsers read it as the start of a selector and dropped the first rule below,
   so "Small" chatbots never got 12px messages until it was removed.) */
.a1ai-font-size-small .a1ai-message {
    font-size: 12px;
}

.a1ai-font-size-small .a1ai-chatbot-title {
    font-size: 14px;
}

.a1ai-font-size-small .a1ai-chatbot-input-field {
    font-size: 12px;
}

.a1ai-font-size-small .a1ai-message-time {
    font-size: 9px;
}

.a1ai-font-size-small .a1ai-chatbot-powered-by {
    font-size: 10px;
}

.a1ai-font-size-medium .a1ai-message {
    font-size: 14px;
}

.a1ai-font-size-medium .a1ai-chatbot-title {
    font-size: 16px;
}

.a1ai-font-size-medium .a1ai-chatbot-input-field {
    font-size: 14px;
}

.a1ai-font-size-medium .a1ai-message-time {
    font-size: 10px;
}

.a1ai-font-size-medium .a1ai-chatbot-powered-by {
    font-size: 11px;
}

.a1ai-font-size-large .a1ai-message {
    font-size: 16px;
}

.a1ai-font-size-large .a1ai-chatbot-title {
    font-size: 18px;
}

.a1ai-font-size-large .a1ai-chatbot-input-field {
    font-size: 16px;
}

.a1ai-font-size-large .a1ai-message-time {
    font-size: 12px;
}

.a1ai-font-size-large .a1ai-chatbot-powered-by {
    font-size: 13px;
}

/* Responsiveness */
@media screen and (max-width: 480px) {
    .a1ai-global-chatbot-dialog {
        width: 300px;
        height: 450px;
    }
    
    .a1ai-message {
        max-width: 85%;
    }
}

/* Error styling */
.a1ai-error {
    color: #d32f2f;
    padding: 16px;
    text-align: center;
    border: 1px solid #ffcdd2;
    background-color: #ffebee;
    border-radius: 4px;
}

/* GDPR Consent Overlay - Base styles (hidden by default) */
.a1ai-gdpr-overlay {
    background-color: rgba(0, 0, 0, 0.8);
    display: none; /* Hidden by default, shown by JavaScript when needed */
    align-items: center;
    justify-content: center;
    z-index: 1000;
    pointer-events: auto;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

/* SHORTCODE CHATBOT GDPR OVERLAY - STRICTLY CONTAINED */
.a1ai-chatbot-container {
    position: relative !important;
    overflow: hidden !important;
    /* Ensure proper positioning context for GDPR overlay */
}

.a1ai-chatbot-container .a1ai-gdpr-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    /* Force containment within chatbot container */
    transform: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Ensure chat input is disabled when GDPR overlay is active */
.a1ai-chatbot-container:has(.a1ai-gdpr-overlay) .a1ai-chatbot-input,
.a1ai-chatbot-container:has(.a1ai-gdpr-overlay) .a1ai-chatbot-messages {
    pointer-events: none;
    opacity: 0.3;
}

/* Alternative for browsers that don't support :has() */
.a1ai-gdpr-active .a1ai-chatbot-input,
.a1ai-gdpr-active .a1ai-chatbot-messages {
    pointer-events: none;
    opacity: 0.3;
}

/* Disable input field specifically when GDPR is active */
.a1ai-gdpr-active .a1ai-chatbot-input-field {
    pointer-events: none !important;
    opacity: 0.3 !important;
    cursor: not-allowed !important;
    background-color: #f5f5f5 !important;
}

.a1ai-gdpr-active .a1ai-chatbot-submit {
    pointer-events: none !important;
    opacity: 0.3 !important;
    cursor: not-allowed !important;
}

/* Ensure input field is properly enabled after GDPR consent */
.a1ai-chatbot-input-field:not([disabled]) {
    pointer-events: auto !important;
    opacity: 1 !important;
    cursor: text !important;
    background-color: white !important;
}

.a1ai-chatbot-submit:not([disabled]) {
    pointer-events: auto !important;
    opacity: 1 !important;
    cursor: pointer !important;
}

.a1ai-gdpr-content {
    background-color: #fff;
    padding: 24px;
    border-radius: 8px;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.a1ai-gdpr-content h4 {
    margin: 0 0 16px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.a1ai-gdpr-text {
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
    color: #555;
}

.a1ai-gdpr-text p {
    margin: 0 0 12px 0;
}

.a1ai-gdpr-text p:last-child {
    margin-bottom: 0;
}

.a1ai-gdpr-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.a1ai-gdpr-agree,
.a1ai-gdpr-decline {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.a1ai-gdpr-agree {
    color: white;
}

.a1ai-gdpr-agree:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.a1ai-gdpr-decline {
    background-color: #f5f5f5;
    color: #666;
    border: 1px solid #ddd;
}

.a1ai-gdpr-decline:hover {
    background-color: #e5e5e5;
    color: #333;
}

/* Themes style every button. Hello Elementor's reset.css gives [type=button], [type=submit]
   and button pink (#c36) text, a pink border and padding, and turns them pink on hover and
   focus. At one class the rules above tie with it and lose on load order, so "I Agree" and
   the send arrow showed pink on the bot colour. A parent class lifts these above the theme. */
.a1ai-gdpr-buttons .a1ai-gdpr-agree,
.a1ai-gdpr-buttons .a1ai-gdpr-agree:hover,
.a1ai-gdpr-buttons .a1ai-gdpr-agree:focus {
    color: #fff;
    border: none;
    padding: 10px 20px;
}

.a1ai-gdpr-buttons .a1ai-gdpr-decline {
    background-color: #f5f5f5;
    color: #666;
    border: 1px solid #ddd;
    padding: 10px 20px;
}

.a1ai-gdpr-buttons .a1ai-gdpr-decline:hover,
.a1ai-gdpr-buttons .a1ai-gdpr-decline:focus {
    background-color: #e5e5e5;
    color: #333;
}

.a1ai-chatbot-form .a1ai-chatbot-submit,
.a1ai-chatbot-form .a1ai-chatbot-submit:hover,
.a1ai-chatbot-form .a1ai-chatbot-submit:focus {
    color: #fff;
    border: none;
    padding: 0;
    /* The same reset sets [type=submit] { width: auto }, which squeezed the round button
       to the 18px icon. */
    width: 40px;
    min-width: 40px;
}

/* Global chatbot GDPR overlay - covers entire page (intended behavior) */
.a1ai-global-chatbot-container .a1ai-gdpr-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    border-radius: 0 !important;
    z-index: 9999 !important;
    /* Global chatbots should cover the entire page for GDPR consent */
}

/* AGGRESSIVE OVERRIDE - Prevent any fixed positioning on shortcode chatbots */
.a1ai-chatbot-container .a1ai-gdpr-overlay,
div.a1ai-chatbot-container div.a1ai-gdpr-overlay,
.a1ai-chatbot-container > .a1ai-gdpr-overlay {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 8px !important;
    overflow: hidden !important;
    transform: none !important;
    margin: 0 !important;
    padding: 0 !important;
    /* Force absolute positioning and prevent any fixed positioning */
}

.a1ai-global-chatbot-container .a1ai-gdpr-content {
    max-width: 400px;
    max-height: 80vh;
}

/* Responsive design for GDPR overlay */
@media screen and (max-width: 480px) {
    .a1ai-gdpr-content {
        margin: 20px;
        padding: 20px;
    }
    
    .a1ai-gdpr-buttons {
        flex-direction: column;
    }
    
    .a1ai-gdpr-agree,
    .a1ai-gdpr-decline {
        width: 100%;
        text-align: center;
    }
}

/* Clickable links in chatbot messages */
.a1ai-message-content a {
    color: #0073aa;
    text-decoration: underline;
    word-break: break-all;
    transition: color 0.2s ease;
}

.a1ai-message-content a:hover {
    color: #005177;
    text-decoration: none;
}

.a1ai-message-content a:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Internal links styling */
.a1ai-link-internal {
    color: #0073aa !important;
    font-weight: 500;
}

.a1ai-link-internal:hover {
    color: #005177 !important;
    text-decoration: underline !important;
}

/* External links styling */
.a1ai-link-external {
    color: #0073aa !important;
    font-weight: 500;
    position: relative;
}

.a1ai-link-external:hover {
    color: #005177 !important;
    text-decoration: underline !important;
}

.a1ai-link-external::after {
    content: " ↗";
    font-size: 0.8em;
    opacity: 0.7;
    margin-left: 2px;
}

/* Ensure links are visible in both light and dark themes */
.a1ai-message-user .a1ai-message-content a,
.a1ai-message-ai .a1ai-message-content a {
    color: #0073aa !important;
}

.a1ai-message-user .a1ai-message-content a:hover,
.a1ai-message-ai .a1ai-message-content a:hover {
    color: #005177 !important;
}

/* Standalone Review Container - displays review form as standalone card, not chat bubble */
.a1ai-standalone-review-container {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    min-height: auto !important;
    overflow: visible !important;
}

/* The review form inside keeps its own styling */
.a1ai-standalone-review-container .a1ai-review-form {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box !important;
    overflow: visible !important;
}

/* Ensure proper display within chat container - remove all flex behavior */
.a1ai-chatbot-messages .a1ai-standalone-review-container {
    display: block !important;
    align-self: auto !important;
    flex-grow: 0 !important;
    flex-shrink: 0 !important;
}

/* Override any inherited chat message styles */
.a1ai-chatbot-messages > .a1ai-standalone-review-container {
    display: block !important;
    flex: none !important;
    position: static !important;
}

/* Hide previous chat messages when review form is shown */
.a1ai-chatbot-messages:has(.a1ai-standalone-review-container) > .a1ai-message {
    display: none !important;
}

/* When review container is present, make messages container non-scrollable and clean */
.a1ai-chatbot-messages:has(.a1ai-standalone-review-container) {
    padding: 0 !important;
    background: transparent !important;
    overflow: visible !important;
    overflow-y: visible !important;
    height: auto !important;
    max-height: none !important;
    flex-grow: 0 !important;
}

/* Force chat interface elements to hide when review is active - CSS fallback */
.a1ai-chatbot-container:has(.a1ai-standalone-review-container) .a1ai-input-wrapper {
    display: none !important;
}

/* Review Mode - Hide all chat interface elements when in review mode */
.a1ai-global-chatbot-container.a1ai-review-mode .a1ai-chatbot-input,
.a1ai-chatbot-container.a1ai-review-mode .a1ai-chatbot-input {
    display: none !important;
}

.a1ai-global-chatbot-container.a1ai-review-mode .a1ai-chatbot-powered-by,
.a1ai-chatbot-container.a1ai-review-mode .a1ai-chatbot-powered-by {
    display: none !important;
}

/* Remove padding, overflow, and all chat styling from messages container in review mode */
.a1ai-global-chatbot-container.a1ai-review-mode .a1ai-chatbot-messages,
.a1ai-chatbot-container.a1ai-review-mode .a1ai-chatbot-messages {
    padding: 0 !important;
    background: transparent !important;
    overflow: visible !important;
    overflow-y: visible !important;
    flex-grow: 0 !important;
    height: auto !important;
    max-height: none !important;
    display: block !important;
    gap: 0 !important;
}

/* Remove scrollbars completely in review mode */
.a1ai-global-chatbot-container.a1ai-review-mode .a1ai-chatbot-messages::-webkit-scrollbar,
.a1ai-chatbot-container.a1ai-review-mode .a1ai-chatbot-messages::-webkit-scrollbar {
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

.a1ai-global-chatbot-container.a1ai-review-mode .a1ai-chatbot-messages,
.a1ai-chatbot-container.a1ai-review-mode .a1ai-chatbot-messages {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

/* Hide header in review mode - make it truly standalone */
.a1ai-global-chatbot-container.a1ai-review-mode .a1ai-chatbot-header,
.a1ai-chatbot-container.a1ai-review-mode .a1ai-chatbot-header {
    display: none !important;
}

/* Hide welcome message when review form is shown */
.a1ai-chatbot-messages:has(.a1ai-standalone-review-container) > .a1ai-message-ai:first-of-type {
    display: none !important;
}

/* Make dialog container borderless and non-scrollable in review mode */
.a1ai-global-chatbot-container.a1ai-review-mode .a1ai-global-chatbot-dialog,
.a1ai-chatbot-container.a1ai-review-mode {
    border-radius: 0 !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
    display: block !important;
    flex-direction: column !important;
}

/* Ensure review form takes full width in review mode */
.a1ai-global-chatbot-container.a1ai-review-mode .a1ai-standalone-review-container,
.a1ai-chatbot-container.a1ai-review-mode .a1ai-standalone-review-container {
    width: 100% !important;
    margin: 0 !important;
    max-width: 100% !important;
    overflow: visible !important;
}

/* Remove any container shadows/borders in review mode for standalone look */
.a1ai-global-chatbot-container.a1ai-review-mode,
.a1ai-chatbot-container.a1ai-review-mode {
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
}

/* Hide toggle button for review chatbots - they should be standalone */
.a1ai-global-chatbot-container.a1ai-review-mode .a1ai-global-chatbot-toggle,
.a1ai-chatbot-container.a1ai-review-mode .a1ai-chatbot-toggle {
    display: none !important;
}

/* Auto-show dialog for review chatbots - make it static/block layout */
.a1ai-global-chatbot-container.a1ai-review-mode .a1ai-global-chatbot-dialog {
    display: block !important;
    position: static !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    max-width: 100% !important;
    overflow: visible !important;
}

/* ==========================================================================
   Managed appearance (1.7.0)

   Applies only to chatbots whose look was published from the A1Ai Workspace:
   the root element carries data-a1ai-appearance="1" and inline custom
   properties (--a1ai-*) written by A1AI_Appearance::resolve(). Every value
   here is !important on purpose: themes restyle buttons and text inside the
   widget, and a published look has to render the same on every theme.
   Chatbots without the attribute never match these rules and render exactly
   as before. Review-mode chatbots are excluded; the review form keeps its
   own styling.

   Display toggles stay with the JavaScript: nothing here sets display on the
   dialog, the GDPR overlay or the launcher icons.
   ========================================================================== */

[data-a1ai-appearance]:not(.a1ai-review-mode) {
    font-family: var(--a1ai-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode).a1ai-font-site {
    font-family: inherit !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) * {
    font-family: inherit !important;
}

/* Panel: the inline widget is the panel; the floating widget uses its dialog as the panel. */
.a1ai-chatbot-container[data-a1ai-appearance]:not(.a1ai-review-mode) {
    width: var(--a1ai-width, 350px) !important;
    height: var(--a1ai-height, 500px) !important;
    max-width: 100% !important;
    border-radius: var(--a1ai-panel-radius, 8px) !important;
    box-shadow: var(--a1ai-panel-shadow, 0 2px 10px rgba(0, 0, 0, 0.1)) !important;
    background-color: var(--a1ai-panel-bg, #ffffff) !important;
    color: var(--a1ai-bot-text, #000000) !important;
}

.a1ai-global-chatbot-container[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-global-chatbot-dialog {
    width: var(--a1ai-width, 350px) !important;
    height: var(--a1ai-height, 500px) !important;
    max-width: calc(100vw - 2 * var(--a1ai-offset-x, 20px)) !important;
    max-height: calc(100vh - var(--a1ai-dialog-offset, 80px) - var(--a1ai-offset-y, 20px) - 16px) !important;
    bottom: var(--a1ai-dialog-offset, 80px) !important;
    border-radius: var(--a1ai-panel-radius, 8px) !important;
    box-shadow: var(--a1ai-panel-shadow, 0 5px 25px rgba(0, 0, 0, 0.2)) !important;
    background-color: var(--a1ai-panel-bg, #ffffff) !important;
    color: var(--a1ai-bot-text, #000000) !important;
}

.a1ai-global-chatbot-container[data-a1ai-appearance].a1ai-position-br {
    bottom: var(--a1ai-offset-y, 20px) !important;
    right: var(--a1ai-offset-x, 20px) !important;
    left: auto !important;
}

.a1ai-global-chatbot-container[data-a1ai-appearance].a1ai-position-bl {
    bottom: var(--a1ai-offset-y, 20px) !important;
    left: var(--a1ai-offset-x, 20px) !important;
    right: auto !important;
}

/* Header */
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-header {
    background-color: var(--a1ai-primary, #0073aa) !important;
    color: var(--a1ai-on-primary, #ffffff) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-header .a1ai-chatbot-title,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-header .a1ai-chatbot-subtitle,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-header .a1ai-chatbot-close {
    color: var(--a1ai-on-primary, #ffffff) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-title {
    margin: 0 !important;
    font-size: calc(var(--a1ai-font-size, 14px) + 2px) !important;
    font-weight: var(--a1ai-header-weight, 600) !important;
    line-height: 1.3 !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-close {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-heading {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-heading-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-avatar {
    width: 32px !important;
    height: 32px !important;
    max-width: none !important;
    margin: 0 !important;
    border-radius: 50% !important;
    object-fit: cover;
    flex: none;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-subtitle {
    font-size: calc(var(--a1ai-font-size, 14px) - 2px) !important;
    line-height: 1.3 !important;
    opacity: 0.85;
}

/* Messages */
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-messages {
    background-color: var(--a1ai-messages-bg, #f9f9f9) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-message {
    font-size: var(--a1ai-font-size, 14px) !important;
    border-radius: var(--a1ai-bubble-radius, 18px) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-message-ai,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-agent-message {
    background-color: var(--a1ai-bot-bubble, #ffffff) !important;
    border-bottom-left-radius: min(4px, var(--a1ai-bubble-radius, 18px)) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-message-user {
    background-color: var(--a1ai-user-bubble, #e3f2fd) !important;
    border-bottom-right-radius: min(4px, var(--a1ai-bubble-radius, 18px)) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-message-ai,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-message-ai .a1ai-message-content,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-message-ai .a1ai-message-content *,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-agent-message,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-agent-message * {
    color: var(--a1ai-bot-text, #000000) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-message-user,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-message-user .a1ai-message-content,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-message-user .a1ai-message-content * {
    color: var(--a1ai-user-text, #000000) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-messages .a1ai-message .a1ai-message-content a,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-messages .a1ai-message .a1ai-message-content a:hover {
    color: var(--a1ai-link, #0073aa) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-messages .a1ai-message .a1ai-message-time {
    color: var(--a1ai-timestamp, #757575) !important;
    font-size: calc(var(--a1ai-font-size, 14px) - 4px) !important;
}

/* The timestamp token is checked against the bot bubble; on the visitor bubble, follow the visitor text color. */
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-messages .a1ai-message-user .a1ai-message-time {
    color: var(--a1ai-user-text, #000000) !important;
    opacity: 0.75;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-loading-dot {
    background-color: var(--a1ai-typing-dots, #bbbbbb) !important;
}

/* Input */
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-input {
    background-color: var(--a1ai-panel-bg, #ffffff) !important;
    border-top: 1px solid var(--a1ai-border, #dddddd) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-input-field,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-input-field:not([disabled]) {
    background-color: var(--a1ai-input-bg, #ffffff) !important;
    color: var(--a1ai-input-text, #000000) !important;
    border: 1px solid var(--a1ai-border, #dddddd) !important;
    border-radius: var(--a1ai-input-radius, 16px) !important;
    font-size: var(--a1ai-font-size, 14px) !important;
    box-shadow: none !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-input-field:focus {
    border-color: var(--a1ai-focus-ring, #0073aa) !important;
    outline: 2px solid var(--a1ai-focus-ring, #0073aa) !important;
    outline-offset: 1px !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-input-field::placeholder {
    color: var(--a1ai-placeholder, #666666) !important;
    opacity: 1 !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-submit {
    background-color: var(--a1ai-primary, #0073aa) !important;
    color: var(--a1ai-on-primary, #ffffff) !important;
    border: none !important;
    border-radius: 50% !important;
    width: 40px !important;
    min-width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    box-shadow: none !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex: none !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-submit svg {
    width: 18px !important;
    height: 18px !important;
    stroke: currentColor !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .screen-reader-text {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip-path: inset(50%) !important;
    white-space: nowrap !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-submit:focus-visible,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-global-chatbot-toggle:focus-visible,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-close:focus-visible,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-gdpr-agree:focus-visible {
    outline: 2px solid var(--a1ai-focus-ring, #0073aa) !important;
    outline-offset: 2px !important;
}

/* Footer credit */
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-powered-by {
    color: var(--a1ai-powered-by, #6b6b6b) !important;
    background-color: var(--a1ai-messages-bg, #f9f9f9) !important;
    border-top: 1px solid var(--a1ai-border, #dddddd) !important;
    font-size: calc(var(--a1ai-font-size, 14px) - 3px) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-chatbot-powered-by a {
    color: var(--a1ai-link, #0073aa) !important;
}

/* Privacy consent */
.a1ai-chatbot-container[data-a1ai-appearance]:not(.a1ai-review-mode) > .a1ai-gdpr-overlay {
    border-radius: var(--a1ai-panel-radius, 8px) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-gdpr-content {
    background-color: var(--a1ai-gdpr-bg, #ffffff) !important;
    border-radius: var(--a1ai-panel-radius, 8px) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-gdpr-content h4,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-gdpr-text,
[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-gdpr-text * {
    color: var(--a1ai-gdpr-text, #333333) !important;
}

[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-gdpr-agree {
    background-color: var(--a1ai-primary, #0073aa) !important;
    color: var(--a1ai-on-primary, #ffffff) !important;
    border: none !important;
}

/* Launcher (floating widget only) */
.a1ai-global-chatbot-container[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-global-chatbot-toggle {
    background-color: var(--a1ai-primary, #0073aa) !important;
    color: var(--a1ai-on-primary, #ffffff) !important;
    border: none !important;
    height: var(--a1ai-launcher-size, 50px) !important;
    min-height: 0 !important;
    padding: 0 22px !important;
    border-radius: 999px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    font-size: var(--a1ai-font-size, 14px) !important;
    line-height: 1 !important;
}

.a1ai-global-chatbot-container[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-global-chatbot-toggle * {
    color: inherit !important;
}

.a1ai-global-chatbot-container[data-a1ai-appearance]:not(.a1ai-review-mode).a1ai-launcher-no-label .a1ai-global-chatbot-toggle {
    width: var(--a1ai-launcher-size, 50px) !important;
    padding: 0 !important;
}

.a1ai-global-chatbot-container[data-a1ai-appearance]:not(.a1ai-review-mode).a1ai-launcher-no-label .a1ai-toggle-text {
    display: none !important;
}

.a1ai-global-chatbot-container[data-a1ai-appearance]:not(.a1ai-review-mode).a1ai-launcher-circle .a1ai-global-chatbot-toggle {
    border-radius: 50% !important;
}

.a1ai-global-chatbot-container[data-a1ai-appearance]:not(.a1ai-review-mode).a1ai-launcher-square .a1ai-global-chatbot-toggle {
    border-radius: calc(var(--a1ai-launcher-size, 50px) / 4) !important;
}

.a1ai-global-chatbot-container[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-toggle-icon svg {
    width: calc(var(--a1ai-launcher-size, 50px) * 0.42) !important;
    height: calc(var(--a1ai-launcher-size, 50px) * 0.42) !important;
}

.a1ai-global-chatbot-container[data-a1ai-appearance]:not(.a1ai-review-mode) .a1ai-toggle-avatar {
    width: calc(var(--a1ai-launcher-size, 50px) * 0.64) !important;
    height: calc(var(--a1ai-launcher-size, 50px) * 0.64) !important;
    max-width: none !important;
    margin: 0 !important;
    border-radius: 50% !important;
    object-fit: cover;
}

/* Phones: optional full-screen chat */
@media screen and (max-width: 480px) {
    .a1ai-global-chatbot-container[data-a1ai-appearance].a1ai-mobile-fullscreen:not(.a1ai-review-mode) .a1ai-global-chatbot-dialog {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
        z-index: 10000 !important;
    }

    .a1ai-chatbot-container[data-a1ai-appearance].a1ai-mobile-fullscreen:not(.a1ai-review-mode) {
        width: 100% !important;
        border-radius: 0 !important;
    }
}
