/* -------------------------------------------------------------------------
   Nijat Farzi Studio — chat widget
   Premium onyx + champagne styling to match the site theme.
   ------------------------------------------------------------------------- */

/* Champagne ramp and onyx tones mirror .panel-onyx / .btn-primary in site.css. */
:root {
  --nf-chat-champagne: #debe84;
  --nf-chat-champagne-2: #b98945;
  --nf-chat-panel: #101216;
  --nf-chat-panel-2: #17191d;
  --nf-chat-line: rgba(222, 190, 132, 0.22);
  --nf-chat-glow: rgba(222, 190, 132, 0.32);
  --nf-chat-user-bg: linear-gradient(135deg, #f0d39c 0%, #c99b58 100%);
  --nf-chat-user-fg: #101216;
  --nf-chat-bot-bg: rgba(255, 255, 255, 0.075);
  --nf-chat-bot-fg: #f8f1e4;
}

/* Launcher (floating button) */
.nf-chat-launcher {
  position: fixed;
  right: 1rem;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 5.5rem);
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.58rem 0.88rem 0.58rem 0.72rem;
  border-radius: 999px;
  border: 1px solid var(--nf-chat-line);
  background:
    linear-gradient(145deg, rgba(222, 190, 132, 0.14) 0%, rgba(222, 190, 132, 0) 42%),
    linear-gradient(160deg, #17191d 0%, #101216 58%, #211a11 100%);
  color: #f8f1e4;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34), 0 0 0 1px rgba(212, 181, 135, 0.08) inset;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
  animation: nfChatLauncherIn 320ms cubic-bezier(0.16, 1, 0.3, 1) 200ms both;
}

@media (min-width: 640px) {
  .nf-chat-launcher {
    right: 1.5rem;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 5rem);
  }
}

.nf-chat-launcher:hover {
  transform: translateY(-2px);
  border-color: rgba(212, 181, 135, 0.36);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(212, 181, 135, 0.16) inset;
}

.nf-chat-launcher:focus-visible {
  outline: 2px solid var(--nf-chat-champagne);
  outline-offset: 3px;
}

.nf-chat-launcher.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px) scale(0.98);
}

.nf-chat-launcher-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.62rem;
  height: 1.62rem;
  border-radius: 999px;
  background: var(--nf-chat-user-bg);
  color: var(--nf-chat-user-fg);
  flex-shrink: 0;
  position: relative;
}

.nf-chat-launcher-icon svg {
  width: 0.92rem;
  height: 0.92rem;
}

.nf-chat-launcher-pulse {
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  border: 1px solid rgba(212, 181, 135, 0.45);
  animation: nfChatPulse 2.4s ease-out infinite;
  pointer-events: none;
}

.nf-chat-launcher-label {
  white-space: nowrap;
}

@media (max-width: 639px) {
  .nf-chat-launcher {
    right: 0.85rem;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 4.85rem);
    width: 3.15rem;
    height: 3.15rem;
    justify-content: center;
    padding: 0;
  }

  .nf-chat-launcher-icon {
    width: 2rem;
    height: 2rem;
  }

  .nf-chat-launcher-icon svg {
    width: 1.05rem;
    height: 1.05rem;
  }

  .nf-chat-launcher-label {
    display: none;
  }
}

@keyframes nfChatPulse {
  0%   { transform: scale(1);   opacity: 0.75; }
  70%  { transform: scale(1.35); opacity: 0; }
  100% { transform: scale(1.35); opacity: 0; }
}

