/*
 * Tamilcube Chatbot widget — modern service-aware styles.
 * Mobile overrides live in widget-mobile.css.
 */

:root {
  --tc-accent: #8b1e3f;
  --tc-ink: #18212f;
  --tc-muted: #647083;
  --tc-soft: #f5f7fb;
  --tc-panel: #ffffff;
  --tc-line: #dde4ee;
  --tc-success: #16825d;
  --tc-radius: 8px;
  --tc-shadow-lg: 0 22px 54px rgba(13, 24, 43, 0.2);
  --tc-shadow-md: 0 12px 28px rgba(13, 24, 43, 0.16);
  --tc-font: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

#tc-launcher,
#tc-chatbot-root,
#tc-chatbot-root * {
  box-sizing: border-box;
}

#tc-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  min-width: 126px;
  height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 999px;
  background: var(--tc-accent);
  color: #fff;
  font-family: var(--tc-font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--tc-shadow-md);
  z-index: 9999;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}

#tc-launcher:hover,
#tc-launcher:focus-visible {
  transform: translateY(-2px);
  box-shadow: var(--tc-shadow-lg);
  filter: saturate(1.08);
}

#tc-launcher:focus-visible,
#tc-close-btn:focus-visible,
#tc-send-btn:focus-visible,
.tc-quick-btn:focus-visible,
.tc-more-btn:focus-visible,
.tc-show-more:focus-visible,
.tc-card a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--tc-accent), white 68%);
  outline-offset: 2px;
}

.tc-launcher-mark {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  font-size: 18px;
  line-height: 1;
}

.tc-launcher-text {
  line-height: 1;
}

#tc-chatbot-root:not(.tc-chatbot-hidden) ~ #tc-launcher {
  display: none;
}

#tc-chatbot-root {
  position: fixed;
  right: 22px;
  bottom: 90px;
  width: min(390px, calc(100vw - 32px));
  height: min(620px, calc(100vh - 118px));
  min-height: 470px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  color: var(--tc-ink);
  background: var(--tc-panel);
  border: 1px solid rgba(221, 228, 238, 0.9);
  border-radius: 18px;
  box-shadow: var(--tc-shadow-lg);
  font-family: var(--tc-font);
  font-size: 14px;
  line-height: 1.45;
}

#tc-chatbot-root.tc-chatbot-hidden {
  display: none;
}

#tc-chatbot-header {
  flex: 0 0 auto;
  min-height: 82px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 16px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0)),
    var(--tc-accent);
}

.tc-header-left {
  min-width: 0;
}

.tc-kicker {
  display: block;
  margin-bottom: 3px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tc-title {
  display: block;
  overflow: hidden;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tc-service-badge {
  max-width: 118px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  padding: 6px 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tc-icon-btn,
.tc-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
}

#tc-close-btn {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
}

#tc-close-btn span,
#tc-close-btn span::after {
  position: absolute;
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: #fff;
  content: "";
  transform: rotate(45deg);
}

#tc-close-btn span::after {
  transform: rotate(90deg);
}

.tc-chatbot-intro {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--tc-line);
  color: var(--tc-muted);
  background: #fff;
  font-size: 12px;
  font-weight: 650;
}

.tc-presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tc-success);
  box-shadow: 0 0 0 4px rgba(22, 130, 93, 0.12);
}

#tc-messages {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 16px;
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--tc-accent), white 88%), transparent 240px),
    var(--tc-soft);
}

#tc-messages::-webkit-scrollbar {
  width: 8px;
}

#tc-messages::-webkit-scrollbar-thumb {
  border: 2px solid var(--tc-soft);
  border-radius: 999px;
  background: rgba(100, 112, 131, 0.45);
}

.tc-message {
  max-width: 88%;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 16px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: tcFadeIn 0.18s ease;
}

.tc-bot {
  align-self: flex-start;
  color: var(--tc-ink);
  background: #fff;
  border: 1px solid var(--tc-line);
  border-bottom-left-radius: 6px;
  box-shadow: 0 8px 20px rgba(13, 24, 43, 0.06);
}

