/**
 * AI Chatbot Widget Styles - Professional Edition
 *
 * Premium chatbot interface with modern design system
 * Based on green theme branding.
 *
 * @package    WordPress_Webhooks
 * @since      1.1.0
 */

/* ========================================================================
   CSS Variables - Design System
   ======================================================================== */

.ai-chat-room-widget {
    /* Colors */
    --primary-color: #5a8a3f;
    --primary-dark: #4a7a2f;
    --primary-light: #6b9b4f;
    --secondary-color: #2d5230;

    /* Backgrounds */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f0f2f5;

    /* Text */
    --text-primary: #1a1a1a;
    --text-secondary: #4a4a4a;
    --text-tertiary: #6b6b6b;
    --text-light: #999999;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.16);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.2);

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 50%;

    /* Transitions */
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================================================
   Base Widget Container
   ======================================================================== */

.ai-chat-room-widget {
    position: fixed;
    bottom: 105px;
    right: 25px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Utility class for hiding elements */
.ai-chat-room-widget .hidden {
    display: none !important;
}

/* Screen reader only text */
.ai-chat-room-widget .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ========================================================================
   Splash Screen & Chat Room Container
   ======================================================================== */

.ai-chat-room-widget .ai-chat-room {
    width: 420px;
    height: 680px;
    border-radius: var(--radius-xl);
    background: var(--bg-primary);
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0, 0, 0, 0.05);
    position: absolute;
    right: 25px;
    bottom: 0;
    z-index: 20;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: all var(--transition-slow);
    display: flex;
    flex-direction: column;
}

.ai-chat-room-widget .ai-chat-splash {
    width: 420px;
    height: 680px;
    border-radius: var(--radius-xl);
    background: var(--bg-primary);
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0, 0, 0, 0.05);
    position: absolute;
    right: 25px;
    bottom: 20px;
    z-index: 20;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.8);
    transition: transform var(--transition-slow), box-shadow var(--transition-slow);
}

/* Maximized State - Backdrop */
.ai-chat-room-widget.maximized::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999998;
    animation: fadeIn var(--transition-base);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Maximized State - Chat Window */
.ai-chat-room-widget.maximized .ai-chat-room {
    position: fixed;
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    transform: translate(-50%, -50%);
    width: 95vw;
    height: 95vh;
    max-width: 1400px;
    max-height: 900px;
    border-radius: var(--radius-lg);
    z-index: 999999;
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.ai-chat-room-widget.maximized .ai-chat-room-head {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.ai-chat-room-widget .ai-chat-splash:hover,
.ai-chat-room-widget .ai-chat-room:hover {
    box-shadow: var(--shadow-xl), 0 0 0 1px rgba(0, 0, 0, 0.08), 0 20px 60px rgba(0, 0, 0, 0.25);
}

/* Splash Screen Specific */
.ai-chat-room-widget .ai-chat-splash {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 40px 30px;
}

.ai-chat-splash-inner {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.ai-chat-splash-inner img {
    width: 70px;
    height: 70px;
    margin-bottom: 16px;
}

.ai-chat-room-widget .ai-chat-splash h4 {
    color: #2d5230;
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 12px 0;
}

.ai-chat-room-widget .ai-chat-splash p {
    color: #393939;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.5;
    margin: 0 0 24px 0;
    padding: 0 16px;
}

.ai-chat-room-widget .ai-chat-splash .open-chat-btn {
    padding: 16px 50px;
    border-radius: 30px;
    background: #5a8a3f;
    color: #FFF;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: background 0.3s ease;
    border: none;
    cursor: pointer;
}

.ai-chat-room-widget .ai-chat-splash .open-chat-btn:hover {
    background: #4a7a2f;
}

/* Chat Room Specific */
.ai-chat-room-widget .ai-chat-room {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
}

/* ========================================================================
   Chat Room Header
   ======================================================================== */

.ai-chat-room-widget .ai-chat-room-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 18px 24px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 249, 250, 0.95) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.05), var(--shadow-sm);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.ai-chat-room-widget .ai-chat-room-head h6 {
    margin: 0;
    padding: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.ai-chat-room-widget .ai-chat-room-head h6 img {
    width: 56px;
    height: 56px;
}

/* Status Indicator Dot */
.ai-chat-room-widget .status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: -4px;
    display: inline-block;
    transition: background-color var(--transition-base);
    position: relative;
}

.ai-chat-room-widget .status-indicator.status-healthy {
    background-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.ai-chat-room-widget .status-indicator.status-degraded {
    background-color: #eab308;
    box-shadow: 0 0 0 2px rgba(234, 179, 8, 0.2);
}

.ai-chat-room-widget .status-indicator.status-checking {
    background-color: #6b7280;
    box-shadow: 0 0 0 2px rgba(107, 114, 128, 0.2);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Header Actions Container */
.ai-chat-room-widget .ai-chat-room-head .header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* New Chat Button */
.ai-chat-room-widget .ai-chat-room-head .new-chat-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    outline: 0;
    padding: 6px;
    cursor: pointer;
    transition: all var(--transition-base);
    border-radius: var(--radius-sm);
    opacity: 0.5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.ai-chat-room-widget .ai-chat-room-head .new-chat-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
}

.ai-chat-room-widget .ai-chat-room-head .new-chat-btn:active {
    transform: scale(0.95);
}

.ai-chat-room-widget .ai-chat-room-head .new-chat-btn svg {
    width: 18px;
    height: 18px;
}

/* Maximize Button */
.ai-chat-room-widget .ai-chat-room-head .maximize-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    outline: 0;
    padding: 6px;
    cursor: pointer;
    transition: all var(--transition-base);
    border-radius: var(--radius-sm);
    opacity: 0.5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.ai-chat-room-widget .ai-chat-room-head .maximize-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
}

.ai-chat-room-widget .ai-chat-room-head .maximize-btn:active {
    transform: scale(0.95);
}

.ai-chat-room-widget .ai-chat-room-head .maximize-btn svg {
    width: 18px;
    height: 18px;
}

/* Close Button */
.ai-chat-room-widget .ai-chat-room-head .close-chat-icon {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    outline: 0;
    position: relative;
    padding: 8px;
    cursor: pointer;
    transition: all var(--transition-base);
    border-radius: var(--radius-sm);
    opacity: 0.5;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-room-widget .ai-chat-room-head .close-chat-icon::before {
    content: '';
    width: 18px;
    height: 18px;
    background: currentColor;
    mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>') center/contain no-repeat;
    -webkit-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>') center/contain no-repeat;
}

.ai-chat-room-widget .ai-chat-room-head .close-chat-icon:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.05);
}