@keyframes nfChatLauncherIn {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Panel */
.nf-chat-panel {
  position: fixed;
  right: 1rem;
  left: 1rem;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 4.75rem);
  z-index: 61;
  display: flex;
  flex-direction: column;
  max-height: min(78dvh, 640px);
  border-radius: 20px;
  overflow: hidden;
  color: var(--nf-chat-bot-fg);
  background:
    linear-gradient(145deg, rgba(222, 190, 132, 0.14) 0%, rgba(222, 190, 132, 0) 42%),
    linear-gradient(160deg, #17191d 0%, #101216 58%, #211a11 100%);
  border: 1px solid var(--nf-chat-line);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(212, 181, 135, 0.08) inset;
  transform-origin: bottom right;
  transform: translateY(16px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: transform 240ms cubic-bezier(0.16, 1, 0.3, 1), opacity 200ms ease;
  backdrop-filter: blur(18px);
}

@media (min-width: 640px) {
  .nf-chat-panel {
    left: auto;
    right: 1.5rem;
    bottom: calc(env(safe-area-inset-bottom, 0px) + 5rem);
    width: 380px;
    max-height: min(72dvh, 620px);
  }
}

.nf-chat-panel.is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.nf-chat-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--nf-chat-line);
  background: linear-gradient(180deg, rgba(255,255,255,0.03) 0%, transparent 100%);
}

.nf-chat-avatar {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(135deg, #e8d0a6 0%, #a17f4d 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #16181c;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(212, 181, 135, 0.35), 0 6px 16px rgba(0, 0, 0, 0.45);
}

.nf-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.nf-chat-heading {
  min-width: 0;
  flex: 1;
}

.nf-chat-heading-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f6f2e6;
  line-height: 1.2;
}

.nf-chat-heading-sub {
  margin-top: 2px;
  font-size: 0.72rem;
  color: rgba(234, 230, 221, 0.74);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.nf-chat-heading-sub .nf-chat-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #7fd18a;
  box-shadow: 0 0 0 3px rgba(127, 209, 138, 0.18);
}

.nf-chat-close {
  background: transparent;
  border: 1px solid var(--nf-chat-line);
  color: rgba(234, 230, 221, 0.68);
  border-radius: 999px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 150ms, border-color 150ms, background 150ms;
}

.nf-chat-close:hover {
  color: #f6f2e6;
  border-color: rgba(212, 181, 135, 0.4);
  background: rgba(212, 181, 135, 0.08);
}

.nf-chat-close svg { width: 14px; height: 14px; }

.nf-chat-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1rem 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(212, 181, 135, 0.32) transparent;
}

.nf-chat-body::-webkit-scrollbar { width: 6px; }
.nf-chat-body::-webkit-scrollbar-thumb { background: rgba(212, 181, 135, 0.32); border-radius: 999px; }

