/**
 * AI Live Chat Widget Styles
 * 
 * @package AI_Chat_Support_For_Affiliates
 * @version 1.2.1
 * @author Thibault Helle
 * @license GPL-2.0+
 */

/* CSS Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    border-width: 0;
    border-style: solid;
    border-color: #e5e7eb;
}

::before, ::after {
    --tw-content: "";
}

html, :host {
    line-height: 1.5;
    -webkit-text-size-adjust: 100%;
    -moz-tab-size: 4;
    -o-tab-size: 4;
    tab-size: 4;
    font-family: ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", Segoe UI Symbol, "Noto Color Emoji";
    font-feature-settings: normal;
    font-variation-settings: normal;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    line-height: inherit;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-size: inherit;
    font-weight: inherit;
}

a {
    color: inherit;
    text-decoration: inherit;
}

b, strong {
    font-weight: bolder;
}

code, kbd, samp, pre {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-feature-settings: normal;
    font-variation-settings: normal;
    font-size: 1em;
}

small {
    font-size: 80%;
}

/* Form Elements */
button, input, optgroup, select, textarea {
    font-family: inherit;
    font-feature-settings: inherit;
    font-variation-settings: inherit;
    font-size: 100%;
    font-weight: inherit;
    line-height: inherit;
    letter-spacing: inherit;
    color: inherit;
    margin: 0;
    padding: 0;
}

button, select {
    text-transform: none;
}

button, input[type="button"], input[type="reset"], input[type="submit"] {
    -webkit-appearance: button;
    background-color: transparent;
    background-image: none;
}

/* Layout Utilities */
.container {
    width: 100%;
}

@media (min-width: 640px) {
    .container {
        max-width: 640px;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 768px;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: 1024px;
    }
}

@media (min-width: 1280px) {
    .container {
        max-width: 1280px;
    }
}

@media (min-width: 1536px) {
    .container {
        max-width: 1536px;
    }
}

/* Positioning */
.fixed {
    position: fixed;
}

.absolute {
    position: absolute;
}

.relative {
    position: relative;
}

.bottom-0 {
    bottom: 0;
}

.bottom-5 {
    bottom: 1.25rem;
}

.bottom-full {
    bottom: 100%;
}

.right-0 {
    right: 0;
}

.right-4 {
    right: 1rem;
}

.right-5 {
    right: 1.25rem;
}

.z-50 {
    z-index: 50;
}

/* Spacing */
.mx-auto {
    margin-left: auto;
    margin-right: auto;
}

.my-2 {
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
}

.mb-1 {
    margin-bottom: 0.25rem;
}

.mb-2 {
    margin-bottom: 0.5rem;
}

.mb-2\.5 {
    margin-bottom: 0.625rem;
}

.ml-2 {
    margin-left: 0.5rem;
}

.mt-1 {
    margin-top: 0.25rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

/* Display */
.block {
    display: block;
}

.flex {
    display: flex;
}

.grid {
    display: grid;
}

.hidden {
    display: none;
}

/* Sizing */
.h-10 {
    height: 2.5rem;
}

.h-2\.5 {
    height: 0.625rem;
}

.h-3 {
    height: 0.75rem;
}

.h-4 {
    height: 1rem;
}

.h-5 {
    height: 1.25rem;
}

.h-6 {
    height: 1.5rem;
}

.h-8 {
    height: 2rem;
}

.h-full {
    height: 100%;
}

.max-h-\[600px\] {
    max-height: 600px;
}

.w-10 {
    width: 2.5rem;
}

.w-2\.5 {
    width: 0.625rem;
}

.w-3 {
    width: 0.75rem;
}

.w-5 {
    width: 1.25rem;
}

.w-6 {
    width: 1.5rem;
}

.w-8 {
    width: 2rem;
}

.w-full {
    width: 100%;
}

.w-max {
    width: max-content;
}

.max-w-sm {
    max-width: 24rem;
}

.max-w-xs {
    max-width: 20rem;
}

/* Flexbox */
.flex-shrink-0 {
    flex-shrink: 0;
}

.flex-grow {
    flex-grow: 1;
}

.flex-grow-0 {
    flex-grow: 0;
}

.flex-col {
    flex-direction: column;
}

.flex-wrap {
    flex-wrap: wrap;
}

.items-end {
    align-items: flex-end;
}

.items-center {
    align-items: center;
}

.justify-start {
    justify-content: flex-start;
}

.justify-end {
    justify-content: flex-end;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: 0.5rem;
}

.space-x-1 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-x-reverse: 0;
    margin-right: calc(0.25rem * var(--tw-space-x-reverse));
    margin-left: calc(0.25rem * calc(1 - var(--tw-space-x-reverse)));
}

