/* ویجت چت آنلاین — حرفه‌ای، سمت چپ، زیر هدر */
:root {
  --nc-z: 1100;
  --nc-radius: 1.25rem;
}

.nc-launcher {
  position: fixed;
  right: 16px;
  left: auto;
  bottom: calc(5.85rem + env(safe-area-inset-bottom, 0px));
  z-index: var(--nc-z);
  width: 56px;
  height: 56px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  color: var(--brand, #100DD1);
  box-shadow:
    0 12px 28px rgba(15, 20, 40, 0.14),
    0 0 0 1px rgba(var(--brand-rgb, 16, 13, 209), 0.12);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.nc-launcher::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 20px;
  border: 2px solid rgba(var(--brand-rgb, 16, 13, 209), 0.35);
  opacity: 0;
  animation: nc-pulse 2.4s ease-out infinite;
  pointer-events: none;
}

.nc-launcher:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 16px 32px rgba(15, 20, 40, 0.18);
}

.nc-launcher.is-open {
  background: var(--brand, #100DD1);
  color: #fff;
  border-color: transparent;
}

.nc-launcher.is-open::after {
  display: none;
}

@keyframes nc-pulse {
  0% { opacity: 0.55; transform: scale(1); }
  70% { opacity: 0; transform: scale(1.18); }
  100% { opacity: 0; transform: scale(1.18); }
}

.nc-launcher .nc-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  left: auto;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #e11d48;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  box-shadow: 0 0 0 2px #fff;
}

.nc-launcher .nc-badge.is-on {
  display: inline-flex;
}

.nc-panel {
  position: fixed;
  right: 12px;
  left: auto;
  bottom: calc(8.4rem + env(safe-area-inset-bottom, 0px));
  z-index: calc(var(--nc-z) + 1);
  width: min(380px, calc(100vw - 24px));
  height: min(560px, calc(100vh - 9.5rem));
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(22px) saturate(1.45);
  -webkit-backdrop-filter: blur(22px) saturate(1.45);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--nc-radius);
  box-shadow: 0 24px 56px rgba(15, 20, 40, 0.2);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.nc-panel.is-open {
  display: flex;
  animation: nc-rise 0.22s ease-out;
}

