/* Modern CSS Reset & Variables */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    /* Design System Colors */
    --emerald-50: #ecfdf5;
    --emerald-100: #d1fae5;
    --emerald-500: #10b981;
    --emerald-600: #059669;
    --emerald-700: #047857;
    --emerald-900: #064e3b;
    
    --slate-50: #f8fafc;
    --slate-100: #f1f5f9;
    --slate-200: #e2e8f0;
    --slate-300: #cbd5e1;
    --slate-400: #94a3b8;
    --slate-500: #64748b;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1e293b;
    --slate-900: #0f172a;
    
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --indigo-500: #6366f1;
    --red-500: #ef4444;
    --green-500: #22c55e;
    
    /* Theme Variables */
    --bg-primary: #ffffff;
    --bg-secondary: var(--slate-50);
    --bg-tertiary: var(--slate-100);
    --text-primary: var(--slate-900);
    --text-secondary: var(--slate-600);
    --text-muted: var(--slate-400);
    --border-primary: var(--slate-200);
    --border-secondary: var(--slate-300);
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, var(--emerald-500) 0%, var(--emerald-600) 50%, var(--emerald-700) 100%);
    --gradient-secondary: linear-gradient(135deg, var(--blue-500) 0%, var(--indigo-500) 100%);
    --gradient-surface: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
    
    /* Spacing Scale */
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    --space-16: 4rem;     /* 64px */
    --space-20: 5rem;     /* 80px */
    
    /* Radius Scale */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;
    --radius-3xl: 2rem;
    --radius-full: 9999px;
    
    /* Shadow Scale */
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --shadow-2xl: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    --shadow-inner: inset 0 2px 4px 0 rgb(0 0 0 / 0.05);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 400ms cubic-bezier(0.34, 1.56, 0.64, 1);
    
    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    
    /* Z-index Scale */
    --z-base: 0;
    --z-docked: 10;
    --z-dropdown: 1000;
    --z-sticky: 1020;
    --z-banner: 1030;
    --z-overlay: 1040;
    --z-modal: 1050;
    --z-popover: 1060;
    --z-tooltip: 1070;
    --z-toast: 1080;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: var(--slate-900);
        --bg-secondary: var(--slate-800);
        --bg-tertiary: var(--slate-700);
        --text-primary: var(--slate-100);
        --text-secondary: var(--slate-300);
        --text-muted: var(--slate-500);
        --border-primary: var(--slate-700);
        --border-secondary: var(--slate-600);
        --gradient-surface: linear-gradient(145deg, var(--slate-900) 0%, var(--slate-800) 100%);
    }
}

/* Base Styles */
html {
    scroll-behavior: smooth;
    height: 100%;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: 0.875rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100%;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

/* Perfect Centering System */
.chat-container {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: var(--z-modal);
}

/* Chat Toggle Button - Perfectly Centered Bottom */
.chat-toggle {
    position: fixed;
    bottom: var(--space-8);
    left: 50%;
    transform: translateX(-50%);
    width: 4rem;
    height: 4rem;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    box-shadow: var(--shadow-xl);
    transition: var(--transition-normal);
    z-index: var(--z-toast);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    pointer-events: all;
    will-change: transform;
}

.chat-toggle:hover {
    transform: translateX(-50%) translateY(-4px) scale(1.1);
    box-shadow: var(--shadow-2xl);
}

.chat-toggle:active {
    transform: translateX(-50%) translateY(-2px) scale(1.05);
}

.chat-toggle .chat-icon,
.chat-toggle .close-icon {
    transition: var(--transition-fast);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.chat-toggle .close-icon {
    display: none;
    font-size: 1.25rem;
    font-weight: 700;
}

.chat-toggle.active {
    background: var(--gradient-secondary);
    transform: translateX(-50%) rotate(45deg);
}

.chat-toggle.active .chat-icon {
    display: none;
}

.chat-toggle.active .close-icon {
    display: block;
    transform: rotate(-45deg);
}

/* Chat Widget - Perfect Center on Desktop */
.chat-widget {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: min(28rem, 90vw);
    height: min(36rem, 85vh);
    max-width: 100%;
    max-height: 100%;
    background: var(--gradient-surface);
    border-radius: var(--radius-3xl);
    box-shadow: var(--shadow-2xl);
    display: none;
    flex-direction: column;
    z-index: var(--z-modal);
    overflow: hidden;
    border: 1px solid var(--border-primary);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    pointer-events: all;
    transition: var(--transition-bounce);
    will-change: transform, opacity;
}

.chat-widget.active {
    display: flex;
    transform: translate(-50%, -50%) scale(1);
    animation: chatWidgetAppear var(--transition-bounce);
}

@keyframes chatWidgetAppear {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8) rotate(5deg);
    }
    50% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1.05) rotate(-2deg);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
    }
}