.space-x-2 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-x-reverse: 0;
    margin-right: calc(0.5rem * var(--tw-space-x-reverse));
    margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse)));
}

.space-y-1 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-y-reverse: 0;
    margin-top: calc(0.25rem * calc(1 - var(--tw-space-y-reverse)));
    margin-bottom: calc(0.25rem * var(--tw-space-y-reverse));
}

.space-y-3 > :not([hidden]) ~ :not([hidden]) {
    --tw-space-y-reverse: 0;
    margin-top: calc(0.75rem * calc(1 - var(--tw-space-y-reverse)));
    margin-bottom: calc(0.75rem * var(--tw-space-y-reverse));
}

.self-start {
    align-self: flex-start;
}

/* Overflow */
.overflow-hidden {
    overflow: hidden;
}

.overflow-y-auto {
    overflow-y: auto;
}

.break-words {
    overflow-wrap: break-word;
}

/* Border Radius */
.rounded {
    border-radius: 0.25rem;
}

.rounded-full {
    border-radius: 9999px;
}

.rounded-lg {
    border-radius: 0.5rem;
}

.rounded-md {
    border-radius: 0.375rem;
}

.rounded-xl {
    border-radius: 0.75rem;
}

.rounded-t-lg {
    border-top-left-radius: 0.5rem;
    border-top-right-radius: 0.5rem;
}

.rounded-bl-none {
    border-bottom-left-radius: 0;
}

.rounded-br-none {
    border-bottom-right-radius: 0;
}

/* Borders */
.border {
    border-width: 1px;
}

.border-2 {
    border-width: 2px;
}

.border-b {
    border-bottom-width: 1px;
}

.border-l-4 {
    border-left-width: 4px;
}

.border-t {
    border-top-width: 1px;
}

.border-gray-200 {
    border-color: rgb(229 231 235);
}

.border-gray-300 {
    border-color: rgb(209 213 219);
}

.border-indigo-200 {
    border-color: rgb(199 210 254);
}

.border-red-500 {
    border-color: rgb(239 68 68);
}

.border-white {
    border-color: rgb(255 255 255);
}

/* Background Colors */
.bg-\[var\(--widget-primary-color\)\] {
    background-color: var(--widget-primary-color);
}

.bg-blue-500 {
    background-color: rgb(59 130 246);
}

.bg-gray-200 {
    background-color: rgb(229 231 235);
}

.bg-gray-50 {
    background-color: rgb(249 250 251);
}

.bg-gray-50\/50 {
    background-color: rgb(249 250 251 / 0.5);
}

.bg-green-500 {
    background-color: rgb(34 197 94);
}

.bg-indigo-50 {
    background-color: rgb(238 242 255);
}

.bg-red-100 {
    background-color: rgb(254 226 226);
}

.bg-slate-50 {
    background-color: rgb(248 250 252);
}

.bg-white {
    background-color: rgb(255 255 255);
}

/* Text Colors */
.text-\[var\(--widget-primary-color\)\] {
    color: var(--widget-primary-color);
}

.text-\[var\(--widget-text-on-primary\)\] {
    color: var(--widget-text-on-primary);
}

.text-blue-600 {
    color: rgb(37 99 235);
}

.text-gray-300 {
    color: rgb(209 213 219);
}