@keyframes nc-rise {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.nc-head {
  color: #fff;
  padding: 0.9rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  background: linear-gradient(135deg, var(--brand, #100DD1), color-mix(in srgb, var(--brand, #100DD1) 55%, #0b1220)) !important;
  border: 0 !important;
  border-radius: 0 !important;
}

.nc-head-main {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.nc-avatar {
  position: relative;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.05rem;
}

.nc-online-dot {
  position: absolute;
  bottom: -1px;
  inset-inline-start: -1px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid rgba(255, 255, 255, 0.95);
}

.nc-head-copy {
  min-width: 0;
}

.nc-head strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.25;
  color: #fff !important;
}

.nc-head span {
  display: block;
  font-size: 0.74rem;
  opacity: 0.9;
  color: #fff !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nc-head-btn {
  border: 0;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  flex-shrink: 0;
}

.nc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.95rem;
  background:
    radial-gradient(ellipse 80% 50% at 0% 0%, rgba(var(--brand-rgb, 16, 13, 209), 0.06), transparent 55%),
    #f4f6fb;
}

.nc-bubble {
  max-width: 85%;
  margin-bottom: 0.7rem;
  padding: 0.7rem 0.85rem;
  border-radius: 1rem;
  background: #fff;
  border: 1px solid rgba(15, 20, 40, 0.05);
  box-shadow: 0 4px 14px rgba(15, 20, 40, 0.04);
}

.nc-bubble.is-staff {
  margin-inline-end: auto;
  margin-inline-start: 0;
  background: var(--brand, #100DD1);
  color: #fff;
  border-color: transparent;
}

.nc-bubble.is-user,
.nc-bubble.is-mine {
  margin-inline-start: auto;
  margin-inline-end: 0;
  background: #fff;
}

.nc-bubble-meta {
  font-size: 0.68rem;
  opacity: 0.72;
  margin-bottom: 0.2rem;
}

.nc-bubble-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.9rem;
  line-height: 1.55;
}

.nc-chat-img {
  max-width: 180px;
  border-radius: 0.65rem;
  display: block;
  margin-top: 0.35rem;
}

.nc-file {
  color: inherit;
  font-size: 0.85rem;
}

.nc-empty {
  text-align: center;
  color: #6b7280;
  padding: 2.2rem 0.75rem;
  font-size: 0.88rem;
  line-height: 1.7;
}

.nc-empty-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 0.75rem;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(var(--brand-rgb, 16, 13, 209), 0.1);
  color: var(--brand, #100DD1);
  font-size: 1.25rem;
}

.nc-typing {
  padding: 0 0.95rem 0.35rem;
  color: #6b7280;
  font-size: 0.76rem;
}

.nc-typing-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  margin-inline: 1px;
  border-radius: 50%;
  background: currentColor;
  animation: nc-dot 1.1s infinite ease-in-out;
}

.nc-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.nc-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes nc-dot {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.nc-emoji {
  display: none;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.15rem;
  padding: 0.5rem 0.65rem;
  border-top: 1px solid rgba(15, 20, 40, 0.06);
  max-height: 120px;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.92);
}

.nc-emoji.is-open { display: grid; }

.nc-emoji button {
  border: 0;
  background: transparent;
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 0.4rem;
}

.nc-composer {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  padding: 0.75rem 0.8rem;
  border-top: 1px solid rgba(15, 20, 40, 0.06);
  background: rgba(255, 255, 255, 0.95);
}

.nc-composer input[type="text"] {
  flex: 1;
  min-width: 0;
  height: 44px;
  border: 1px solid rgba(15, 20, 40, 0.08);
  border-radius: 999px;
  padding: 0 1rem;
  background: #f7f8fc;
  font-size: 0.9rem;
}

.nc-composer input[type="text"]:focus {
  outline: none;
  border-color: rgba(var(--brand-rgb, 16, 13, 209), 0.4);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb, 16, 13, 209), 0.12);
  background: #fff;
}