/* Chat Header - Premium Design */
.chat-header {
    background: var(--gradient-primary);
    color: white;
    padding: var(--space-6) var(--space-8);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    overflow: hidden;
    min-height: 5rem;
}

.chat-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0.05) 50%, transparent 100%);
    pointer-events: none;
}

.chat-header::after {
    content: '';
    position: absolute;
    top: -100%;
    right: -50%;
    width: 200%;
    height: 300%;
    background: radial-gradient(ellipse, rgba(255,255,255,0.15) 0%, transparent 60%);
    pointer-events: none;
    animation: headerShimmer 6s ease-in-out infinite;
}

@keyframes headerShimmer {
    0%, 100% { 
        opacity: 0.3;
        transform: rotate(0deg);
    }
    50% { 
        opacity: 0.7;
        transform: rotate(180deg);
    }
}

.chat-header h3 {
    font-family: var(--font-display);
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    position: relative;
    z-index: 2;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.status-indicator {
    width: 0.875rem;
    height: 0.875rem;
    background: var(--green-500);
    border-radius: var(--radius-full);
    position: relative;
    z-index: 2;
    border: 3px solid rgba(255,255,255,0.4);
    animation: statusPulse 2.5s ease-in-out infinite;
}

@keyframes statusPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.8);
    }
    50% {
        transform: scale(1.2);
        box-shadow: 0 0 0 10px rgba(34, 197, 94, 0);
    }
}

/* Messages Container - Enhanced */
.chat-messages {
    flex: 1;
    padding: var(--space-8);
    overflow-y: auto;
    background: var(--bg-secondary);
    scrollbar-width: thin;
    scrollbar-color: var(--border-secondary) transparent;
    scroll-behavior: smooth;
    position: relative;
}

.chat-messages::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(to bottom, var(--bg-secondary), transparent);
    pointer-events: none;
    z-index: 1;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
    border-radius: var(--radius-full);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: var(--radius-full);
    transition: var(--transition-fast);
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Message Layout - Perfect */
.message {
    margin-bottom: var(--space-8);
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    animation: messageSlideIn var(--transition-bounce);
    position: relative;
}

@keyframes messageSlideIn {
    0% {
        opacity: 0;
        transform: translateY(1.5rem) scale(0.9);
    }
    60% {
        opacity: 0.8;
        transform: translateY(-0.25rem) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-avatar {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: var(--shadow-lg);
    transition: var(--transition-normal);
    position: relative;
    z-index: 1;
}

.bot-message .message-avatar {
    background: var(--gradient-primary);
    color: white;
}

.bot-message .message-avatar::after {
    content: '';
    position: absolute;
    inset: -3px;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    z-index: -1;
    opacity: 0.3;
    animation: avatarGlow 3s ease-in-out infinite;
}

@keyframes avatarGlow {
    0%, 100% { 
        transform: scale(1); 
        opacity: 0.3; 
    }
    50% { 
        transform: scale(1.2); 
        opacity: 0.1; 
    }
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    background: var(--gradient-secondary);
    color: white;
}

.message-content {
    background: var(--bg-primary);
    padding: var(--space-5) var(--space-6);
    border-radius: var(--radius-2xl);
    font-size: 0.9375rem;
    line-height: 1.7;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-primary);
    max-width: calc(100% - 4rem);
    position: relative;
    transition: var(--transition-normal);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(145deg, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0.1) 100%);
    border-radius: var(--radius-2xl);
    pointer-events: none;
    opacity: 0;
    transition: var(--transition-fast);
}

