/* style.css - تمیز شده و بهینه‌سازی شده */
:root {
  --primary-color: #5d5fef;
  --secondary-color: #7e57c2;
  --bg-color: #f5f7fb;
  --card-bg: #ffffff;
  --text-color: #333333;
  --border-radius: 16px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --border-color: #e0e0e0;
  --hover-color: rgba(93, 95, 239, 0.1);
}

:root[data-theme="dark"] {
  --bg-color: #121212;
  --card-bg: #1e1e1e;
  --text-color: #e0e0e0;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  --primary-color: #7e7eff;
  --border-color: #444;
  --hover-color: rgba(126, 126, 255, 0.1);
}

/* ===== RESET & BASE STYLES ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Vazirmatn", "Iran Sans", "Segoe UI", Tahoma, Geneva, Verdana,
    sans-serif;
  background: linear-gradient(135deg, var(--bg-color) 0%, #e4edf5 100%);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  background-attachment: fixed;
}

/* ===== LAYOUT ===== */
.container {
  display: flex;
  max-width: 1800px;
  margin: 0 auto;
  padding: 1rem;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ===== SIDEBARS ===== */
.model-sidebar {
  width: 340px;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  height: calc(100vh - 2rem);
  overflow-y: auto;
  position: sticky;
  top: 1rem;
  order: -1;
}

.ads-sidebar {
  width: 300px;
  background: var(--card-bg);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  height: calc(100vh - 2rem);
  overflow-y: auto;
  position: sticky;
  top: 1rem;
  order: 1;
}

/* ===== NEW CHAT BUTTON ===== */
.new-chat-btn {
  background: linear-gradient(135deg, #4caf50, #45a049);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  font-family: "Vazirmatn", "Iran Sans", sans-serif;
}

/* ===== MODEL SELECTION ===== */
.model-selection h3 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.search-container {
  position: relative;
  margin-bottom: 0.3rem;
}

.search-container input {
  width: 100%;
  padding: 0.85rem 2.5rem 0.85rem 1rem;
  border: 1px solid #ddd;
  border-radius: 50px;
  font-size: 0.95rem;
  background-color: #f8f9fa;
  transition: var(--transition);
  font-family: inherit;
  color: var(--text-color);
}

:root[data-theme="dark"] .search-container input {
  background-color: #2d2d2d;
  border-color: #444;
  color: #e0e0e0;
}

.search-container input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(93, 95, 239, 0.2);
  outline: none;
}

.search-icon {
  position: absolute;
  right: 1.2rem;
  top: 50%;
  transform: translateY(-50%);
  color: #888;
  pointer-events: none;
}

.selected-model-container {
  text-align: center;
  position: relative;
}

#selected-model-label {
  position: absolute;
  top: 0px;
  right: 10px;
  font-size: 0.8rem;
  color: var(--primary-color);
  background-color: var(--bg-color);
  padding: 0 5px;
  z-index: 1;
}

#selected-model-display {
  padding: 10px;
  background-color: var(--card-bg);
  border: 1px solid var(--primary-color);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text-color);
  display: inline-block;
  width: 90%;
  margin-top: 10px;
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: center;
}

#selected-model-display:hover {
  background-color: var(--hover-color);
}

/* ===== MODELS LIST ===== */
.models-list {
  max-height: 57vh;
  overflow-y: auto;
  border: 3px solid var(--border-color);
  border-radius: 8px;
  padding: 5px;
}

.models-list::-webkit-scrollbar {
  width: 6px;
}

.models-list::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

:root[data-theme="dark"] .models-list::-webkit-scrollbar-track {
  background: #333;
}

.models-list::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 10px;
}

.model-group {
  margin-bottom: 1.5rem;
}

.model-group-header {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background-color: var(--bg-color);
  border-radius: 5px;
  margin-top: 10px;
  font-size: 1rem;
  color: #555;
  border-bottom: 1px solid #eee;
}

:root[data-theme="dark"] .model-group-header {
  color: #bbb;
  border-color: #444;
}

.model-group-header:hover {
  background-color: var(--hover-color);
}

.model-group-header i {
  transition: transform 0.3s ease;
}

.model-group.collapsed .model-group-header i {
  transform: rotate(-90deg);
}

.model-group.collapsed .model-items-container {
  display: none;
}

.model-items-container {
  padding-top: 5px;
}

.model-item {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid #eee;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
}

:root[data-theme="dark"] .model-item {
  border-color: #444;
  background: #252525;
}

.model-item:hover {
  background: var(--hover-color);
  border-color: var(--primary-color);
}

.model-item.active {
  background: linear-gradient(
    135deg,
    rgba(93, 95, 239, 0.18),
    rgba(126, 87, 194, 0.18)
  );
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(93, 95, 239, 0.35) inset,
    0 4px 12px rgba(93, 95, 239, 0.25);
  position: relative;
}

.model-item.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary-color);
  border-radius: 4px 0 0 4px;
}

.model-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
  color: white;
  flex-shrink: 0;
  background: var(--primary-color);
}

.model-name {
  font-weight: 500;
  font-size: 0.95rem;
  word-break: break-word;
  white-space: normal;
  flex: 1;
}

.model-provider {
  font-size: 0.75rem;
  color: #777;
  margin-top: 2px;
}

