/* Neon glow animation - optimized for performance */
@keyframes neon-glow {
    0% {
        box-shadow: 
            0 0 10px #ff00de,
            0 0 20px #ff00de,
            0 0 30px #ff00de,
            0 0 40px #ff00de;
    }
    25% {
        box-shadow: 
            0 0 10px #00ffff,
            0 0 20px #00ffff,
            0 0 30px #00ffff,
            0 0 40px #00ffff;
    }
    50% {
        box-shadow: 
            0 0 10px #39ff14,
            0 0 20px #39ff14,
            0 0 30px #39ff14,
            0 0 40px #39ff14;
    }
    75% {
        box-shadow: 
            0 0 10px #ff00ff,
            0 0 20px #ff00ff,
            0 0 30px #ff00ff,
            0 0 40px #ff00ff;
    }
    100% {
        box-shadow: 
            0 0 10px #ff00de,
            0 0 20px #ff00de,
            0 0 30px #ff00de,
            0 0 40px #ff00de;
    }
}

/* Simplified mobile animation with proper glow */
@keyframes neon-glow-mobile {
    0%, 100% {
        border-color: #ff00de;
        box-shadow: 
            0 0 5px rgba(255, 0, 222, 0.4),
            0 0 10px rgba(255, 0, 222, 0.3),
            0 0 15px rgba(255, 0, 222, 0.2),
            0 4px 16px rgba(0, 0, 0, 0.6),
            inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    }
    50% {
        border-color: #00ffff;
        box-shadow: 
            0 0 5px rgba(0, 255, 255, 0.4),
            0 0 10px rgba(0, 255, 255, 0.3),
            0 0 15px rgba(0, 255, 255, 0.2),
            0 4px 16px rgba(0, 0, 0, 0.6),
            inset 0 0 0 1px rgba(255, 255, 255, 0.1);
    }
}

/* Mobile-first responsive optimizations - REMOVED (consolidated below) */

/* Reduced motion preference - disable animations for accessibility */
@media (prefers-reduced-motion: reduce) {
  .chat-container {
    animation: none !important;
    backdrop-filter: none !important;
  }
  
  .theme-toggle-btn:hover {
    transform: none !important;
  }
  
  .new-session-btn:active {
    transform: none !important;
  }
}

/* Day Mode - clean, bright theme */
body.day-mode {
  background: linear-gradient(135deg, #f0f4f8 0%, #e6f3ff 50%, #f0f4f8 100%) !important;
  color: #333 !important;
}

body.day-mode .chat-container {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(10px) !important;
  border: 1px solid rgba(0, 136, 255, 0.2) !important;
  animation: none !important;
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.1),
    0 0 0 1px rgba(0, 136, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
}

body.day-mode .chat-header {
  background: rgba(255, 255, 255, 0.9) !important;
  backdrop-filter: blur(20px) !important;
  border-bottom: 2px solid rgba(0, 136, 255, 0.3) !important;
  box-shadow: 0 2px 20px rgba(0, 136, 255, 0.1) !important;
  color: #333 !important;
  text-shadow: none !important;
}

body.day-mode .chat-header h1 {
  color: #0088ff !important;
  text-shadow: none !important;
}

body.day-mode .new-session-btn {
  background-color: #0088ff !important;
  color: white !important;
  border: 1px solid #0088ff !important;
  text-shadow: none !important;
  box-shadow: 0 2px 4px rgba(0, 136, 255, 0.2) !important;
}

body.day-mode .new-session-btn:hover {
  background-color: #0066cc !important;
  border-color: #0066cc !important;
  box-shadow: 0 4px 8px rgba(0, 136, 255, 0.3) !important;
  transform: none !important;
}

body.day-mode .theme-toggle-btn {
  border-color: #0088ff !important;
  box-shadow: 0 0 10px rgba(0, 136, 255, 0.2) !important;
}

body.day-mode .theme-toggle-btn:hover {
  box-shadow: 0 0 15px rgba(0, 136, 255, 0.3) !important;
}

body.day-mode .theme-icon {
  filter: none !important;
}

/* Classic mode - disable neon effects */
body.classic-mode {
  background: #f5f5f5 !important;
  color: #333 !important;
}

body.classic-mode .chat-container {
  background: white !important;
  backdrop-filter: none !important;
  border: none !important;
  animation: none !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
}

body.classic-mode .chat-header {
  background: white !important;
  backdrop-filter: none !important;
  border-bottom: 3px solid #0088ff !important;
  box-shadow: none !important;
  color: #333 !important;
  text-shadow: none !important;
}

body.classic-mode .chat-header h1 {
  color: #0088ff !important;
  text-shadow: none !important;
}

body.classic-mode .new-session-btn {
  background-color: #0088ff !important;
  color: white !important;
  border: 1px solid #0088ff !important;
  text-shadow: none !important;
  box-shadow: none !important;
}

/* Language selection modal styling */
.language-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white !important;
  color: #333 !important;
  border-radius: 15px;
  padding: 30px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 0 30px rgba(0, 255, 255, 0.3);
  border: 2px solid rgba(0, 255, 255, 0.2);
}

