/**
 * 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-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;
}

.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;
}
    position: absolute;
    width: 1px;
    word-wrap: normal !important;
}

/* Font Size Classes */
.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;
}

/* 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;
}