/* TecClub Premium Chatbot Stylesheet */

:root {
  --tc-brand-primary: #0E59F2;
  --tc-brand-purple: #7B2FF7;
  --tc-brand-gradient: linear-gradient(135deg, #0E59F2 0%, #7B2FF7 100%);
  --tc-brand-gradient-hover: linear-gradient(135deg, #0C4ED6 0%, #6C25E0 100%);
  --tc-chat-bg: rgba(255, 255, 255, 0.92);
  --tc-chat-border: rgba(226, 232, 240, 0.8);
  --tc-chat-text: #0F172A;
  --tc-chat-text-muted: #64748B;
  --tc-chat-text-light: #94A3B8;
  --tc-bot-bubble-bg: #F1F5F9;
  --tc-bot-bubble-border: #E2E8F0;
  --tc-shadow-lg: 0 20px 50px -10px rgba(15, 23, 42, 0.18), 0 0 1px rgba(15, 23, 42, 0.12);
  --tc-shadow-md: 0 10px 25px -5px rgba(14, 89, 242, 0.12);
  --tc-shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Floating Action Button (Trigger) */
.tc-chatbot-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--tc-brand-gradient);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 9999;
  box-shadow: 0 8px 25px rgba(14, 89, 242, 0.35);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
}

.tc-chatbot-trigger:hover {
  transform: scale(1.06) rotate(4deg);
  box-shadow: 0 12px 30px rgba(14, 89, 242, 0.45);
}

.tc-chatbot-trigger:active {
  transform: scale(0.94);
}

.tc-chatbot-trigger svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  transition: transform 0.3s ease, opacity 0.3s ease;
  position: absolute;
}

.tc-chatbot-trigger .tc-icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

.tc-chatbot-trigger.active .tc-icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

.tc-chatbot-trigger.active .tc-icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Chat Window Container */
.tc-chatbot-window {
  position: fixed;
  right: 24px;
  bottom: 96px;
  width: 390px;
  height: 600px;
  max-height: calc(100vh - 120px);
  border-radius: 24px;
  background: var(--tc-chat-bg);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--tc-chat-border);
  box-shadow: var(--tc-shadow-lg);
  z-index: 9998;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92) translateY(20px);
  transform-origin: bottom right;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.tc-chatbot-window.open {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1) translateY(0);
}

/* Chat Header */
.tc-chatbot-header {
  background: #ffffff;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.tc-chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tc-chatbot-avatar-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tc-chatbot-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(14, 89, 242, 0.08) 0%, rgba(123, 47, 247, 0.08) 100%);
  border: 1.5px solid rgba(14, 89, 242, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tc-brand-primary);
  box-shadow: var(--tc-shadow-sm);
  overflow: hidden;
}

.tc-header-avatar-img {
  width: 26px;
  height: 26px;
  object-fit: contain;
}

.tc-status-pulse {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  background: #10B981;
  border: 2px solid #ffffff;
  border-radius: 50%;
}

.tc-chatbot-details {
  display: flex;
  flex-direction: column;
}

.tc-chatbot-title {
  color: var(--tc-chat-text);
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.2px;
}

.tc-chatbot-status {
  color: var(--tc-chat-text-muted);
  font-size: 11.5px;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  font-weight: 500;
}

.tc-chatbot-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10B981;
  display: inline-block;
  animation: tc-pulse 2s infinite;
}

@keyframes tc-pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 5px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.tc-chatbot-header-close {
  background: rgba(241, 245, 249, 0.8);
  border: 1px solid rgba(226, 232, 240, 0.8);
  color: var(--tc-chat-text-muted);
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  outline: none;
}

.tc-chatbot-header-close:hover {
  background: #E2E8F0;
  color: var(--tc-chat-text);
  transform: scale(1.05);
}

/* Chat Body */
.tc-chatbot-body {
  flex: 1;
  padding: 20px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}

.tc-chatbot-body::-webkit-scrollbar {
  width: 4px;
}

.tc-chatbot-body::-webkit-scrollbar-track {
  background: transparent;
}

.tc-chatbot-body::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 4px;
}

/* Message Bubbles */
.tc-chatbot-msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: tc-fadeInUp 0.3s ease forwards;
}

