/* TrustNexo Alejandro — chat widget */
:root {
  --tn-navy: #060e1a;
  --tn-navy-card: #0a1628;
  --tn-cyan: #00A3C4;
  --tn-cyan-glow: rgba(0, 163, 196, 0.15);
  --tn-gold: #d4a843;
  --tn-silver: #cbd5e1;
  --tn-text-muted: #94a3b8;
  --tn-white: #ffffff;
  --tn-bg: #060e1a;
}

#tn-chat-root {
  font-family: 'DM Sans', system-ui, sans-serif;
  z-index: 9998;
}

#tn-chat-toggle {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1.6rem 0.85rem 1.4rem;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--tn-cyan), #1d4ed8);
  color: var(--tn-white);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0, 163, 196, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  font-family: inherit;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

#tn-chat-toggle:hover {
  transform: translateX(-50%) translateY(-2px);
  box-shadow: 0 12px 36px rgba(0, 163, 196, 0.6);
}

#tn-chat-toggle svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.tn-launcher-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.15;
  text-align: left;
}

.tn-launcher-title {
  font-size: 0.88rem;
  font-weight: 800;
}

.tn-launcher-sub {
  font-size: 0.68rem;
  font-weight: 600;
  opacity: 0.9;
}

#tn-chat-panel {
  position: fixed;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  right: auto;
  width: min(400px, calc(100vw - 2rem));
  height: min(560px, calc(100vh - 7rem));
  z-index: 9999;
  display: none;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  background: var(--tn-navy-card);
  border: 1px solid rgba(0, 163, 196, 0.35);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

#tn-chat-panel.is-open {
  display: flex;
}

.tn-chat-header {
  padding: 1rem 1.1rem;
  background: linear-gradient(135deg, var(--tn-navy), #0d1b32);
  border-bottom: 1px solid rgba(0, 163, 196, 0.15);
}

.tn-chat-header h3 {
  margin: 0;
  font-size: 1rem;
  color: #fff;
  font-family: 'Playfair Display', serif;
}

.tn-chat-header p {
  margin: 0.25rem 0 0;
  font-size: 0.78rem;
  color: var(--tn-text-muted);
}

.tn-chat-badge {
  display: inline-block;
  margin-bottom: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(0, 163, 196, 0.2);
  color: var(--tn-cyan);
  border: 1px solid rgba(0, 163, 196, 0.45);
}

.tn-chat-howto {
  margin: 0;
  padding: 0.55rem 0.85rem;
  font-size: 0.72rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.82);
  background: rgba(0, 163, 196, 0.1);
  border-bottom: 1px solid rgba(0, 163, 196, 0.15);
}

.tn-chat-howto strong {
  color: var(--tn-cyan);
  font-weight: 700;
}

.tn-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.tn-bubble {
  max-width: 88%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.tn-bubble--user {
  align-self: flex-end;
  background: var(--tn-cyan);
  color: var(--tn-white);
  border-bottom-right-radius: 4px;
}

.tn-bubble--bot {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.08);
  color: #e8eef4;
  border-bottom-left-radius: 4px;
}

.tn-bubble--typing {
  opacity: 0.7;
  font-style: italic;
}

.tn-community-cta {
  padding: 0.75rem 1rem;
  background: rgba(0, 163, 196, 0.1);
  border-top: 1px solid rgba(0, 163, 196, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.tn-community-cta__text {
  margin: 0 0 0.6rem;
  font-size: 0.78rem;
  line-height: 1.4;
  color: #e8eef4;
}

.tn-community-cta__text strong {
  color: var(--tn-cyan);
  font-weight: 600;
}

.tn-community-cta__form {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tn-community-cta__input {
  flex: 1;
  min-width: 140px;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 0.85rem;
  font-family: inherit;
}

.tn-community-cta__submit {
  padding: 0.5rem 0.9rem;
  border: none;
  border-radius: 8px;
  background: var(--tn-cyan);
  color: var(--tn-white);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s;
}

.tn-community-cta__submit:hover {
  background: #008eb0;
}

.tn-community-cta__dismiss {
  display: block;
  margin-top: 0.45rem;
  padding: 0;
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.45);
  font-size: 0.72rem;
  cursor: pointer;
  text-decoration: underline;
  font-family: inherit;
}

.tn-community-cta__dismiss:hover {
  color: rgba(255, 255, 255, 0.7);
}

.tn-chat-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(0, 163, 196, 0.15);
  background: var(--tn-navy);
}

.tn-chat-toolbar {
  display: flex;
  gap: 0.4rem;
  align-items: flex-end;
}

.tn-chat-input {
  flex: 1;
  resize: none;
  min-height: 42px;
  max-height: 120px;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  font-family: inherit;
  font-size: 0.9rem;
}

.tn-chat-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.tn-icon-btn {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--tn-cyan);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.tn-icon-btn:hover {
  background: rgba(0, 163, 196, 0.25);
}

.tn-icon-btn.is-active {
  background: var(--tn-cyan);
  color: var(--tn-white);
}

.tn-mic-hint {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: #f0c674;
}

.tn-stop-btn {
  background: rgba(220, 80, 80, 0.25) !important;
}

.tn-stop-btn:not([hidden]) {
  animation: tn-pulse 1.2s ease-in-out infinite;
}

@keyframes tn-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

#tn-mic-btn.is-active {
  background: rgba(0, 163, 196, 0.35) !important;
  box-shadow: 0 0 0 2px rgba(0, 163, 196, 0.5);
}

.tn-chat-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.4rem;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.5);
}

.tn-chat-options label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

@media (max-width: 480px) {
  #tn-chat-panel {
    left: 0.5rem;
    right: 0.5rem;
    width: auto;
    height: min(500px, calc(100vh - 6rem));
    bottom: 5rem;
    transform: none;
    border-radius: 12px;
  }

  #tn-chat-toggle {
    padding: 0.7rem 1.2rem 0.7rem 1rem;
    font-size: 0.88rem;
    bottom: 1rem;
    width: calc(100% - 2rem);
    max-width: 320px;
  }

  #tn-chat-toggle svg {
    width: 20px;
    height: 20px;
  }

  #tn-chat-toggle:hover {
    transform: translateX(-50%) translateY(-2px);
  }

  .tn-launcher-title {
    font-size: 0.82rem;
  }

  .tn-launcher-sub {
    display: none;
  }

  .tn-chat-header {
    padding: 0.75rem 0.9rem;
  }

  .tn-chat-header h3 {
    font-size: 0.92rem;
  }

  .tn-chat-messages {
    padding: 0.7rem;
  }

  .tn-bubble {
    font-size: 0.85rem;
    padding: 0.55rem 0.75rem;
  }

  .tn-chat-footer {
    padding: 0.55rem;
  }

  .tn-chat-input {
    min-height: 38px;
    font-size: 0.85rem;
    padding: 0.45rem 0.65rem;
  }

  .tn-icon-btn {
    width: 38px;
    height: 38px;
  }

  .tn-community-cta {
    padding: 0.55rem 0.75rem;
  }

  .tn-community-cta__text {
    font-size: 0.75rem;
  }
}

@media (max-width: 380px) {
  #tn-chat-toggle {
    padding: 0.65rem 1rem;
    font-size: 0.82rem;
    max-width: 280px;
  }

  #tn-chat-panel {
    left: 0.3rem;
    right: 0.3rem;
    height: min(450px, calc(100vh - 5.5rem));
  }
}