:root[data-theme="dark"] .model-provider {
  color: #aaa;
}

/* ===== ADS ===== */
.ads-container h3 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ad-item {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  color: white;
  text-align: center;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  transition: var(--transition);
}

.ad-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.ad-title {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.ad-text {
  font-size: 0.9rem;
  opacity: 0.9;
}

/* ===== CHAT CONTAINER ===== */
.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 100%;
  min-width: 0;
  order: 0;
}

.chat-header {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  color: white;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 4px 12px rgba(93, 95, 239, 0.2);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.chat-header::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.1) 0%,
    rgba(255, 255, 255, 0) 70%
  );
  transform: rotate(30deg);
}

.chat-header h1 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 2;
}

.chat-header p {
  opacity: 0.9;
  font-size: 1rem;
  position: relative;
  z-index: 2;
  margin-bottom: 1rem;
}

.dark-mode-toggle {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: transform 0.2s;
  position: relative;
  z-index: 2;
}

.dark-mode-toggle:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.3);
}

/* ===== CHAT MESSAGES ===== */
.chat-messages {
  flex: 1;
  background: var(--card-bg);
  border-radius: 0 0 var(--border-radius) var(--border-radius);
  padding: 1.5rem;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: var(--shadow);
  min-height: 300px;
  max-height: calc(100vh - 280px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  scroll-behavior: smooth;
}

@media (min-width: 1025px) {
  .chat-messages {
    max-height: calc(100vh - 290px);
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .chat-messages {
    max-height: calc(100vh - 300px);
    min-height: 400px;
  }
}

@media (max-width: 768px) {
  .chat-messages {
    max-height: none;
    flex-grow: 1;
    min-height: 200px;
    padding-bottom: 80px;
    overflow-y: auto;
  }
}

.message {
  max-width: 90%;
  padding: 1rem 1.5rem;
  border-radius: 18px;
  position: relative;
  animation: fadeInUp 0.4s ease-out;
  line-height: 1.6;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-message {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 5px;
}

.bot-message {
  background: #f0f4ff;
  color: var(--text-color);
  align-self: flex-start;
  border-bottom-left-radius: 5px;
}

:root[data-theme="dark"] .bot-message {
  background: #2a2a35;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.message-sender {
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.message-time {
  opacity: 0.7;
  margin-right: 10px;
}

.bot-message .message-sender i {
  color: var(--primary-color);
}

.message-content {
  font-size: 1.05rem;
  line-height: 1.7;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}

.message-content table {
  border-collapse: collapse;
  width: 100%;
  margin: 1rem 0;
  font-size: 0.95rem;
  direction: ltr;
  text-align: left;
}

.message-content table th,
.message-content table td {
  padding: 0.75rem 1rem;
  border: 1px solid #ddd;
  vertical-align: top;
}

.message-content table th {
  background-color: rgba(93, 95, 239, 0.1);
  font-weight: 600;
  color: #333;
  text-align: center;
}

.message-content table tr:nth-child(even) {
  background-color: rgba(93, 95, 239, 0.03);
}

:root[data-theme="dark"] .message-content table th {
  background-color: rgba(126, 126, 255, 0.15);
  color: #e0e0e0;
  border-color: #444;
}

:root[data-theme="dark"] .message-content table td {
  border-color: #444;
}

:root[data-theme="dark"] .message-content table tr:nth-child(even) {
  background-color: rgba(126, 126, 255, 0.05);
}

@media (max-width: 768px) {
  .message-content table {
    font-size: 0.85rem;
  }

  .message-content table th,
  .message-content table td {
    padding: 0.5rem 0.75rem;
  }
}

@media (max-width: 768px) {
  .message-content {
    overflow-x: auto;
    max-width: 100%;
  }

  .message-content table {
    min-width: 100%;
    overflow-x: auto;
    display: block;
  }
}

.message-content pre,
.message-content code {
  white-space: pre-wrap !important;
  word-break: break-word !important;
  overflow-wrap: break-word !important;
  max-width: 100% !important;
}

.message-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 0.5rem 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message-content pre {
  direction: ltr !important;
  text-align: left !important;
  background: #f8f9fa !important;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 1rem;
  margin: 1rem 0;
  overflow-x: auto;
  font-family: "Fira Code", "Consolas", monospace;
  font-size: 0.95rem;
  line-height: 1.5;
}

:root[data-theme="dark"] .message-content pre {
  background: #0b1020 !important;
  border-color: #1f2937;
  color: #e5e7eb !important;
}

.message-content code {
  font-family: "Fira Code", "Consolas", monospace;
  direction: ltr !important;
  text-align: left !important;
  white-space: pre;
  color: #24292e;
  unicode-bidi: isolate;
}

:root[data-theme="dark"] .message-content code {
  color: #f8f8f2;
}

/* ===== MATH FORMULAS STYLES ===== */
.message-content .MathJax {
  font-size: 1.1em !important;
  overflow-x: auto;
  overflow-y: hidden;
}

/* فرمول‌های بلوکی */
.message-content mjx-container[display="true"] {
  display: block !important;
  margin: 1rem 0 !important;
  padding: 0.75rem;
  overflow-x: auto;
  text-align: center;
  background: rgba(93, 95, 239, 0.03);
  border-radius: 8px;
  border: 1px solid rgba(93, 95, 239, 0.1);
}

:root[data-theme="dark"] .message-content mjx-container[display="true"] {
  background: rgba(126, 126, 255, 0.05);
  border-color: rgba(126, 126, 255, 0.15);
}

/* فرمول‌های خطی */
.message-content mjx-container:not([display="true"]) {
  display: inline-block !important;
  margin: 0 0.2rem;
  vertical-align: middle;
}

/* اسکرول افقی برای فرمول‌های طولانی */
.message-content mjx-container {
  max-width: 100%;
}

/* تنظیم رنگ فرمول‌ها در حالت تاریک */
:root[data-theme="dark"] .message-content mjx-container {
  color: #e0e0e0;
}

:root[data-theme="dark"] .bot-message .message-content mjx-container {
  color: var(--text-color);
}

/* جلوگیری از شکستن فرمول‌ها */
.message-content .MathJax_Display {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
}

/* استایل برای فرمول‌های داخل جدول */
.message-content table mjx-container {
  font-size: 0.95em !important;
}

/* ریسپانسیو برای موبایل */
@media (max-width: 768px) {
  .message-content mjx-container[display="true"] {
    font-size: 0.9em !important;
    padding: 0.5rem;
    margin: 0.75rem 0 !important;
  }

  .message-content .MathJax {
    font-size: 1em !important;
  }
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
  align-self: flex-start;
  background: #f0f4ff;
  padding: 1rem;
  border-radius: 18px;
  border-bottom-left-radius: 5px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

:root[data-theme="dark"] .typing-indicator {
  background: #2a2a35;
}

.typing-dot {
  width: 8px;
  height: 8px;
  background: #999;
  border-radius: 50%;
  display: inline-block;
  animation: typingAnimation 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}
.typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typingAnimation {
  0%,
  80%,
  100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ===== CHAT INPUT ===== */
.chat-input-container {
  position: sticky;
  bottom: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 1rem;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.1);
  z-index: 100;
  margin-top: 1rem;
}

:root[data-theme="dark"] .chat-input-container {
  background: rgba(30, 30, 30, 0.95);
}

.chat-input-wrapper {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  padding: 1rem 1.5rem;
  border: 2px solid #e0e4f0;
  border-radius: 50px;
  font-size: 1rem;
  resize: none;
  min-height: 56px;
  max-height: 200px;
  transition: var(--transition);
  font-family: inherit;
  direction: rtl;
  color: var(--text-color);
  background: var(--card-bg);
}

:root[data-theme="dark"] .chat-input {
  border-color: #444;
  background: #252525;
  color: #e0e0e0;
}

.chat-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(93, 95, 239, 0.2);
  outline: none;
}

.send-btn,
.history-btn,
.new-chat-btn,
.attach-file-btn {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  color: white;
  border: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  box-shadow: 0 4px 15px rgba(93, 95, 239, 0.3);
}

.send-btn:hover,
.history-btn:hover,
.new-chat-btn:hover,
.attach-file-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(93, 95, 239, 0.4);
}

.send-btn:active,
.history-btn:active,
.new-chat-btn:active,
.attach-file-btn:active {
  transform: scale(0.95);
}

.history-btn,
.new-chat-btn,
.attach-file-btn {
  background: white;
  border: 2px solid #e0e4f0;
  color: var(--primary-color);
}

:root[data-theme="dark"] .history-btn,
:root[data-theme="dark"] .new-chat-btn,
:root[data-theme="dark"] .attach-file-btn {
  background: #252525;
  border-color: #444;
  color: var(--primary-color);
}

.history-btn:hover,
.new-chat-btn:hover,
.attach-file-btn:hover {
  background: var(--hover-color);
  border-color: var(--primary-color);
  transform: translateY(-2px) scale(1.02);
}

:root[data-theme="dark"] .history-btn:hover,
:root[data-theme="dark"] .new-chat-btn:hover,
:root[data-theme="dark"] .attach-file-btn:hover {
  background: var(--hover-color);
  border-color: var(--primary-color);
  transform: translateY(-2px) scale(1.02);
}

:root[data-theme="dark"] .hljs {
  background: #141414 !important;
  color: #d2d2d2 !important;
}

.raw-layer {
  display: none;
}

.new-chat-btn:hover {
  background-color: rgba(0, 255, 242, 0.288);
}

:root[data-theme="dark"] .new-chat-btn:hover {
  background-color: rgb(160, 183, 181);
  color: #0b1020;
}

.new-chat-btn:active,
.history-btn:active,
.attach-file-btn:active {
  transform: translateY(0) scale(1);
}

/* ===== HISTORY PANEL ===== */
.history-panel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.history-panel.active {
  opacity: 1;
  pointer-events: all;
}

.history-content {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transform: translateY(20px);
  transition: transform 0.3s ease;
  border: #764ba2 solid 5px;
}

.history-panel.active .history-content {
  transform: translateY(0);
}

.history-header {
  padding: 1.5rem;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

:root[data-theme="dark"] .history-header {
  border-color: #444;
}

.history-header h2 {
  color: var(--primary-color);
  font-size: 1.5rem;
  margin: 0;
}

.history-controls {
  display: flex;
  gap: 0.5rem;
}

.clear-history {
  background: #ec7e87;
  border: none;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.3s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: "Vazirmatn", sans-serif;
}

.clear-history:hover {
  background: #ff2e43;
}

.close-history {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #888;
  cursor: pointer;
  transition: color 0.2s;
  width: auto;
}

:root[data-theme="dark"] .close-history {
  color: #bbb;
}

.close-history:hover {
  color: var(--primary-color);
}

.history-list {
  padding: 1rem;
}

.history-item {
  padding: 1rem;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: var(--transition);
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

:root[data-theme="dark"] .history-item {
  border-color: #444;
  background: #252525;
}

.history-item:hover {
  background: #f5f7ff;
}

:root[data-theme="dark"] .history-item:hover {
  background: #2d2d38;
}

.history-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.history-item-title {
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: var(--text-color);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.history-item-time {
  font-size: 0.85rem;
  color: #777;
}

:root[data-theme="dark"] .history-item-time {
  color: #aaa;
}

.history-item.live {
  border-color: var(--primary-color);
  box-shadow: 0 2px 8px rgba(93, 95, 239, 0.15);
}

.history-live-badge {
  display: inline-block;
  margin-right: 0.5rem;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  color: #fff;
  border-radius: 8px;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
}

.no-history {
  text-align: center;
  padding: 2rem;
  color: #777;
}

:root[data-theme="dark"] .no-history {
  color: #aaa;
}

/* ===== ATTACH FILE MODAL ===== */
.attach-file-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  backdrop-filter: blur(5px);
}

.attach-file-modal.active {
  opacity: 1;
  visibility: visible;
}

.attach-file-content {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  transform: translateY(30px);
  transition: transform 0.3s ease;
}

.attach-file-modal.active .attach-file-content {
  transform: translateY(0);
}

.attach-file-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  color: white;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
}

.attach-file-header h2 {
  margin: 0;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.close-attach-file {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: var(--transition);
}

.close-attach-file:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

.attach-file-body {
  padding: 2rem;
}

.attach-warning {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 25px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  color: #856404;
}

:root[data-theme="dark"] .attach-warning {
  background: #332701;
  border-color: #856404;
  color: #ffd54f;
}

.attach-warning i {
  font-size: 1.2rem;
  margin-top: 2px;
}

.attach-warning p {
  margin: 0;
  line-height: 1.6;
}

.upload-btn {
  display: block;
  width: 100%;
  padding: 25px;
  background: linear-gradient(135deg, #3498db, #2ecc71);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  margin: 15px 0;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
  text-align: center;
}

.upload-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(52, 152, 219, 0.3);
  background: linear-gradient(135deg, #2980b9, #27ae60);
}

.upload-btn:active {
  transform: translateY(0);
}

.supported-formats {
  font-size: 13px;
  color: #7f8c8d;
  margin-top: 10px;
  text-align: center;
}

.progress-container {
  margin: 10px 0;
  padding: 20px;
  background: linear-gradient(135deg, #fff8e1, #e3f2fd);
  border-radius: 10px;
  display: none;
  border-right: 4px solid #3498db;
}

:root[data-theme="dark"] .progress-container {
  background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  margin-top: 15px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2ecc71, #3498db);
  width: 0%;
  transition: width 0.5s ease;
  border-radius: 4px;
}

.stats {
  display: flex;
  justify-content: space-between;
  margin-top: 15px;
  font-size: 13px;
  color: #7f8c8d;
}

.file-list {
  margin-top: 20px;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 10px;
  border: 2px dashed #dee2e6;
}

:root[data-theme="dark"] .file-list {
  background: #252525;
  border-color: #444;
}

.file-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #e9ecef;
}

:root[data-theme="dark"] .file-list-header {
  border-color: #444;
}

.clear-all-btn {
  background: #95a5a6;
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s ease;
}

.clear-all-btn:hover {
  background: #7f8c8d;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  margin: 8px 0;
  background: white;
  border-radius: 8px;
  border: 1px solid #e1e5eb;
  transition: all 0.2s ease;
}

:root[data-theme="dark"] .file-item {
  background: #1e1e1e;
  border-color: #444;
}

.file-item:hover {
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.05);
  transform: translateX(-3px);
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.file-icon {
  font-size: 20px;
}

.file-details {
  display: flex;
  flex-direction: column;
}

.file-name {
  font-weight: 600;
  color: #2c3e50;
}

:root[data-theme="dark"] .file-name {
  color: #e0e0e0;
}

.file-meta {
  font-size: 12px;
  color: #7f8c8d;
  display: flex;
  gap: 15px;
  margin-top: 3px;
}

.remove-btn {
  padding: 6px 15px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
}

.remove-btn:hover {
  background: #c0392b;
  transform: scale(1.05);
}

.drag-hint {
  text-align: center;
  color: #7f8c8d;
  font-size: 14px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #f8f9fa;
  border: 1px dashed #dee2e6;
}

:root[data-theme="dark"] .drag-hint {
  background: #252525;
  border-color: #444;
}

.attach-file-actions {
  display: flex;
  gap: 10px;
  margin-top: 25px;
}

.attach-analyze-btn {
  flex: 1;
  padding: 18px;
  background: linear-gradient(135deg, #9b59b6, #e74c3c);
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(155, 89, 182, 0.2);
}

.attach-analyze-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(155, 89, 182, 0.3);
  background: linear-gradient(135deg, #8e44ad, #c0392b);
}

.attach-analyze-btn:disabled {
  background: #bdc3c7;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.attach-cancel-btn {
  padding: 18px 30px;
  background: #95a5a6;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.attach-cancel-btn:hover {
  background: #7f8c8d;
}

#modal-customPrompt {
  width: 100%;
  height: 100px;
  margin-top: 20px;
  padding: 15px;
  border: 2px solid #e1e5eb;
  border-radius: 10px;
  resize: vertical;
  font-family: inherit;
  font-size: 15px;
  transition: border-color 0.3s ease;
  background: #f8f9fa;
}

:root[data-theme="dark"] #modal-customPrompt {
  background: #252525;
  border-color: #444;
  color: #e0e0e0;
}

#modal-customPrompt:focus {
  outline: none;
  border-color: #3498db;
  background: white;
}

:root[data-theme="dark"] #modal-customPrompt:focus {
  background: #1e1e1e;
}

/* ===== FIRST VISIT POPUP ===== */
.first-visit-popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.first-visit-popup.active {
  opacity: 1;
  pointer-events: all;
}

.first-visit-content {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 640px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transform: translateY(20px) scale(0.98);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  animation: popIn 0.35s ease forwards;
}

.first-visit-popup.active .first-visit-content {
  transform: translateY(0) scale(1);
  box-shadow: 0 15px 40px rgba(93, 95, 239, 0.25);
}

.first-visit-content::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: var(--border-radius) var(--border-radius) 0 0;
  background: linear-gradient(90deg, #5d5fef, #7e57c2, #5d5fef);
  filter: saturate(120%);
}

.first-visit-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

:root[data-theme="dark"] .first-visit-header {
  border-color: #444;
}

.first-visit-headline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.first-visit-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  box-shadow: 0 6px 16px rgba(93, 95, 239, 0.35);
}

.first-visit-title {
  font-size: 1.2rem;
  color: var(--primary-color);
}

.close-first-visit {
  background: none;
  border: none;
  font-size: 1.4rem;
  color: #888;
  cursor: pointer;
  transition: color 0.2s;
}

:root[data-theme="dark"] .close-first-visit {
  color: #bbb;
}

.close-first-visit:hover {
  color: var(--primary-color);
}

.first-visit-body {
  padding: 1.25rem 1.25rem 0.5rem;
  font-size: 1.05rem;
  line-height: 1.9;
}

.first-visit-body p {
  margin-bottom: 0.9rem;
}

.first-visit-body p:first-child {
  font-size: 1.25rem;
  text-align: center;
}

.first-visit-warning {
  color: #c62828;
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
}

.first-visit-footer {
  padding: 1rem;
  display: flex;
  justify-content: center;
}

.first-visit-close-btn {
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  color: white;
  border: none;
  border-radius: 50px;
  padding: 0.7rem 1.35rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.first-visit-close-btn:hover {
  transform: translateY(-2px);
}

.first-visit-close-btn i {
  margin-left: 0.4rem;
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===== MOBILE ADS ===== */
.mobile-in-reply-ad {
  display: none;
  margin: 1.5rem auto;
  padding: 1rem;
  background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
  border-radius: 12px;
  color: white;
  text-align: center;
  max-width: 500px;
}

/* ===== SCROLLBAR STYLES ===== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 10px;
}

:root[data-theme="dark"] ::-webkit-scrollbar-track {
  background: #333;
}

::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--secondary-color);
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1024px) {
  .model-sidebar {
    order: 2;
    width: 100%;
    height: auto;
    position: static;
    margin-top: 1rem;
    max-height: 400px;
  }
  .ads-sidebar {
    display: none;
  }
  .mobile-in-reply-ad {
    display: block;
  }
  .chat-container {
    order: 1;
  }
  .models-list {
    max-height: 250px;
  }
}

@media (max-width: 768px) {
  body,
  html {
    height: 100%;
    overflow: hidden;
  }

  .container {
    height: 100%;
    display: flex;
    flex-direction: column;
  }

  .chat-header h1 {
    font-size: 1.5rem;
  }

  .chat-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
  }

  .chat-input-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--background-color);
    padding: 10px;
    border-top: 1px solid var(--border-color);
  }

  .message {
    max-width: 95%;
    padding: 0.8rem 1.2rem;
    font-size: 0.95rem;
  }

  .chat-input {
    padding: 0.8rem 1.2rem;
    min-height: 48px;
  }
  .send-btn,
  .history-btn,
  .new-chat-btn,
  .attach-file-btn {
    width: 48px;
    height: 48px;
  }

  .attach-file-content {
    width: 95%;
    max-height: 85vh;
    margin: 10px;
  }

  .attach-file-actions {
    flex-direction: column;
  }

  .attach-analyze-btn,
  .attach-cancel-btn {
    width: 100%;
  }
}
/* ===== ATTACH FILE MODAL BUTTONS FONT  ===== */
.attach-analyze-btn,
.attach-cancel-btn {
  font-family: "Vazirmatn", "Iran Sans", "Segoe UI", Tahoma, Geneva, Verdana,
    sans-serif;
}

.upload-btn {
  font-family: "Vazirmatn", "Iran Sans", "Segoe UI", Tahoma, Geneva, Verdana,
    sans-serif;
}

.clear-all-btn {
  font-family: "Vazirmatn", "Iran Sans", "Segoe UI", Tahoma, Geneva, Verdana,
    sans-serif;
}

.remove-btn {
  font-family: "Vazirmatn", "Iran Sans", "Segoe UI", Tahoma, Geneva, Verdana,
    sans-serif;
}

/* استایل دکمه کپی کل پیام در هدر */
.copy-message-btn {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: inherit;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  font-family: "Vazirmatn", sans-serif;
  margin-right: auto;
}

.bot-message .copy-message-btn {
  background: rgba(93, 95, 239, 0.1);
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.copy-message-btn:hover {
  background: var(--primary-color);
  color: white;
}

/* استایل دکمه کپی کد داخل باکس کد */
.copy-code-btn {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #444;
  color: #fff;
  border: none;
  padding: 5px 10px;
  font-size: 0.7rem;
  border-radius: 5px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s, background 0.2s;
  z-index: 10;
  font-family: "Vazirmatn", sans-serif;
}

.copy-code-btn:hover {
  opacity: 1;
  background: var(--primary-color);
}

.copy-code-btn.copied {
  background: #4caf50 !important;
}

/* اصلاح باکس کد برای جا دادن دکمه */
.message-content pre {
  position: relative;
  padding-top: 40px !important;
}

:root[data-theme="dark"] .copy-code-btn {
  background: #333;
  border: 1px solid #555;
}

/* ===== CUSTOM CONFIRMATION MODAL ===== */
.confirmation-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1001;
  backdrop-filter: blur(3px);
}

.confirmation-content {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  width: 90%;
  max-width: 400px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  transform: translateY(20px);
  transition: transform 0.3s ease;
  animation: modalAppear 0.3s forwards;
}

@keyframes modalAppear {
  to {
    transform: translateY(0);
  }
}

.confirmation-header {
  padding: 1.5rem 1.5rem 0.5rem;
  text-align: center;
  border-bottom: 1px solid var(--border-color);
}

.warning-icon {
  font-size: 2.5rem;
  color: #ff9800;
  margin-bottom: 0.5rem;
}

.confirmation-header h3 {
  color: var(--text-color);
  margin: 0;
}

.confirmation-body {
  padding: 1.5rem;
  text-align: center;
}

.confirmation-body p {
  margin: 0 0 1rem 0;
  color: var(--text-color);
  line-height: 1.6;
}

.warning-text {
  color: #ff5252 !important;
  font-weight: 500;
  font-size: 0.9rem;
}

.confirmation-footer {
  padding: 1rem 1.5rem 1.5rem;
  display: flex;
  justify-content: center;
  gap: 1rem;
}

.btn-cancel,
.btn-confirm {
  padding: 0.7rem 1.5rem;
  border-radius: 50px;
  font-family: "Vazirmatn", sans-serif;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
}

.btn-cancel {
  background: #f5f5f5;
  color: #333;
}

:root[data-theme="dark"] .btn-cancel {
  background: #333;
  color: #e0e0e0;
}

.btn-cancel:hover {
  background: #e0e0e0;
}

:root[data-theme="dark"] .btn-cancel:hover {
  background: #444;
}

.btn-confirm {
  background: linear-gradient(135deg, #ff5252, #b33939);
  color: white;
  box-shadow: 0 4px 12px rgba(255, 82, 82, 0.3);
}

.btn-confirm:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(255, 82, 82, 0.4);
}

.history-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.delete-history-item {
  background: #ff5252;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 5px rgba(255, 82, 82, 0.3);
}

.delete-history-item:hover {
  background: #ff0000;
  transform: scale(1.1);
  box-shadow: 0 4px 8px rgba(255, 82, 82, 0.4);
}

.delete-history-item:active {
  transform: scale(0.95);
}

.delete-history-item i {
  color: white;
  font-size: 14px;
}

:root[data-theme="dark"] .delete-history-item {
  background: #ff5252;
  box-shadow: 0 2px 5px rgba(255, 82, 82, 0.2);
}

:root[data-theme="dark"] .delete-history-item:hover {
  background: #ff0000;
  box-shadow: 0 4px 8px rgba(255, 82, 82, 0.3);
}

/* استایل مشترک برای دکمه‌های هدر */
.action-btn {
  background: var(--secondary-bg);
  border: 1px solid var(--border-color);
  color: var(--text-color);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 1.1rem;
}

.action-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* هماهنگی چیدمان دکمه‌ها در هدر */
.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.header-actions .attach-file-btn {
  width: 38px;
  height: 38px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: var(--transition);
}

.header-actions .attach-file-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* در حالت موبایل مثل دکمه تاریخچه */
@media (max-width: 768px) {
  .header-actions .attach-file-btn {
    background: white;
    border: 2px solid #e0e4f0;
    color: var(--primary-color);
  }

  :root[data-theme="dark"] .header-actions .attach-file-btn {
    background: #252525;
    border-color: #444;
    color: var(--primary-color);
  }
}

/* تنظیمات مخصوص موبایل */
@media (max-width: 768px) {
  .chat-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(
      135deg,
      var(--primary-color),
      var(--secondary-color)
    );
    color: white;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    padding: 1.5rem;
    text-align: center;
    box-shadow: 0 4px 12px rgba(93, 95, 239, 0.2);
  }

  .mobile-only {
    display: flex !important;
    z-index: 2;
  }

  .chat-input-wrapper .new-chat-btn,
  .chat-input-wrapper .history-btn,
  .chat-input-wrapper .attach-file-btn {
    display: none;
  }

  .chat-input-wrapper .model-sidebar-btn {
    display: flex;
  }
}

@media (min-width: 769px) {
  .mobile-only {
    display: none !important;
  }

  .chat-input-wrapper .model-sidebar-btn {
    display: none;
  }
}

/* ===== MOBILE MODEL SIDEBAR ===== */
.model-sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

.model-sidebar-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.model-sidebar-mobile {
  background: var(--card-bg);
  width: 320px;
  max-width: 90%;
  height: 100%;
  overflow-y: auto;
  box-shadow: -5px 0 15px rgba(0, 0, 0, 0.1);
  position: absolute;
  top: 0;
  right: 0;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  border-radius: 16px 0 0 16px;
  z-index: 1001;
}

.model-sidebar-overlay.active .model-sidebar-mobile {
  transform: translateX(0);
}

body.sidebar-open {
  overflow: hidden;
}

.model-sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  color: white;
  border-radius: 16px 0 0 0;
}

.model-sidebar-header h3 {
  margin: 0;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.close-model-sidebar {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: var(--transition);
}

.close-model-sidebar:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

#search-model-mobile {
  width: 100%;
  padding: 0.85rem 2.5rem 0.85rem 1rem;
  border: 1px solid #ddd;
  border-radius: 50px;
  font-size: 0.95rem;
  background-color: #f8f9fa;
  transition: var(--transition);
  font-family: inherit;
  color: var(--text-color);
  margin-bottom: 1rem;
}

:root[data-theme="dark"] #search-model-mobile {
  background-color: #2d2d2d;
  border-color: #444;
  color: #e0e0e0;
}

#search-model-mobile:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(93, 95, 239, 0.2);
  outline: none;
}

