/* Chattr Widget Styles */
:root {
    --chattr-primary: #5032B3;
    --chattr-primary-rgb: 80, 50, 179;
    --chattr-secondary: #FF8A65;
    --chattr-bg: #ffffff;
    --chattr-bg-secondary: #f8f9fa;
    --chattr-text-primary: #333333;
    --chattr-text-secondary: #666666;
    --chattr-border: #e9ecef;
    --chattr-danger: #dc3545;
    --chattr-success: #28a745;
    --chattr-font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Pulse animation for AI status */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(83, 108, 221, 0.7);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(83, 108, 221, 0);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(83, 108, 221, 0);
        transform: scale(1);
    }
}

/* Dark mode colors */
[data-chattr-theme="dark"] {
    --chattr-bg: #1a1a1a;
    --chattr-bg-secondary: #2d2d2d;
    --chattr-text-primary: #ffffff;
    --chattr-text-secondary: #cccccc;
    --chattr-border: #404040;
}

/* Auto theme - respects system preference */
@media (prefers-color-scheme: dark) {
    [data-chattr-theme="auto"] {
        --chattr-bg: #1a1a1a;
        --chattr-bg-secondary: #2d2d2d;
        --chattr-text-primary: #ffffff;
        --chattr-text-secondary: #cccccc;
        --chattr-border: #404040;
    }
}

#chattr-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: var(--chattr-primary);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: all 0.3s ease;
}

#chattr-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

#chattr-bubble i {
    color: white;
    font-size: 24px;
}

#chattr-bubble svg {
	color: white;
	width: 32px;
	height: 32px;
	fill: currentColor;
	filter: drop-shadow(2px 2px 0 rgba(0, 0, 0, 0.3));
}

#chattr-bubble.has-notification {
    animation: pulse 2s infinite;
}

#chattr-bubble.pulsing {
    animation: gentlePulse 2.5s infinite ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

@keyframes gentlePulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    50% { 
        transform: scale(1.08);
        box-shadow: 0 6px 20px rgba(var(--chattr-primary-rgb), 0.4);
    }
}

/* Bubble notification indicator */
.chattr-bubble-notification {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 12px;
    height: 12px;
    background: #ff4444;
    border: 2px solid white;
    border-radius: 50%;
    display: none;
}

.chattr-bubble-notification.chattr-has-conversation {
    display: block;
    background: #10b981;
}

.chattr-bubble-notification.chattr-new-message {
    display: block;
    background: #ff4444;
    animation: pulse 1.5s infinite;
}

/* Widget Container */
#chattr-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    z-index: 9998;
    display: none;
    overflow: hidden;
    font-family: var(--chattr-font-family);
    transform: scale(0.8) translateY(20px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#chattr-widget.opening {
    display: block;
    transform: scale(1) translateY(0);
    opacity: 1;
}

@media (max-width: 480px) {
    #chattr-widget {
        width: calc(100vw - 40px);
        height: calc(100vh - 40px);
        bottom: 20px;
        right: 20px;
    }
}

.chattr-widget-card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Header */
.chattr-header {
	background: #ffffff;
	padding: 10px 15px;
	border-bottom: 1px solid #f0f0f0;
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex-shrink: 0;
	/* height: 80px; */
}

.chattr-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chattr-header-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chattr-widget-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.chattr-header-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.chattr-form-actions {
	display: flex;
	align-items: center;
	gap: 8px;
}

.chattr-header-actions button {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s ease;
}

.chattr-header-actions button:hover {
    background: #f5f5f5;
    color: #333;
}

.chattr-close {
    font-size: 18px;
}

/* Theme Toggle Button */
.chattr-user-theme-toggle {
    position: relative;
}

.chattr-user-theme-toggle i {
    font-size: 16px;
    transition: transform 0.3s ease;
}

.chattr-user-theme-toggle:hover i {
    transform: rotate(180deg);
}

