﻿body.ic-lorex .ic-header,
body.ic-lorex .ic-footer,
body.ic-lorex .ic-tabbar,
body.ic-lorex .ic-tabbar-dock {
  display: none !important;
}

body.ic-lorex {
  padding-bottom: 0 !important;
}

.ic-lorex {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  background: #fff;
  direction: rtl;
  overflow: hidden;
}

body.ic-lorex.ic-lorex-kb-open .ic-lorex {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100%;
  z-index: 40;
}

/* Ù‡Ø¯Ø± */
.ic-lorex-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  padding: 8px 16px;
  border-bottom: 1px solid #e5e5ea;
  background: #fff;
  position: relative;
  flex-shrink: 0;
}

.ic-lorex-close {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  z-index: 2;
}

.ic-lorex-close-icon {
  background-color: #418bff;
  width: 24px;
  height: 24px;
}

.ic-lorex-header-title {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-family: "IRANYekan", Tahoma, sans-serif;
  font-size: 11.5px;
  color: #333;
  pointer-events: none;
}

/* Ù†Ø§Ø­ÛŒÙ‡ Ù¾ÛŒØ§Ù…â€ŒÙ‡Ø§ */
.ic-lorex-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 0 0 28px;
}

/* Ø§ÙˆØ±Ù„ÛŒ Ù„ÙˆØ¯/Ø®Ø·Ø§ */
.ic-lorex-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  z-index: 10;
}

.ic-lorex-overlay[hidden] {
  display: none;
}

.ic-lorex-overlay-inner {
  text-align: center;
}

.ic-lorex-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e5e9f2;
  border-top-color: #418bff;
  border-radius: 50%;
  animation: ic-lorex-spin 0.7s linear infinite;
  margin: 0 auto 12px;
}

@keyframes ic-lorex-spin {
  to { transform: rotate(360deg); }
}

.ic-lorex-err-box[hidden] { display: none; }

.ic-lorex-err-text {
  font-size: 13px;
  color: #6b7a94;
  margin-bottom: 12px;
}

.ic-lorex-retry-btn {
  background: #418bff;
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 8px 20px;
  font-size: 12px;
  cursor: pointer;
}

/* خوش‌آمدگویی — مثل AichatScreen */
.ic-lorex-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 0 20px 24px;
  text-align: center;
}

.ic-lorex-welcome.is-hidden { display: none; }

.ic-lorex-welcome-title {
  width: 100%;
  max-width: calc(100vw - 76px);
  font-family: "IRANYekan", Tahoma, sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  color: #2d3a4a;
  margin: 0 0 12px;
  text-align: center;
}

.ic-lorex-welcome-text {
  font-family: "IRANYekan", Tahoma, sans-serif;
  font-size: 12px;
  font-weight: 400;
  color: #919aaf;
  line-height: 24px;
  margin: 0 0 5px;
  max-width: 280px;
}

/* لیست پیام‌ها — مثل AichatScreen: چسبیده به راست (flex-start در RTL) */
.ic-lorex-msgs {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 10px 18px 20px 18px;
  box-sizing: border-box;
}

.ic-lorex-msg-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: auto;
  max-width: 88%;
  box-sizing: border-box;
}

.ic-lorex-msg-row + .ic-lorex-msg-row {
  margin-top: 5px;
}

.ic-lorex-msg-row.is-user + .ic-lorex-msg-row.is-ai {
  margin-top: 20px;
}

.ic-lorex-msg-row.is-ai + .ic-lorex-msg-row.is-user {
  margin-top: 12px;
}

.ic-lorex-msg-row.is-user {
  max-width: 88%;
}

.ic-lorex-msg-row.is-ai {
  max-width: 90%;
  width: 90%;
  margin-bottom: 6px;
}

.ic-lorex-msg-row.is-thinking {
  margin-bottom: 50px;
}

.ic-lorex-day-sep {
  align-self: center;
  background: #f4f7fc;
  padding: 4px 12px 6px;
  border-radius: 12px;
  font-size: 10px;
  color: #4c5662;
  margin: 10px 0;
}

.ic-lorex-bubble {
  width: fit-content;
  max-width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  border-radius: 16px;
  font-family: "IRANYekan", Tahoma, sans-serif;
  font-size: 11.8px;
  line-height: 1.8;
  word-break: break-word;
  text-align: right;
  direction: rtl;
}

.ic-lorex-msg-row.is-user .ic-lorex-bubble {
  background: #e9edfe;
  color: #283568;
  border-radius: 16px 16px 4px 16px;
  white-space: pre-wrap;
  padding: 12px 14px;
  align-self: flex-start;
}

.ic-lorex-msg-row.is-ai .ic-lorex-bubble {
  width: 100%;
  background: transparent;
  color: #333;
  padding: 4px 0;
  padding-top: 10px;
  border-radius: 0;
  align-self: stretch;
}

