/* Chat Interface Styles - Main chat page (index.html) */

/* Day mode overrides for chat interface */
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, 0, 0, 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: #000000 !important;
  text-shadow: none !important;
}

body.day-mode .new-session-btn {
  background-color: #000000 !important;
  color: white !important;
  border: 2px solid #ffffff !important;
  text-shadow: none !important;
  box-shadow: none !important;
}

body.day-mode .new-session-btn:hover {
  background-color: #333333 !important;
  border-color: #ffffff !important;
  box-shadow: none !important;
  transform: none !important;
}

body.day-mode .theme-toggle-btn {
  background-color: #000000 !important;
  border-color: #ffffff !important;
  box-shadow: none !important;
}

body.day-mode .theme-toggle-btn:hover {
  background-color: #333333 !important;
  box-shadow: none !important;
}

body.day-mode .theme-icon {
  color: #ffffff !important;
  filter: none !important;
}

body.day-mode .theme-icon svg {
  fill: currentColor;
}

body.day-mode .language-btn {
  background-color: #000000 !important;
  color: #ffffff !important;
  border: 2px solid #ffffff !important;
}

body.day-mode .language-btn:hover {
  background-color: #333333 !important;
  color: #ffffff !important;
  border-color: #ffffff !important;
}

body.day-mode .language-btn.active {
  background-color: #444444 !important;
  color: #ffffff !important;
}

body.day-mode .language-btn svg {
  fill: currentColor;
  vertical-align: middle;
  margin-left: 4px;
}

/* Day mode styling for new chat modal */
body.day-mode .new-chat-modal-content {
  background: #ffffff !important;
  color: #000000 !important;
  border: 2px solid #000000 !important;
  box-shadow: 
    0 0 30px rgba(0, 0, 0, 0.1),
    0 8px 32px rgba(0, 0, 0, 0.2) !important;
}

body.day-mode .new-chat-modal-header h3 {
  color: #000000 !important;
}

body.day-mode .new-chat-modal-message {
  color: #000000 !important;
}

body.day-mode .new-chat-modal-btn.confirm {
  background-color: #000000 !important;
  color: #ffffff !important;
  border-color: #000000 !important;
}

body.day-mode .new-chat-modal-btn.confirm:hover {
  background-color: #333333 !important;
  border-color: #333333 !important;
  box-shadow: none !important;
  transform: translateY(-1px);
}

body.day-mode .new-chat-modal-btn.cancel {
  background-color: #000000 !important;
  color: #ffffff !important;
  border-color: #000000 !important;
}

body.day-mode .new-chat-modal-btn.cancel:hover {
  background-color: #333333 !important;
  border-color: #333333 !important;
  color: #ffffff !important;
}

body.day-mode .language-buttons .language-btn.selector-btn,
body.day-mode button.selector-btn,
body.day-mode .selector-btn,
body.day-mode [data-selector="true"] {
  background-color: #000000 !important;
  color: #ffffff !important;
  border: 2px solid #000000 !important;
  border-color: #000000 !important;
}

body.day-mode .language-buttons .language-btn.selector-btn:hover,
body.day-mode button.selector-btn:hover,
body.day-mode .selector-btn:hover,
body.day-mode button:contains("🌐"):hover,
body.day-mode [data-selector="true"]:hover {
  background-color: #333333 !important;
  color: #ffffff !important;
  border: 2px solid #000000 !important;
  border-color: #000000 !important;
}

body.day-mode .chat-input button {
  background-color: #000000 !important;
  color: #ffffff !important;
  border: 2px solid #ffffff !important;
}

body.day-mode .chat-input button:hover {
  background-color: #333333 !important;
  border-color: #ffffff !important;
}

/* Main body layout */
body {
  height: 100vh;
  height: 100dvh; /* Dynamic viewport height for iOS */
  display: flex;
  align-items: center;
  justify-content: center;
  direction: rtl;
  text-align: right;
  box-sizing: border-box;
  /* Night mode background overlay for better contrast */
  /* iOS safe area aware height */
  min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  min-height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}

.chat-container {
  width: 100%;
  max-width: 800px;
  height: 90vh;
  height: 90dvh; /* Dynamic viewport height for iOS */
  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;
  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: #1a1a1a;
  border-bottom: 1px solid #333;
  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 #ffffff;
  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: #ffffff;
  text-shadow: 0 0 10px #ffffff;
  margin: 0;
  flex: 1;
  text-align: center;
}