/* Splash screen close button */
.ai-chat-room-widget .ai-chat-splash .ai-chat-room-head {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px 24px;
    text-align: right;
    box-shadow: none;
}

/* ========================================================================
   Chat Room Body (Messages Area)
   ======================================================================== */

.ai-chat-room-widget .ai-chat-room-body {
    flex-grow: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    overflow: hidden;
    background: linear-gradient(180deg, #fafbfc 0%, #f5f7f9 100%);
    position: relative;
}

.ai-chat-room-widget .ai-chat-room-body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.03), transparent);
    pointer-events: none;
    z-index: 1;
}

.ai-chat-room-widget .ai-chat-room-body .ai-chat-room-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Custom scrollbar */
.ai-chat-room-widget .ai-chat-room-body .ai-chat-room-scroll::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-room-widget .ai-chat-room-body .ai-chat-room-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.ai-chat-room-widget .ai-chat-room-body .ai-chat-room-scroll::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.ai-chat-room-widget .ai-chat-room-body .ai-chat-room-scroll::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* ========================================================================
   Message Bubbles
   ======================================================================== */

.ai-chat-room-widget .send-msg-wrapper {
    position: relative;
    width: 100%;
    padding: 0 0 8px 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    animation: messageSlideIn 0.3s ease-out;
    opacity: 0;
    animation-fill-mode: forwards;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* User Message (right-aligned, green) */
.ai-chat-room-widget .send-msg-wrapper .send-content {
    border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
    background: var(--primary-color);
    box-shadow: var(--shadow-sm), 0 1px 2px rgba(90, 138, 63, 0.15);
    padding: 11px 16px;
    text-align: left;
    max-width: 85%;
    margin-left: auto;
    word-wrap: break-word;
    position: relative;
    transition: transform var(--transition-base), box-shadow var(--transition-base);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.ai-chat-room-widget .send-msg-wrapper .send-content:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 0 2px 4px rgba(90, 138, 63, 0.2);
}

.ai-chat-room-widget .send-msg-wrapper .send-content p {
    color: #ffffff;
    font-size: 15px;
    font-weight: 400;
    line-height: 1.4;
    margin: 0;
    word-break: break-word;
    letter-spacing: -0.01em;
}

/* Formatted text elements */
.ai-chat-room-widget .send-msg-wrapper .send-content strong {
    font-weight: 700;
}

.ai-chat-room-widget .send-msg-wrapper .send-content em {
    font-style: italic;
}

.ai-chat-room-widget .send-msg-wrapper .send-content code {
    background: rgba(0, 0, 0, 0.15);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.95);
}

.ai-chat-room-widget .send-msg-wrapper.received .send-content code {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
}