#selected-model-display-mobile {
  padding: 10px;
  background-color: var(--card-bg);
  border: 1px solid var(--primary-color);
  border-radius: 8px;
  font-size: 1rem;
  color: var(--text-color);
  display: inline-block;
  width: 90%;
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: center;
}

#selected-model-display-mobile:hover {
  background-color: var(--hover-color);
}

.models-list-mobile {
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  border: 3px solid var(--border-color);
  border-radius: 8px;
  padding: 5px;
  margin-top: 1rem;
}

.model-group-mobile {
  margin-bottom: 1.5rem;
}

.model-group-header-mobile {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background-color: var(--bg-color);
  border-radius: 5px;
  margin-top: 10px;
  font-size: 1rem;
  color: #555;
  border-bottom: 1px solid #eee;
}

:root[data-theme="dark"] .model-group-header-mobile {
  color: #bbb;
  border-color: #444;
}

.model-group-header-mobile:hover {
  background-color: var(--hover-color);
}

.model-group-header-mobile i {
  transition: transform 0.3s ease;
}

.model-group-mobile.collapsed .model-group-header-mobile i {
  transform: rotate(-90deg);
}

.model-group-mobile.collapsed .model-items-container-mobile {
  display: none;
}

.model-items-container-mobile {
  padding-top: 5px;
}