.new-session-btn {
  background-color: #000000;
  color: #ffffff;
  border: 2px solid #ffffff;
  border-radius: 5px;
  padding: 8px 12px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  z-index: 20;
  position: relative;
  text-shadow: none;
  box-shadow: none;
  /* Performance optimizations */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: background-color, border-color, box-shadow;
}

.new-session-btn:hover {
  background-color: #333333;
  border-color: #ffffff;
  box-shadow: none;
}

.new-session-btn:active {
  background-color: #444444;
  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: #000000;
  border: 2px solid #ffffff;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: none;
  /* Performance optimizations */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  will-change: box-shadow, transform;
}

.theme-toggle-btn:hover {
  background-color: #333333;
  transform: scale(1.1);
}

.theme-icon {
  font-size: 18px;
  color: #ffffff;
  filter: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* 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: #000000;
  color: #ffffff;
  border: 2px solid #ffffff;
  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: #333333;
  color: white;
  transform: translateY(-1px);
  box-shadow: none;
}

.language-btn.active {
  background-color: #444444;
  color: white;
  font-weight: 600;
}

.language-btn:active {
  transform: translateY(0);
}

.language-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  vertical-align: middle;
  margin-left: 4px;
}

/* Special styling for language selector button - consistent with other buttons */
.language-buttons .language-btn.selector-btn,
button.selector-btn,
.selector-btn,
[data-selector="true"] {
  background-color: #000000 !important;
  color: #ffffff !important;
  border: 2px solid #ffffff !important;
  border-color: #ffffff !important;
  font-weight: 400 !important;
  font-size: 14px !important; /* Adjusted font size for mixed content */
  padding: 6px 12px !important;
  min-width: 60px !important;
}

.language-buttons .language-btn.selector-btn:hover,
button.selector-btn:hover,
.selector-btn:hover,
[data-selector="true"]:hover {
  background-color: #333333 !important;
  color: #ffffff !important;
  border: 2px solid #ffffff !important;
  border-color: #ffffff !important;
}


.chat-messages {
  flex: 1;
  padding: 20px 20px 80px 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: auto;
  scrollbar-color: #000 #f5f5f5;
  height: calc(90vh - 130px);
  height: calc(90dvh - 130px); /* Dynamic viewport height for iOS */
  min-height: 300px;
  position: relative;
  display: block;
  background: white;
  /* Mobile touch optimizations */
  overscroll-behavior: contain;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  /* iOS safe area aware padding */
  padding-bottom: calc(80px + env(safe-area-inset-bottom));
}

/* 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: #000;
  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;
}

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;
}

/* LTR styling for system messages to match assistant messages */
body.dir-ltr .message.system,
html[dir="ltr"] .message.system {
  margin-left: auto;
  margin-right: 0;
  border-bottom-right-radius: 4px;
  border-bottom-left-radius: 16px;
  text-align: left; /* LTR alignment */
}

body.dir-ltr .chat-input button,
html[dir="ltr"] .chat-input button {
  margin-right: 15px; /* 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 textarea,
html[dir="ltr"] .chat-input textarea {
  order: 1; /* Textarea 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;
}

/* 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: normal; /* Stop converting \n to <br> */
  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.5; /* Tighter line height, was 1.8 */
}

.message.user {
  margin-left: auto; /* Right-aligned in RTL */
  margin-right: 0;
  background-color: transparent;
  color: #000;
  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: #000000;
  border-bottom-left-radius: 4px; /* Changed to left for RTL */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message.system {
  margin-right: auto; /* Left-aligned in RTL like assistant messages */
  margin-left: 0;
  background-color: #f1f1f1; /* Same as assistant messages */
  color: #000000; /* Complete black like other messages */
  font-size: 1rem; /* Same as regular messages */
  border-radius: 16px; /* Same as regular messages */
  border-bottom-left-radius: 4px; /* Same corner styling as assistant */
  max-width: 80%; /* Same as regular messages */
  text-align: right; /* RTL alignment like assistant messages */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); /* Same shadow as assistant */
}

.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 {
  margin: 0 0 8px; /* No top margin, small bottom margin */
}