.ai-chat-room-widget .send-msg-wrapper .send-content code.code-block {
    display: block;
    padding: 10px 12px;
    margin: 8px 0;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.ai-chat-room-widget .send-msg-wrapper .send-content a {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
    transition: opacity var(--transition-fast);
}

.ai-chat-room-widget .send-msg-wrapper.received .send-content a {
    color: var(--primary-color);
    font-weight: 500;
}

.ai-chat-room-widget .send-msg-wrapper .send-content a:hover {
    opacity: 0.8;
}

.ai-chat-room-widget .send-msg-wrapper .send-content ul,
.ai-chat-room-widget .send-msg-wrapper .send-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.ai-chat-room-widget .send-msg-wrapper .send-content li {
    margin: 6px 0;
    line-height: 1.6;
}

.ai-chat-room-widget .send-msg-wrapper .send-content ul {
    list-style-type: disc;
}

.ai-chat-room-widget .send-msg-wrapper .send-content ol {
    list-style-type: decimal;
}

/* Nested lists */
.ai-chat-room-widget .send-msg-wrapper .send-content li > ul,
.ai-chat-room-widget .send-msg-wrapper .send-content li > ol {
    margin: 6px 0;
}

/* Headings in messages */
.ai-chat-room-widget .send-msg-wrapper .send-content h1,
.ai-chat-room-widget .send-msg-wrapper .send-content h2,
.ai-chat-room-widget .send-msg-wrapper .send-content h3,
.ai-chat-room-widget .send-msg-wrapper .send-content h4,
.ai-chat-room-widget .send-msg-wrapper .send-content h5,
.ai-chat-room-widget .send-msg-wrapper .send-content h6 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

.ai-chat-room-widget .send-msg-wrapper .send-content h1 {
    font-size: 20px;
    border-bottom: 2px solid var(--bg-tertiary);
    padding-bottom: 6px;
}

.ai-chat-room-widget .send-msg-wrapper .send-content h2 {
    font-size: 18px;
    border-bottom: 1px solid var(--bg-tertiary);
    padding-bottom: 4px;
}

.ai-chat-room-widget .send-msg-wrapper .send-content h3 {
    font-size: 16px;
}

.ai-chat-room-widget .send-msg-wrapper .send-content h4 {
    font-size: 15px;
}

.ai-chat-room-widget .send-msg-wrapper .send-content h5,
.ai-chat-room-widget .send-msg-wrapper .send-content h6 {
    font-size: 14px;
}

/* Code blocks with syntax highlighting */
.ai-chat-room-widget .send-msg-wrapper .send-content pre {
    background: #f6f8fa;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 12px;
    margin: 12px 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.ai-chat-room-widget .send-msg-wrapper .send-content pre code {
    background: transparent;
    border: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* Inline code */
.ai-chat-room-widget .send-msg-wrapper .send-content code {
    background: #f6f8fa;
    border: 1px solid #e1e4e8;
    border-radius: 3px;
    padding: 2px 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 13px;
    color: #e83e8c;
}

/* Blockquotes */
.ai-chat-room-widget .send-msg-wrapper .send-content blockquote {
    margin: 12px 0;
    padding: 8px 16px;
    border-left: 4px solid var(--primary-color);
    background: var(--bg-secondary);
    border-radius: 4px;
    color: var(--text-secondary);
    font-style: italic;
}

.ai-chat-room-widget .send-msg-wrapper .send-content blockquote p {
    margin: 0;
}

/* Tables */
.ai-chat-room-widget .send-msg-wrapper .send-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 12px 0;
    font-size: 14px;
}

.ai-chat-room-widget .send-msg-wrapper .send-content th,
.ai-chat-room-widget .send-msg-wrapper .send-content td {
    border: 1px solid #e1e4e8;
    padding: 8px 12px;
    text-align: left;
}

.ai-chat-room-widget .send-msg-wrapper .send-content th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.ai-chat-room-widget .send-msg-wrapper .send-content tr:nth-child(even) {
    background: var(--bg-secondary);
}

/* Horizontal rules */
.ai-chat-room-widget .send-msg-wrapper .send-content hr {
    border: none;
    border-top: 2px solid var(--bg-tertiary);
    margin: 16px 0;
}

/* Paragraphs spacing */
.ai-chat-room-widget .send-msg-wrapper .send-content p {
    margin: 8px 0;
}

.ai-chat-room-widget .send-msg-wrapper .send-content p:first-child {
    margin-top: 0;
}

.ai-chat-room-widget .send-msg-wrapper .send-content p:last-child {
    margin-bottom: 0;
}

/* Task lists (GitHub style) */
.ai-chat-room-widget .send-msg-wrapper .send-content input[type="checkbox"] {
    margin-right: 6px;
    vertical-align: middle;
}

/* Bot Message (left-aligned, white) */
.ai-chat-room-widget .send-msg-wrapper.received {
    align-items: flex-start;
    padding: 0 0 8px 0px;
}

.ai-chat-room-widget .send-msg-wrapper.received .send-content {
    margin-left: 0;
    max-width: 85%;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
    background: var(--bg-primary);
    box-shadow: var(--shadow-sm), 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: transform var(--transition-base), box-shadow var(--transition-base);
    border: 1px solid rgba(0, 0, 0, 0.06);
    padding: 11px 16px;
}

.ai-chat-room-widget .send-msg-wrapper.received .send-content:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 0 2px 4px rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.08);
}

.ai-chat-room-widget .send-msg-wrapper.received .send-content p {
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.4;
    letter-spacing: -0.01em;
}

/* Links in bot messages */
.ai-chat-room-widget .send-msg-wrapper.received .send-content p a {
    color: #5a8a3f;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.ai-chat-room-widget .send-msg-wrapper.received .send-content p a:hover {
    color: #4a7a2f;
}

