/*
 * استایل‌های اختصاصی ابزار استخراج متن و گفتگوی تصویری (Image Chat & OCR)
 * سامانه rembg.ir
 */

.bg-rose {
  background: rgba(244, 63, 94, 0.12);
  color: #e11d48;
}

/* گرید اصلی اپلیکیشن */
.imgchat-app-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  align-items: start;
  margin-bottom: 40px;
}

@media (max-width: 960px) {
  .imgchat-app-grid {
    grid-template-columns: 1fr;
  }
}

/* سایدبار کناری */
.imgchat-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title::before {
  content: '';
  width: 4px;
  height: 16px;
  background: #e11d48;
  border-radius: 2px;
}

.model-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: #10b981;
  background: #ecfdf5;
  padding: 3px 10px;
  border-radius: 20px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  animation: pulseGreen 1.8s infinite;
}

@keyframes pulseGreen {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.3; transform: scale(0.8); }
}

#imgFileInput,
.sr-only {
  display: none !important;
  opacity: 0 !important;
  visibility: hidden !important;
  position: absolute !important;
  width: 0 !important;
  height: 0 !important;
  pointer-events: none !important;
}

/* دراپ‌زون عکس */
.img-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-subtle);
  transition: var(--transition);
  position: relative;
}

.img-dropzone:hover,
.img-dropzone.dragover {
  border-color: #e11d48;
  background: rgba(225, 29, 72, 0.04);
}

.dz-icon-wrap {
  color: #e11d48;
  margin-bottom: 8px;
}

.dz-main-text {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.dz-sub-text {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
}

.img-preview-box {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #f1f5f9;
}

.sidebar-img {
  width: 100%;
  max-height: 200px;
  object-fit: contain;
  display: block;
  background: #0f172a;
}

.btn-clear-img {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.btn-clear-img:hover {
  background: #e11d48;
}

.img-meta-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
  padding-top: 4px;
  border-top: 1px solid var(--border-light);
}

.meta-name {
  font-weight: 700;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
  text-align: left;
}

/* کارت اقدامات سریع */
.quick-actions-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

.quick-prompts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quick-prompt-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #ffffff;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  text-align: right;
  font-family: inherit;
}

.quick-prompt-btn:hover {
  border-color: #e11d48;
  background: rgba(225, 29, 72, 0.03);
  transform: translateY(-1px);
}

.qp-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.qp-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.qp-title {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-main);
}

.qp-desc {
  font-size: 11px;
  color: var(--text-muted);
}

/* پنجره اصلی چت */
.chat-box-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 600px;
  max-height: 720px;
  overflow: hidden;
}

.chat-header {
  padding: 16px 20px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bot-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: rgba(225, 29, 72, 0.1);
  border: 1.5px solid rgba(225, 29, 72, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.chat-bot-title {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

.chat-bot-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.btn-clear-chat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-clear-chat:hover {
  color: #e11d48;
  border-color: #fecdd3;
  background: #fff1f2;
}

/* بدنه چت */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
}

/* صفحه خوش‌آمدگویی */
.welcome-screen {
  margin: auto;
  max-width: 460px;
  text-align: center;
  padding: 30px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.welcome-icon {
  font-size: 2.5rem;
}

.welcome-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

.welcome-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

.welcome-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
  text-align: right;
}

.w-step {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e11d48;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  flex-shrink: 0;
}

.step-txt {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
}

/* فید پیام‌ها */
.messages-feed {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.msg-row {
  display: flex;
  gap: 10px;
  max-width: 86%;
  animation: fadeInMsg 0.2s ease;
}

@keyframes fadeInMsg {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-row.user {
  align-self: flex-start;
  flex-direction: row;
}

.msg-row.ai {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.msg-row.user .msg-avatar-icon {
  background: #3b82f6;
  color: #ffffff;
}

.msg-row.ai .msg-avatar-icon {
  background: #e11d48;
  color: #ffffff;
}

.msg-content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.7;
  word-wrap: break-word;
  position: relative;
}

.msg-row.user .msg-bubble {
  background: var(--primary);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(25, 75, 251, 0.2);
}

.msg-row.ai .msg-bubble {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-light);
  border-top-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.msg-bubble.is-error {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #e11d48;
}

.msg-bubble pre {
  background: #0f172a;
  color: #f8fafc;
  padding: 12px 14px;
  border-radius: 8px;
  direction: ltr;
  text-align: left;
  overflow-x: auto;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12.5px;
  margin: 8px 0;
}

.msg-bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Consolas', monospace;
  font-size: 0.9em;
  direction: ltr;
  display: inline-block;
}

.msg-row.user .msg-bubble code {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.msg-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--text-light);
  padding: 0 4px;
}

.btn-copy-bubble {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: var(--transition);
}

.btn-copy-bubble:hover {
  background: var(--bg-subtle);
  color: var(--primary);
}

/* انیمیشن تایپینگ لودینگ */
.typing-dots-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 4px;
}

.t-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e11d48;
  animation: typingBounce 1.2s infinite ease-in-out;
}

.t-dot:nth-child(2) { animation-delay: 0.2s; }
.t-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* نوار عکس الصاق شده */
.attached-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: rgba(225, 29, 72, 0.06);
  border-top: 1px solid rgba(225, 29, 72, 0.15);
}

.attached-thumb-img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border-light);
}

.attached-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: ltr;
}

.attached-tag {
  font-size: 11px;
  color: #e11d48;
  background: #ffffff;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 700;
  margin-right: auto;
}

/* ورودی پیام */
.chat-input-area {
  padding: 14px 18px;
  background: #ffffff;
  border-top: 1px solid var(--border-light);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-subtle);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  transition: var(--transition);
}

.chat-input-wrapper:focus-within {
  border-color: #e11d48;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.1);
}

.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-main);
  resize: none;
  max-height: 140px;
  min-height: 28px;
}

.btn-send-message {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #e11d48;
  color: #ffffff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-send-message:hover:not(:disabled) {
  background: #be123c;
  transform: translateY(-1px);
}

.btn-send-message:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

@media (max-width: 640px) {
  .chat-box-card {
    min-height: 480px;
    max-height: 85vh;
  }

  .sidebar-card {
    padding: 16px;
  }

  .chat-header {
    padding: 12px 14px;
  }

  .chat-body {
    padding: 14px;
  }

  .chat-input-area {
    padding: 10px 12px;
  }
}