* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: rgb(0, 0, 0);
  color: rgb(255, 255, 255);
  overflow: hidden;
  color-scheme: dark;
  position: fixed;
  -webkit-overflow-scrolling: touch;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: -webkit-fill-available;
}

/* اسم التطبيق في أعلى اليمين */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  padding: 15px 30px;
  padding-top: max(15px, env(safe-area-inset-top));
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(0, 0, 0, 0.98);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 999999;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.header-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: rgb(255, 255, 255);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-icon-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.05);
}

.header-icon-button:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.05);
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-image {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  object-fit: cover;
}

.logout-button {
  width: 38px;
  height: 38px;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 99, 71, 0.5);
  border-radius: 8px;
  color: rgb(255, 99, 71);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logout-button:hover {
  background: rgba(255, 99, 71, 0.1);
  border-color: rgb(255, 99, 71);
  transform: scale(1.05);
}

.logout-button:active {
  transform: scale(0.95);
}

.app-title {
  font-size: 28px;
  font-weight: bold;
  color: rgb(255, 255, 255);
  letter-spacing: 1px;
  text-align: left;
}

/* منطقة الدردشة */
main {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-top: 100px;
  display: flex;
  flex-direction: column;
  scrollbar-width: none; /* إخفاء scrollbar في Firefox */
  -ms-overflow-style: none; /* إخفاء scrollbar في IE و Edge */
}

/* إخفاء scrollbar في Chrome, Safari و Opera */
main::-webkit-scrollbar {
  display: none;
}

.chat-container {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 15px;
  padding-bottom: 20px;
}

/* رسالة المستخدم */
.message {
  padding: 12px 18px;
  border-radius: 12px;
  max-width: 70%;
  word-wrap: break-word;
  animation: fadeIn 0.3s ease-in;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* رسالة AI بعرض كامل */
.ai-message {
  max-width: 100%;
  width: 100%;
}

.user-message {
  background: rgba(40, 40, 40, 0.3);
  align-self: flex-end;
  margin-left: auto;
  border: none;
  align-items: flex-end;
  position: relative;
  padding-right: 50px;
}

.ai-message {
  background: transparent;
  align-self: flex-start;
  margin-right: auto;
  border: none;
  align-items: flex-start;
  line-height: 1.8;
  position: relative;
  padding-left: 50px;
}

/* تنسيق العناوين في رسائل AI */
.ai-message h1,
.ai-message h2,
.ai-message h3,
.ai-message .heading {
  color: #ffffff;
  font-weight: bold;
  margin: 15px 0 10px 0;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.ai-message h1 { font-size: 1.5em; }
.ai-message h2 { font-size: 1.3em; }
.ai-message h3 { font-size: 1.1em; }

/* النص العادي */
.ai-message p,
.ai-message span,
.ai-message .body-text {
  color: #c5cae9;
  line-height: 1.8;
}

/* تنسيق القوائم */
.ai-message ul,
.ai-message ol {
  color: #c5cae9;
  margin: 10px 0;
  padding-right: 25px;
}

.ai-message li {
  margin: 5px 0;
}

/* النص الغامق */
.ai-message strong,
.ai-message b {
  color: #e3f2fd;
  font-weight: bold;
}

/* أيقونة المستخدم */
.user-avatar {
  position: absolute;
  right: 10px;
  top: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

/* أيقونة الذكاء الاصطناعي */
.ai-avatar {
  position: absolute;
  left: 10px;
  top: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4a90e2 0%, #2196f3 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  font-weight: bold;
  box-shadow: 0 2px 10px rgba(74, 144, 226, 0.5);
}

/* تأثير الشعاع المتحرك للذكاء الاصطناعي */
/* موجة هواء رفيعة تمتد من أيقونة AI بعرض الشاشة */
.ai-avatar.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  right: auto;
  width: 200vw;
  height: 1px;
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.3) 0%, 
    rgba(255, 255, 255, 0.15) 30%,
    rgba(255, 255, 255, 0.1) 60%,
    transparent 100%
  );
  transform: translateY(-50%);
  pointer-events: none;
  z-index: 1;
}