.tc-user {
  align-self: flex-end;
  color: #fff;
  background: var(--tc-accent);
  border-bottom-right-radius: 6px;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--tc-accent), transparent 75%);
}

.tc-typing {
  display: inline-flex;
  gap: 5px;
  width: auto;
  min-width: 62px;
}

.tc-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tc-muted);
  animation: tcTyping 1s infinite ease-in-out;
}

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

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

.tc-card {
  width: 100%;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--tc-line);
  border-radius: 8px;
  background: #fff;
}

.tc-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}

.tc-topic {
  display: inline-flex;
  max-width: 100%;
  overflow: hidden;
  border-radius: 999px;
  padding: 4px 8px;
  color: var(--tc-accent);
  background: color-mix(in srgb, var(--tc-accent), white 88%);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tc-question {
  margin: 0 0 8px;
  color: var(--tc-ink);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.35;
}

.tc-answer {
  color: #2d3748;
  font-size: 13px;
}

.tc-answer p {
  margin: 0 0 8px;
}

.tc-answer p:last-child {
  margin-bottom: 0;
}

.tc-answer.tc-collapsed {
  position: relative;
  max-height: 68px;
  overflow: hidden;
}

.tc-answer.tc-collapsed::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 34px;
  background: linear-gradient(rgba(255, 255, 255, 0), #fff);
  content: "";
}

.tc-show-more {
  margin-top: 8px;
  border: 0;
  padding: 0;
  color: var(--tc-accent);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.tc-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tc-cta-btn,
.tc-extra-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  text-decoration: none;
}

.tc-cta-btn {
  color: #fff;
  background: var(--tc-accent);
}

.tc-extra-link {
  border: 1px solid color-mix(in srgb, var(--tc-accent), white 68%);
  color: var(--tc-accent);
  background: #fff;
}

.tc-extra-link::after {
  margin-left: 6px;
  content: "\2197";
  font-size: 11px;
}

.tc-chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.tc-chip-title {
  width: 100%;
  color: var(--tc-muted);
  font-size: 12px;
  font-weight: 800;
}

.tc-quick-btn,
.tc-more-btn {
  border: 1px solid color-mix(in srgb, var(--tc-accent), white 72%);
  border-radius: 999px;
  padding: 8px 11px;
  color: var(--tc-accent);
  background: #fff;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.tc-quick-btn:hover,
.tc-more-btn:hover {
  background: color-mix(in srgb, var(--tc-accent), white 91%);
  transform: translateY(-1px);
}

.tc-more-btn {
  align-self: flex-start;
}

.tc-section-title {
  align-self: stretch;
  margin: 5px 2px -2px;
  color: var(--tc-muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#tc-input-area {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 9px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid var(--tc-line);
  background: #fff;
}

#tc-input {
  min-width: 0;
  height: 44px;
  border: 1px solid #cdd7e4;
  border-radius: 999px;
  padding: 0 15px;
  color: var(--tc-ink);
  background: #fff;
  font-family: var(--tc-font);
  font-size: 14px;
  outline: none;
}

#tc-input:focus {
  border-color: var(--tc-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tc-accent), transparent 82%);
}

#tc-input:disabled {
  color: var(--tc-muted);
  background: #f1f5f9;
}

#tc-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--tc-accent);
  transition: transform 0.15s ease, opacity 0.15s ease;
}

#tc-send-btn span {
  width: 0;
  height: 0;
  margin-left: 3px;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 14px solid #fff;
}

#tc-send-btn:not(:disabled):hover {
  transform: translateY(-1px);
}

#tc-send-btn:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

@keyframes tcFadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes tcTyping {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  #tc-launcher,
  .tc-message,
  .tc-quick-btn,
  .tc-more-btn,
  #tc-send-btn,
  .tc-typing span {
    animation: none;
    transition: none;
  }
}