@keyframes tc-fadeInUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tc-chatbot-msg.bot {
  align-self: flex-start;
}

.tc-chatbot-msg.user {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 82%;
}

.tc-chatbot-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ffffff;
  border: 1px solid var(--tc-bot-bubble-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--tc-brand-primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  overflow: hidden;
}

.tc-msg-avatar-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.tc-chatbot-msg-avatar svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.tc-chatbot-msg-content-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 100%;
}

.tc-chatbot-msg-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  letter-spacing: -0.1px;
}

.tc-chatbot-msg.bot .tc-chatbot-msg-bubble {
  background: var(--tc-bot-bubble-bg);
  border: 1px solid var(--tc-bot-bubble-border);
  color: var(--tc-chat-text);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.tc-chatbot-msg.user .tc-chatbot-msg-bubble {
  background: var(--tc-brand-gradient);
  color: #ffffff;
  border-top-right-radius: 4px;
  box-shadow: 0 4px 14px rgba(14, 89, 242, 0.22);
}

.tc-chatbot-msg-time {
  font-size: 10.5px;
  color: var(--tc-chat-text-light);
  margin-top: 4px;
  font-weight: 500;
}

.tc-chatbot-msg.bot .tc-chatbot-msg-time {
  text-align: left;
  margin-left: 2px;
}

.tc-chatbot-msg.user .tc-chatbot-msg-time {
  text-align: right;
  margin-right: 2px;
}

/* Quick Replies / Chips */
.tc-chatbot-chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  padding-left: 42px;
  animation: tc-fadeInUp 0.35s ease forwards;
}

.tc-chip-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tc-chat-text-muted);
  margin-bottom: 2px;
}

.tc-chatbot-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tc-chatbot-chip {
  background: #ffffff;
  border: 1px solid #CBD5E1;
  color: var(--tc-chat-text);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.tc-chatbot-chip:hover {
  background: #F8FAFC;
  border-color: var(--tc-brand-primary);
  color: var(--tc-brand-primary);
  transform: translateY(-1.5px);
  box-shadow: 0 4px 10px rgba(14, 89, 242, 0.12);
}

.tc-chatbot-chip:active {
  transform: translateY(0);
}

/* Approval Cards */
.tc-chatbot-msg-bubble.tc-approval-card {
  padding: 0;
  border-radius: 16px;
  background: #ffffff !important;
  border: 1px solid rgba(14, 89, 242, 0.2) !important;
  box-shadow: 0 10px 25px -5px rgba(14, 89, 242, 0.1) !important;
  overflow: hidden;
  min-width: 260px;
}

.tc-approval-header {
  background: linear-gradient(135deg, rgba(14, 89, 242, 0.06) 0%, rgba(123, 47, 247, 0.06) 100%);
  padding: 12px 16px;
  border-bottom: 1px solid rgba(14, 89, 242, 0.12);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tc-approval-header-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: rgba(14, 89, 242, 0.1);
  color: var(--tc-brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tc-approval-header-icon svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.tc-approval-title {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--tc-brand-primary);
  margin: 0;
}

.tc-approval-body {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tc-approval-block + .tc-approval-block {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px stroke #F1F5F9;
}

.tc-approval-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  padding: 3px 0;
}

.tc-approval-key {
  color: var(--tc-chat-text-muted);
  font-weight: 500;
}

.tc-approval-value {
  font-weight: 600;
  color: var(--tc-chat-text);
  background: #F8FAFC;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid #E2E8F0;
  font-size: 12px;
}

.tc-approval-reason {
  margin: 8px 0 0 0;
  font-size: 11.5px;
  color: var(--tc-chat-text-muted);
  line-height: 1.45;
  background: #FFFBEB;
  border: 1px solid #FEF3C7;
  padding: 8px 10px;
  border-radius: 8px;
}

.tc-approval-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #F8FAFC;
  border-top: 1px solid #E2E8F0;
}

.tc-approval-btn {
  flex: 1;
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.tc-approval-btn:disabled {
  cursor: default;
  opacity: 0.6;
}

.tc-approval-confirm {
  background: var(--tc-brand-gradient);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(14, 89, 242, 0.25);
}

.tc-approval-confirm:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(14, 89, 242, 0.35);
}

.tc-approval-cancel {
  background: #ffffff;
  border-color: #CBD5E1;
  color: var(--tc-chat-text);
}

.tc-approval-cancel:hover:not(:disabled) {
  background: #F1F5F9;
  border-color: #94A3B8;
}

/* Chat Footer */
.tc-chatbot-footer {
  padding: 14px 18px 12px 18px;
  border-top: 1px solid rgba(226, 232, 240, 0.8);
  background: #ffffff;
}

.tc-chatbot-input-container {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

/* A textarea so Shift+Enter can insert a newline; it grows with the content. */
.tc-chatbot-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 44px;
  min-height: 44px;
  max-height: 120px;
  box-sizing: border-box !important;
  background: #F8FAFC;
  border: 1px solid #E2E8F0;
  border-radius: 22px;
  padding: 12px 20px !important;
  color: var(--tc-chat-text);
  font-size: 13.5px;
  font-family: inherit;
  line-height: 18px;
  outline: none;
  margin: 0;
  text-indent: 0;
  resize: none;
  overflow-y: auto;
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.tc-chatbot-input::-webkit-scrollbar {
  width: 3px;
}

.tc-chatbot-input::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 3px;
}

.tc-chatbot-input:focus {
  border-color: var(--tc-brand-primary);
  background: #ffffff;
  box-shadow: 0 0 0 3.5px rgba(14, 89, 242, 0.12);
}

.tc-chatbot-input::placeholder {
  color: var(--tc-chat-text-light);
  opacity: 1;
  line-height: normal;
}

.tc-chatbot-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--tc-brand-gradient);
  border: none;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  outline: none;
  box-shadow: 0 4px 12px rgba(14, 89, 242, 0.2);
}

