/* Enhanced AI Chat with Perfect Contextual Responses */
:root {
    --bg-dark: #111827;
    --bg-darker: #0f172a;
    --bg-card: #1f2937;
    --bg-message-user: #2563eb;
    --bg-message-ai: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #9ca3af;
    --border-color: #4b5563;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --accent-red: #ef4444;
}

/* Base styling with dark theme */
body {
    background-color: var(--bg-darker);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

/* Enhanced message styling with perfect contrast */
.user-message {
    background: linear-gradient(135deg, var(--bg-message-user) 0%, #1d4ed8 100%);
    color: #ffffff;
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.ai-message {
    background-color: var(--bg-message-ai);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
}

.message-text {
    word-wrap: break-word;
    line-height: 1.5;
    font-weight: 500;
    color: inherit;
}

/* Form input enhancements for dark theme */
input, textarea {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

input:focus, textarea:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Button styling with proper contrast */
button {
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

.bg-blue-600 {
    background-color: var(--accent-blue);
    color: #ffffff;
}

.bg-blue-600:hover:not(:disabled) {
    background-color: #2563eb;
}

.bg-gray-600 {
    background-color: #4b5563;
    color: var(--text-primary);
}

.bg-gray-600:hover:not(:disabled) {
    background-color: #374151;
}

/* Status indicator colors */
.text-green-400 {
    color: var(--accent-green);
}

.text-yellow-400 {
    color: var(--accent-yellow);
}

.text-red-400 {
    color: var(--accent-red);
}

/* Timestamp styling */
.opacity-75 {
    opacity: 0.75;
}

.user-message .opacity-75 {
    color: rgba(255, 255, 255, 0.8);
}

.ai-message .opacity-75 {
    color: var(--text-muted);
}

/* Enhanced typing indicator */
.animate-bounce {
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translateY(0);
    }
    40%, 43% {
        transform: translateY(-8px);
    }
    70% {
        transform: translateY(-4px);
    }
    90% {
        transform: translateY(-2px);
    }
}

/* Message bubble animations */
.message-bubble {
    animation: messageSlideIn 0.3s ease-out;
    transform-origin: bottom;
}

.user-message {
    animation: messageSlideInRight 0.3s ease-out;
}

.ai-message {
    animation: messageSlideInLeft 0.3s ease-out;
}

@keyframes messageSlideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes messageSlideInRight {
    from {
        opacity: 0;
        transform: translateX(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Smooth scrolling for messages */
.overflow-y-auto {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) var(--bg-card);
}

.overflow-y-auto::-webkit-scrollbar {
    width: 6px;
}

.overflow-y-auto::-webkit-scrollbar-track {
    background: var(--bg-card);
}

.overflow-y-auto::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Connection status indicators */
.connection-connected {
    color: var(--accent-green);
    text-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}

.connection-trying {
    color: var(--accent-yellow);
    animation: pulse 2s infinite;
}

.connection-error {
    color: var(--accent-red);
}

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

/* Enhanced setup modal for dark theme */
.fixed.inset-0 {
    backdrop-filter: blur(6px);
}

/* Progress bar animation */
.w-1\/4.h-2 {
    transition: all 0.4s ease-in-out;
}

/* Focus states for better accessibility */
input:focus, textarea:focus, button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* Button hover effects */
button:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

button:active:not(:disabled) {
    transform: translateY(0);
}

/* Enhanced avatar styling */
.w-8.h-8.rounded-full {
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.2s ease-in-out;
}

.w-8.h-8.rounded-full:hover {
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

/* Message timestamp styling */
.message-bubble:hover .text-xs.opacity-75 {
    opacity: 1;
}

/* Model success indicator (subtle) */
.model-success {
    border-left: 3px solid var(--accent-green);
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.1), transparent);
}

/* Enhanced responsive design */
@media (max-width: 768px) {
    .w-80 {
        width: 100%;
        position: fixed;
        z-index: 20;
        height: 100%;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }
    
    .sidebar-open {
        transform: translateX(0);
    }
    
    .max-w-xs {
        max-width: 85%;
    }
    
    .lg\:max-w-md {
        max-width: 85%;
    }
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    .animate-bounce, .message-bubble, button {
        animation: none;
    }
    
    .transition-colors, .transition-all {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .user-message {
        background: #0000ff;
        color: #ffffff;
        border: 2px solid #ffffff;
    }
    
    .ai-message {
        background: #ffffff;
        color: #000000;
        border: 2px solid #000000;
    }
    
    input, textarea {
        border: 2px solid #ffffff;
        background: var(--bg-darker);
        color: #ffffff;
    }
}

/* Advanced contextual response indicators */
.contextual-response {
    position: relative;
}

.contextual-response::before {
    content: "💡";
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 12px;
    background: var(--accent-green);
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Filter bypass visual feedback */
.bypass-successful {
    border-left: 3px solid var(--accent-green);
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.1), transparent);
}

.bypass-retrying {
    border-left: 3px solid var(--accent-yellow);
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.1), transparent);
    animation: pulseAmber 2s infinite;
}

@keyframes pulseAmber {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.8;
    }
}

/* Enhanced friend color classes */
.bg-pink-500 {
    background-color: #ec4899;
}

.bg-purple-500 {
    background-color: #8b5cf6;
}

.bg-red-500 {
    background-color: #ef4444;
}

.bg-green-500 {
    background-color: #10b981;
}

.bg-blue-500 {
    background-color: #3b82f6;
}

/* Text size adjustments for better readability */
.text-xs {
    font-size: 0.75rem;
    line-height: 1rem;
}

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

/* Enhanced spacing for chat messages */
.space-y-4 > * + * {
    margin-top: 1rem;
}

/* Better visual hierarchy */
.font-bold {
    font-weight: 700;
}

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

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

/* Ensure all interactive elements are accessible */
button, input, textarea {
    min-height: 44px;
}

/* Enhanced border styles */
.border-gray-600 {
    border-color: var(--border-color);
}

.border-gray-700 {
    border-color: #374151;
}

/* Background color overrides for dark theme */
.bg-gray-700 {
    background-color: var(--bg-message-ai);
}

.bg-gray-800 {
    background-color: var(--bg-card);
}

.bg-gray-900 {
    background-color: var(--bg-dark);
}

/* Text color adjustments */
.text-white {
    color: var(--text-primary);
}

.text-gray-100 {
    color: var(--text-primary);
}

.text-gray-200 {
    color: var(--text-secondary);
}

.text-gray-300 {
    color: var(--text-secondary);
}

.text-gray-400 {
    color: var(--text-muted);
}

/* Final enhancement: Ensure message text is always readable */
.message-text {
    text-shadow: none;
    font-weight: 500;
    line-height: 1.4;
}

/* Special styling for user input display */
.user-message .message-text {
    font-weight: 600;
    color: #ffffff;
}

.ai-message .message-text {
    font-weight: 500;
    color: var(--text-primary);
}