/* موجة بيضاء متحركة ذهاباً وإياباً من الأيقونة */
.ai-avatar.loading::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 100%;
  width: 120px;
  height: 3px;
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.9),
    rgba(255, 255, 255, 0.7),
    rgba(255, 255, 255, 0.4),
    transparent
  );
  transform: translateY(-50%);
  animation: textWaveMoveFromIcon 2.8s ease-in-out infinite;
  pointer-events: none;
  z-index: 2;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.6);
  border-radius: 50%;
}

@keyframes textWaveMoveFromIcon {
  0% {
    left: 100%;
    width: 120px;
    opacity: 0;
  }
  5% {
    opacity: 1;
  }
  45% {
    left: calc(100vw - 150px);
    width: 80px;
    opacity: 0.8;
  }
  50% {
    left: calc(100vw - 150px);
    opacity: 0.6;
  }
  55% {
    left: calc(100vw - 150px);
    width: 120px;
    opacity: 1;
  }
  95% {
    left: 100%;
    opacity: 1;
  }
  100% {
    left: 100%;
    width: 120px;
    opacity: 0;
  }
}

/* صندوق توليد الصور */
.image-generation-box {
  margin-top: 10px;
  margin-left: 0;
  padding: 40px 20px;
  background: linear-gradient(135deg, rgba(40, 40, 40, 0.7) 0%, rgba(60, 60, 60, 0.5) 100%);
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 500px;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* تأثير بصري - شبكة متحركة تتكون تدريجياً */
.image-generation-box::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: 
    repeating-linear-gradient(0deg, 
      rgba(255, 255, 255, 0.03) 0px, 
      transparent 1px, 
      transparent 20px
    ),
    repeating-linear-gradient(90deg, 
      rgba(255, 255, 255, 0.03) 0px, 
      transparent 1px, 
      transparent 20px
    );
  animation: gridFormation 3s ease-in-out infinite;
  opacity: 0;
}

/* موجات متعددة تتحرك من اليسار لليمين */
.image-generation-box::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, 
    transparent 0%,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 75%,
    transparent 100%
  );
  animation: imageWaveSweep 2.5s ease-in-out infinite;
}