.tc-chatbot-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(14, 89, 242, 0.3);
}

.tc-chatbot-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}

.tc-chatbot-send-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.tc-chatbot-branding {
  font-size: 10.5px;
  color: var(--tc-chat-text-light);
  text-align: center;
  margin-top: 8px;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-weight: 500;
}

.tc-chatbot-branding svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

/* Typing Indicator (Bounce Dots) */
.tc-typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
}

.tc-typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--tc-chat-text-muted);
  border-radius: 50%;
  display: inline-block;
  animation: tc-bounce 1.3s infinite ease-in-out;
  opacity: 0.7;
}

.tc-typing-indicator span:nth-child(2) {
  animation-delay: 0.15s;
}

.tc-typing-indicator span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes tc-bounce {
  0%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-5px);
  }
}

/* Rendered markdown inside bot bubbles */
.tc-chatbot-msg-bubble p {
  margin: 0 0 8px 0;
}

.tc-chatbot-msg-bubble p:last-child {
  margin-bottom: 0;
}

.tc-chatbot-msg-bubble ul, .tc-chatbot-msg-bubble ol {
  margin: 0 0 8px 0;
  padding-left: 18px;
}

.tc-chatbot-msg-bubble ul:last-child, .tc-chatbot-msg-bubble ol:last-child {
  margin-bottom: 0;
}

.tc-chatbot-msg-bubble li {
  margin-bottom: 4px;
}

.tc-chatbot-msg-bubble strong {
  font-weight: 700;
}

.tc-chatbot-msg-bubble code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 4px;
  padding: 2px 5px;
}

.tc-chatbot-msg.bot .tc-chatbot-msg-bubble a {
  color: var(--tc-brand-primary);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tc-chatbot-msg.bot .tc-chatbot-msg-bubble a:hover {
  opacity: 0.8;
}

/* Disabled input while the assistant is replying */
.tc-chatbot-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background: #F1F5F9;
}

.tc-chatbot-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .tc-chatbot-trigger {
    bottom: 18px;
    right: 18px;
    width: 54px;
    height: 54px;
  }
  
  .tc-chatbot-window {
    right: 12px;
    left: 12px;
    bottom: 84px;
    width: auto;
    height: calc(100vh - 100px);
    max-height: 560px;
    border-radius: 20px;
  }

  .tc-chatbot-chips {
    padding-left: 0;
  }
}