.model-item-mobile {
  padding: 0.75rem 1rem;
  border-radius: 10px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid #eee;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
}

:root[data-theme="dark"] .model-item-mobile {
  border-color: #444;
  background: #252525;
}

.model-item-mobile:hover {
  background: var(--hover-color);
  border-color: var(--primary-color);
}

.model-item-mobile.active {
  background: linear-gradient(
    135deg,
    rgba(93, 95, 239, 0.18),
    rgba(126, 87, 194, 0.18)
  );
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(93, 95, 239, 0.35) inset,
    0 4px 12px rgba(93, 95, 239, 0.25);
  position: relative;
}

.model-item-mobile.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary-color);
  border-radius: 4px 0 0 4px;
}

.btn-model-sidebar {
  background: white;
  border: 2px solid #e0e4f0;
  color: var(--primary-color);
}

:root[data-theme="dark"] .btn-model-sidebar {
  background: #252525;
  border-color: #444;
  color: var(--primary-color);
}

.btn-model-sidebar:hover {
  background: var(--hover-color);
  border-color: var(--primary-color);
  transform: translateY(-2px) scale(1.02);
}

:root[data-theme="dark"] .btn-model-sidebar:hover {
  background: var(--hover-color);
  border-color: var(--primary-color);
  transform: translateY(-2px) scale(1.02);
}