@keyframes gridFormation {
  0%, 30% {
    opacity: 0;
    transform: scale(0.8);
  }
  60%, 100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes imageWaveSweep {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

.image-generation-text {
  color: rgba(255, 255, 255, 0.95);
  font-size: 15px;
  text-align: center;
  position: relative;
  z-index: 1;
  font-weight: 500;
  letter-spacing: 0.5px;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* صندوق الإدخال في الأسفل */
.input-container {
  width: calc(100% - 40px);
  max-width: 900px;
  margin: 0 auto 20px auto;
  padding: 5px;
  background: transparent;
  border-radius: 20px;
  border: none;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.message-input {
  width: 100%;
  min-height: 28px;
  max-height: 150px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(74, 144, 226, 0.3);
  border-radius: 12px;
  color: #ffffff;
  font-size: 16px;
  resize: vertical;
  outline: none;
  transition: all 0.3s ease;
  font-family: inherit;
}

.message-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.message-input:focus {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: none;
}

/* صف الأزرار */
.buttons-row {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.send-button {
  width: 36px;
  height: 36px;
  padding: 0;
  background: rgb(0, 0, 0);
  border: none;
  border-radius: 50%;
  color: rgb(255, 255, 255);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.send-button.has-text {
  background: rgb(255, 255, 255);
  color: rgb(0, 0, 0);
}

.send-button:hover {
  transform: scale(1.05);
}

.send-button:active {
  transform: scale(0.95);
}

.menu-button {
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: rgb(255, 255, 255);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.menu-button:hover {
  transform: scale(1.05);
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.menu-button:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.05);
}

/* القائمة الجانبية */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

.sidebar-panel {
  position: fixed;
  top: 0;
  right: -80%;
  width: 80%;
  max-width: 400px;
  height: 100vh;
  background: rgb(0, 0, 0);
  border-left: 3px solid;
  border-image: linear-gradient(180deg, rgb(255, 255, 255) 0%, rgb(74, 144, 226) 50%, rgb(33, 150, 243) 100%) 1;
  box-shadow: -4px 0 20px rgba(74, 144, 226, 0.4);
  transition: right 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-overlay.active .sidebar-panel {
  right: 0;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 20px;
  font-weight: bold;
  color: rgb(255, 255, 255);
  margin: 0;
}

.close-sidebar-button {
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: rgb(255, 255, 255);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-sidebar-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.05);
}

.close-sidebar-button:active {
  transform: scale(0.95);
}

.sidebar-content {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.sidebar-placeholder {
  color: rgb(255, 255, 255);
  text-align: center;
  padding: 40px 20px;
  font-size: 16px;
}

/* قسم الحساب في القائمة الجانبية */
.sidebar-user-section {
  margin-bottom: 20px;
  padding: 15px;
  background: linear-gradient(135deg, #1a1a2e 0%, #0f3460 100%);
  border: 2px solid #4a90e2;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.sidebar-user-image {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  object-fit: cover;
}

.sidebar-user-name {
  color: rgb(255, 255, 255);
  font-size: 16px;
  font-weight: bold;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.expand-user-button {
  width: 100%;
  padding: 10px 15px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: rgb(255, 255, 255);
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.expand-user-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.user-options {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  margin-top: 0;
}

.user-options.expanded {
  max-height: 200px;
  margin-top: 12px;
}

.user-option-button {
  width: 100%;
  padding: 12px 15px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: rgb(255, 255, 255);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.user-option-button:last-child {
  margin-bottom: 0;
}

.user-option-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.user-option-button.logout-option {
  border-color: rgba(255, 99, 71, 0.5);
  color: rgb(255, 99, 71);
}

.user-option-button.logout-option:hover {
  background: rgba(255, 99, 71, 0.1);
  border-color: rgb(255, 99, 71);
}

/* أزرار القسم العلوي في القائمة الجانبية */
.sidebar-top-buttons {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.sidebar-tab-button {
  flex: 1;
  padding: 12px 20px;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  color: rgb(255, 255, 255);
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.sidebar-tab-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.sidebar-tab-button.active {
  background: linear-gradient(135deg, #1a1a2e 0%, #0f3460 100%);
  border-color: #4a90e2;
  box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}

/* قسم الدردشات المحفوظة */
.saved-chats-section {
  margin-top: 20px;
}

.section-title {
  font-size: 16px;
  font-weight: bold;
  color: rgb(255, 255, 255);
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.saved-chats-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  background: linear-gradient(135deg, #1a1a2e 0%, #0f3460 100%);
  border: 1px solid rgba(74, 144, 226, 0.3);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.chat-item:hover {
  background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
  border-color: #4a90e2;
  transform: translateX(-3px);
}

.chat-item-name {
  color: rgb(255, 255, 255);
  font-size: 14px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 10px;
}

.delete-chat-button {
  width: 30px;
  height: 30px;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 100, 100, 0.5);
  border-radius: 6px;
  color: rgb(255, 100, 100);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.delete-chat-button:hover {
  background: rgba(255, 100, 100, 0.2);
  border-color: rgb(255, 100, 100);
  transform: scale(1.1);
}

.delete-chat-button svg {
  width: 16px;
  height: 16px;
}

.no-chats-message {
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  padding: 30px 20px;
  font-size: 14px;
}

/* صفحة AI Studio */
.ai-studio-page,
.create-model-page {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  scrollbar-width: none;
  -ms-overflow-style: none;
  max-width: 900px;
  margin: 0 auto;
  width: 100%;
}

.ai-studio-page::-webkit-scrollbar,
.create-model-page::-webkit-scrollbar {
  display: none;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 30px;
  justify-content: space-between;
}

.back-button {
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  color: rgb(255, 255, 255);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.back-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.05);
}

.back-button:active {
  transform: scale(0.95);
}

.page-title {
  font-size: 24px;
  font-weight: bold;
  color: rgb(255, 255, 255);
  margin: 0;
  flex: 1;
}

.create-model-header-button {
  padding: 10px 20px;
  background: linear-gradient(135deg, #1a1a2e 0%, #0f3460 100%);
  border: 2px solid #4a90e2;
  border-radius: 10px;
  color: rgb(255, 255, 255);
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
  white-space: nowrap;
  flex-shrink: 0;
}

.create-model-header-button:hover {
  background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
  border-color: #2196f3;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

.create-model-header-button:active {
  transform: translateY(0);
}

/* علامات التبويب في AI Studio */
.studio-tabs {
  display: flex;
  gap: 15px;
  margin-bottom: 25px;
}

.studio-tab {
  flex: 1;
  padding: 12px 20px;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  color: rgb(255, 255, 255);
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.studio-tab:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.studio-tab.active {
  background: linear-gradient(135deg, #1a1a2e 0%, #0f3460 100%);
  border-color: #4a90e2;
  box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}


/* قائمة النماذج */
.models-container {
  flex: 1;
}

.models-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.no-models-message {
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  padding: 40px 20px;
  font-size: 16px;
}

/* نموذج في القائمة */
.model-item {
  padding: 16px 20px;
  background: rgb(0, 0, 0);
  border: 2px solid rgb(255, 255, 255);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 12px;
}

.model-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: #4a90e2;
  transform: translateY(-2px);
  box-shadow: 0 4px 20px rgba(74, 144, 226, 0.4);
}

.model-item-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.model-item-icon-img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(74, 144, 226, 0.5);
}

.model-item-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.model-item-name {
  font-size: 17px;
  font-weight: bold;
  color: rgb(255, 255, 255);
}

.model-item-description {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
  line-height: 1.5;
}

/* معلومات منشئ النموذج */
.model-creator-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.model-creator-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.model-creator-name {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
}

/* قائمة النموذج */
.model-menu-container {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.model-menu-button {
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: rgb(255, 255, 255);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.model-menu-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  transform: scale(1.05);
}

.model-menu-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: rgb(15, 15, 20);
  border: 2px solid rgba(74, 144, 226, 0.5);
  border-radius: 10px;
  min-width: 160px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.model-menu-dropdown.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.menu-dropdown-item {
  width: 100%;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: rgb(255, 255, 255);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: right;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.menu-dropdown-item:last-child {
  border-bottom: none;
}

.menu-dropdown-item:hover {
  background: rgba(74, 144, 226, 0.2);
}

.menu-dropdown-item.delete {
  color: rgb(255, 100, 100);
}

.menu-dropdown-item.delete:hover {
  background: rgba(255, 100, 100, 0.2);
}

.menu-dropdown-item svg {
  flex-shrink: 0;
}

/* صفحة إنشاء نموذج */
.create-form {
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-label {
  font-size: 16px;
  font-weight: bold;
  color: rgb(255, 255, 255);
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 12px 15px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(74, 144, 226, 0.3);
  border-radius: 10px;
  color: rgb(255, 255, 255);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: all 0.3s ease;
}

.form-input:focus,
.form-textarea:focus {
  border-color: #4a90e2;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 15px rgba(74, 144, 226, 0.2);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* مجموعة الراديو */
.radio-group {
  display: flex;
  gap: 20px;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 15px;
  color: rgb(255, 255, 255);
}

.radio-option input[type="radio"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #4a90e2;
}

/* أزرار النموذج */
.form-actions {
  display: flex;
  gap: 15px;
  margin-top: 10px;
}

.cancel-button,
.save-button {
  flex: 1;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
}

.cancel-button {
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: rgb(255, 255, 255);
}

.cancel-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.save-button {
  background: linear-gradient(135deg, #1a1a2e 0%, #0f3460 100%);
  border: 2px solid #4a90e2;
  color: rgb(255, 255, 255);
  box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}

.save-button:hover {
  background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
  border-color: #2196f3;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

.save-button:active {
  transform: translateY(0);
}

/* القائمة المنبثقة */
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

.menu-panel {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 100%);
  width: 90%;
  max-width: 500px;
  height: 50vh;
  background: rgb(0, 0, 0);
  border-radius: 20px 20px 0 0;
  border-top: 2px solid rgb(255, 255, 255);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
  transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.menu-overlay.active .menu-panel {
  transform: translate(-50%, 0);
}

.menu-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}

.menu-title {
  font-size: 20px;
  font-weight: bold;
  color: rgb(255, 255, 255);
  margin: 0;
  text-align: center;
}

.close-menu-button {
  position: absolute;
  right: 15px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  color: rgb(255, 255, 255);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-menu-button:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-50%) scale(1.05);
}

.close-menu-button:active {
  transform: translateY(-50%) scale(0.95);
}

.menu-content {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.menu-placeholder {
  color: rgb(255, 255, 255);
  text-align: center;
  padding: 40px 20px;
  font-size: 16px;
}

/* أداة في القائمة المنبثقة */
.menu-tool-item {
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 15px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.3s ease;
  width: 100%;
  text-align: right;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
}

.menu-tool-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(74, 144, 226, 0.4);
}

.menu-tool-item:active {
  transform: scale(0.98);
}

.menu-tool-icon {
  width: 45px;
  height: 45px;
  background: linear-gradient(135deg, rgba(74, 144, 226, 0.2), rgba(33, 150, 243, 0.2));
  border: 1px solid rgba(74, 144, 226, 0.3);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4a90e2;
  flex-shrink: 0;
}

.menu-tool-name {
  font-size: 16px;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
  flex: 1;
  text-align: right;
}

.menu-tool-toggle {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
  flex-shrink: 0;
}

.menu-tool-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.menu-tool-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: 0.3s;
  border-radius: 26px;
}

.menu-tool-toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: #ffffff;
  transition: 0.3s;
  border-radius: 50%;
}

.menu-tool-toggle input:checked + .menu-tool-toggle-slider {
  background-color: #4a90e2;
  border-color: #4a90e2;
  box-shadow: 0 0 10px rgba(74, 144, 226, 0.5);
}

.menu-tool-toggle input:checked + .menu-tool-toggle-slider:before {
  transform: translateX(24px);
}

.menu-tool-toggle-slider:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

.menu-tool-toggle input:checked + .menu-tool-toggle-slider:hover {
  background-color: #5ca0f2;
}

/* زر استيراد الصورة في القائمة */
.menu-option-button {
  width: 100%;
  padding: 15px 20px;
  background: linear-gradient(135deg, #1a1a2e 0%, #0f3460 100%);
  border: 2px solid #4a90e2;
  border-radius: 12px;
  color: #ffffff;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 15px;
  box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
}

.menu-option-button:hover {
  background: linear-gradient(135deg, #0f3460 0%, #16213e 100%);
  border-color: #2196f3;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4);
}

.menu-option-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(74, 144, 226, 0.3);
}

.menu-option-button svg {
  width: 24px;
  height: 24px;
}

/* تخصيص شريط التمرير - فقط للقائمة */
.menu-content::-webkit-scrollbar {
  width: 8px;
}

.menu-content::-webkit-scrollbar-track {
  background: #1a1a1a;
}

.menu-content::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #2196f3, #4a90e2);
  border-radius: 4px;
}

.menu-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #1976d2, #2196f3);
}

/* توافق مع الشاشات الصغيرة والهواتف */
@media (max-width: 768px) {
  header {
    padding: 15px 20px;
    position: fixed;
    top: 0;
    z-index: 999999;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }
  
  .app-title {
    font-size: 22px;
  }
  
  .input-container {
    width: calc(100% - 30px);
    margin: 0 auto 15px auto;
    padding: 15px;
    gap: 10px;
    border-radius: 18px;
  }
  
  .input-container::before {
    border-radius: 21px;
  }
  
  .input-container::after {
    border-radius: 24px;
  }
  
  .message-input {
    min-height: 40px;
    max-height: 120px;
    padding: 10px;
    font-size: 15px;
  }
  
  .send-button,
  .menu-button {
    width: 40px;
    height: 40px;
    font-size: 18px;
  }
  
  .send-button svg,
  .menu-button svg {
    width: 18px;
    height: 18px;
  }
  
  main {
    padding: 15px;
    padding-top: 90px;
  }
  
  .menu-panel {
    width: 95%;
    height: 55vh;
  }
  
  .menu-header {
    padding: 15px;
  }
  
  .menu-title {
    font-size: 18px;
  }
  
  .close-menu-button {
    width: 35px;
    height: 35px;
  }
  
  /* تحسينات صفحة AI Studio على الأجهزة اللوحية */
  .ai-studio-page,
  .create-model-page {
    padding: 15px;
  }
  
  .page-header {
    gap: 10px;
    margin-bottom: 20px;
  }
  
  .page-title {
    font-size: 20px;
  }
  
  .create-model-header-button {
    padding: 8px 16px;
    font-size: 14px;
  }
  
  .studio-tabs {
    gap: 10px;
    margin-bottom: 20px;
  }
  
  .studio-tab {
    padding: 10px 16px;
    font-size: 15px;
  }
  
  .model-item {
    padding: 14px 16px;
  }
  
  .model-item-icon,
  .model-item-icon-img {
    width: 32px;
    height: 32px;
  }
  
  .model-item-name {
    font-size: 16px;
  }
  
  .model-item-description {
    font-size: 13px;
  }
  
  .menu-tool-item {
    padding: 14px;
  }
  
  .menu-tool-icon {
    width: 40px;
    height: 40px;
  }
  
  .menu-tool-name {
    font-size: 15px;
  }
  
  .menu-tool-description {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  header {
    padding: 12px 15px;
    position: fixed;
    top: 0;
    z-index: 999999;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
  }
  
  .app-title {
    font-size: 20px;
  }
  
  .input-container {
    width: calc(100% - 20px);
    margin: 0 auto 10px auto;
    padding: 12px;
    border-radius: 16px;
  }
  
  .input-container::before {
    border-radius: 19px;
  }
  
  .input-container::after {
    border-radius: 22px;
  }
  
  .message-input {
    min-height: 38px;
    padding: 10px;
    font-size: 14px;
  }
  
  .send-button,
  .menu-button {
    width: 38px;
    height: 38px;
  }
  
  .send-button svg,
  .menu-button svg {
    width: 16px;
    height: 16px;
  }
  
  main {
    padding: 10px;
    padding-top: 75px;
  }
  
  .menu-panel {
    width: 98%;
    max-height: 80vh;
  }
  
  .menu-header {
    padding: 12px;
  }
  
  .menu-title {
    font-size: 16px;
  }
  
  .close-menu-button {
    width: 32px;
    height: 32px;
    right: 10px;
  }
  
  .menu-content {
    padding: 15px;
  }
  
  /* تحسينات صفحة AI Studio على الهواتف */
  .ai-studio-page,
  .create-model-page {
    padding: 12px;
  }
  
  .page-header {
    gap: 8px;
    margin-bottom: 15px;
  }
  
  .page-title {
    font-size: 18px;
  }
  
  .back-button {
    width: 35px;
    height: 35px;
  }
  
  .create-model-header-button {
    padding: 8px 12px;
    font-size: 13px;
  }
  
  .studio-tabs {
    gap: 8px;
    margin-bottom: 15px;
  }
  
  .studio-tab {
    padding: 10px 12px;
    font-size: 14px;
  }
  
  .model-item {
    padding: 12px 14px;
    gap: 10px;
  }
  
  .model-item-icon,
  .model-item-icon-img {
    width: 28px;
    height: 28px;
  }
  
  .model-item-name {
    font-size: 15px;
  }
  
  .model-item-description {
    font-size: 12px;
  }
  
  .menu-tool-item {
    padding: 12px;
  }
  
  .menu-tool-icon {
    width: 38px;
    height: 38px;
  }
  
  .menu-tool-icon svg {
    width: 24px;
    height: 24px;
  }
  
  .menu-tool-name {
    font-size: 14px;
  }
  
  .menu-tool-description {
    font-size: 11px;
  }
  
  .model-menu-button {
    width: 28px;
    height: 28px;
  }
  
  .form-label {
    font-size: 15px;
  }
  
  .form-input,
  .form-textarea {
    font-size: 14px;
  }
}

/* تأثير النقاط المتحركة للانتظار - تصميم بسيط */
.loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: transparent;
  border-radius: 12px;
  position: relative;
}

.loading-dots .dot {
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots .dot:nth-child(1) {
  animation-delay: 0s;
}

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

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

@keyframes dotPulse {
  0%, 100% {
    transform: translateY(0);
    opacity: 1;
  }
  50% {
    transform: translateY(-15px);
    opacity: 0.6;
  }
}

/* معاينة الصورة في صندوق الإدخال */
.input-container.has-image {
  padding: 20px 5px 5px 5px;
  min-height: 180px;
}

.image-preview-container {
  width: 100%;
  display: flex;
  justify-content: flex-end;
  padding: 0 15px 10px 0;
}

.image-preview {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid #4a90e2;
  box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3);
  flex-shrink: 0;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(5px);
}

.image-preview-overlay.hidden {
  display: none;
}

/* دائرة التحميل - دائرة سوداء كبيرة وداخلها دائرة بيضاء تدور */
.spinner-container {
  width: 50px;
  height: 50px;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* تنسيق الصور داخل الرسائل */
.message img {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease;
}

.message img:hover {
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
}

/* ===== صفحة الأدوات ===== */
.tools-page {
  position: fixed;
  top: 70px;
  left: 0;
  right: 0;
  bottom: 80px;
  background: rgb(0, 0, 0);
  overflow-y: auto;
  padding: 20px;
}

.tools-container {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tool-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.3s ease;
}

.tool-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.tool-info {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.tool-icon {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, rgba(74, 144, 226, 0.2), rgba(33, 150, 243, 0.2));
  border: 1px solid rgba(74, 144, 226, 0.3);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4a90e2;
  flex-shrink: 0;
}

.tool-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tool-name {
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
}

.tool-description {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
  line-height: 1.4;
}

.tool-toggle {
  position: relative;
  display: inline-block;
  width: 54px;
  height: 28px;
  flex-shrink: 0;
}

.tool-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.tool-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: 0.3s;
  border-radius: 28px;
}

.tool-toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 3px;
  background-color: #ffffff;
  transition: 0.3s;
  border-radius: 50%;
}

.tool-toggle input:checked + .tool-toggle-slider {
  background-color: #4a90e2;
  border-color: #4a90e2;
}

.tool-toggle input:checked + .tool-toggle-slider:before {
  transform: translateX(26px);
}

.tool-toggle-slider:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

.tool-toggle input:checked + .tool-toggle-slider:hover {
  background-color: #5ca0f2;
}

/* ===== معاينة الصور المتعددة ===== */
.multiple-images-preview-container {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 15px 10px 15px;
  max-height: 250px;
  overflow-y: auto;
}

.single-image-preview {
  position: relative;
  flex-shrink: 0;
}

.single-image-preview .image-preview {
  width: 100px;
  height: 100px;
}

.image-number {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(0, 0, 0, 0.8);
  color: #ffffff;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  font-weight: 600;
  z-index: 10;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

.upload-status {
  color: #ffffff;
  font-size: 12px;
  text-align: center;
  margin-top: 5px;
  font-weight: 500;
}

.upload-success {
  color: #4ade80;
  font-size: 32px;
  font-weight: bold;
  animation: successPop 0.3s ease-out;
}

@keyframes successPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* تنسيق شريط التمرير للصور المتعددة */
.multiple-images-preview-container::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.multiple-images-preview-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
}

.multiple-images-preview-container::-webkit-scrollbar-thumb {
  background: rgba(74, 144, 226, 0.5);
  border-radius: 3px;
}

.multiple-images-preview-container::-webkit-scrollbar-thumb:hover {
  background: rgba(74, 144, 226, 0.7);
}