/* Lists in bot messages */
.ai-chat-room-widget .send-msg-wrapper.received .send-content li {
    color: #393939;
    font-size: 15px;
    line-height: 1.5;
    margin-left: 20px;
}

/* Timestamp */
.ai-chat-room-widget .send-msg-wrapper span {
    color: rgba(0, 0, 0, 0.4);
    font-size: 11px;
    font-weight: 500;
    display: block;
    margin-top: 6px;
}

.ai-chat-room-widget .send-msg-wrapper.received span {
    margin-left: 0;
}

/* ========================================================================
   CTA Button
   ======================================================================== */

.ai-chat-room-widget .send-msg-wrapper.cta-wrapper .send-content {
    max-width: 85%;
}

.ai-chat-room-widget .cta-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #fff !important;
    text-decoration: none !important;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm), 0 1px 2px rgba(90, 138, 63, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    letter-spacing: -0.01em;
}

.ai-chat-room-widget .cta-button::after {
    content: '';
    width: 14px;
    height: 14px;
    background: currentColor;
    mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg>') center/contain no-repeat;
    -webkit-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="12" x2="19" y2="12"/><polyline points="12 5 19 12 12 19"/></svg>') center/contain no-repeat;
    transition: transform var(--transition-base);
}

.ai-chat-room-widget .cta-button:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--secondary-color) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md), 0 2px 4px rgba(90, 138, 63, 0.2);
}

.ai-chat-room-widget .cta-button:hover::after {
    transform: translateX(3px);
}

/* ========================================================================
   Typing Indicator
   ======================================================================== */

.ai-chat-room-widget .bot-typing {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 15px;
    position: relative;
}

.ai-chat-room-widget .dots-cont {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 30px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.ai-chat-room-widget .dot {
    width: 8px;
    height: 8px;
    background: #5a8a3f;
    display: inline-block;
    border-radius: 50%;
    animation: jump 1.4s infinite;
}

.ai-chat-room-widget .dot-1 {
    animation-delay: 0ms;
}

.ai-chat-room-widget .dot-2 {
    animation-delay: 200ms;
}

.ai-chat-room-widget .dot-3 {
    animation-delay: 400ms;
}

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

/* ========================================================================
   Chat Room Footer (Input Form)
   ======================================================================== */

.ai-chat-room-widget .ai-chat-room-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 16px 20px;
    gap: 12px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 249, 250, 0.98) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
    box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.05), var(--shadow-sm);
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.ai-chat-room-widget .ai-chat-room-foot input[type="text"] {
    flex: 1;
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 22px;
    background: rgba(248, 249, 250, 0.8);
    height: 44px;
    padding: 0 18px;
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 400;
    transition: all var(--transition-base);
    letter-spacing: -0.01em;
    line-height: 1.4;
}

.ai-chat-room-widget .ai-chat-room-foot input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(90, 138, 63, 0.1), var(--shadow-sm);
    transform: translateY(-1px);
}

.ai-chat-room-widget .ai-chat-room-foot input[type="text"]::placeholder {
    color: var(--text-light);
}

.ai-chat-room-widget .ai-chat-room-foot input[type="text"]:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Input shake animation for validation errors */
.ai-chat-room-widget .ai-chat-room-foot input[type="text"].shake {
    animation: inputShake 0.5s ease;
    border-color: #f44336 !important;
}

@keyframes inputShake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.ai-chat-room-widget .ai-chat-room-foot .send-btn {
    border: none;
    background: transparent;
    padding: 0;
    cursor: pointer;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    transition: transform var(--transition-base);
    border-radius: var(--radius-sm);
}

.ai-chat-room-widget .ai-chat-room-foot .send-btn:hover:not(:disabled) {
    transform: scale(1.08);
    background: rgba(90, 138, 63, 0.08);
}

.ai-chat-room-widget .ai-chat-room-foot .send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-chat-room-widget .ai-chat-room-foot .send-btn img {
    width: 100%;
    height: 100%;
}

/* ========================================================================
   Chat Icon & Bubble
   ======================================================================== */

.ai-chat-room-widget .open-chat-btn-wrapper {
    position: relative;
}

/* Hide chat icon when chat room or splash screen is opened */
.ai-chat-room-widget .ai-chat-room:not(.hidden) ~ .open-chat-btn-wrapper,
.ai-chat-room-widget .ai-chat-splash:not(.hidden) ~ .open-chat-btn-wrapper {
    display: none;
}

.ai-chat-room-widget button.open-chat-btn {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    border: none;
    padding: 0;
    outline: 0;
    cursor: pointer;
    box-shadow: var(--shadow-lg), 0 0 0 0 rgba(90, 138, 63, 0);
    transition: all var(--transition-slow);
    position: relative;
    overflow: hidden;
}