/* Sound Toggle Button (muted state) */
.chattr-user-sound-toggle.muted {
    opacity: 0.6;
}

/* Start Screen */
.chattr-start-screen {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 40px 20px;
	text-align: center;
	overflow-x: hidden !important;
}

.chattr-start-screen {
	overflow: scroll;
	height: auto;
	padding-top: 200px;
}

.chattr-preview-container .chattr-start-screen {
	padding-top: 0;
}

.chattr-welcome-message h3 {
    font-size: 20px;
    color: #333;
    margin: 0 0 20px 0;
    font-weight: 600;
}

.chattr-action-btn {
    background: var(--chattr-primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    margin-bottom: 20px;
    position: relative;
}

.chattr-action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--chattr-primary-rgb), 0.3);
}

/* Start chat button with session info */
.chattr-start-chat-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chattr-start-chat-status {
    font-size: 11px;
    opacity: 0.9;
    font-weight: 400;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chattr-start-chat-status i {
    font-size: 12px;
}

/* Active session state */
.chattr-action-btn.chattr-has-active-session {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.chattr-action-btn.chattr-has-active-session:hover {
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* Ended session state */
.chattr-action-btn.chattr-has-ended-session {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}

.chattr-action-btn.chattr-has-ended-session:hover {
    box-shadow: 0 4px 12px rgba(107, 114, 128, 0.3);
}

.chattr-quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.chattr-quick-action {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #495057;
    font-size: 14px;
}

.chattr-quick-action:hover {
    background: #e9ecef;
    transform: translateY(-1px);
}

/* Chat UI */
.chattr-chat-ui {
    flex: 1;
    display: none;
    flex-direction: column;
    min-height: 0;
}

/* Show/hide screens based on chat-active state */
.chattr-widget-card:not(.chat-active) .chattr-start-screen {
    display: flex;
}

.chattr-widget-card:not(.chat-active) .chattr-chat-ui {
    display: none;
}

.chattr-widget-card.chat-active .chattr-start-screen {
    display: none;
}

.chattr-widget-card.chat-active .chattr-chat-ui {
    display: flex;
}

.chattr-messages {
	flex: 1;
	padding: 15px;
	overflow-y: auto;
	background: #fafbfc;
	display: flex;
	flex-direction: column;
}

/* Scrollbar styling for messages */
.chattr-messages::-webkit-scrollbar {
    width: 6px;
}

.chattr-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chattr-messages::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 3px;
}

.chattr-messages::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

.chattr-empty {
    text-align: center;
    padding: 40px 20px;
}

.chattr-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.chattr-empty h4 {
    font-size: 18px;
    color: #333;
    margin: 0 0 8px 0;
    font-weight: 600;
}

.chattr-empty p {
    color: #666;
    margin: 0;
    font-size: 14px;
}

/* Messages - Support both .chattr-message and .chattr-msg */
.chattr-message, .chattr-msg {
	margin-bottom: 16px;
	display: flex;
	gap: 5px;
	animation: fadeInSoft 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: translateY(15px) scale(0.95); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

@keyframes fadeInSoft {
    from { 
        opacity: 0; 
        transform: translateY(8px); 
    }
    to { 
        opacity: 1; 
        transform: translateY(0); 
    }
}

.chattr-message.user, .chattr-msg-user {
    flex-direction: row-reverse;
}

.chattr-message-avatar, .chattr-msg-avatar {
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: #e9ecef;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	color: #666;
	font-weight: 600;
	flex-shrink: 0;
	overflow: hidden;
    margin-bottom: 25px;
}

.chattr-message.agent .chattr-message-avatar, .chattr-msg-agent .chattr-msg-avatar {
	background: linear-gradient(135deg, #10b981 0%, #059669 100%);
	color: white;
	border-radius: 100px;
	overflow: hidden;
}

.chattr-message-content, .chattr-msg-content {
    flex: 1;
    max-width: 75%;
}

.chattr-message.user .chattr-message-content, .chattr-msg-user .chattr-msg-content {
	text-align: left;
	width: 100%;
	border-radius: 18px 18px 3px 18px;
}

.chattr-message-sender, .chattr-msg-sender {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
    font-weight: 500;
}

.chattr-message.user .chattr-message-sender,
.chattr-msg-user .chattr-msg-sender {
    display: none;
}

.chattr-msg.chattr-msg-agent {
	align-items: flex-end;
}

.chattr-msg-wrapper {
	display: flex;
	flex-direction: column;
}

.chattr-msg-sender {
	order: 1;
}

.chattr-msg-agent .chattr-msg-content {
	border-radius: 15px 15px 15px 3px;
}

.chattr-message-bubble, .chattr-msg-content {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    color: #333;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    word-wrap: break-word;
}

.chattr-message.user .chattr-message-bubble, .chattr-msg-user .chattr-msg-content {
	color: #2f2f2f;
	background-color: #F1F1F2;
	border: 1px solid #ccc;
}

.chattr-message.ai .chattr-message-bubble,
.chattr-msg-ai .chattr-msg-content {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.chattr-message.agent .chattr-message-bubble,
.chattr-msg-agent .chattr-msg-content {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
}

.chattr-message-time, .chattr-msg-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* Message wrapper for JavaScript-generated messages */
.chattr-msg-wrapper {
    flex: 1;
    max-width: 100%;
}

.chattr-msg-user .chattr-msg-wrapper {
	text-align: left;
	align-items: flex-end;
}

/* Offline Form Screen */
.chattr-offline-screen {
    position: absolute;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 50px; /* Leave space for footer */
    background: white; /* Force light mode */
    overflow-y: auto;
    padding: 20px;
}

.chattr-offline-form-wrapper {
    max-width: 400px;
    margin: 0 auto;
}

.chattr-offline-form input:focus,
.chattr-offline-form textarea:focus {
    outline: none;
    border-color: var(--chattr-primary);
    box-shadow: 0 0 0 3px rgba(var(--chattr-primary-rgb), 0.1);
}

.chattr-offline-submit-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chattr-offline-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Offline Form Navigation Button */
.chattr-offline-form-nav-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Back button in offline form */
.chattr-back-to-start:hover {
    background: var(--chattr-primary) !important;
    color: white !important;
    transform: translateX(-4px);
}

/* Input Form */
.chattr-form {
	flex-shrink: 0;
	padding: 10px;
	background: white;
	border-top: 1px solid #f0f0f0;
}

.chattr-input-container {
	display: flex;
	align-items: center;
	gap: 12px;
	background: #f8f9fa;
	border: 1px solid #e9ecef;
	border-radius: 20px;
	padding: 3px 12px;
	transition: all 0.2s ease;
	height: fit-content;
}

.chattr-input-container:focus-within {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(var(--chattr-primary-rgb), 0.1);
}

.chattr-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    font-family: inherit;
}

/* Conversation Ended Banner Styles */
.chattr-conversation-ended-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border: 1px solid #bbdefb;
    border-radius: 8px;
    padding: 16px;
    margin: 16px;
    color: #1565c0;
    animation: chattr-banner-slide-in 0.3s ease-out;
}

.chattr-ended-icon {
    width: 32px;
    height: 32px;
    background: #1976d2;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    flex-shrink: 0;
}

.chattr-ended-content {
    flex: 1;
}

.chattr-ended-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #1565c0;
}

.chattr-ended-subtitle {
    font-size: 14px;
    color: #1976d2;
    opacity: 0.8;
}

@keyframes chattr-banner-slide-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Dark mode styles for ended banner */
[data-chattr-theme="dark"] .chattr-conversation-ended-banner {
    background: linear-gradient(135deg, #1a237e 0%, #4a148c 100%);
    border-color: #3949ab;
    color: #e8eaf6;
}

[data-chattr-theme="dark"] .chattr-ended-icon {
    background: #3f51b5;
}

[data-chattr-theme="dark"] .chattr-ended-title {
    color: #e8eaf6;
}

[data-chattr-theme="dark"] .chattr-ended-subtitle {
    color: #c5cae9;
}

.chattr-input::placeholder {
    color: #adb5bd;
}

.chattr-input.chattr-message-input {
	outline: none !important;
	padding-left: 5px;
	padding-right: 0;
}


.chattr-header-actions {
	display: flex;
	flex-direction: row;
}

.chattr-send-btn, .chattr-gif-btn, .chattr-file-btn, .chattr-emoji-btn {
	background: none;
	border: none;
	width: 16px;
	height: 16px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	color: var(--chattr-text-secondary);
}

label.chattr-file-btn {
	margin-bottom: 0;
}

.chattr-send-btn:hover {
    color: var(--chattr-primary);
}

.chattr-send-btn:disabled {
    background: #dee2e6;
    cursor: not-allowed;
    transform: none;
}

/* Restart Button */
.chattr-restart-btn {
    background: var(--chattr-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
    margin-top: 12px;
    width: 100%;
    justify-content: center;
}

.chattr-restart-btn:hover {
    background: linear-gradient(135deg, #5a5fcf 0%, #6941a0 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--chattr-primary-rgb), 0.3);
}

.chattr-restart-btn i {
    font-size: 16px;
}

.chattr-footer {
	padding: 10px 20px;
	background: #f8f9fa;
	border-top: 1px solid #f0f0f0;
	text-align: center;
	line-height: 1;
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 5px;
	margin-top: auto;
}

.chattr-powered-by {
    font-size: 12px;
    color: #666;
    text-decoration: none;
}

.chattr-footer-logo {
    width: 60px;
    height: auto;
    object-fit: contain;
}

.chattr-footer-link {
    display: flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    color: #666;
    transition: opacity 0.2s ease;
}

.chattr-footer-link:hover {
    opacity: 0.8;
}

.chattr-powered-by:hover {
    color: #333;
}

/* Typing Indicator - Support both structures */
.chattr-typing-indicator, .chattr-typing {
    display: none;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.chattr-typing-indicator.active, .chattr-typing {
    display: flex;
}

.chattr-typing-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--chattr-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
}

.chattr-typing-bubble, .chattr-typing-dots {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    display: flex;
    gap: 4px;
    align-items: center;
}

.chattr-typing-dot {
    width: 6px;
    height: 6px;
    background: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.chattr-typing-dot:nth-child(1) { animation-delay: 0s; }
.chattr-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.chattr-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* Form States */
.chattr-form-closed .chattr-input {
    background: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

.chattr-form-closed .chattr-send-btn {
    display: none !important;
}

/* Hidden states */
.chattr-hidden {
    display: none !important;
}

/* GIF Modal */
.chattr-gif-modal {
    position: fixed;
    z-index: 10000;
    max-width: 320px;
    width: 320px;
}

.chattr-gif-container {
    background: var(--chattr-bg);
    border: 1px solid var(--chattr-border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    width: 450px;
    max-width: 90vw;
    max-height: 400px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.chattr-gif-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--chattr-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--chattr-bg-secondary);
}

.chattr-gif-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--chattr-text-primary);
}

.chattr-gif-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--chattr-text-secondary);
    padding: 4px;
    font-size: 18px;
    line-height: 1;
}

.chattr-gif-close:hover {
    color: var(--chattr-text-primary);
}

.chattr-gif-search {
    padding: 12px 16px;
    border-bottom: 1px solid var(--chattr-border);
}

.chattr-gif-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--chattr-border);
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    background: var(--chattr-bg);
    color: var(--chattr-text-primary);
}

.chattr-gif-input:focus {
    border-color: var(--chattr-primary);
    box-shadow: 0 0 0 2px rgba(var(--chattr-primary-rgb), 0.1);
}

.chattr-gif-results {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    max-height: 300px;
    min-height: 250px;
}

.chattr-gif-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.chattr-gif-item {
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: var(--chattr-bg-secondary);
}

.chattr-gif-item:hover {
    transform: scale(1.05);
}

.chattr-gif-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* File Upload Styles */
.chattr-file-btn:hover {
    background: none;
    color: var(--chattr-text-secondary);
}

.chattr-file-btn i {
    font-size: 18px;
}

.chattr-file-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    max-width: 280px;
}