.nc-icon {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: #f1f3f8;
  color: #4b5563;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.nc-icon:hover {
  background: rgba(var(--brand-rgb, 16, 13, 209), 0.1);
  color: var(--brand, #100DD1);
}

.nc-send {
  --nc-send-h: 44px;
  border: 0;
  background: var(--brand, #100DD1);
  background-image: linear-gradient(135deg, var(--brand, #100DD1) 0%, rgba(0, 0, 0, 0.18) 160%);
  color: #fff;
  min-width: var(--nc-send-h);
  height: var(--nc-send-h);
  padding: 0 0.95rem;
  border-radius: 999px;
  box-shadow:
    0 8px 18px rgba(var(--brand-rgb, 16, 13, 209), 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease,
    filter 0.18s ease,
    background 0.18s ease;
}
.nc-send i {
  font-size: 0.92rem;
  transform: rotate(-45deg) scaleX(-1);
  line-height: 1;
}
.nc-send-label {
  line-height: 1;
}
.nc-send:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(var(--brand-rgb, 16, 13, 209), 0.34);
  filter: brightness(1.05);
}
.nc-send:active:not(:disabled) {
  transform: translateY(0) scale(0.97);
}
.nc-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
  filter: grayscale(0.15);
}
.nc-send.is-sending {
  pointer-events: none;
  opacity: 0.85;
}
.nc-send.is-sending i {
  animation: nc-send-fly 0.7s ease infinite;
}
@keyframes nc-send-fly {
  0% { transform: rotate(-45deg) scaleX(-1) translate(0, 0); opacity: 1; }
  60% { transform: rotate(-45deg) scaleX(-1) translate(-4px, -3px); opacity: 0.55; }
  100% { transform: rotate(-45deg) scaleX(-1) translate(0, 0); opacity: 1; }
}

@media (max-width: 380px) {
  .nc-send {
    padding: 0;
    width: var(--nc-send-h);
  }
  .nc-send-label { display: none; }
}

.nc-chat-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.nc-chat-body.is-locked {
  display: none;
}

.nc-guest-gate {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.15rem 1rem 1.25rem;
  background: transparent;
}

.nc-guest-gate[hidden] {
  display: none !important;
}

.nc-guest-gate-copy strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--text, #1d2433);
  font-size: 1rem;
}

.nc-guest-gate-copy p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted, #747794);
  line-height: 1.7;
}

.nc-field {
  display: grid;
  gap: 0.3rem;
}

.nc-field span {
  font-size: 0.78rem;
  font-weight: 700;
  color: #4b5563;
}

.nc-field input {
  height: 46px;
  border: 1px solid rgba(15, 20, 40, 0.1);
  border-radius: 0.85rem;
  padding: 0 0.9rem;
  background: #fff;
}

.nc-guest-error {
  margin: 0;
  color: #dc2626;
  font-size: 0.8rem;
}

.nc-guest-start {
  margin-top: 0.25rem;
  border: 0;
  border-radius: 0.9rem;
  height: 48px;
  background: var(--brand, #100DD1);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 10px 22px rgba(var(--brand-rgb, 16, 13, 209), 0.28);
}

.nc-guest-start:disabled {
  opacity: 0.65;
}

html[theme-color="dark"] .nc-launcher {
  background: rgba(18, 22, 42, 0.78);
  border-color: rgba(255, 255, 255, 0.1);
  color: #e8ebf7;
}

html[theme-color="dark"] .nc-launcher.is-open {
  background: var(--brand, #100DD1);
  color: #fff;
}

html[theme-color="dark"] .nc-panel {
  background: rgba(18, 22, 42, 0.9);
  border-color: rgba(255, 255, 255, 0.08);
}

html[theme-color="dark"] .nc-messages {
  background:
    radial-gradient(ellipse 80% 50% at 0% 0%, rgba(var(--brand-rgb), 0.16), transparent 55%),
    #12162a;
}

html[theme-color="dark"] .nc-bubble.is-user,
html[theme-color="dark"] .nc-bubble.is-mine {
  background: #1a2035;
  border-color: rgba(255, 255, 255, 0.06);
  color: var(--text, #f3f4f8);
}

html[theme-color="dark"] .nc-composer,
html[theme-color="dark"] .nc-emoji {
  background: rgba(18, 22, 42, 0.95);
  border-color: rgba(255, 255, 255, 0.06);
}

html[theme-color="dark"] .nc-composer input[type="text"] {
  background: #1a2035;
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text, #f3f4f8);
}

html[theme-color="dark"] .nc-icon {
  background: #1a2035;
  color: #c7d2fe;
}
html[theme-color="dark"] .nc-icon:hover {
  background: rgba(var(--brand-rgb, 16, 13, 209), 0.22);
  color: #fff;
}
html[theme-color="dark"] .nc-send:disabled {
  opacity: 0.35;
}

html[theme-color="dark"] .nc-guest-gate-copy strong {
  color: var(--text, #f3f4f8);
}

html[theme-color="dark"] .nc-field input {
  background: #1a2035;
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--text, #f3f4f8);
}

@media (min-width: 992px) {
  .nc-launcher {
    bottom: 24px;
    right: 22px;
    left: auto;
  }
  .nc-panel {
    bottom: 92px;
    right: 22px;
    left: auto;
  }
}

@media (max-width: 991.98px) {
  .nc-launcher {
    right: 14px;
    left: auto;
  }
  .nc-panel {
    right: 10px;
    left: auto;
    bottom: calc(8.2rem + env(safe-area-inset-bottom, 0px));
  }
}