.ai-chat-room-widget button.open-chat-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, rgba(255, 255, 255, 0.2) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.ai-chat-room-widget button.open-chat-btn:hover {
    transform: scale(1.08) translateY(-2px);
    box-shadow: var(--shadow-xl), 0 0 0 8px rgba(90, 138, 63, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
}

.ai-chat-room-widget button.open-chat-btn:hover::before {
    opacity: 1;
}

.ai-chat-room-widget button.open-chat-btn:active {
    transform: scale(1.02);
}

.ai-chat-room-widget button.open-chat-btn img {
    width: 100%;
    height: 100%;
}

/* Attention Bubble */
.ai-chat-room-widget .alert-popup {
    width: 200px;
    position: absolute;
    background: #fff;
    padding: 14px 18px;
    box-sizing: border-box;
    right: 85px;
    z-index: 99;
    border-radius: 16px;
    bottom: 30px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    animation: bubblePulse 2s infinite;
}

.ai-chat-room-widget .alert-popup:hover {
    animation: none;
}

.ai-chat-room-widget .alert-popup p {
    margin: 0;
    color: #2d5230;
    font-size: 14px;
    line-height: 1.4;
    text-align: center;
    font-weight: 500;
}

.ai-chat-room-widget .alert-popup::after {
    content: "";
    position: absolute;
    right: -8px;
    bottom: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid #fff;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
}

@keyframes bubblePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

/* ========================================================================
   Responsive Design
   ======================================================================== */

@media (max-width: 667px) {
    .ai-chat-room-widget .ai-chat-splash,
    .ai-chat-room-widget .ai-chat-room {
        width: 360px;
        height: 520px;
    }

    .ai-chat-room-widget .send-msg-wrapper .send-content,
    .ai-chat-room-widget .send-msg-wrapper.received .send-content {
        max-width: 90%;
    }
}

@media (max-width: 470px) {
    .ai-chat-room-widget {
        bottom: 105px;
        right: 10px;
    }

    .ai-chat-room-widget .ai-chat-splash,
    .ai-chat-room-widget .ai-chat-room {
        width: calc(100vw - 80px);
        height: calc(100vh - 120px);
        max-width: 360px;
        max-height: 600px;
        right: 10px;
        bottom: 10px;
    }

    .ai-chat-room-widget button.open-chat-btn {
        width: 72px;
        height: 72px;
    }

    .ai-chat-room-widget .alert-popup {
        width: 180px;
        right: 66px;
        font-size: 13px;
    }

    .ai-chat-room-widget .ai-chat-splash h4 {
        font-size: 28px;
    }

    .ai-chat-room-widget .ai-chat-splash p {
        font-size: 14px;
    }
}

@media (max-width: 380px) {
    .ai-chat-room-widget .ai-chat-splash,
    .ai-chat-room-widget .ai-chat-room {
        width: calc(100vw - 20px);
        height: calc(100vh - 100px);
        right: 10px;
        bottom: 80px;
    }
}

/* ========================================================================
   Message Actions (Copy, Retry)
   ======================================================================== */

.ai-chat-room-widget .message-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
    align-self: flex-start; /* Prevent stretching */
}

.ai-chat-room-widget .send-msg-wrapper:hover .message-actions {
    opacity: 1;
}

.ai-chat-room-widget .message-action-btn {
    background: transparent;
    border: none;
    padding: 4px 8px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s ease, color 0.2s ease;
}

.ai-chat-room-widget .message-action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #5a8a3f;
}

.ai-chat-room-widget .message-action-btn::before {
    content: '';
    width: 14px;
    height: 14px;
    margin-right: 6px;
    background: currentColor;
    display: inline-block;
    vertical-align: middle;
}

.ai-chat-room-widget .message-action-copy::before {
    mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>') center/contain no-repeat;
    -webkit-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>') center/contain no-repeat;
}

.ai-chat-room-widget .message-action-retry::before {
    mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"/></svg>') center/contain no-repeat;
    -webkit-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21.5 2v6h-6M2.5 22v-6h6M2 11.5a10 10 0 0 1 18.8-4.3M22 12.5a10 10 0 0 1-18.8 4.2"/></svg>') center/contain no-repeat;
}

/* ========================================================================
   Quick Reply Suggestions
   ======================================================================== */

.ai-chat-room-widget .quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    animation: quickReplySlideUp 0.3s ease-out;
}

@keyframes quickReplySlideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chat-room-widget .quick-reply-btn {
    background: var(--bg-primary);
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 24px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-sm);
    letter-spacing: -0.01em;
}

.ai-chat-room-widget .quick-reply-btn:hover {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #ffffff;
    border-color: transparent;
    transform: translateY(-3px);
    box-shadow: var(--shadow-md), 0 0 0 4px rgba(90, 138, 63, 0.1);
}

.ai-chat-room-widget .quick-reply-btn:active {
    transform: translateY(-1px);
}

.ai-chat-room-widget .quick-reply-btn::before {
    content: '';
    width: 16px;
    height: 16px;
    background: currentColor;
    mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>') center/contain no-repeat;
    -webkit-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>') center/contain no-repeat;
}

/* ========================================================================
   Character Counter
   ======================================================================== */