.text-gray-500 {
    color: rgb(107 114 128);
}

.text-gray-600 {
    color: rgb(75 85 99);
}

.text-gray-700 {
    color: rgb(55 65 81);
}

.text-gray-800 {
    color: rgb(31 41 55);
}

.text-indigo-600 {
    color: rgb(79 70 229);
}

.text-indigo-700 {
    color: rgb(67 56 202);
}

.text-red-700 {
    color: rgb(185 28 28);
}

.text-white {
    color: rgb(255 255 255);
}

.text-yellow-400 {
    color: rgb(250 204 21);
}

/* Typography */
.text-left {
    text-align: left;
}

.text-center {
    text-align: center;
}

.text-2xl {
    font-size: 1.5rem;
    line-height: 2rem;
}

.text-lg {
    font-size: 1.125rem;
    line-height: 1.75rem;
}

.text-sm {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.text-xs {
    font-size: 0.75rem;
    line-height: 1rem;
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.italic {
    font-style: italic;
}

.underline {
    text-decoration-line: underline;
}

/* Opacity */
.opacity-0 {
    opacity: 0;
}

.opacity-100 {
    opacity: 1;
}

/* Shadows */
.shadow {
    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
}

.shadow-2xl {
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
}

.shadow-md {
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.shadow-sm {
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.shadow-xl {
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* Focus States */
.focus\:border-transparent:focus {
    border-color: transparent;
}

.focus\:outline-none:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
}

.focus\:ring-1:focus {
    box-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
}

.focus\:ring-2:focus {
    box-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
}

.focus\:ring-4:focus {
    box-shadow: var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);
}

.focus\:ring-blue-400:focus {
    --tw-ring-color: rgb(96 165 250);
}

.focus\:ring-blue-500:focus {
    --tw-ring-color: rgb(59 130 246);
}

.focus\:ring-yellow-400:focus {
    --tw-ring-color: rgb(250 204 21);
}

.focus\:ring-offset-1:focus {
    --tw-ring-offset-width: 1px;
}

/* Hover States */
.hover\:scale-110:hover {
    transform: scale(1.1);
}

.hover\:border-gray-400:hover {
    border-color: rgb(156 163 175);
}

.hover\:bg-blue-600:hover {
    background-color: rgb(37 99 235);
}

.hover\:bg-gray-100:hover {
    background-color: rgb(243 244 246);
}

.hover\:bg-gray-50:hover {
    background-color: rgb(249 250 251);
}

.hover\:text-blue-700:hover {
    color: rgb(29 78 216);
}

.hover\:text-gray-700:hover {
    color: rgb(55 65 81);
}

.hover\:text-yellow-300:hover {
    color: rgb(253 224 71);
}

.hover\:text-yellow-500:hover {
    color: rgb(234 179 8);
}

.hover\:brightness-90:hover {
    filter: brightness(0.9);
}

/* Disabled States */
.disabled\:cursor-not-allowed:disabled {
    cursor: not-allowed;
}

.disabled\:bg-gray-300:disabled {
    background-color: rgb(209 213 219);
}

/* Transitions */
.transition {
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.transition-all {
    transition-property: all;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.transition-colors {
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.transition-opacity {
    transition-property: opacity;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.transition-shadow {
    transition-property: box-shadow;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.transition-transform {
    transition-property: transform;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

.duration-150 {
    transition-duration: 150ms;
}

.duration-200 {
    transition-duration: 200ms;
}

.duration-300 {
    transition-duration: 300ms;
}

.duration-500 {
    transition-duration: 500ms;
}

.ease-in-out {
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.ease-out {
    transition-timing-function: cubic-bezier(0, 0, 0.2, 1);
}

/* Animations */
@keyframes fade-in-up-nudge {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in-up-nudge {
    animation: fade-in-up-nudge 0.5s ease-out forwards;
}

@keyframes pulse-subtle {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 10px 10px -5px rgb(0 0 0 / 0.04);
    }
}

.animate-pulse-subtle {
    animation: pulse-subtle 2.5s infinite ease-in-out;
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Base Styles */
html {
    font-size: 14px;
}

body {
    font-family: Inter, sans-serif;
    line-height: 1.6;
    color: #333;
    background-color: rgb(243 244 246);
}

body > main {
    max-width: 800px;
    margin: 2rem auto;
    background-color: #fff;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgb(0 0 0 / 0.1);
}

body > main h1,
body > main h2,
body > main h3 {
    color: #1a202c;
    margin-bottom: 0.75rem;
}

body > main h1 {
    font-size: 2rem;
    font-weight: 600;
}

body > main h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

body > main p {
    margin-bottom: 1rem;
}

body > main ul {
    margin-left: 1.5rem;
    list-style-type: disc;
    margin-bottom: 1rem;
}

/* Sample Content Header */
.sample-content-header {
    background-color: #f0f4f8;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
    border-left: 5px solid #4a90e2;
}

.sample-content-header p {
    margin: 0;
    font-style: italic;
    color: #4a5568;
}

/* Responsive Design */
@media (min-width: 640px) {
    .sm\:bottom-5 {
        bottom: 1.25rem;
    }
    
    .sm\:right-5 {
        right: 1.25rem;
    }
    
    .sm\:h-6 {
        height: 1.5rem;
    }
    
    .sm\:h-\[70vh\] {
        height: 70vh;
    }
    
    .sm\:w-6 {
        width: 1.5rem;
    }
    
    .sm\:w-96 {
        width: 24rem;
    }
    
    .sm\:max-w-\[calc\(100\%-3rem\)\] {
        max-width: calc(100% - 3rem);
    }
    
    .sm\:rounded-lg {
        border-radius: 0.5rem;
    }
}

/* Chat Widget Specific Styles */
.ai-chat-widget {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    z-index: 1000;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ai-chat-widget.embedded-mode {
    position: relative;
    bottom: auto;
    right: auto;
    margin: 0 auto;
    max-width: 900px;
    width: 100%;
    z-index: auto;
}

.ai-chat-embedded-host {
    position: relative;
    width: 100%;
}

.ai-chat-embedded-host.alignwide .ai-chat-widget.embedded-mode {
    max-width: min(100%, var(--wp--style--global--wide-size, 1100px));
}

.ai-chat-embedded-host.alignfull .ai-chat-widget.embedded-mode {
    max-width: none;
}

.ai-chat-widget.embedded-mode .chat-toggle {
    display: none;
}

.ai-chat-widget .chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0;
    padding-bottom: 1.75rem;
}

.ai-chat-widget .chat-body.embedded-body {
    gap: 1.25rem;
}

.ai-chat-widget.embedded-mode .chat-body {
    padding: 1.25rem 1.5rem 1.5rem;
}

.ai-chat-widget .chat-container.embedded {
    background: transparent;
    border: none;
    border-radius: 28px;
    box-shadow: none;
    backdrop-filter: none;
}

.ai-chat-widget.embedded-mode .chat-container::before {
    display: none;
}

.ai-chat-widget.embedded-mode .chat-embedded-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 0 0.5rem;
    color: #0f172a;
}

.ai-chat-widget.embedded-mode .chat-embedded-title {
    font-weight: 600;
    font-size: 1.15rem;
}

.ai-chat-widget .chat-restart.embedded {
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    color: #0f172a;
    font-size: 0.85rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    width: auto;
    height: auto;
    box-shadow: none;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.ai-chat-widget .chat-restart.embedded:hover,
.ai-chat-widget .chat-restart.embedded:focus {
    background: rgba(15, 23, 42, 0.08);
    border-color: rgba(15, 23, 42, 0.18);
    transform: none;
}

.ai-chat-widget .chat-restart.embedded .chat-restart-icon {
    font-size: 0.95rem;
    line-height: 1;
}

.ai-chat-widget .chat-restart.embedded .chat-restart-text {
    line-height: 1;
}


.ai-chat-widget.embedded-mode .chat-messages {
    background: transparent;
    border: none;
    border-radius: 20px;
    padding: 1.2rem 1.4rem;
    box-shadow: none;
}

.ai-chat-widget.embedded-mode .chat-input-container {
    border-top: none;
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 14px;
    padding: 0.85rem;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.ai-chat-widget.embedded-mode .chat-input {
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.92);
}

.ai-chat-widget.embedded-mode .chat-send {
    box-shadow: none;
    background: linear-gradient(135deg, var(--widget-primary-color, #2563eb), var(--widget-secondary-color, #1e40af));
    color: #fff;
}

.ai-chat-widget.embedded-mode .chat-send:hover {
    filter: brightness(0.95);
}

.ai-chat-widget.embedded-mode .suggested-questions {
    padding: 0;
    gap: 0.65rem;
}

.ai-chat-widget.embedded-mode .suggested-question {
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(148, 163, 184, 0.25);
}

.ai-chat-widget.embedded-mode .rating-container {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(148, 163, 184, 0.25);
    margin: 0;
}

.ai-chat-widget .chat-inline-error {
    color: #d93025;
    font-size: 0.78rem;
    margin: 0 1rem 0.5rem;
}

.ai-chat-widget .chat-inline-success {
    color: #047857;
    font-size: 0.78rem;
    margin: 0 1rem 0.5rem;
}

.ai-chat-widget.embedded-mode .chat-inline-error,
.ai-chat-widget.embedded-mode .chat-inline-success {
    margin: 0 0.25rem;
}

.ai-chat-widget * {
    box-sizing: border-box;
}

.ai-chat-widget .chat-container {
    width: 350px;
    height: 500px;
    max-height: calc(100vh - 2.5rem);
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(100%);
    transition: transform 0.3s ease-out;
}

.ai-chat-widget .chat-container.open {
    transform: translateY(0);
    margin-bottom: 1rem;
}


.ai-chat-widget.embedded-mode .chat-container {
    width: 100%;
    max-width: 100%;
    min-height: 320px;
    height: auto;
    transform: none;
    background: transparent;
    border: none;
    border-radius: 28px;
    box-shadow: none;
    backdrop-filter: none;
}

.ai-chat-widget.embedded-mode .chat-container.open {
    transform: none;
    margin-bottom: 0;
}

.ai-chat-widget.embedded-mode .chat-messages {
    max-height: 60vh;
}

.ai-chat-widget.embedded-compact .chat-messages {
    max-height: 45vh;
}

.ai-chat-widget.embedded-mode .chat-container::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 12px;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.05);
}

.ai-chat-widget .chat-header {
    background: var(--widget-primary-color, #3b82f6);
    color: var(--widget-text-color, #ffffff);
    padding: 1rem;
    margin-bottom: 0;
    position: sticky;
    top: 0;
    z-index: 5;
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
}

.ai-chat-widget .chat-header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.ai-chat-widget .chat-title {
    font-weight: 600;
    font-size: 1rem;
}

.ai-chat-widget .chat-header-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-chat-widget .chat-restart,
.ai-chat-widget .chat-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, transform 0.2s;
    outline: none;
    width: 32px;
    height: 32px;
}

.ai-chat-widget .chat-restart:hover,
.ai-chat-widget .chat-close:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.ai-chat-widget .chat-messages {
    flex: 1;
    padding: 1rem;
    padding-top: 1.25rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    -webkit-overflow-scrolling: touch;
}

.ai-chat-widget .message-container {
    display: flex;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    max-width: 100%;
}

.ai-chat-widget .message-container.user {
    justify-content: flex-end;
}

.ai-chat-widget .message-container.assistant {
    justify-content: flex-start;
}

.ai-chat-widget .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 8px;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
}

.ai-chat-widget .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Online Status Indicator */
.ai-chat-widget .avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.ai-chat-widget .message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    word-wrap: break-word;
    font-size: 0.9rem; /* slightly smaller text for messages */
    line-height: 1.5;
}

.ai-chat-widget .message.user {
    background: var(--widget-primary-color, #3b82f6);
    color: var(--widget-text-color, #ffffff);
}

.ai-chat-widget .message.assistant {
    background: #f3f4f6;
    color: #374151;
}

/* Assistant links: visible and wrapped */
.ai-chat-widget .message.assistant a {
    color: #0b6bcb;
    font-weight: 600;
    position: relative;
    padding: 0 1px 0 1px; /* tighter padding */
    margin: 0 1px;
    text-decoration: none;
}

/* Custom underline (closer to text baseline, thinner) */
.ai-chat-widget .message.assistant a:after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 1px;
    background: rgba(11, 107, 203, 0.55);
    transform: translateY(2px); /* reduce vertical gap */
    pointer-events: none;
}

.ai-chat-widget .message.assistant a:hover,
.ai-chat-widget .message.assistant a:focus {
    color: #084e94;
    text-decoration: none;
}

.ai-chat-widget .message.assistant a:hover:after,
.ai-chat-widget .message.assistant a:focus:after {
    background: rgba(11, 107, 203, 0.9);
    height: 2px;
}

.ai-chat-widget .message.system {
    align-self: center;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.875rem;
    font-style: italic;
}

.ai-chat-widget .chat-input-container {
    padding: 1rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 0.5rem;
}

.ai-chat-widget .chat-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

.ai-chat-widget .chat-input:focus {
    border-color: var(--widget-primary-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.ai-chat-widget .chat-send {
    background: var(--widget-primary-color, #3b82f6);
    color: var(--widget-text-color, #ffffff);
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color 0.2s;
}

.ai-chat-widget .chat-send:hover {
    background: var(--widget-secondary-color, #1e40af);
}

.ai-chat-widget .chat-send:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

.ai-chat-widget .suggested-questions {
    padding: 0 1rem 1rem;
    display: flex;
    flex-direction: column-reverse;
    gap: 0.5rem;
}

.ai-chat-widget .suggested-question {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    text-align: left;
    transition: all 0.2s;
}

.ai-chat-widget .suggested-question:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

/* Suggestion row: button + optional brand links */
.ai-chat-widget .suggestion-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ai-chat-widget .suggestion-links {
    display: flex;
    gap: 0.5rem;
    margin-left: 0.25rem;
    flex-wrap: wrap;
    align-items: center;
}

.ai-chat-widget .suggestion-links a {
    padding: 0.25rem 0.5rem;
    background: #eef2ff;
    color: var(--widget-primary-color, #3b82f6);
    border: 1px solid rgba(59,130,246,0.12);
    border-radius: 9999px;
    font-size: 0.8125rem;
    text-decoration: none;
    white-space: nowrap;
}

.ai-chat-widget .suggestion-links a:hover {
    background: rgba(59,130,246,0.08);
    text-decoration: none;
}

/* Rating Component Styles */
.ai-chat-widget .rating-container {
    padding: 1rem;
    margin: 0.5rem;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    text-align: center;
}

.ai-chat-widget .rating-text {
    font-size: 0.875rem;
    color: #374151;
    margin-bottom: 0.75rem;
    font-weight: 500;
}

.ai-chat-widget .rating-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
}

.ai-chat-widget .rating-button {
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.ai-chat-widget .rating-button:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    transform: translateY(-1px);
}

.ai-chat-widget .rating-button.positive:hover {
    background: #ecfdf5;
    border-color: #10b981;
    color: #059669;
}

.ai-chat-widget .rating-button.neutral:hover {
    background: #fffbeb;
    border-color: #f59e0b;
    color: #d97706;
}

.ai-chat-widget .rating-button.negative:hover {
    background: #fef2f2;
    border-color: #ef4444;
    color: #dc2626;
}

/* Talk to Agent Button Styles */
.ai-chat-widget .chat-actions {
    padding: 0.75rem 1rem;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.ai-chat-widget .talk-to-agent-btn {
    width: 100%;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.ai-chat-widget .talk-to-agent-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
    color: #111827;
}

/* Agent Form Modal Styles */
.ai-chat-widget .agent-form-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    padding: 1rem;
}

.ai-chat-widget .agent-form-modal {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
}

.ai-chat-widget .agent-form-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1.5rem 1rem;
    border-bottom: 1px solid #e5e7eb;
}

.ai-chat-widget .agent-form-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
}

.ai-chat-widget .agent-form-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.ai-chat-widget .agent-form-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.ai-chat-widget .agent-form {
    padding: 1.5rem;
}

.ai-chat-widget .agent-form-field {
    margin-bottom: 1rem;
}

.ai-chat-widget .agent-form-field label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 0.5rem;
}

.ai-chat-widget .agent-form-field input,
.ai-chat-widget .agent-form-field textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 0.875rem;
    transition: border-color 0.2s;
    resize: vertical;
}

.ai-chat-widget .agent-form-field input:focus,
.ai-chat-widget .agent-form-field textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.ai-chat-widget .agent-form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

.ai-chat-widget .agent-form-cancel {
    background: #f9fafb;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-chat-widget .agent-form-cancel:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.ai-chat-widget .agent-form-submit {
    background: #3b82f6;
    border: 1px solid #3b82f6;
    border-radius: 6px;
    padding: 0.75rem 1.5rem;
    font-size: 0.875rem;
    color: #ffffff;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-chat-widget .agent-form-submit:hover:not(:disabled) {
    background: #2563eb;
    border-color: #2563eb;
}

.ai-chat-widget .agent-form-submit:disabled {
    background: #9ca3af;
    border-color: #9ca3af;
    cursor: not-allowed;
}

.ai-chat-widget .typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: #f3f4f6;
    border-radius: 18px;
    max-width: 80px;
}

.ai-chat-widget .typing-dot {
    width: 6px;
    height: 6px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.ai-chat-widget .typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-chat-widget .typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

.ai-chat-widget .chat-toggle {
    width: 60px;
    height: 60px;
    background: var(--widget-primary-color, #3b82f6);
    color: var(--widget-text-color, #ffffff);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    overflow: hidden;
    position: relative;
}

.ai-chat-widget .chat-toggle-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* When the chat is closed, show the avatar inset with a circular colored ring matching the primary color */
.ai-chat-widget .chat-toggle:not(.open) .chat-toggle-avatar {
    width: 84%;
    height: 84%;
    display: block;
    margin: 0 auto;
    border-radius: 50%;
    /* white separator so the colored ring is visible even if button uses the same color */
    border: 3px solid #ffffff;
    box-shadow: 0 0 0 4px var(--widget-primary-color, #3b82f6);
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.ai-chat-widget .chat-toggle:not(.open):hover .chat-toggle-avatar {
    transform: scale(1.03);
}

/* Online Status Indicator for Chat Toggle */
.ai-chat-widget .chat-toggle::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 14px;
    height: 14px;
    background: #10b981;
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.ai-chat-widget .chat-toggle:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.ai-chat-widget .chat-toggle.open {
    background: var(--widget-secondary-color, #1e40af);
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .ai-chat-widget .chat-container {
        width: calc(100vw - 2rem);
        height: calc(100vh - 2rem);
        max-height: 600px;
    }
    
    .ai-chat-widget {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
    }
    
    /* Agent Form Mobile Styles */
    .ai-chat-widget .agent-form-overlay {
        padding: 0.5rem;
    }
    
    .ai-chat-widget .agent-form-modal {
        max-width: none;
        width: 100%;
        margin: 0;
    }
    
    .ai-chat-widget .agent-form-header,
    .ai-chat-widget .agent-form {
        padding: 1rem;
    }
    
    .ai-chat-widget .agent-form-actions {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .ai-chat-widget .agent-form-cancel,
    .ai-chat-widget .agent-form-submit {
        width: 100%;
        justify-content: center;
    }
}