.chattr-file-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.chattr-file-info {
    flex: 1;
    min-width: 0;
}

.chattr-file-name {
    font-weight: 500;
    color: #1e293b;
    margin-bottom: 2px;
}

.chattr-file-name a {
    color: inherit;
    text-decoration: none;
    word-break: break-word;
}

.chattr-file-name a:hover {
    text-decoration: underline;
}

.chattr-file-size {
    font-size: 12px;
    color: #64748b;
}

.chattr-file-upload-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #6b7280;
}

.chattr-upload-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Image Preview Modal */
.chattr-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.chattr-image-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chattr-image-modal img {
    max-width: 100%;
    max-height: calc(90vh - 80px);
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.chattr-image-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 10px 0;
    color: white;
}

.chattr-image-modal-title {
    font-size: 16px;
    font-weight: 500;
    margin: 0;
    word-break: break-word;
}

.chattr-image-modal-close {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background 0.2s ease;
    margin-left: 16px;
    flex-shrink: 0;
}

.chattr-image-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chattr-image-preview {
    position: relative;
    display: inline-block;
    border-radius: 8px;
    overflow: hidden;
    max-width: 280px;
}

.chattr-image-preview img {
    width: 100%;
    height: auto;
    max-height: 200px;
    object-fit: cover;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.chattr-image-preview img:hover {
    opacity: 0.9;
}

.chattr-image-message {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

.chattr-image-caption {
    margin-top: 4px;
    font-size: 11px;
    color: var(--chattr-text-secondary);
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chattr-image-filename {
    word-break: break-word;
    line-height: 1.3;
}

.chattr-image-size {
    opacity: 0.8;
}

/* Emoji Picker */

.chattr-emoji-btn:hover, .chattr-file-btn:hover, .chattr-gif-btn:hover, .chattr-send-btn:hover {
    color: var(--chattr-primary);
}

.chattr-emoji-picker {
    position: fixed;
    background: var(--chattr-bg);
    border: 1px solid var(--chattr-border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    padding: 10px;
    width: 252px;
    max-height: 320px;
    overflow: hidden;
    z-index: 10000;
    display: none;
}

.chattr-emoji-picker.active {
    display: block;
}

.chattr-emoji-categories {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--chattr-border);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.chattr-emoji-category {
    background: none;
    border: none;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--chattr-text-secondary);
    border-radius: 6px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    white-space: nowrap;
}

.chattr-emoji-category:hover,
.chattr-emoji-category.active {
    background: var(--chattr-primary);
    color: white;
}

.chattr-emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 3px;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 200px;
    padding: 2px;
}

.chattr-emoji-item {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    font-size: 18px;
    border-radius: 4px;
    transition: background 0.2s ease;
    line-height: 1;
    width: 100%;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chattr-emoji-search {
    width: calc(100% - 4px);
    padding: 8px 10px;
    border: 1px solid var(--chattr-border);
    border-radius: 6px;
    margin-bottom: 10px;
    box-sizing: border-box;
    font-size: 14px;
    background: var(--chattr-bg);
    color: var(--chattr-text-primary);
}

.chattr-emoji-search:focus {
    outline: none;
    border-color: var(--chattr-primary);
}

/* GIF Paste Indicator */
.chattr-paste-indicator {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 10px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.chattr-paste-indicator.active {
    opacity: 1;
}

.chattr-paste-indicator::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.8);
}

/* GIF Preview */
.chattr-gif-preview {
    display: inline-block;
    margin: 4px 0;
    border-radius: 8px;
    overflow: hidden;
    max-width: 100%;
}

.chattr-gif-preview img {
    display: block;
    width: auto;
    height: auto;
    max-width: 200px;
    max-height: 200px;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.chattr-gif-preview img:hover {
    opacity: 0.9;
}

/* Proactive Message Popup */
.chattr-proactive-popup {
    position: fixed;
    bottom: 100px;
    right: 20px;
    background: var(--chattr-card-bg);
    border: 1px solid var(--chattr-border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 16px 20px;
    max-width: 280px;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.chattr-proactive-popup.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chattr-proactive-popup::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 30px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--chattr-card-bg);
}

.chattr-proactive-popup::before {
    content: '';
    position: absolute;
    bottom: -9px;
    right: 30px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid var(--chattr-border);
}

.chattr-proactive-message {
    font-size: 14px;
    line-height: 1.4;
    color: var(--chattr-text);
    margin: 0 0 12px 0;
}

.chattr-proactive-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.chattr-proactive-btn {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.chattr-proactive-btn--primary {
    background: var(--chattr-primary);
    color: white;
}

.chattr-proactive-btn--primary:hover {
    background: var(--chattr-primary-hover);
}

.chattr-proactive-btn--secondary {
    background: transparent;
    color: var(--chattr-text-secondary);
    border: 1px solid var(--chattr-border);
}

.chattr-proactive-btn--secondary:hover {
    background: var(--chattr-bg-secondary);
}

/* File Upload Styles */
.chattr-file-preview-container {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	padding: 8px 16px;
	background: #f8f9fa;
	border-top: 1px solid #e9ecef;
	max-height: 120px;
	overflow-y: auto;
}

.chattr-file-preview {
	position: relative;
	background: #0000000a;
	border: 1px solid #e9ecef;
	border-radius: 8px;
	padding: 0px 8px;
	display: flex;
	align-items: center;
	gap: 2px;
	max-width: 200px;
	font-size: 10px;
}

.chattr-file-preview-icon {
	font-size: 14px;
	color: var(--chattr-primary);
}

.chattr-file-preview-name {
	flex: 1;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	color: #adb5bd;
	font-weight: 600;
}

.chattr-file-preview-size {
	color: #adb5bd;
	font-size: 9px;
	font-weight: 400;
}

.chattr-file-preview-remove {
	position: absolute;
	top: -6px;
	right: -3px;
	color: #f42323;
	border: none;
	border-radius: 50%;
	width: 18px;
	height: 18px;
	font-size: 12px;
	cursor: pointer;
	display: flex;
	align-items: center;
    
	justify-content: center;
	padding: 0;
	line-height: 1;
	background: none;
	font-weight: 500;
}

.chattr-file-preview-remove:hover {
    font-weight: 700;
}

/* Drag & Drop Styles */
.chattr-chat-ui.chattr-drag-over .chattr-messages {
    position: relative;
}

.chattr-chat-ui.chattr-drag-over .chattr-messages::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(var(--chattr-primary-rgb), 0.1);
    border: 2px dashed var(--chattr-primary);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.chattr-drop-overlay {
    position: absolute;
    inset: 0;
    background: rgba(var(--chattr-primary-rgb), 0.95);
    border-radius: 12px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    color: white;
    font-size: 18px;
    font-weight: 600;
    pointer-events: none;
}

.chattr-chat-ui.chattr-drag-over .chattr-drop-overlay {
    display: flex;
}

.chattr-drop-overlay-content {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.chattr-drop-overlay-icon {
    font-size: 48px;
    display: block;
    animation: bounceIn 0.5s ease;
}

.chattr-drop-overlay-text {
    font-size: 14px;
    opacity: 0.9;
    font-weight: 500;
}

@keyframes bounceIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* File Upload Progress */
.chattr-upload-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--chattr-bg-secondary);
    border-radius: 0 0 8px 8px;
    overflow: hidden;
}

.chattr-upload-progress-bar {
    height: 100%;
    background: var(--chattr-primary);
    transition: width 0.3s ease;
    width: 0;
}

/* File message styles */
.chattr-message-file {
    background: var(--chattr-bg-secondary);
    border: 1px solid var(--chattr-border);
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.chattr-message-file:hover {
    background: var(--chattr-bg-hover);
}

.chattr-message-file-icon {
    font-size: 24px;
    color: var(--chattr-primary);
}

.chattr-message-file-info {
    flex: 1;
}

.chattr-message-file-name {
    font-weight: 500;
    color: var(--chattr-text-primary);
    margin-bottom: 2px;
}

.chattr-message-file-size {
    font-size: 12px;
    color: var(--chattr-text-secondary);
}

.chattr-message-file-download {
    color: var(--chattr-primary);
    font-size: 18px;
}

/* Image preview in messages */
.chattr-message-image {
    margin-top: 8px;
    border-radius: 8px;
    overflow: hidden;
    max-width: 100%;
}

.chattr-message-image img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
}

/* File type specific colors */
.chattr-file-preview-icon.chattr-file-pdf {
    color: #dc3545;
}

.chattr-file-preview-icon.chattr-file-doc {
    color: #0066cc;
}

.chattr-file-preview-icon.chattr-file-image {
    color: #28a745;
}

.chattr-file-preview-icon.chattr-file-default {
    color: var(--chattr-text-secondary);
}

/* Session Info on Home Screen */
.chattr-session-info {
    margin: 16px 0;
    padding: 0 20px;
}

.chattr-session-card {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid var(--chattr-border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.chattr-session-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--chattr-primary);
    font-weight: 600;
    font-size: 14px;
}

.chattr-session-status i {
    font-size: 16px;
}

.chattr-agent-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 8px 0;
    border-top: 1px solid rgba(var(--chattr-primary-rgb), 0.1);
    border-bottom: 1px solid rgba(var(--chattr-primary-rgb), 0.1);
}

.chattr-agent-avatar {
    width: 36px;
    height: 36px;
    background: var(--chattr-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.chattr-agent-avatar i {
    font-size: 18px;
}

.chattr-agent-details {
    flex: 1;
}

.chattr-agent-name {
    font-weight: 600;
    color: var(--chattr-text-primary);
    font-size: 14px;
    margin-bottom: 2px;
}

.chattr-agent-status {
    font-size: 12px;
    color: var(--chattr-success);
    display: flex;
    align-items: center;
    gap: 4px;
}

.chattr-agent-status::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--chattr-success);
    border-radius: 50%;
    display: inline-block;
}

.chattr-session-duration {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--chattr-text-secondary);
    font-size: 12px;
}

.chattr-session-duration i {
    font-size: 14px;
}

/* Session info for ended conversations */
.chattr-session-card.ended {
    background: linear-gradient(135deg, #fafafa 0%, #e5e5e5 100%);
    opacity: 0.8;
}

.chattr-session-card.ended .chattr-session-status {
    color: var(--chattr-text-secondary);
}

.chattr-session-card.ended .chattr-session-text::after {
    content: ' (ended)';
    font-weight: normal;
}

/* Offline form highlight effect */
.chattr-module-offline-form.chattr-highlight {
	animation: chattr-pulse 0.5s ease-in-out 3;
	box-shadow: 0 0 20px rgba(80, 54, 214, 0.5);
}

@keyframes chattr-pulse {
	0% {
		transform: scale(1);
		box-shadow: 0 0 20px rgba(80, 54, 214, 0.5);
	}
	50% {
		transform: scale(1.02);
		box-shadow: 0 0 30px rgba(80, 54, 214, 0.7);
	}
	100% {
		transform: scale(1);
		box-shadow: 0 0 20px rgba(80, 54, 214, 0.5);
	}
}

/* Star Rating Modal */
.chattr-rating-modal {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.5);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 10003;
	backdrop-filter: blur(2px);
}

.chattr-rating-container {
	background: var(--chattr-widget-bg);
	border-radius: 16px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
	max-width: 400px;
	width: 90%;
	max-height: 90vh;
	overflow: hidden;
	animation: chattr-slide-up 0.3s ease-out;
}

.chattr-rating-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px;
	border-bottom: 1px solid var(--chattr-border);
}