.message-content:hover::before {
    opacity: 1;
}

.message-content:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-secondary);
    transform: translateY(-2px);
}

.user-message .message-content {
    background: var(--emerald-500);
    color: white;
    border-color: var(--emerald-500);
}

/* Quick Actions - Premium Pills */
.quick-actions {
    margin-top: var(--space-5);
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    justify-content: flex-start;
}

.quick-btn {
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-normal);
    color: var(--text-primary);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.quick-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(16, 185, 129, 0.2), transparent);
    transition: left 0.6s ease;
}

.quick-btn:hover::before {
    left: 100%;
}

.quick-btn:hover {
    background: var(--emerald-500);
    color: white;
    border-color: var(--emerald-500);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.quick-btn:active {
    transform: translateY(-1px);
}

/* Input Container - Modern Design */
.chat-input-container {
    padding: var(--space-8);
    background: var(--bg-primary);
    border-top: 1px solid var(--border-primary);
    display: flex;
    gap: var(--space-4);
    align-items: flex-end;
    min-height: 6rem;
    position: relative;
}

.chat-input-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--border-primary), transparent);
}

#chat-input {
    flex: 1;
    padding: var(--space-4) var(--space-6);
    border: 2px solid var(--border-primary);
    border-radius: var(--radius-2xl);
    outline: none;
    font-size: 0.9375rem;
    line-height: 1.6;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: var(--transition-normal);
    resize: none;
    min-height: 3.5rem;
    max-height: 10rem;
    font-family: inherit;
    scroll-behavior: smooth;
}

#chat-input:focus {
    border-color: var(--emerald-500);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.15);
    background: var(--bg-primary);
    transform: translateY(-2px);
}

#chat-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

#send-btn {
    background: var(--gradient-primary);
    color: white;
    border: none;
    padding: var(--space-4) var(--space-8);
    border-radius: var(--radius-2xl);
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    transition: var(--transition-normal);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 3.5rem;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

#send-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    transition: left 0.7s ease;
}

#send-btn:hover::before {
    left: 100%;
}

#send-btn:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl);
}

#send-btn:active {
    transform: translateY(-1px);
}

#send-btn:disabled {
    background: var(--border-secondary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

/* Typing Indicator - Enhanced */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-6);
    background: var(--bg-primary);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-primary);
}

.typing-dot {
    width: 0.625rem;
    height: 0.625rem;
    background: var(--emerald-500);
    border-radius: var(--radius-full);
    animation: typingDance 1.4s infinite ease-in-out;
}

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

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

@keyframes typingDance {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-1rem);
        opacity: 1;
    }
}

/* Perfect Responsive Design */

