/* ===== Your existing CSS Variables & Reset ===== */
:root {
  --color-primary: #6200ee;
  --color-primary-dark: #3700b3;
  --color-accent: #03dac6;
  --color-bg: #f0f2f5;
  --color-header: #333;
  --color-footer-bg: #eee;
  --color-footer-text: #555;
  --color-text: #222;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.highlighted-word {
  background: yellow;
  padding: 2px;
  border-radius: 3px;
}

/* ===== Header and Footer ===== */
header {
  background: var(--color-header);
  color: #fff;
  padding: 10px 20px;
}

footer {
  background: var(--color-footer-bg);
  color: var(--color-footer-text);
  padding: 10px 20px;
  text-align: center;
  font-size: 0.85rem;
}

/* ===== Navigation ===== */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: #fff;
}

.logo-link img {
  height: 40px;
  width: auto;
}

.logo-link h1 {
  font-size: 1.4rem;
  margin: 0;
}

nav a:not(.logo-link) {
  text-decoration: none;
  background-color: var(--color-primary);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

nav a:not(.logo-link):hover {
  background-color: var(--color-primary-dark);
  transform: translateY(-2px);
}

nav a:not(.logo-link):active {
  background-color: var(--color-accent);
  transform: translateY(0);
}

nav a:not(.logo-link):focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

nav a:not(.logo-link) + a:not(.logo-link) {
  margin-left: 0.5rem;
}

/* Editor and Preview Styles */
#editor,
#preview {
  flex: 1;
  /* equal width side by side */
  padding: 20px;
  font-size: 18px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  background: white;
  border: none;
  overflow-y: auto;
  resize: none;
}

#preview {
  white-space: normal;
}

#preview code {
  background: #eee;
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
}

#preview pre {
  background: #eee;
  padding: 10px;
  border-radius: 4px;
  overflow-x: auto;
}

#editorInfo {
  display: flex;
  justify-content: space-between;
  padding: 30px;
  color: var(--color-text);
  border-radius: 8px;
  margin-top: 20px;
}

/* Modal styles */
/* تأكد إن الـ main يحتل المساحة كلها */
main {
  flex: 1;
  display: flex;
  flex-direction: row;
  /* side by side */
  align-items: stretch;
  /* make them stretch vertically */
  gap: 20px;
  padding: 20px;
  background: var(--color-bg);
}

/* ===== Camera Screen Layout ===== */
main.camera-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--color-bg);
  padding: 20px;
  gap: 20px;
}

/* Video feed styling */
#localVideo,
#streamVideo {
  width: 100%;
  max-width: 600px;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  object-fit: cover;
}

/* Flip camera button */
#flipCamera {
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  background: var(--color-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: background-color 0.3s ease, transform 0.2s ease;
}

#flipCamera:hover {
  background: var(--color-primary-dark);
  transform: translateY(-2px);
}

#flipCamera:active {
  background: var(--color-accent);
  transform: translateY(0);
}

#flipCamera:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ===== Responsive adjustments ===== */
@media (max-width: 768px) {
  nav {
    flex-direction: column;
  }
  nav a:not(.logo-link) {
    width: 100%;
    text-align: center;
  }
  main.camera-screen {
    padding: 10px;
  }
  #localVideo,
  #streamVideo {
    max-width: 100%;
    border-radius: 8px;
  }
  #flipCamera {
    width: 100%;
    padding: 14px;
  }
  #aiChatContent {
    width: 95vw;
    height: 85vh;
    padding: 12px 16px;
  }
  #aiChatInput {
    height: 80px;
    font-size: 16px;
    padding: 12px 14px;
  }
  #aiChatSendBtn {
    padding: 12px 20px;
    font-size: 1rem;
  }
}

/* Camera orientation specific */
@media (orientation: portrait) {
  #localVideo,
  #streamVideo {
    aspect-ratio: 9 / 16;
  }
}

@media (orientation: landscape) {
  #localVideo,
  #streamVideo {
    aspect-ratio: 16 / 9;
  }
}