@media (max-width: 768px) {
  .chat-input-wrapper {
    gap: 0.5rem;
  }
  .model-sidebar {
    display: none;
  }
  .search-container {
    margin-top: 0.8rem;
  }
  .chat-input-wrapper .btn-model-sidebar {
    display: flex;
  }

  .chat-input {
    flex: 1;
    padding: 1rem 1.5rem;
    border: 2px solid #e0e4f0;
    border-radius: 50px;
    font-size: 1rem;
    resize: none;
    min-height: 56px;
    max-height: 200px;
    transition: var(--transition);
    font-family: inherit;
    direction: rtl;
    color: var(--text-color);
    background: var(--card-bg);
  }
}
/* ===== دکمه Attach File در دسکتاپ ===== */
.attach-file-btn {
  background: white;
  border: 2px solid #e0e4f0;
  color: var(--primary-color);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

:root[data-theme="dark"] .attach-file-btn {
  background: #252525;
  border-color: #444;
  color: var(--primary-color);
}

.attach-file-btn:hover {
  background: var(--hover-color);
  border-color: var(--primary-color);
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 4px 12px rgba(93, 95, 239, 0.2);
}

:root[data-theme="dark"] .attach-file-btn:hover {
  background: rgba(126, 126, 255, 0.1);
  border-color: var(--primary-color);
  transform: translateY(-2px) scale(1.02);
}

.attach-file-btn:active {
  transform: translateY(0) scale(1);
}

/* ===== استایل دکمه Attach File در موبایل (حالت تاریک) ===== */
@media (max-width: 768px) {
  .attach-file-btn {
    width: 48px;
    height: 48px;
  }

  :root[data-theme="dark"] .attach-file-btn {
    background: #252525;
    border-color: #444;
    color: var(--primary-color);
  }

  :root[data-theme="dark"] .attach-file-btn:hover {
    background: rgba(126, 126, 255, 0.1);
    border-color: var(--primary-color);
  }
}

/* ===== استایل هشدار در مودال ===== */
.attach-warning p {
  margin: 0;
  line-height: 1.6;
  text-align: right;
  direction: rtl;
}

.attach-warning strong {
  color: #d32f2f;
}

:root[data-theme="dark"] .attach-warning strong {
  color: #ff5252;
}

/* ===== حذف textarea از مودال ===== */
/* حذف استایل‌های مربوط به textarea در مودال */
#modal-customPrompt {
  display: none;
}

