/* ===============================================================
   TechVaddadi Chat — self-built widget (v4)
   No dependency on @n8n/chat's internal markup. Every class here
   is ours, defined by chat.js right below it, so nothing can
   silently fail to match like it did when we were reskinning a
   third-party widget.
   =============================================================== */

:root{
  --tv-bg: #0A0E0D;
  --tv-card: #101613;
  --tv-card-2: #141C18;
  --tv-border: #1E2A25;
  --tv-border-bright: #2B3B34;
  --tv-text: #DCE7E2;
  --tv-muted: #728077;
  --tv-dim: #4B5A52;
  --tv-accent: #E8A33D;
  --tv-online: #4FD1A0;
}

#tv-chat *{ box-sizing: border-box; }

/* ---------------------------------------------------------------
   Floating launcher
   --------------------------------------------------------------- */

#tv-chat-launcher{
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20000;

  height: 42px;
  padding: 0 17px;

  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

  border: 1px solid var(--tv-accent);
  border-radius: 22px;
  background: var(--tv-accent);
  color: var(--tv-bg);

  font: 700 13px Inter, sans-serif;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(0,0,0,.4);
}
#tv-chat-launcher:hover{ transform: translateY(-1px); }
#tv-chat-launcher svg{
  width: 17px; height: 17px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
#tv-chat-launcher.tv-hidden{ display: none; }

/* ---------------------------------------------------------------
   Window shell
   --------------------------------------------------------------- */

#tv-chat-window{
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20000;

  width: min(390px, calc(100vw - 28px));
  height: min(600px, calc(100vh - 105px));

  display: flex;
  flex-direction: column;

  background: var(--tv-bg);
  border: 1px solid var(--tv-border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);

  font-family: Inter, -apple-system, sans-serif;
  color: var(--tv-text);
}
#tv-chat-window.tv-hidden{ display: none; }

#tv-chat-window.tv-maximized{
  top: 3vh; left: 3vw;
  width: 94vw; height: 94vh;
  right: auto; bottom: auto;
  z-index: 20001;
}

/* ---------------------------------------------------------------
   Header
   --------------------------------------------------------------- */

#tv-chat-header{
  flex: 0 0 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px 0 18px;
  background: var(--tv-card);
  border-bottom: 1px solid var(--tv-border);
}

#tv-chat-title{
  font-family: "JetBrains Mono", monospace;
  font-size: 15px;
  font-weight: 600;
  color: var(--tv-accent);
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1 1 auto;
}

#tv-chat-header-actions{
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

#tv-chat-header-actions button{
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 7px;
  background: transparent;
  color: var(--tv-muted);
  cursor: pointer;
  padding: 0;
}
#tv-chat-header-actions button:hover{
  background: var(--tv-card-2);
  color: var(--tv-accent);
}
#tv-chat-header-actions svg{
  width: 17px; height: 17px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

/* ---------------------------------------------------------------
   Message list
   --------------------------------------------------------------- */

#tv-chat-messages{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--tv-bg);
}

.tv-row{
  display: flex;
  max-width: 88%;
  min-width: 0;
}
.tv-row.tv-bot{
  align-items: flex-end;
  gap: 9px;
  align-self: flex-start;
}
.tv-row.tv-user{
  align-self: flex-end;
}

.tv-avatar{
  flex: 0 0 30px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--tv-card);
  border: 1px solid var(--tv-border);
  display: flex; align-items: center; justify-content: center;
  color: var(--tv-accent);
}
.tv-avatar svg{
  width: 16px; height: 16px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.tv-col{
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 100%;
}
.tv-row.tv-bot .tv-col{ align-items: flex-start; }
.tv-row.tv-user .tv-col{ align-items: flex-end; }

.tv-bubble{
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 14px;
  border-radius: 16px;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
}
.tv-row.tv-bot .tv-bubble{
  background: var(--tv-card);
  border: 1px solid var(--tv-border);
  border-bottom-left-radius: 4px;
}
.tv-row.tv-user .tv-bubble{
  background: rgba(79,209,160,.10);
  border: 1px solid rgba(79,209,160,.28);
  border-bottom-right-radius: 4px;
}

.tv-meta{
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  padding: 0 3px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10.5px;
  color: var(--tv-dim);
}
.tv-meta .tv-check{ display: inline-flex; align-items: center; color: var(--tv-dim); }
.tv-meta .tv-check.tv-delivered{ color: var(--tv-online); }
.tv-meta .tv-check svg{
  width: 13px; height: 13px;
  fill: none; stroke: currentColor;
  stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round;
}

.tv-typing{
  display: flex;
  gap: 4px;
  padding: 12px 14px;
}
.tv-typing span{
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--tv-muted);
  animation: tv-bounce 1.1s infinite ease-in-out;
}
.tv-typing span:nth-child(2){ animation-delay: .15s; }
.tv-typing span:nth-child(3){ animation-delay: .3s; }
@keyframes tv-bounce{
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------------------------------------------------------------
   Input pill
   --------------------------------------------------------------- */

#tv-chat-input-row{
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 12px 14px;
  background: var(--tv-card);
  border-top: 1px solid var(--tv-border);
}

#tv-chat-textarea{
  flex: 1 1 auto;
  resize: none;
  max-height: 180px;
  overflow-y: hidden;
  background: var(--tv-card-2);
  color: var(--tv-text);
  border: 1px solid var(--tv-border);
  border-right: 0;
  border-radius: 18px 0 0 18px;
  padding: 11px 6px 11px 18px;
  font: 13px Inter, sans-serif;
  outline: none;
}
#tv-chat-textarea::placeholder{
  color: var(--tv-muted);
  font-family: "JetBrains Mono", monospace;
}

#tv-chat-mic{
  flex: 0 0 34px;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--tv-border);
  border-left: 0; border-right: 0;
  background: var(--tv-card-2);
  color: var(--tv-muted);
  cursor: pointer;
  padding: 0;
}
#tv-chat-mic:hover{ color: var(--tv-accent); }
#tv-chat-mic.tv-recording{ color: var(--tv-accent); }
#tv-chat-mic svg{
  width: 17px; height: 17px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

#tv-chat-send{
  flex: 0 0 38px;
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--tv-border);
  border-radius: 0 999px 999px 0;
  background: var(--tv-accent);
  color: var(--tv-bg);
  cursor: pointer;
  padding: 0;
}
#tv-chat-send:disabled{ opacity: .5; cursor: default; }
#tv-chat-send svg{ width: 16px; height: 16px; }

/* ---------------------------------------------------------------
   Mobile
   --------------------------------------------------------------- */

@media (max-width: 680px){
  #tv-chat-launcher{
    right: 16px; bottom: 16px;
    width: 48px; height: 48px;
    padding: 0; border-radius: 50%;
  }
  #tv-chat-launcher span{ display: none; }

  #tv-chat-window{
    right: 10px; bottom: 78px;
    width: calc(100vw - 20px);
    height: min(650px, calc(100vh - 90px));
  }
  #tv-chat-window.tv-maximized{
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw; height: 100dvh;
    border-radius: 0;
  }
}