/* ===== AI Chat - Fullscreen & Input fixed bottom overrides ===== */
/* #aiChatContent {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  width: 100vw !important;
  height: 100vh !important;
  background: #fff !important;
  padding: 16px 24px 80px 24px !important; /* leave bottom padding for input */
  box-sizing: border-box !important;
  display: flex !important;
  flex-direction: column !important;
  color: #222 !important;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif !important;
  overflow: hidden !important;
  border-radius: 0 !important; /* remove rounded corners */
  box-shadow: none !important; /* remove shadow */
  z-index: 9999 !important; /* above other content */
}

#aiChatContent > h2 {
  margin-bottom: 16px !important;
  font-size: 1.9rem !important;
  font-weight: 700 !important;
  color: var(--color-primary-dark) !important;
  text-align: center !important;
  user-select: none !important;
  flex-shrink: 0 !important;
}

/* Messages area takes all vertical space above input */
#aiChatResponse {
  flex: 1 !important;
  overflow-y: auto !important;
  background: #fefefe !important;
  border: none !important;
  border-radius: 0 !important;
  padding: 12px 8px !important;
  white-space: pre-wrap !important;
  font-size: 18px !important;
  line-height: 1.5 !important;
  direction: rtl !important;
  text-align: right !important;
  unicode-bidi: isolate !important;
  box-shadow: none !important;
  scroll-behavior: smooth !important;
  margin-bottom: 12px !important;
}

/* Message bubbles */
#aiChatResponse .message {
  max-width: 80% !important;
  margin-bottom: 12px !important;
  padding: 12px 16px !important;
  border-radius: 20px !important;
  display: inline-block !important;
  word-break: break-word !important;
  animation: fadeInUp 0.3s ease forwards !important;
}

#aiChatResponse .message.ai {
  background: #e4e6eb !important;
  color: #222 !important;
  border-bottom-left-radius: 4px !important;
  direction: rtl !important;
  text-align: right !important;
  float: left !important;
  clear: both !important;
}

#aiChatResponse .message.user {
  background: var(--color-primary) !important;
  color: white !important;
  border-bottom-right-radius: 4px !important;
  direction: rtl !important;
  text-align: right !important;
  float: right !important;
  clear: both !important;
}

#aiChatResponse::after {
  content: "" !important;
  display: block !important;
  clear: both !important;
}

/* Input fixed at bottom */
#aiChatInput {
  position: fixed !important;
  bottom: 16px !important;
  left: 24px !important;
  right: 24px !important;
  width: calc(100vw - 96px) !important;
  height: 90px !important;
  font-size: 18px !important;
  resize: none !important;
  padding: 16px 20px !important;
  border-radius: 16px !important;
  border: 1px solid #ccc !important;
  box-sizing: border-box !important;
  direction: rtl !important;
  text-align: right !important;
  font-family: inherit !important;
  background: #fff !important;
  z-index: 10000 !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
  transition: border-color 0.3s ease !important;
}

#aiChatInput:focus {
  border-color: var(--color-primary) !important;
  outline: none !important;
}

/* Buttons container fixed bottom right */
#aiChatButtons {
  position: fixed !important;
  bottom: 28px !important;
  right: 40px !important;
  z-index: 10001 !important;
  text-align: right !important;
} */

/* Send button styling */
/* #aiChatSendBtn {
  background: var(--color-primary) !important;
  border: none !important;
  border-radius: 16px !important;
  padding: 16px 32px !important;
  font-size: 1.1rem !important;
  font-weight: 600 !important;
  color: white !important;
  cursor: pointer !important;
  box-shadow: 0 4px 8px rgba(98, 0, 238, 0.3) !important;
  transition: background-color 0.3s ease !important;
  user-select: none !important;
  white-space: nowrap !important;
}

#aiChatSendBtn:hover {
  background: var(--color-primary-dark) !important;
}

#aiChatSendBtn:disabled {
  background: #aaa !important;
  cursor: not-allowed !important;
} */

/* Cursor animation */
.cursor {
  display: inline-block !important;
  width: 2px !important;
  height: 25px;
  background-color: var(--color-primary-dark) !important;
  margin-left: 4px !important;
  animation: blink 1s steps(2, start) infinite !important;
  vertical-align: bottom !important;
}