/* ===== تنظیمات مودال بدون پرامپت ===== */
.attach-file-actions {
  display: flex;
  gap: 10px;
  margin-top: 25px;
  flex-direction: column;
}

@media (min-width: 768px) {
  .attach-file-actions {
    flex-direction: row;
  }
}

.attach-analyze-btn {
  flex: 1;
  padding: 18px;
  background: linear-gradient(
    135deg,
    var(--primary-color),
    var(--secondary-color)
  );
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(93, 95, 239, 0.2);
}

.attach-analyze-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(93, 95, 239, 0.3);
  background: linear-gradient(135deg, #4d4fe6, #6b46c1);
}

.attach-analyze-btn:disabled {
  background: #bdc3c7;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.attach-cancel-btn {
  padding: 18px;
  background: #95a5a6;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 600;
  transition: all 0.3s ease;
  flex: 1;
}

.attach-cancel-btn:hover {
  background: #7f8c8d;
  transform: translateY(-2px);
}

@media (min-width: 768px) {
  .attach-cancel-btn {
    flex: 0 0 auto;
    padding: 18px 30px;
  }
}

/* ===== استایل جدید برای نشان دادن فایل‌های انتخاب شده در نوار چت ===== */
.attached-files-indicator {
  background: #f0f4ff;
  border: 2px dashed #5d5fef;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 15px;
  display: none;
  animation: fadeInUp 0.3s ease-out;
}