.chattr-rating-header h3 {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
	color: var(--chattr-text-primary);
}

.chattr-rating-close {
	background: none;
	border: none;
	color: var(--chattr-text-secondary);
	cursor: pointer;
	padding: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.2s ease;
	border-radius: 6px;
}

.chattr-rating-close:hover {
	background: var(--chattr-hover-bg);
	color: var(--chattr-text-primary);
}

.chattr-rating-content {
	padding: 20px;
}

.chattr-rating-prompt {
	text-align: center;
	margin: 0 0 20px;
	color: var(--chattr-text-secondary);
	font-size: 14px;
}

.chattr-rating-stars {
	display: flex;
	justify-content: center;
	gap: 8px;
	margin-bottom: 20px;
}

.chattr-star {
	background: none;
	border: none;
	cursor: pointer;
	padding: 8px;
	transition: all 0.2s ease;
	color: #d1d5db;
	font-size: 32px;
	line-height: 1;
}

.chattr-star:hover {
	transform: scale(1.1);
}

.chattr-star.active {
	color: #fbbf24;
}

.chattr-star.active i::before {
	content: "\EA51"; /* ri-star-fill */
}

.chattr-rating-feedback {
	margin-bottom: 20px;
}

.chattr-rating-feedback label {
	display: block;
	margin-bottom: 8px;
	font-size: 14px;
	color: var(--chattr-text-primary);
	font-weight: 500;
}