/* Extra Small Mobile (320px - 374px) */
@media (max-width: 374px) {
    .chat-toggle {
        width: 3.25rem;
        height: 3.25rem;
        bottom: var(--space-4);
        font-size: 1.125rem;
    }
    
    .chat-widget {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        transform: translate(0, 0) scale(0);
        top: 0;
        left: 0;
    }
    
    .chat-widget.active {
        transform: translate(0, 0) scale(1);
    }
    
    .chat-header {
        padding: var(--space-4) var(--space-5);
        padding-top: calc(var(--space-4) + env(safe-area-inset-top));
        min-height: 4rem;
    }
    
    .chat-header h3 {
        font-size: 1.125rem;
    }
    
    .chat-messages {
        padding: var(--space-4);
    }
    
    .message-avatar {
        width: 2.25rem;
        height: 2.25rem;
        font-size: 1rem;
    }
    
    .message-content {
        max-width: calc(100% - 3rem);
        padding: var(--space-3) var(--space-4);
        font-size: 0.8125rem;
    }
    
    .chat-input-container {
        padding: var(--space-4);
        padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
        min-height: 5rem;
    }
    
    #chat-input {
        padding: var(--space-3) var(--space-4);
        font-size: 1rem;
        min-height: 3rem;
    }
    
    #send-btn {
        padding: var(--space-3) var(--space-5);
        min-height: 3rem;
        font-size: 0.8125rem;
    }
}

/* Small Mobile (375px - 479px) */
@media (min-width: 375px) and (max-width: 479px) {
    .chat-toggle {
        width: 3.5rem;
        height: 3.5rem;
        bottom: var(--space-6);
        font-size: 1.25rem;
    }
    
    .chat-widget {
        position: fixed;
        inset: 0;
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
        transform: translate(0, 0) scale(0);
        top: 0;
        left: 0;
    }
    
    .chat-widget.active {
        transform: translate(0, 0) scale(1);
    }
    
    .chat-header {
        padding: var(--space-5) var(--space-6);
        padding-top: calc(var(--space-5) + env(safe-area-inset-top));
        min-height: 4.5rem;
    }
    
    .chat-header h3 {
        font-size: 1.25rem;
    }
    
    .chat-messages {
        padding: var(--space-5);
    }
    
    .message-avatar {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1.0625rem;
    }
    
    .message-content {
        max-width: calc(100% - 3.25rem);
        padding: var(--space-4) var(--space-5);
        font-size: 0.875rem;
    }
    
    .chat-input-container {
        padding: var(--space-5) var(--space-6);
        padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
        min-height: 5.5rem;
    }
    
    #chat-input {
        padding: var(--space-4) var(--space-5);
        font-size: 1rem;
        min-height: 3.25rem;
    }
    
    #send-btn {
        padding: var(--space-4) var(--space-6);
        min-height: 3.25rem;
        font-size: 0.875rem;
    }
}

/* Large Mobile (480px - 767px) */
@media (min-width: 480px) and (max-width: 767px) {
    .chat-widget {
        width: min(95vw, 28rem);
        height: min(90vh, 36rem);
        position: fixed;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%) scale(0);
        border-radius: var(--radius-2xl);
    }
    
    .chat-widget.active {
        transform: translate(-50%, -50%) scale(1);
    }
    
    .chat-toggle {
        bottom: var(--space-8);
    }
}

/* Tablet Portrait (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .chat-widget {
        width: min(26rem, 70vw);
        height: min(34rem, 80vh);
    }
    
    .chat-toggle {
        bottom: var(--space-10);
    }
}

/* Tablet Landscape & Small Desktop (1024px - 1279px) */
@media (min-width: 1024px) and (max-width: 1279px) {
    .chat-widget {
        width: min(28rem, 60vw);
        height: min(36rem, 75vh);
    }
    
    .chat-toggle {
        bottom: var(--space-12);
    }
}

/* Large Desktop (1280px - 1919px) */
@media (min-width: 1280px) and (max-width: 1919px) {
    .chat-widget {
        width: min(30rem, 50vw);
        height: min(38rem, 70vh);
    }
    
    .chat-messages {
        padding: var(--space-10);
    }
    
    .chat-input-container {
        padding: var(--space-10);
    }
}

/* Ultra-wide Desktop (1920px+) */
@media (min-width: 1920px) {
    .chat-widget {
        width: min(32rem, 40vw);
        height: min(42rem, 65vh);
    }
    
    .chat-messages {
        padding: var(--space-12);
    }
    
    .chat-input-container {
        padding: var(--space-12);
    }
}