.nf-chat-msg {
  max-width: 86%;
  padding: 0.55rem 0.8rem;
  border-radius: 14px;
  font-size: 0.85rem;
  line-height: 1.45;
  animation: nfChatMsgIn 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.nf-chat-msg.is-bot {
  background: var(--nf-chat-bot-bg);
  color: var(--nf-chat-bot-fg);
  border: 1px solid rgba(255,255,255,0.05);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.nf-chat-msg.is-user {
  background: var(--nf-chat-user-bg);
  color: var(--nf-chat-user-fg);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  font-weight: 500;
  box-shadow: 0 6px 18px rgba(212, 181, 135, 0.22);
}

@keyframes nfChatMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.nf-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 0.55rem 0.8rem;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  background: var(--nf-chat-bot-bg);
  border: 1px solid rgba(255,255,255,0.05);
  align-self: flex-start;
  animation: nfChatMsgIn 220ms ease both;
}

.nf-chat-typing span {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: rgba(212, 181, 135, 0.75);
  animation: nfChatTypingBlink 1.2s infinite;
}

.nf-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.nf-chat-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes nfChatTypingBlink {
  0%, 60%, 100% { opacity: 0.28; transform: translateY(0); }
  30%           { opacity: 1;    transform: translateY(-2px); }
}

/* Quick-reply chips */
.nf-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-self: flex-start;
  max-width: 100%;
  animation: nfChatMsgIn 260ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.nf-chat-chip {
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  border: 1px solid rgba(212, 181, 135, 0.32);
  background: rgba(212, 181, 135, 0.06);
  color: #f6f2e6;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 160ms, border-color 160ms, color 160ms;
}

.nf-chat-chip:hover {
  background: rgba(212, 181, 135, 0.16);
  border-color: rgba(212, 181, 135, 0.55);
}

/* Attachment chips */
.nf-chat-attachments {
  padding: 0 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.nf-chat-attachments:empty { display: none; }

.nf-chat-att {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 4px 8px 4px 6px;
  border-radius: 999px;
  border: 1px solid rgba(212, 181, 135, 0.28);
  background: rgba(212, 181, 135, 0.08);
  color: #f6f2e6;
  font-size: 0.72rem;
  line-height: 1;
}

.nf-chat-att-icon {
  width: 18px; height: 18px;
  border-radius: 4px;
  background: rgba(212, 181, 135, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #14161a;
  flex-shrink: 0;
}

.nf-chat-att-icon svg { width: 12px; height: 12px; }
.nf-chat-att-icon img { width: 18px; height: 18px; object-fit: cover; border-radius: 4px; }

.nf-chat-att-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.nf-chat-att-remove {
  border: none;
  background: transparent;
  color: rgba(234, 230, 221, 0.7);
  cursor: pointer;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
}

.nf-chat-att-remove:hover { color: #ffbaba; }

/* Input row */
.nf-chat-input-wrap {
  border-top: 1px solid var(--nf-chat-line);
  background: linear-gradient(180deg, rgba(255,255,255,0.02) 0%, transparent 100%);
  padding: 0.6rem 0.75rem 0.75rem 0.75rem;
}

.nf-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  padding: 6px 6px 6px 10px;
  transition: border-color 160ms;
}

.nf-chat-input-row:focus-within {
  border-color: rgba(212, 181, 135, 0.42);
}

.nf-chat-input {
  flex: 1;
  min-height: 22px;
  max-height: 120px;
  resize: none;
  background: transparent;
  border: none;
  outline: none;
  color: #f6f2e6;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.4;
  padding: 6px 4px;
}

.nf-chat-input::placeholder { color: rgba(234, 230, 221, 0.58); }

.nf-chat-icon-btn {
  border: none;
  background: transparent;
  color: rgba(234, 230, 221, 0.68);
  width: 34px; height: 34px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 160ms, background 160ms;
  flex-shrink: 0;
}

.nf-chat-icon-btn:hover:not(:disabled) {
  color: var(--nf-chat-champagne);
  background: rgba(212, 181, 135, 0.09);
}

.nf-chat-icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.nf-chat-icon-btn svg { width: 18px; height: 18px; }

.nf-chat-send {
  color: var(--nf-chat-user-fg);
  background: var(--nf-chat-user-bg);
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(212, 181, 135, 0.28);
}

.nf-chat-send:hover:not(:disabled) {
  background: var(--nf-chat-user-bg);
  color: var(--nf-chat-user-fg);
  filter: brightness(1.06);
}

.nf-chat-send:disabled {
  background: rgba(212, 181, 135, 0.18);
  color: rgba(20, 22, 26, 0.5);
  box-shadow: none;
}

.nf-chat-hint {
  margin-top: 6px;
  font-size: 0.68rem;
  color: rgba(234, 230, 221, 0.64);
  padding: 0 4px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.nf-chat-hint-error {
  color: #f2b8b8;
}

/* Success + fallback contacts */
.nf-chat-success-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  align-self: flex-start;
}

.nf-chat-success-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(212, 181, 135, 0.32);
  background: rgba(212, 181, 135, 0.06);
  color: #f6f2e6;
  font-size: 0.76rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 160ms, border-color 160ms;
}

.nf-chat-success-links a:hover {
  background: rgba(212, 181, 135, 0.16);
  border-color: rgba(212, 181, 135, 0.5);
}

.nf-chat-success-links svg { width: 14px; height: 14px; }

/* Small helpers */
.nf-chat-hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .nf-chat-launcher,
  .nf-chat-panel,
  .nf-chat-msg,
  .nf-chat-typing,
  .nf-chat-chips,
  .nf-chat-launcher-pulse {
    animation: none !important;
    transition: none !important;
  }
}