.chattr-rating-comment {
	width: 100%;
	padding: 12px;
	border: 1px solid var(--chattr-border);
	border-radius: 8px;
	background: var(--chattr-input-bg);
	color: var(--chattr-text-primary);
	font-size: 14px;
	line-height: 1.5;
	resize: vertical;
	min-height: 80px;
	transition: border-color 0.2s ease;
}

.chattr-rating-comment:focus {
	outline: none;
	border-color: var(--chattr-primary);
}

.chattr-rating-actions {
	display: flex;
	gap: 12px;
	justify-content: center;
}

.chattr-rating-submit,
.chattr-rating-skip {
	padding: 10px 24px;
	border-radius: 8px;
	font-size: 14px;
	font-weight: 500;
	cursor: pointer;
	transition: all 0.2s ease;
	border: none;
}

.chattr-rating-submit {
	background: var(--chattr-primary);
	color: white;
}

.chattr-rating-submit:hover {
	transform: translateY(-1px);
	box-shadow: 0 4px 12px rgba(80, 54, 214, 0.3);
}

.chattr-rating-submit:disabled {
	opacity: 0.6;
	cursor: not-allowed;
	transform: none;
}

.chattr-rating-skip {
	background: transparent;
	color: var(--chattr-text-secondary);
	border: 1px solid var(--chattr-border);
}

.chattr-rating-skip:hover {
	background: var(--chattr-hover-bg);
	color: var(--chattr-text-primary);
}

/* Star animation */
@keyframes chattr-star-bounce {
	0%, 100% {
		transform: scale(1) rotate(0deg);
	}
	50% {
		transform: scale(1.2) rotate(5deg);
	}
}

.chattr-star.animate {
	animation: chattr-star-bounce 0.3s ease;
}