.ai-chat-room-widget .character-counter {
    position: absolute;
    bottom: 58px;
    right: 24px;
    font-size: 11px;
    color: #999;
    background: rgba(255, 255, 255, 0.95);
    padding: 4px 8px;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.ai-chat-room-widget .character-counter.visible {
    opacity: 1;
}

.ai-chat-room-widget .character-counter.warning {
    color: #ff9800;
}

.ai-chat-room-widget .character-counter.error {
    color: #f44336;
}

/* ========================================================================
   Notification Badge
   ======================================================================== */

.ai-chat-room-widget .notification-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
    color: #fff;
    border-radius: var(--radius-full);
    width: 22px;
    height: 22px;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(255, 68, 68, 0.5), 0 0 0 3px rgba(255, 255, 255, 0.9);
    animation: badgePulse 2s infinite;
    letter-spacing: -0.02em;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* ========================================================================
   Error Message Styling
   ======================================================================== */

.ai-chat-room-widget .error-message {
    background: #fff3f3;
    border: 1px solid #ffcdd2;
    color: #c62828;
    padding: 12px 16px;
    border-radius: 12px;
    margin: 10px 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: errorShake 0.5s ease;
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

.ai-chat-room-widget .send-msg-wrapper.error-message {
    background: transparent;
    border: none;
    padding: 0 0 8px 15px;
    margin: 0;
    animation: messageSlideIn 0.3s ease-out;
}

.ai-chat-room-widget .send-msg-wrapper.error-message .send-content {
    background: #fff5e6;
    border-left: 3px solid #ff9800;
    padding: 16px;
}

.ai-chat-room-widget .send-msg-wrapper.error-message .send-content strong {
    color: #ff6f00;
    display: block;
    margin-bottom: 8px;
}

.ai-chat-room-widget .retry-btn {
    margin-top: 12px;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-base);
    display: inline-block;
}

.ai-chat-room-widget .retry-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* ========================================================================
   Slow Response Notice
   ======================================================================== */

.ai-chat-room-widget .slow-response-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    margin: 0 16px 12px 16px;
    background: rgba(255, 193, 7, 0.15);
    border: 1px solid rgba(255, 193, 7, 0.4);
    border-radius: 12px;
    color: #f57c00;
    font-size: 13px;
    font-weight: 500;
    animation: slowNoticeSlideIn 0.3s ease-out;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.1);
}

@keyframes slowNoticeSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-chat-room-widget .slow-response-notice svg {
    flex-shrink: 0;
    animation: slowNoticeRotate 2s linear infinite;
}

@keyframes slowNoticeRotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.ai-chat-room-widget .slow-response-notice span {
    flex: 1;
    line-height: 1.4;
}

/* ========================================================================
   Streaming Loader - Minimalist Design
   ======================================================================== */

.ai-chat-room-widget .streaming-loader {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 0;
    opacity: 0.7;
}

.ai-chat-room-widget .streaming-loader .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary-color);
    animation: dotPulse 1.4s ease-in-out infinite;
}

.ai-chat-room-widget .streaming-loader .dot:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes dotPulse {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.7;
    }
    30% {
        transform: scale(1.3);
        opacity: 1;
    }
}

.ai-chat-room-widget .streaming-text {
    display: none;
}

.ai-chat-room-widget .streaming-active .streaming-text {
    display: block;
}

.ai-chat-room-widget .error-message::before {
    content: '';
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    background: currentColor;
    mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>') center/contain no-repeat;
    -webkit-mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>') center/contain no-repeat;
}

/* ========================================================================
   Scroll to Bottom Button
   ======================================================================== */