:root[data-theme="dark"] .attached-files-indicator {
  background: #2a2a35;
  border-color: #7e7eff;
}

.attached-files-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.attached-files-title {
  font-weight: 600;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 8px;
}

.attached-files-count {
  background: var(--primary-color);
  color: white;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
}

.attached-files-clear {
  background: none;
  border: none;
  color: #ff5252;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.attached-files-clear:hover {
  text-decoration: underline;
}

.attached-files-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.attached-file-tag {
  background: rgba(93, 95, 239, 0.1);
  border: 1px solid rgba(93, 95, 239, 0.3);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 200px;
}

:root[data-theme="dark"] .attached-file-tag {
  background: rgba(126, 126, 255, 0.1);
  border-color: rgba(126, 126, 255, 0.3);
}

.attached-file-icon {
  font-size: 14px;
}

.attached-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.attached-file-remove {
  background: none;
  border: none;
  color: #ff5252;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.attached-file-remove:hover {
  background: rgba(255, 82, 82, 0.1);
}
/* ===== MOBILE ATTACH FILE BUTTON - SAME AS HISTORY BUTTON ===== */
@media (max-width: 768px) {
  .chat-header .attach-file-btn.action-btn {
    background: var(--secondary-bg);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    box-shadow: none;
  }

  :root[data-theme="dark"] .chat-header .attach-file-btn.action-btn {
    background: var(--secondary-bg);
    border-color: 1px solid #444;
    color: var(--text-color);
  }

  .chat-header .attach-file-btn.action-btn:hover {
    background: var(--hover-color);
    border-color: var(--primary-color);
    transform: translateY(-2px) scale(1.02);
  }

  :root[data-theme="dark"] .chat-header .attach-file-btn.action-btn:hover {
    background: var(--hover-color);
    border-color: var(--primary-color);
  }
}