.message pre, .message blockquote {
  margin-bottom: 8px;
}

/* Fix list styles broken by universal CSS reset */
.message ol {
  list-style-type: decimal; /* Ensure numbered lists show numbers */
}

.message ul {
  list-style-type: disc; /* Ensure bullet lists show bullets */
}

.message li {
  margin-bottom: 4px; /* Add spacing between list items */
}

/* 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; /* Keep pre-wrap only for streaming text */
}

.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: outside;
}

body.dir-ltr .message ul, 
body.dir-ltr .message ol {
  padding-left: 20px;
  padding-right: 0;
  list-style-position: outside;
}

@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;
  /* iOS safe area support */
  padding-bottom: calc(15px + env(safe-area-inset-bottom));
  min-height: calc(70px + env(safe-area-inset-bottom));
}

.chat-input textarea {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 20px;
  outline: none;
  font-size: 1rem;
  order: 1;
  /* Auto-expanding textarea specific styles */
  min-height: 48px;
  max-height: 72px !important; /* Stricter limit - about 3 lines */
  resize: none;
  overflow-y: hidden; /* Start with hidden, JS will control */
  line-height: 1.4;
  font-family: inherit;
  /* Ensure scrollbar styling matches design */
  scrollbar-width: thin;
  scrollbar-color: #ccc #f9f9f9;
  /* Force height constraints */
  box-sizing: border-box;
  /* Mobile input optimizations */
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  /* Smooth height transitions */
  transition: height 0.1s ease;
}

/* WebKit scrollbar styling for textarea */
.chat-input textarea::-webkit-scrollbar {
  width: 6px;
}

.chat-input textarea::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 3px;
}

.chat-input textarea::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.chat-input textarea::-webkit-scrollbar-thumb:hover {
  background: #bbb;
}

.chat-input textarea:focus {
  border-color: #0088ff;
}

.chat-input button {
  margin-left: 15px;
  margin-right: 15px;
  padding: 12px 24px;
  background-color: #000;
  color: white;
  border: 2px solid #ffffff;
  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: #333;
  border-color: #ffffff;
}

.chat-input button:disabled,
.chat-input textarea: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: 8px 12px;
  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;
  display: flex;
  align-items: center;
  justify-content: center;
}

.feedback-icon {
  width: 16px;
  height: 16px;
  filter: grayscale(100%) opacity(0.7);
  transition: filter 0.2s ease;
}

.feedback-button:hover {
  background-color: #f0f0f0;
  border-color: #0088ff;
  color: #0088ff;
}

.feedback-button:hover .feedback-icon {
  filter: grayscale(0%) opacity(1);
}

.feedback-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: #f5f5f5;
}

.feedback-button:disabled .feedback-icon {
  filter: grayscale(100%) opacity(0.3);
}

.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;
}

/* New Chat Confirmation Modal */
.new-chat-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: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.new-chat-modal.show {
  opacity: 1;
  visibility: visible;
}

.new-chat-modal-content {
  background: #1a1a1a !important;
  color: #ffffff !important;
  border-radius: 15px;
  padding: 30px;
  max-width: 400px;
  width: 90%;
  box-shadow: 
    0 0 30px rgba(0, 255, 255, 0.3),
    0 8px 32px rgba(0, 0, 0, 0.5);
  border: 2px solid #ffffff;
  text-align: center;
  position: relative;
  transform: scale(0.7);
  transition: transform 0.3s ease;
}

.new-chat-modal.show .new-chat-modal-content {
  transform: scale(1);
}

.new-chat-modal-header {
  margin-bottom: 20px;
}

.new-chat-modal-header h3 {
  color: #ffffff !important;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.new-chat-modal-message {
  margin-bottom: 25px;
  font-size: 1rem;
  line-height: 1.5;
  color: #ffffff !important;
}

.new-chat-modal-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
}

.new-chat-modal-btn {
  padding: 12px 24px;
  border: 2px solid;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  min-width: 100px;
  font-family: inherit;
}

.new-chat-modal-btn.confirm {
  background-color: #000000;
  color: #ffffff;
  border-color: #ffffff;
}

.new-chat-modal-btn.confirm:hover {
  background-color: #333333;
  border-color: #ffffff;
  transform: translateY(-1px);
  box-shadow: none;
}