/* Animations */
@keyframes blink {
  0%, 50% {
    opacity: 1;
  }
  50.01%, 100% {
    opacity: 0;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Scrollbar styling */
:root { 
  --color-primary: #6200ee; 
  --color-primary-dark: #3700b3; 
  --color-accent: #03dac6; 
  --color-bg: #f0f2f5; 
  --color-text: #222; 
} 

* { 
  margin: 0; 
  padding: 0; 
  box-sizing: border-box; 
} 

body { 
  font-family: "Segoe UI", sans-serif; 
  background: var(--color-bg); 
  color: var(--color-text); 
  line-height: 1.6; 
  min-height: 100vh; 
  display: flex; 
  flex-direction: column; 
} 

/* ===== AI Chat Fullscreen Layout ===== */ 
#aiChatContent { 
  position: fixed; 
  top: 0; 
  left: 0; 
  width: 100vw; 
  height: 100vh; 
  background: #fff; 
  padding: 16px 24px 100px 24px; 
  display: flex; 
  flex-direction: column; 
  overflow: hidden; 
  z-index: 9999; 
} 

#aiChatContent > h2 { 
  margin-bottom: 16px; 
  font-size: 1.9rem; 
  font-weight: 700; 
  color: var(--color-primary-dark); 
  text-align: center; 
  flex-shrink: 0; 
} 

/* Messages area */ 
#aiChatResponse { 
  flex: 1; 
  overflow-y: auto; 
  display: flex; 
  flex-direction: column; 
  gap: 8px; 
  padding: 8px; 
  background: #f5f5f5; 
  border-radius: 8px; 
  white-space: pre-wrap; 
  font-size: 18px; 
  line-height: 1.5; 
  scroll-behavior: smooth; 
} 

/* Message bubbles */ 
.chat-bubble { 
  padding: 10px 14px; 
  border-radius: 16px; 
  max-width: 70%; 
  word-wrap: break-word; 
  box-shadow: 0 2px 5px rgba(0,0,0,0.1); 
} 

.chat-bubble.user { 
  align-self: flex-end; 
  background-color: #0b5394; 
  color: white; 
} 

.chat-bubble.ai { 
  align-self: flex-start; 
  background-color: #38761d; 
  color: white; 
} 

.chat-bubble.error { 
  background-color: #b20000; 
  color: white; 
} 

/* Input and button at bottom */ 
#aiChatForm { 
  display: flex; 
  gap: 8px; 
  position: fixed; 
  bottom: 16px; 
  left: 24px; 
  right: 24px; 
  z-index: 10000; 
} 

#aiChatInput { 
  flex: 1; 
  padding: 16px 20px; 
  font-size: 16px; 
  border-radius: 16px; 
  border: 1px solid #ccc; 
  box-sizing: border-box; 
} 

#aiChatSendBtn { 
  background: var(--color-primary); 
  border: none; 
  border-radius: 16px; 
  padding: 16px 32px; 
  font-size: 1.1rem; 
  font-weight: 600; 
  color: white; 
  cursor: pointer; 
  transition: background-color 0.3s ease; 
} 

#aiChatSendBtn:hover { 
  background: var(--color-primary-dark); 
} 

#aiChatSendBtn:disabled { 
  background: #aaa; 
  cursor: not-allowed; 
} 

/* Scrollbar */ 
#aiChatResponse::-webkit-scrollbar { 
  width: 8px; 
} 
#aiChatResponse::-webkit-scrollbar-thumb { 
  background: var(--color-primary); 
  border-radius: 8px; 
} 
#aiChatResponse::-webkit-scrollbar-track { 
  background: #f1f1f1; 
} 

/* Responsive adjustments */
@media (max-width: 768px) {
  #aiChatContent {
    padding: 12px 16px 80px 16px !important;
  }
  #aiChatInput {
    height: 70px !important;
    padding: 12px 14px !important;
    font-size: 16px !important;
    width: calc(100vw - 32px) !important;
    left: 16px !important;
    right: 16px !important;
  }
  #aiChatSendBtn {
    padding: 12px 24px !important;
    font-size: 1rem !important;
  }
  #aiChatButtons {
    bottom: 24px !important;
    right: 32px !important;
  }
}

/* ===== Other repeated existing CSS can stay here if you want ===== */
