/* =============================================
   NORLUC Chat Widget — chat-widget.css
   Hereda paleta/tipo de home.css via var()
   ============================================= */

#nc-widget {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1500;
  font-family: var(--font, 'Space Grotesk', system-ui, sans-serif);
}

/* ── Bubble trigger ── */
.nc-bubble {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--black, #0a0a0a);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
  transition: transform 0.24s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.24s cubic-bezier(0.4, 0, 0.2, 1);
  animation: nc-pulse 3.5s ease-out infinite 2s;
  position: relative;
}

.nc-bubble:hover {
  transform: translateY(-2px) scale(1.06);
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.3);
  animation: none;
}

.nc-bubble.nc-active {
  animation: none;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.25);
}

@keyframes nc-pulse {
  0%   { box-shadow: 0 4px 18px rgba(0,0,0,0.25), 0 0 0 0 rgba(37,99,235,0.45); }
  70%  { box-shadow: 0 4px 18px rgba(0,0,0,0.25), 0 0 0 11px rgba(37,99,235,0); }
  100% { box-shadow: 0 4px 18px rgba(0,0,0,0.25), 0 0 0 0 rgba(37,99,235,0); }
}

/* ── Bubble icon swap ── */
.nc-bubble-icon {
  position: absolute;
  transition: opacity 0.22s ease,
              transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.nc-icon-chat  { opacity: 1; transform: scale(1) rotate(0deg); }
.nc-icon-close { opacity: 0; transform: scale(0.55) rotate(-90deg); }

.nc-bubble.nc-active .nc-icon-chat  { opacity: 0; transform: scale(0.55) rotate(90deg); }
.nc-bubble.nc-active .nc-icon-close { opacity: 1; transform: scale(1) rotate(0deg); }

/* ── Panel ── */
.nc-panel {
  position: absolute;
  bottom: calc(56px + 0.85rem);
  right: 0;
  width: 360px;
  height: 520px;
  background: var(--white, #ffffff);
  border-radius: 18px;
  border: 1px solid var(--g200, #e6e8ee);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.13), 0 4px 18px rgba(0, 0, 0, 0.07);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* closed state */
  opacity: 0;
  transform: translateY(18px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
}

.nc-panel.nc-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ── */
.nc-header {
  background: var(--black, #0a0a0a);
  color: var(--white, #ffffff);
  padding: 0.95rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-shrink: 0;
}

.nc-header-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.nc-header-mark {
  width: 22px;
  height: 22px;
  fill: var(--white, #ffffff);
  flex-shrink: 0;
}

.nc-header-word {
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.18em;
  color: var(--white, #ffffff);
}

.nc-header-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--blue, #2563eb);
  flex-shrink: 0;
  animation: nc-dot-ping 3s ease-out infinite 1s;
}

@keyframes nc-dot-ping {
  0%   { box-shadow: 0 0 0 0 rgba(37,99,235,0.65); }
  70%  { box-shadow: 0 0 0 6px rgba(37,99,235,0); }
  100% { box-shadow: 0 0 0 0 rgba(37,99,235,0); }
}

.nc-header-sub {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.nc-close-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.45);
  padding: 5px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background 0.2s ease;
  flex-shrink: 0;
}

.nc-close-btn:hover {
  color: var(--white, #ffffff);
  background: rgba(255,255,255,0.1);
}

/* ── Messages ── */
.nc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  scroll-behavior: smooth;
}

.nc-messages::-webkit-scrollbar { width: 3px; }
.nc-messages::-webkit-scrollbar-track { background: transparent; }
.nc-messages::-webkit-scrollbar-thumb { background: var(--g200, #e6e8ee); border-radius: 2px; }

/* ── Message rows ── */
.nc-msg {
  display: flex;
  opacity: 0;
  transform: translateY(8px);
  animation: nc-msg-in 0.38s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes nc-msg-in { to { opacity: 1; transform: none; } }

.nc-msg-bot   { justify-content: flex-start; }
.nc-msg-user  { justify-content: flex-end; }
.nc-msg-error { justify-content: flex-start; }

/* ── Bubble text ── */
.nc-bubble-text {
  max-width: 82%;
  padding: 0.62rem 0.88rem;
  font-size: 0.875rem;
  line-height: 1.52;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.nc-msg-bot .nc-bubble-text {
  background: var(--g100, #f1f3f6);
  color: var(--black, #0a0a0a);
  border-radius: 4px 14px 14px 14px;
}

.nc-msg-user .nc-bubble-text {
  background: var(--black, #0a0a0a);
  color: var(--white, #ffffff);
  border-radius: 14px 4px 14px 14px;
}

.nc-msg-error .nc-bubble-text {
  background: #fef2f2;
  color: #991b1b;
  border-radius: 4px 14px 14px 14px;
  font-size: 0.82rem;
}

/* ── Typing indicator ── */
.nc-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 0;
}

.nc-typing i {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--g400, #9aa1b1);
  animation: nc-dot-bounce 1.2s ease-in-out infinite;
  font-style: normal;
}

.nc-typing i:nth-child(2) { animation-delay: 0.15s; }
.nc-typing i:nth-child(3) { animation-delay: 0.30s; }

@keyframes nc-dot-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-5px); }
}

/* ── Footer / input ── */
.nc-footer {
  border-top: 1px solid var(--g200, #e6e8ee);
  padding: 0.7rem 0.9rem;
  flex-shrink: 0;
  background: var(--white, #ffffff);
}

.nc-input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.45rem;
  background: var(--g50, #f8f9fb);
  border: 1px solid var(--g200, #e6e8ee);
  border-radius: 12px;
  padding: 0.48rem 0.48rem 0.48rem 0.82rem;
  transition: border-color 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

.nc-input-row:focus-within {
  border-color: var(--blue, #2563eb);
}

.nc-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: var(--font, 'Space Grotesk', system-ui, sans-serif);
  font-size: 0.875rem;
  color: var(--black, #0a0a0a);
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  padding: 0;
}

.nc-input::placeholder { color: var(--g400, #9aa1b1); }
.nc-input:disabled      { opacity: 0.45; }

/* ── Send button ── */
.nc-send {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--black, #0a0a0a);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.24s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

.nc-send:hover  { background: var(--g800, #1b1f29); transform: scale(1.08); }
.nc-send:active { transform: scale(0.93); }
.nc-send:disabled { opacity: 0.35; cursor: not-allowed; transform: none; }
.nc-send svg { color: var(--white, #ffffff); }

/* ── Powered ── */
.nc-powered {
  text-align: center;
  font-size: 0.63rem;
  color: var(--g400, #9aa1b1);
  margin-top: 0.42rem;
  letter-spacing: 0.025em;
}

/* ── Mobile: pantalla completa ── */
@media (max-width: 900px) {
  #nc-widget {
    bottom: 1rem;
    right: 1rem;
  }

  .nc-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
    transform: translateY(100%) scale(1);
  }

  .nc-panel.nc-open {
    transform: translateY(0) scale(1);
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .nc-bubble,
  .nc-header-dot,
  .nc-typing i    { animation: none !important; }

  .nc-bubble       { box-shadow: 0 4px 18px rgba(0,0,0,0.25) !important; }
  .nc-header-dot   { box-shadow: none !important; }

  .nc-panel        { transition: none !important; }
  .nc-bubble-icon  { transition: none !important; }
  .nc-msg          { animation: none !important; opacity: 1 !important; transform: none !important; }
}