.new-chat-modal-btn.cancel {
  background-color: #000000;
  color: #ffffff;
  border-color: #ffffff;
}

.new-chat-modal-btn.cancel:hover {
  background-color: #333333;
  border-color: #ffffff;
  color: #ffffff;
}

/* Hide mobile elements on desktop */
.mobile-header {
  display: none;
}

.burger-overlay {
  display: none;
}

/* Hide desktop elements on mobile */
.desktop-only {
  display: flex;
}

/* Copyright notice */
.copyright {
  display: flex; /* Show by default on all screens */
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 14px;
  color: #555;
  padding: 15px 20px;
  margin-top: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.15);
  background: rgba(255, 255, 255, 0.8);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  direction: ltr;
  backdrop-filter: blur(10px);
  font-weight: 500;
  width: 100%;
  box-sizing: border-box;
}

/* Legal links styling */
.legal-links {
  display: block; /* Show by default on all screens */
  font-size: 10px;
  text-align: center;
  margin-top: 4px;
  margin-bottom: 10px;
  opacity: 0.8;
  color: #666;
}

.legal-links a {
  color: inherit;
  text-decoration: none;
  transition: opacity 0.2s ease;
}

.legal-links a:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Enhanced mobile responsiveness */
@media (max-width: 768px) {
  /* Show mobile elements on mobile */
  .mobile-header {
    display: flex;
  }
  
  /* Show copyright and legal links on mobile */
  .copyright {
    display: flex;
    font-size: 13px;
    padding: 12px 15px;
    margin-top: 8px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    margin-bottom: env(safe-area-inset-bottom);
  }
  
  .legal-links {
    display: block;
  }
  
  html {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for iOS */
    height: -webkit-fill-available;
  }
  
  body {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for iOS */
    height: -webkit-fill-available;
    -webkit-overflow-scrolling: touch;
    /* Additional iOS safe area support */
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
  }
  
  .chat-container {
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for iOS */
    /* Account for safe areas on mobile */
    height: calc(100vh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
    height: calc(100dvh - env(safe-area-inset-top, 0) - env(safe-area-inset-bottom, 0));
    border-radius: 0;
    max-width: 100%;
    width: 100%;
    margin: 0;
    /* Remove backdrop filter on mobile for better performance */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    /* Solid background that works without blur */
    background: rgba(0, 0, 0, 0.95) !important;
    border: 2px solid transparent !important;
    /* Hardware acceleration for better mobile performance */
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    will-change: box-shadow, border-color !important;
  }
  
  /* Keep background image on mobile but optimize */
  body:not(.day-mode) {
    background-attachment: scroll !important;
    background-size: cover !important;
  }
  
  body:not(.day-mode)::before {
    background: rgba(0, 0, 0, 0.6) !important;
  }
  
  /* Enhanced glow effects on mobile */
  .new-session-btn {
    text-shadow: none !important;
    box-shadow: none !important;
  }
  
  .new-session-btn:hover {
    box-shadow: none !important;
  }
  
  .theme-toggle-btn {
    box-shadow: none !important;
  }
  
  .theme-toggle-btn:hover {
    box-shadow: none !important;
  }
  
  .chat-header h1 {
    text-shadow: 
      0 0 8px #ffffff !important,
      0 0 16px rgba(255, 255, 255, 0.5) !important;
  }
  
  .chat-header {
    position: relative;
    align-items: center;
    justify-content: center;
    padding: 12px 15px;
    min-height: 50px;
    /* Remove backdrop filter on mobile for performance */
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(0, 0, 0, 0.95) !important;
    /* Use drop-shadow instead of box-shadow for mobile glow */
    border-bottom: 2px solid #ffffff !important;
    filter: drop-shadow(0 2px 8px rgba(0, 255, 255, 0.4)) !important;
    /* Hardware acceleration */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }
  
  .chat-header h1 {
    font-size: 1rem;
    margin: 0;
    text-align: center;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 50%;
    z-index: 1;
  }
  
  .header-controls {
    display: none;
  }
  
  .language-buttons {
    display: none;
  }
  
  .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);
    height: calc(100dvh - 200px); /* Dynamic viewport height for iOS */
    /* Account for safe areas */
    height: calc(100vh - 200px - env(safe-area-inset-bottom, 0));
    height: calc(100dvh - 200px - env(safe-area-inset-bottom, 0));
    padding: 15px 12px 60px 12px;
    /* Additional bottom padding for safe area */
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0));
    -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;
    /* Account for iOS safe area at bottom */
    height: calc(80px + env(safe-area-inset-bottom, 0));
    min-height: calc(80px + env(safe-area-inset-bottom, 0));
    padding: 15px 12px;
    /* Additional bottom padding for safe area */
    padding-bottom: calc(15px + env(safe-area-inset-bottom, 0));
    gap: 12px;
    background-color: #f9f9f9;
    border-top: 2px solid #eee;
    /* iOS keyboard support */
    position: relative;
    /* Ensure input area stays above keyboard */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
  }
  
  .chat-input textarea {
    font-size: 16px; /* Prevent iOS zoom on focus */
    padding: 14px 18px;
    min-height: 50px;
    max-height: 60px !important; /* Even smaller max height on mobile */
    border-radius: 25px;
    /* iOS specific textarea fixes */
    -webkit-appearance: none;
    -webkit-border-radius: 25px;
    /* Prevent iOS keyboard from pushing content up */
    position: relative;
    z-index: 1000;
  }
  
  .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: 12px 16px;
    min-height: 44px;
    font-size: 0.9rem;
  }
  
  .feedback-icon {
    width: 18px;
    height: 18px;
  }
  
  .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;
  }
  
  /* Burger Menu Styles for Mobile */
  .mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    pointer-events: none;
  }
  
  .burger-menu-btn {
    pointer-events: all;
  }
  
  .language-toggle-container {
    pointer-events: all;
  }
  
  /* RTL: Swap order for right-to-left */
  .chat-header[dir="rtl"] .burger-menu-btn {
    order: 2 !important;
  }
  
  .chat-header[dir="rtl"] .language-toggle-container {
    order: 0 !important;
  }
  
  .burger-menu-btn {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    width: 32px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
  }
  
  .burger-line {
    width: 100%;
    height: 3px;
    background-color: #333;
    border-radius: 2px;
    transition: all 0.3s ease;
  }
  
  /* Night mode burger lines should be white */
  body:not(.day-mode) .burger-line {
    background-color: #ffffff;
  }
  
  .burger-line:nth-child(1) {
    transform-origin: top left;
  }
  
  .burger-line:nth-child(3) {
    transform-origin: bottom left;
  }
  
  .burger-menu-btn.active .burger-line:nth-child(1) {
    transform: rotate(45deg) translate(2px, -2px);
  }
  
  .burger-menu-btn.active .burger-line:nth-child(2) {
    opacity: 0;
    transform: translateX(-10px);
  }
  
  .burger-menu-btn.active .burger-line:nth-child(3) {
    transform: rotate(-45deg) translate(2px, 2px);
  }
  
  .language-toggle-container {
    display: flex;
    align-items: center;
  }
  
  .burger-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    display: none;
  }
  
  .burger-overlay.active {
    opacity: 1;
    visibility: visible;
    display: block;
  }
  
  .burger-menu {
    position: absolute;
    top: 0;
    width: 280px;
    height: 100%;
    background-color: #fff;
    transition: transform 0.3s ease;
    z-index: 10000;
    overflow-y: auto;
  }
  
  /* LTR: Slide from left */
  [dir="ltr"] .burger-menu {
    left: 0 !important;
    right: auto !important;
    box-shadow: 3px 0 15px rgba(0, 0, 0, 0.1);
    transform: translateX(-100%);
  }
  
  [dir="ltr"] .burger-overlay.active .burger-menu {
    transform: translateX(0) !important;
  }
  
  /* RTL: Slide from right */
  [dir="rtl"] .burger-menu {
    right: 0 !important;
    left: auto !important;
    box-shadow: -3px 0 15px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
  }
  
  [dir="rtl"] .burger-overlay.active .burger-menu {
    transform: translateX(0) !important;
  }
  
  .burger-menu-header {
    display: flex;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
  }
  
  /* LTR: Close button on right */
  [dir="ltr"] .burger-menu-header {
    justify-content: flex-end;
  }
  
  /* RTL: Close button on right (which is start in RTL) */
  [dir="rtl"] .burger-menu-header {
    justify-content: flex-start;
  }
  
  .close-burger-btn {
    background: transparent;
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
  }
  
  .close-burger-btn:hover {
    background-color: #f0f0f0;
  }
  
  .burger-menu-content {
    padding: 20px 0;
    display: block !important;
    width: 100%;
    visibility: visible;
    opacity: 1;
    background-color: transparent;
  }
  
  .burger-menu-item {
    display: flex !important;
    align-items: center;
    width: 100%;
    padding: 15px 20px;
    background: transparent;
    border: none;
    font-size: 16px;
    color: #333 !important;
    cursor: pointer;
    transition: background-color 0.2s ease;
    min-height: 50px;
    visibility: visible !important;
    opacity: 1 !important;
  }
  
  /* LTR menu items */
  [dir="ltr"] .burger-menu-item {
    text-align: left;
    justify-content: flex-start;
  }
  
  /* RTL menu items */
  [dir="rtl"] .burger-menu-item {
    text-align: right;
    justify-content: flex-end;
  }
  
  .burger-menu-item:hover {
    background-color: #f0f0f0;
  }
  
  .theme-toggle-mobile {
    gap: 12px;
    justify-content: space-between;
  }
  
  .theme-icon-mobile {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(45deg, #FFD700 50%, #4169E1 50%);
    transition: transform 0.3s ease;
    flex-shrink: 0;
    display: block !important;
    visibility: visible !important;
  }
  
  /* Theme toggle direction based on language */
  .theme-toggle-mobile {
    flex-direction: row;
  }
  
  .language-selector-mobile {
    flex-direction: column;
    align-items: stretch;
    padding-bottom: 10px;
  }
  
  .language-selector-mobile > span {
    font-weight: bold;
    margin-bottom: 15px;
    display: block;
  }
  
  /* LTR language selector */
  [dir="ltr"] .language-selector-mobile {
    align-items: flex-start;
  }
  
  [dir="ltr"] .language-selector-mobile > span {
    text-align: left;
  }
  
  /* RTL language selector */
  [dir="rtl"] .language-selector-mobile {
    align-items: flex-end;
  }
  
  [dir="rtl"] .language-selector-mobile > span {
    text-align: right;
  }
  
  .mobile-language-buttons {
    display: flex;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 0;
    margin-top: 10px;
  }
  
  /* Hide desktop elements on mobile */
  .desktop-only {
    display: none !important;
  }
  
  /* Mobile toggle button styles */
  .mobile-toggle-btn {
    padding: 8px 16px;
    background: #0088ff;
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
  }
  
  .mobile-toggle-btn:hover {
    background: #0066cc;
    transform: translateY(-1px);
  }

  /* Night mode styles for mobile toggle button */
  body:not(.day-mode) .mobile-toggle-btn {
    background: black;
    border: 1px solid white;
    color: white;
  }

  body:not(.day-mode) .mobile-toggle-btn:hover {
    background: #333;
    border: 1px solid white;
  }
  
  .mobile-lang-btn {
    padding: 8px 12px;
    background: #f0f0f0;
    color: #333 !important;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    text-align: center;
    display: block !important;
    visibility: visible !important;
  }
  
  .mobile-lang-btn:hover {
    background: #e0e0e0;
    border-color: #0088ff;
  }
}

/* Mobile Landscape Block - Show flip phone message */
@media (max-width: 1024px) and (max-height: 480px) and (orientation: landscape) {
  /* Hide all chat interface elements */
  .logo-header,
  .chat-header,
  .mobile-header,
  .chat-messages,
  .chat-input,
  .copyright,
  .legal-links,
  .burger-overlay {
    display: none !important;
  }
  
  /* Show landscape block message */
  .landscape-block {
    display: flex !important;
  }
}

/* Landscape Block Styling - Hidden by default */
.landscape-block {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 9999;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: white;
}

.landscape-message {
  max-width: 400px;
  padding: 40px 20px;
}

.phone-rotate-icon {
  font-size: 4rem;
  margin-bottom: 20px;
  animation: rotatePhone 2s ease-in-out infinite;
}

@keyframes rotatePhone {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(90deg); }
}

.landscape-message h2 {
  font-size: 2rem;
  margin: 0 0 16px 0;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.landscape-message p {
  font-size: 1.1rem;
  margin: 0;
  opacity: 0.9;
  line-height: 1.5;
}