/* Landscape Mobile Optimization */
@media (max-height: 480px) and (orientation: landscape) {
    .chat-widget {
        height: 95vh;
        width: min(32rem, 85vw);
    }
    
    .chat-header {
        padding: var(--space-3) var(--space-6);
        min-height: 3.5rem;
    }
    
    .chat-messages {
        padding: var(--space-4);
    }
    
    .chat-input-container {
        padding: var(--space-4) var(--space-6);
        min-height: 4.5rem;
    }
}

/* High Resolution Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .message-content,
    .quick-btn,
    #chat-input,
    #send-btn {
        border-width: 0.5px;
    }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .chat-toggle:hover {
        transform: translateX(-50%) scale(1.05);
    }
    
    .chat-widget.active {
        transform: translate(-50%, -50%) scale(1);
        animation: none;
    }
}

/* Focus Management */
.chat-widget:focus-within {
    outline: 3px solid var(--emerald-500);
    outline-offset: 4px;
}

.quick-btn:focus,
#send-btn:focus {
    outline: 2px solid var(--emerald-500);
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .chat-toggle,
    .chat-widget {
        display: none !important;
    }
}

/* Enhanced Loading States */
.loading {
    opacity: 0.7;
    pointer-events: none;
    filter: grayscale(30%) blur(0.5px);
}

/* Error & Success Message States */
.error-message .message-content {
    background: linear-gradient(145deg, #fef2f2, #fee2e2);
    border-color: #fecaca;
    color: var(--red-500);
}

.success-message .message-content {
    background: linear-gradient(145deg, #f0fdf4, #dcfce7);
    border-color: #bbf7d0;
    color: var(--green-500);
}

/* Glassmorphism Support */
@supports (backdrop-filter: blur(10px)) {
    .chat-widget {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }
    
    .chat-header {
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }
}

/* Container Queries for Future */
@supports (container-type: inline-size) {
    .chat-widget {
        container-type: inline-size;
    }
    
    @container (max-width: 320px) {
        .chat-input-container {
            flex-direction: column;
            gap: var(--space-2);
        }
        
        #send-btn {
            width: 100%;
            justify-content: center;
        }
    }
}

/* Safe Area Support for Notched Devices */
@supports (padding: max(0px)) {
    @media (max-width: 767px) {
        .chat-header {
            padding-top: max(var(--space-4), env(safe-area-inset-top));
        }
        
        .chat-input-container {
            padding-bottom: max(var(--space-4), env(safe-area-inset-bottom));
        }
    }
}

/* Perfect RTL Support */
[dir="rtl"] .chat-toggle {
    left: var(--space-8);
    right: auto;
    transform: translateX(50%);
}

[dir="rtl"] .chat-toggle:hover {
    transform: translateX(50%) translateY(-4px) scale(1.1);
}

[dir="rtl"] .chat-toggle.active {
    transform: translateX(50%) rotate(-45deg);
}

[dir="rtl"] .user-message {
    flex-direction: row;
}

[dir="rtl"] .bot-message {
    flex-direction: row-reverse;
}

/* Color Scheme Adaptation */
@media (prefers-color-scheme: light) {
    :root {
        color-scheme: light;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
    }
}

/* Contrast Preference Support */
@media (prefers-contrast: high) {
    :root {
        --border-primary: var(--slate-400);
        --border-secondary: var(--slate-500);
    }
    
    .message-content {
        border-width: 2px;
    }
    
    .quick-btn {
        border-width: 2px;
    }
}

/* Perfect Animation Performance */
.chat-toggle,
.chat-widget,
.message,
.message-avatar,
.message-content,
.quick-btn,
#send-btn {
    will-change: transform;
}

/* Smooth Scroll for All */
* {
    scroll-behavior: smooth;
}

/* Enhanced Accessibility */
@media (prefers-reduced-transparency: reduce) {
    .chat-widget,
    .chat-toggle {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}