/* ÙˆØ¶Ø¹ÛŒØª Ø®Ø·Ø§/Ø§Ù†ØªØ¸Ø§Ø± */
.ic-lorex-msg-meta {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.ic-lorex-msg-err {
  font-size: 10px;
  color: #d18a86;
  cursor: pointer;
}

/* Ø­Ø¨Ø§Ø¨ Â«Ø¯Ø±Ø­Ø§Ù„ ØªÙÚ©Ø±Â» */
.ic-lorex-thinking {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-start;
  padding: 8px 0;
  color: #afafaf;
  font-family: "IRANYekan", Tahoma, sans-serif;
  font-size: 11px;
}

.ic-lorex-thinking-dots {
  display: flex;
  gap: 4px;
}

.ic-lorex-thinking-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d0d5e0;
  display: inline-block;
  animation: ic-lorex-dot-bounce 1.2s infinite ease-in-out;
}

.ic-lorex-thinking-dots span:nth-child(2) { animation-delay: .2s; }
.ic-lorex-thinking-dots span:nth-child(3) { animation-delay: .4s; }

@keyframes ic-lorex-dot-bounce {
  0%, 80%, 100% { transform: scale(1); opacity: .5; }
  40% { transform: scale(1.3); opacity: 1; }
}

/* CTA ارتقا */
.ic-lorex-limit-cta {
  padding: 0 12px 18px;
  flex-shrink: 0;
}

.ic-lorex-limit-cta[hidden] { display: none; }

.ic-lorex-dock:has(.ic-lorex-limit-cta:not([hidden])) .ic-lorex-suggestions {
  display: none;
}

.ic-lorex-limit-box {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: #f3f8fe;
  border-radius: 20px;
  padding: 14px 20px 14px 16px;
  box-sizing: border-box;
}

.ic-lorex-limit-title {
  font-family: "IRANYekan", Tahoma, sans-serif;
  font-size: 14px;
  font-weight: 700;
  color: #2d3a4a;
  text-align: right;
  margin: 0 0 5px;
}

.ic-lorex-limit-desc {
  font-family: "IRANYekan", Tahoma, sans-serif;
  font-size: 12px;
  color: #4c5662;
  text-align: right;
  line-height: 23px;
  margin: 0 0 12px;
}

.ic-lorex-upgrade-btn {
  align-self: flex-end;
  display: inline-block;
  background: #4e91e6;
  color: #fff;
  border-radius: 14px;
  padding: 9px 16px;
  margin-bottom: 5px;
  font-family: "IRANYekan", Tahoma, sans-serif;
  font-size: 10px;
  font-weight: 400;
  text-decoration: none;
  flex-shrink: 0;
}

/* داک پایین — داخل flex تا با کیبورد جمع شود */
.ic-lorex-dock {
  position: relative;
  flex-shrink: 0;
  z-index: 5;
  background: #fff;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  touch-action: manipulation;
}

/* پیشنهادهای اولیه */
.ic-lorex-suggestions {
  padding: 5px 10px 12px 0;
  margin-bottom: 0;
  flex-shrink: 0;
  background: #fff;
  border-top: 1px solid transparent;
}

.ic-lorex-suggestions.is-hidden { display: none; }

.ic-lorex-suggestions-scroll {
  display: flex;
  flex-direction: row;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0 10px 2px;
}

.ic-lorex-suggestions-scroll::-webkit-scrollbar { display: none; }

.ic-lorex-sug-btn {
  flex-shrink: 0;
  background: #f3f8fe;
  color: #3e4d5b;
  border: none;
  border-radius: 22px;
  padding: 10px 18px;
  font-family: "IRANYekan", Tahoma, sans-serif;
  font-size: 11.5px;
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
}

.ic-lorex-sug-btn:active { opacity: 0.5; }

/* نوار ورودی — مثل اپ: اینپوت چپ، ارسال راست */
.ic-lorex-composer {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  direction: ltr;
  padding: 10px 8px;
  border-top: 1px solid #e5e5ea;
  background: #fff;
  flex-shrink: 0;
  touch-action: manipulation;
}

.ic-lorex-input {
  flex: 1;
  border: none;
  outline: none;
  background: #fff;
  border-radius: 20px;
  font-family: "IRANYekan", Tahoma, sans-serif;
  font-size: 12px;
  font-weight: 400;
  color: #2d3a4a;
  text-align: right;
  direction: rtl;
  resize: none;
  padding: 8px 5px;
  margin: 0 8px;
  line-height: 1.6;
  min-height: 38px;
  max-height: 17vh;
  overflow-y: auto;
  scrollbar-width: none;
  -webkit-appearance: none;
  appearance: none;
}

.ic-lorex-input::-webkit-scrollbar { display: none; }
.ic-lorex-input::placeholder {
  color: #919aaf;
  font-family: "IRANYekan", Tahoma, sans-serif;
  font-weight: 400;
}

.ic-lorex-send {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  order: 2;
}

.ic-lorex-send-icon {
  background-color: #bfccd4;
  width: 24px;
  height: 24px;
  transition: background-color 0.15s ease;
}

.ic-lorex-send.is-ready .ic-lorex-send-icon {
  background-color: #418bff;
}

.ic-lorex-send.is-busy {
  pointer-events: none;
  cursor: default;
}

.ic-lorex-send-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e5e9f2;
  border-top-color: #418bff;
  border-radius: 50%;
  animation: ic-lorex-spin 0.7s linear infinite;
}

.ic-lorex-send-spinner[hidden] { display: none; }