.ai-chat-room-widget .scroll-to-bottom {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 13px;
    font-weight: 500;
    z-index: 10;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.ai-chat-room-widget .scroll-to-bottom.visible {
    display: flex;
    animation: scrollBtnSlideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes scrollBtnSlideUp {
    0% {
        transform: translateX(-50%) translateY(40px);
        opacity: 0;
    }
    100% {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

.ai-chat-room-widget .scroll-to-bottom:hover {
    transform: translateX(-50%) translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2), 0 3px 6px rgba(0, 0, 0, 0.12);
    background: var(--bg-secondary);
    border-color: rgba(0, 0, 0, 0.15);
}

.ai-chat-room-widget .scroll-to-bottom:active {
    transform: translateX(-50%) translateY(0);
}

.ai-chat-room-widget .scroll-to-bottom svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--primary-color);
}

.ai-chat-room-widget .scroll-to-bottom .scroll-btn-text {
    white-space: nowrap;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

/* ========================================================================
   Enhanced Accessibility
   ======================================================================== */

.ai-chat-room-widget :focus-visible {
    outline: 2px solid #5a8a3f;
    outline-offset: 2px;
}

.ai-chat-room-widget .skip-to-input {
    position: absolute;
    left: -9999px;
    z-index: 999;
}

.ai-chat-room-widget .skip-to-input:focus {
    left: 10px;
    top: 10px;
    padding: 8px 12px;
    background: #5a8a3f;
    color: #fff;
    border-radius: 4px;
    text-decoration: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ai-chat-room-widget .send-msg-wrapper .send-content {
        border: 2px solid #2d5230;
    }

    .ai-chat-room-widget .send-msg-wrapper.received .send-content {
        border: 2px solid #393939;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .ai-chat-room-widget * {
        animation: none !important;
        transition: none !important;
    }
}

/* ========================================================================
   Responsive Design - Mobile & Tablet Support
   ======================================================================== */

@media (max-width: 1024px) {
    /* Tablets and smaller desktops */
    .ai-chat-room-widget .ai-chat-splash,
    .ai-chat-room-widget .ai-chat-room {
        width: 380px;
        height: 600px;
        right: 15px;
        bottom: 15px;
    }

    /* Maximized state on tablets - fullscreen */
    .ai-chat-room-widget.maximized .ai-chat-room {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        transform: none !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: none !important;
        max-height: none !important;
        border-radius: 0 !important;
    }

    .ai-chat-room-widget.maximized .ai-chat-room-head {
        border-radius: 0 !important;
    }
}

/* Mobile landscape and smaller tablets */
@media (max-width: 768px) {
    .ai-chat-room-widget {
        bottom: 105px;
        right: 10px;
    }

    .ai-chat-room-widget .ai-chat-splash,
    .ai-chat-room-widget .ai-chat-room {
        width: 100vw;
        height: 100vh;
        max-width: 100%;
        max-height: 100%;
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
        border-radius: 0;
        position: fixed;
        z-index: 999999; /* Ensure it's on top */
    }

    /* Adjust header for mobile */
    .ai-chat-room-widget .ai-chat-room-head {
        padding: 16px 20px;
        border-radius: 0;
        /* Add safe area for notch devices */
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .ai-chat-room-widget .ai-chat-room-head h6 {
        font-size: 16px;
        font-weight: 600;
    }

    .ai-chat-room-widget .ai-chat-room-head h6 img {
        width: 48px;
        height: 48px;
    }

    .ai-chat-room-widget .status-indicator {
        width: 7px;
        height: 7px;
    }

    /* Make header icons more visible on mobile */
    .ai-chat-room-widget .ai-chat-room-head .header-actions {
        gap: 12px;
    }

    .ai-chat-room-widget .ai-chat-room-head .close-chat-icon,
    .ai-chat-room-widget .ai-chat-room-head .new-chat-btn,
    .ai-chat-room-widget .ai-chat-room-head .maximize-btn {
        opacity: 0.7;
        width: 36px;
        height: 36px;
    }

    .ai-chat-room-widget .ai-chat-room-head .close-chat-icon:active,
    .ai-chat-room-widget .ai-chat-room-head .new-chat-btn:active,
    .ai-chat-room-widget .ai-chat-room-head .maximize-btn:active {
        opacity: 1;
        background: rgba(0, 0, 0, 0.1);
    }

    /* Adjust splash screen for mobile */
    .ai-chat-room-widget .ai-chat-splash {
        padding: 30px 20px;
    }

    .ai-chat-splash-inner img {
        width: 60px;
        height: 60px;
    }

    .ai-chat-room-widget .ai-chat-splash h4 {
        font-size: 24px;
    }

    .ai-chat-room-widget .ai-chat-splash p {
        font-size: 14px;
    }

    /* Adjust chat body for mobile */
    .ai-chat-room-widget .ai-chat-room-body {
        flex: 1;
        min-height: 0;
    }

    .ai-chat-room-widget .ai-chat-room-scroll {
        height: 100%;
    }

    /* Adjust messages for mobile */
    .ai-chat-room-widget .send-msg-wrapper {
        max-width: 100%;
        margin-bottom: 12px;
        padding: 0 12px 8px 12px; /* Balanced padding */
    }

    .ai-chat-room-widget .send-msg-wrapper.received {
        padding: 0 12px 8px 12px; /* Keep avatar space on left */
    }

    .ai-chat-room-widget .send-msg-wrapper .send-content {
        padding: 12px 14px;
        font-size: 14px;
    }

    .ai-chat-room-widget .send-msg-wrapper span {
        font-size: 11px;
    }

    /* Adjust input for mobile */
    .ai-chat-room-widget .ai-chat-room-foot {
        padding: 12px 16px;
        /* Add safe area for home indicator */
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .ai-chat-room-widget .ai-chat-room-foot input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 16px;
        height: 48px; /* Larger tap target */
    }

    .ai-chat-room-widget .send-btn {
        width: 48px;
        height: 48px;
        flex-shrink: 0;
    }

    .ai-chat-room-widget .send-btn img {
        width: 24px;
        height: 24px;
    }

    /* Adjust notification bubble position for mobile */
    .ai-chat-room-widget .alert-popup {
        right: 75px;
        bottom: 30px;
        max-width: calc(100vw - 100px);
    }

    /* Quick replies on mobile */
    .ai-chat-room-widget .quick-replies {
        gap: 8px;
        padding: 0 12px;
    }

    .ai-chat-room-widget .quick-reply-btn {
        font-size: 13px;
        padding: 8px 14px;
    }

    /* Character counter on mobile */
    .ai-chat-room-widget .character-counter {
        font-size: 11px;
        padding: 6px 16px;
    }

    /* Message actions on mobile */
    .ai-chat-room-widget .message-actions {
        position: static;
        opacity: 1;
        margin-top: 4px;
        justify-content: flex-end; /* Align with message bubble */
        align-self: flex-end;
    }

    .ai-chat-room-widget .send-msg-wrapper.received .message-actions {
        justify-content: flex-start; /* Align with bot message */
        align-self: flex-start;
    }

    .ai-chat-room-widget .message-action-btn {
        font-size: 11px;
        padding: 4px 10px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .ai-chat-room-widget .ai-chat-room-head {
        padding: 14px 16px;
    }

    .ai-chat-room-widget .ai-chat-room-head h6 {
        font-size: 15px;
    }

    .ai-chat-room-widget .ai-chat-splash h4 {
        font-size: 22px;
    }

    .ai-chat-room-widget .ai-chat-splash p {
        font-size: 13px;
        padding: 0 8px;
    }

    .ai-chat-room-widget .send-msg-wrapper {
        max-width: 100%;
        padding: 0 10px 8px 10px; /* Balanced padding for small screens */
    }

    .ai-chat-room-widget .send-msg-wrapper.received {
        padding: 0 10px 8px 10px; /* Keep avatar space */
    }

    .ai-chat-room-widget .send-msg-wrapper .send-content {
        padding: 10px 12px;
        font-size: 14px;
        max-width: 90%; /* Limit bubble width */
    }

    .ai-chat-room-widget .ai-chat-room-foot {
        padding: 10px 12px;
    }

    .ai-chat-room-widget .ai-chat-room-foot input {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 16px;
    }

    /* Adjust floating button for small screens */
    .ai-chat-room-widget .open-chat-btn {
        width: 56px;
        height: 56px;
    }

    .ai-chat-room-widget .open-chat-btn img {
        width: 28px;
        height: 28px;
    }

    /* Better slow response notice on small screens */
    .ai-chat-room-widget .slow-response-notice {
        font-size: 12px;
        padding: 10px 12px;
        margin: 0 12px 10px 12px;
    }

    .ai-chat-room-widget .slow-response-notice svg {
        width: 14px;
        height: 14px;
    }
}

/* Landscape orientation adjustments */
@media (max-width: 1024px) and (orientation: landscape) {
    .ai-chat-room-widget .ai-chat-splash,
    .ai-chat-room-widget .ai-chat-room {
        height: 90vh;
        right: -10px;
        bottom: -90px;
    }

    .ai-chat-room-widget .ai-chat-room-head {
        padding: 12px 20px;
    }

    .ai-chat-room-widget .ai-chat-room-foot {
        padding: 10px 16px;
    }

    .ai-chat-room-widget .send-msg-wrapper {
        margin-bottom: 10px;
    }

    .ai-chat-room-widget button.open-chat-btn {
        width: 72px;
        height: 72px;
    }

    .ai-chat-room-widget .ai-chat-room-head h6 img {
        width: 48px;
        height: 48px;
    }

    .ai-chat-room-widget .alert-popup {
        right: 75px;
        bottom: 30px;
    }
}

/* Touch device improvements */
@media (hover: none) and (pointer: coarse) {
    /* Increase tap targets for touch devices */
    .ai-chat-room-widget .close-chat-icon,
    .ai-chat-room-widget .new-chat-btn,
    .ai-chat-room-widget .maximize-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 12px;
    }

    .ai-chat-room-widget .send-btn,
    .ai-chat-room-widget .scroll-to-bottom {
        min-height: 44px;
        padding: 12px 18px;
        bottom: 16px;
    }

    .ai-chat-room-widget .message-action-btn {
        min-width: 44px;
        min-height: 44px;
    }

    /* Remove hover effects on touch devices */
    .ai-chat-room-widget .send-btn:hover,
    .ai-chat-room-widget .close-chat-icon:hover,
    .ai-chat-room-widget .quick-reply-btn:hover {
        transform: none;
    }

    /* Show message actions by default on touch */
    .ai-chat-room-widget .message-actions {
        opacity: 1;
    }
}

/* ========================================================================
   Session Management Styles
   ======================================================================== */

/* Session Expired Message */
.ai-chat-room-widget .send-msg-wrapper.session-expired .send-content {
    background: #fff5e6;
    border-left: 3px solid #ff9800;
    padding: 16px;
}

.ai-chat-room-widget .send-msg-wrapper.session-expired .send-content strong {
    color: #ff6f00;
    display: block;
    margin-bottom: 8px;
}

.ai-chat-room-widget .send-msg-wrapper.session-expired .new-chat-btn {
    margin-top: 12px;
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-base);
    display: inline-block;
}

.ai-chat-room-widget .send-msg-wrapper.session-expired .new-chat-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