.modal-header {
  text-align: center;
  margin-bottom: 20px;
}

.modal-header h2 {
  color: #0088ff !important;
  margin-bottom: 10px;
  text-shadow: none;
}

.modal-header .country-flag {
  width: 48px;
  height: 36px;
}

.language-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.language-option {
  padding: 15px;
  border: 2px solid #e9ecef;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  font-weight: 500;
  background: white !important;
  color: #333 !important;
}

.language-option:hover {
  border-color: #0088ff;
  background: #f8f9fa !important;
  color: #333 !important;
}

.language-option.primary {
  border-color: #0088ff;
  background: #e3f2fd !important;
  color: #0066cc !important;
}

.close-modal {
  position: absolute;
  top: 15px;
  right: 15px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666 !important;
  padding: 5px;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-modal:hover {
  background: #f0f0f0;
  color: #333 !important;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'IRAN', 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
    Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

html, body {
  background-color: #000;
  color: #fff;
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  direction: rtl;
  text-align: right;
  transition: direction 0.3s ease, font-family 0.3s ease;
  /* Mobile optimizations */
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Night mode background with bg.jpeg */
body:not(.day-mode):not(.classic-mode) {
  background-image: url('/bg.jpeg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/* LTR language support */
body.dir-ltr, html[dir="ltr"] {
  direction: ltr;
  text-align: left;
}

body.dir-ltr .chat-container,
html[dir="ltr"] .chat-container {
  direction: ltr;
  text-align: left;
}

body.dir-ltr .message,
html[dir="ltr"] .message {
  direction: ltr;
  text-align: left;
}

body.dir-ltr .message.user,
html[dir="ltr"] .message.user {
  margin-right: auto;
  margin-left: 0;
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 16px;
}

body.dir-ltr .message.assistant,
html[dir="ltr"] .message.assistant {
  margin-left: auto;
  margin-right: 0;
  border-bottom-right-radius: 4px;
  border-bottom-left-radius: 16px;
}

body.dir-ltr .chat-input button,
html[dir="ltr"] .chat-input button {
  margin-right: 10px; /* Right margin for LTR - button on right side */
  margin-left: 0;
  order: 2; /* Button after input in LTR - appears on right */
}

body.dir-ltr .chat-input input,
html[dir="ltr"] .chat-input input {
  order: 1; /* Input before button in LTR */
}

body.dir-ltr .message-content,
html[dir="ltr"] .message-content {
  direction: ltr !important;
  text-align: left !important;
}

body.dir-ltr .message ul, .message ol,
html[dir="ltr"] .message ul, .message ol {
  padding-left: 20px;
  padding-right: 0;
}

/* Dynamic font support using CSS variables */
:root {
  --language-font: 'IRAN', 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Apply language font to body when language classes are present */
body[class*="lang-"] {
  font-family: var(--language-font, system-ui, -apple-system, sans-serif);
}

/* Ensure all text elements use the language font */
body[class*="lang-"] * {
  font-family: inherit;
}

body {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  direction: rtl;
  text-align: right;
  box-sizing: border-box;
  /* Night mode background overlay for better contrast */
}

body:not(.day-mode):not(.classic-mode)::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: -1;
  pointer-events: none;
}

.chat-container {
  width: 100%;
  max-width: 800px;
  height: 90vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border-radius: 15px;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  animation: neon-glow 5s infinite alternate;
  min-height: 500px;
  /* Mobile optimizations */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  /* Enhanced glass morphism effect for night mode */
  box-shadow: 
    0 8px 32px rgba(0, 0, 0, 0.5),
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.logo-header {
  padding: 12px 20px;
  background: white;
  border-bottom: 1px solid #e0e0e0;
  flex: 0 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

.logo {
  height: 40px;
  width: auto;
  max-width: 160px;
  object-fit: contain;
}

.chat-header {
  padding: 15px 20px;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #00ffff;
  border-bottom: 2px solid #00ffff;
  text-shadow: 0 0 5px #00ffff;
  flex: 0 0 auto;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
  min-height: 80px;
  /* Enhanced glass effect */
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1);
}

.chat-header h1 {
  font-size: 1.2rem;
  font-weight: 500;
  color: #00ffff;
  text-shadow: 0 0 10px #00ffff;
  margin: 0;
  flex: 1;
  text-align: center;
}

.new-session-btn {
  background-color: transparent;
  color: #ff00de;
  border: 2px solid #ff00de;
  border-radius: 5px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 20;
  position: relative;
  text-shadow: 0 0 5px #ff00de;
  box-shadow: 0 0 10px rgba(255, 0, 222, 0.3);
  /* Performance optimizations */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: background-color, border-color, box-shadow;
}

.new-session-btn:hover {
  background-color: rgba(255, 0, 222, 0.1);
  border-color: #ff00de;
  box-shadow: 0 0 20px rgba(255, 0, 222, 0.5);
}

.new-session-btn:active {
  background-color: rgba(255, 0, 222, 0.2);
  transform: scale(0.95);
}

/* Header controls container */
.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Theme toggle button */
.theme-toggle-btn {
  background: transparent;
  border: 2px solid #00ffff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
  /* Performance optimizations */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: box-shadow, transform;
}

.theme-toggle-btn:hover {
  box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
  transform: scale(1.1);
}

.theme-icon {
  font-size: 18px;
  filter: drop-shadow(0 0 3px #00ffff);
}

/* Language buttons styling */
.language-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  order: -1; /* Force to appear first in flex layout */
  flex-shrink: 0;
  max-width: calc(50% - 40px); /* Prevent overlap with title */
}

.language-btn {
  background-color: white;
  color: #0088ff;
  border: 2px solid #0088ff;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
  min-width: 60px;
  text-align: center;
}

.language-btn:hover {
  background-color: #0088ff;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 136, 255, 0.3);
}

.language-btn.active {
  background-color: #0088ff;
  color: white;
  font-weight: 600;
}

.language-btn:active {
  transform: translateY(0);
}

/* Special styling for language selector button */
.language-btn.selector-btn {
  background-color: #f8f9fa;
  color: #6c757d;
  border-color: #6c757d;
  font-weight: 400;
  font-size: 16px; /* Larger font for icon */
  padding: 6px 10px;
  min-width: 40px;
}

.language-btn.selector-btn:hover {
  background-color: #6c757d;
  color: white;
  border-color: #6c757d;
}


.chat-messages {
  flex: 1;
  padding: 20px 20px 80px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: auto;
  scrollbar-color: #0088ff #f5f5f5;
  height: calc(90vh - 130px);
  min-height: 300px;
  position: relative;
  display: block;
  background: white;
  /* Mobile touch optimizations */
  overscroll-behavior: contain;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* WebKit (Chrome, Safari, etc.) scrollbar styling */
.chat-messages::-webkit-scrollbar {
  width: 14px; /* Increased width for better usability */
  background-color: #f5f5f5;
  height: auto;
}

/* Force reflow class for scrollbar recalculation */
.chat-messages.force-reflow {
  opacity: 0.99; /* Almost imperceptible change to force reflow */
}

.chat-messages::-webkit-scrollbar-track {
  background: #f5f5f5;
  border-radius: 10px;
  border: 1px solid #e0e0e0;
  margin: 5px 0; /* Add some margin */
}

.chat-messages::-webkit-scrollbar-thumb {
  background-color: #0088ff;
  border-radius: 10px;
  border: 2px solid #f5f5f5;
  min-height: 60px; /* Increased min-height */
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.2); /* Add shadow for depth */
}

/* Ensure scrolling works properly */
.chat-container {
  overflow: hidden; /* Prevent double scrollbars */
}

.message {
  max-width: 80%;
  padding: 10px 15px;
  border-radius: 16px;
  word-break: break-word;
  margin-bottom: 10px;
}

/* Default RTL styling (Persian) */
body:not(.dir-ltr) .message {
  direction: rtl;
  text-align: right;
}

/* LTR styling for LTR languages */
body.dir-ltr .message {
  direction: ltr;
  text-align: left;
}

/* Ensure the last message has extra bottom margin */
.message:last-child, .message.last-message {
  margin-bottom: 30px; /* Extra margin for the last message */
  padding-bottom: 15px; /* Extra padding at bottom */
}

.message-content {
  width: 100%;
  min-height: 1em; /* Ensure even empty messages have height */
  overflow-wrap: break-word;
  overflow: visible; /* Ensure content isn't cut off and doesn't create nested scrollbars */
  padding-bottom: 3px; /* Add a little extra space at the bottom */
  white-space: pre-line; /* Changed to pre-line for better line breaks */
  unicode-bidi: embed; /* Using 'embed' instead of 'bidi-override' for better compatibility */
  display: block; /* Force block display */
  /* Direction and alignment will be set by language classes */
  line-height: 1.8; /* Consistent line height */
}

.message.user {
  margin-left: auto; /* Right-aligned in RTL */
  margin-right: 0;
  background-color: #0088ff;
  color: white;
  border-bottom-right-radius: 4px; /* Changed to right for RTL */
}

.message.assistant {
  margin-right: auto; /* Left-aligned in RTL */
  margin-left: 0;
  background-color: #f1f1f1;
  color: #333;
  border-bottom-left-radius: 4px; /* Changed to left for RTL */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message.system {
  align-self: center;
  background-color: #ffecb3;
  color: #5d4037;
  font-size: 0.9rem;
  border-radius: 8px;
  max-width: 90%;
  text-align: center;
}

.message.typing .message-content {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  min-height: 20px;
}

/* Typing indicator content will be set dynamically by JavaScript */

/* Support for markdown content */
.message p, .message ul, .message ol, .message pre, .message blockquote {
  margin-bottom: 8px;
}

/* RTL markdown content */
body:not(.dir-ltr) .message p, 
body:not(.dir-ltr) .message ul, 
body:not(.dir-ltr) .message ol, 
body:not(.dir-ltr) .message pre, 
body:not(.dir-ltr) .message blockquote {
  direction: rtl;
  text-align: right;
}

/* LTR markdown content */
body.dir-ltr .message p, 
body.dir-ltr .message ul, 
body.dir-ltr .message ol, 
body.dir-ltr .message pre, 
body.dir-ltr .message blockquote {
  direction: ltr;
  text-align: left;
}

.message p:last-child, .message ul:last-child, 
.message ol:last-child, .message pre:last-child, 
.message blockquote:last-child {
  margin-bottom: 0;
}

/* Message elements will inherit direction from body/container */
.message *, 
.message p,
.message div,
.message span {
  unicode-bidi: embed;
}

/* Message content direction based on language */
body:not(.dir-ltr) .message-content {
  direction: rtl;
  text-align: right;
}

body.dir-ltr .message-content {
  direction: ltr;
  text-align: left;
}

/* Special styles for streaming content */
.message-content[data-streaming="true"] {
  /* Direction inherited from language classes */
  white-space: pre-wrap;
}

.message code {
  background-color: rgba(0, 0, 0, 0.1);
  padding: 2px 4px;
  border-radius: 3px;
  font-family: 'Courier New', monospace;
}

.message pre {
  background-color: rgba(0, 0, 0, 0.05);
  padding: 8px;
  border-radius: 5px;
  overflow-x: auto;
}

.message pre code {
  background-color: transparent;
  padding: 0;
}

.message a {
  color: #0066cc;
  text-decoration: none;
}

.message a:hover {
  text-decoration: underline;
}

/* List padding based on direction */
body:not(.dir-ltr) .message ul, 
body:not(.dir-ltr) .message ol {
  padding-right: 20px;
  padding-left: 0;
  list-style-position: inside;
}

body.dir-ltr .message ul, 
body.dir-ltr .message ol {
  padding-left: 20px;
  padding-right: 0;
  list-style-position: inside;
}

@keyframes typing {
  0% { opacity: 0.2; }
  50% { opacity: 1; }
  100% { opacity: 0.2; }
}

.chat-input {
  display: flex;
  padding: 15px;
  background-color: #f9f9f9;
  border-top: 1px solid #eee;
  height: 70px;
  min-height: 70px;
  flex: 0 0 auto;
  width: 100%;
  position: relative;
  z-index: 10;
  box-sizing: border-box;
  align-items: center;
  /* Mobile input optimizations */
  -webkit-tap-highlight-color: transparent;
}

.chat-input input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 20px;
  outline: none;
  font-size: 1rem;
  order: 1;
  /* Mobile input optimizations */
  min-height: 48px;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

.chat-input input:focus {
  border-color: #0088ff;
}

.chat-input button {
  margin-left: 10px;
  padding: 12px 24px;
  background-color: #0088ff;
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s;
  order: 2;
  /* Mobile touch target optimization */
  min-height: 48px;
  min-width: 48px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.chat-input button:hover {
  background-color: #0066cc;
}

.chat-input button:disabled,
.chat-input input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Feedback System Styles */
.feedback-container {
  margin-top: 8px;
  padding: 8px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  direction: rtl;
}

.feedback-button {
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 12px;
  background-color: white;
  color: #666;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.feedback-button:hover {
  background-color: #f0f0f0;
  border-color: #0088ff;
  color: #0088ff;
}

.feedback-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #f5f5f5;
}

.feedback-text-container {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  align-items: center;
  direction: rtl;
}

.feedback-text-input {
  flex: 1;
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.8rem;
  direction: rtl;
  text-align: right;
  font-family: inherit;
}

.feedback-text-input:focus {
  outline: none;
  border-color: #0088ff;
}

.feedback-text-submit {
  padding: 4px 12px;
  border: 1px solid #0088ff;
  border-radius: 8px;
  background-color: #0088ff;
  color: white;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.feedback-text-submit:hover {
  background-color: #0066cc;
}

.feedback-text-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.feedback-confirmation {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
  border-radius: 8px;
  padding: 6px 10px;
  margin-top: 8px;
  font-size: 0.85rem;
  text-align: center;
  direction: rtl;
}

.feedback-error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
  border-radius: 8px;
  padding: 6px 10px;
  margin-top: 8px;
  font-size: 0.85rem;
  text-align: center;
  direction: rtl;
}

/* Only show feedback on assistant messages */
.message.user .feedback-container {
  display: none;
}

/* Ensure feedback container respects RTL layout */
.feedback-container * {
  direction: rtl;
  text-align: right;
}

/* Enhanced mobile responsiveness */
@media (max-width: 768px) {
  html {
    height: 100vh;
    height: -webkit-fill-available;
  }
  
  body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100vh;
    height: -webkit-fill-available;
    -webkit-overflow-scrolling: touch;
  }
  
  .chat-container {
    height: 100vh;
    border-radius: 0;
    max-width: 100%;
    width: 100%;
    margin: 0;
    animation: neon-glow-mobile 3s infinite ease-in-out !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(0, 0, 0, 0.9) !important;
    border: 2px solid transparent !important;
    will-change: border-color, box-shadow !important;
  }
  
  /* Keep background image on mobile but optimize */
  body:not(.day-mode):not(.classic-mode) {
    background-attachment: scroll !important;
    background-size: cover !important;
  }
  
  body:not(.day-mode):not(.classic-mode)::before {
    background: rgba(0, 0, 0, 0.6) !important;
  }
  
  /* Restore some glow effects on mobile */
  .new-session-btn {
    text-shadow: 0 0 3px #ff00de !important;
    box-shadow: 0 2px 8px rgba(255, 0, 222, 0.3) !important;
  }
  
  .theme-toggle-btn {
    box-shadow: 0 0 8px rgba(0, 255, 255, 0.3) !important;
  }
  
  .chat-header h1 {
    text-shadow: 0 0 5px #00ffff !important;
  }
  
  .chat-header {
    flex-direction: column;
    align-items: center;
    padding: 12px 15px;
    min-height: auto;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(0, 0, 0, 0.9) !important;
    box-shadow: none !important;
  }
  
  .chat-header h1 {
    font-size: 1.1rem;
    margin: 8px 0;
    text-align: center;
  }
  
  .header-controls {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
  }
  
  .language-buttons {
    width: 100%;
    justify-content: center;
    margin-bottom: 8px;
    flex-wrap: wrap;
  }
  
  .language-btn {
    font-size: 12px;
    padding: 8px 12px;
    min-width: 60px;
    min-height: 36px;
    margin: 2px;
  }
  
  .theme-toggle-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  
  .new-session-btn {
    padding: 10px 16px;
    font-size: 14px;
    min-height: 44px;
  }
  
  .chat-messages {
    height: calc(100vh - 200px);
    padding: 15px 12px 60px 12px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  
  .message {
    max-width: 85%;
    padding: 12px 16px;
    margin-bottom: 12px;
    font-size: 0.95rem;
    line-height: 1.6;
  }
  
  .message:last-child {
    margin-bottom: 40px;
  }
  
  .chat-input {
    height: 80px;
    min-height: 80px;
    padding: 15px 12px;
    gap: 12px;
    background-color: #f9f9f9;
    border-top: 2px solid #eee;
  }
  
  .chat-input input {
    font-size: 16px;
    padding: 14px 18px;
    min-height: 50px;
    border-radius: 25px;
  }
  
  .chat-input button {
    padding: 14px 20px;
    min-height: 50px;
    min-width: 80px;
    border-radius: 25px;
    font-size: 14px;
    margin-left: 0;
  }
  
  .feedback-container {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 12px;
  }
  
  .feedback-button {
    padding: 10px 12px;
    min-height: 40px;
    font-size: 0.9rem;
  }
  
  .feedback-text-container {
    flex-direction: column;
    gap: 8px;
  }
  
  .feedback-text-input {
    width: 100%;
    padding: 10px 12px;
    min-height: 40px;
    font-size: 0.9rem;
  }
  
  .feedback-text-submit {
    padding: 10px 16px;
    min-height: 40px;
    font-size: 0.9rem;
  }
}

/* Tablet landscape adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
  .chat-container {
    max-width: 90%;
    height: 85vh;
  }
  
  .message {
    max-width: 75%;
  }
}

/* Large mobile phones */
@media (max-width: 480px) {
  .chat-header h1 {
    font-size: 1rem;
  }
  
  .language-btn {
    font-size: 11px;
    padding: 6px 10px;
    min-width: 50px;
  }
  
  .chat-messages {
    padding: 12px 10px 50px 10px;
  }
  
  .message {
    max-width: 90%;
    padding: 10px 14px;
    font-size: 0.9rem;
  }
}