/* KM Tech Chat — alive Delta blue UI (v0.5.0) */
.km-tc-wrap {
  --km-blue: #0090e0;
  --km-blue-dark: #0070b8;
  --km-blue-hover: #00a8f0;
  --km-navy: #2c3548;
  --km-muted: #556278;
  --km-line: #dce4ee;
  --km-bg: #f2f6fa;
  --km-white: #ffffff;
  --km-accent: #f59e0b;
  --km-radius: 12px;
  --km-font: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;

  max-width: 720px;
  margin: 1.25rem auto 1.75rem;
  padding: 0;
  border: 1px solid var(--km-line);
  border-radius: 16px;
  background: var(--km-white);
  color: var(--km-navy);
  font-family: var(--km-font);
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 90, 158, 0.1);
}

.km-tc-head {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0;
  padding: 1rem 1.15rem 0.85rem;
  padding-left: 2.5rem;
  background:
    radial-gradient(ellipse 80% 120% at 0% 0%, rgba(0, 168, 240, 0.35) 0%, transparent 55%),
    linear-gradient(135deg, #0090e0 0%, #0070b8 55%, #2c3548 100%);
  color: #fff;
}

.km-tc-head strong {
  font-size: 1.08rem;
  font-weight: 800;
  color: #fff;
}

.km-tc-head span {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.5;
}

.km-tc-close {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  border: 0;
  background: rgba(255, 255, 255, 0.16);
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: #fff;
  z-index: 2;
}

.km-tc-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.km-tc-body {
  padding: 0.85rem 1rem 1rem;
  background: linear-gradient(180deg, #f7fbfe 0%, var(--km-bg) 100%);
}

.km-tc-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.km-tc-chips button {
  border: 1px solid var(--km-line);
  background: var(--km-white);
  color: var(--km-navy);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.4rem 0.7rem 0.4rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.km-tc-chips button::before {
  content: "";
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  border-radius: 6px;
  background-color: var(--km-blue);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: 0.78rem;
  mask-size: 0.78rem;
}

.km-tc-chips button[data-icon="link"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/%3E%3Cpath d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/%3E%3C/svg%3E");
}

.km-tc-chips button[data-icon="drive"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M13 2L3 14h9l-1 8 10-12h-9l1-8z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M13 2L3 14h9l-1 8 10-12h-9l1-8z'/%3E%3C/svg%3E");
}

.km-tc-chips button[data-icon="fix"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4'/%3E%3C/svg%3E");
}

.km-tc-chips button[data-icon="screen"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='2' y='3' width='20' height='14' rx='2'/%3E%3Cpath d='M8 21h8M12 17v4'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Crect x='2' y='3' width='20' height='14' rx='2'/%3E%3Cpath d='M8 21h8M12 17v4'/%3E%3C/svg%3E");
}

.km-tc-chips button[data-icon="quote"]::before {
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M12 1v22M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2'%3E%3Cpath d='M12 1v22M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6'/%3E%3C/svg%3E");
}

.km-tc-chips button:hover {
  border-color: var(--km-blue);
  color: var(--km-blue-dark);
  box-shadow: 0 4px 14px rgba(0, 144, 224, 0.12);
  transform: translateY(-1px);
}

.km-tc-nudge {
  align-self: stretch;
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 0.85rem;
  margin: 0;
  border-radius: 12px;
  border: 1px solid rgba(245, 158, 11, 0.4);
  background: #fffbeb;
  color: #78350f;
  font-size: 0.84rem;
  line-height: 1.55;
}

.km-tc-nudge button {
  border: 0;
  background: var(--km-accent);
  color: #1a1206;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
}

.km-tc-nudge button:hover {
  background: #d97706;
  color: #fff;
}

.km-tc-log {
  min-height: 220px;
  max-height: 420px;
  overflow: auto;
  background: var(--km-white);
  border: 1px solid var(--km-line);
  border-radius: 14px;
  padding: 0.85rem;
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.km-tc-msg {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.7;
  white-space: pre-wrap;
  max-width: 92%;
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  word-break: break-word;
}

.km-tc-msg.user {
  align-self: flex-start;
  background: rgba(0, 144, 224, 0.12);
  color: var(--km-navy);
  border: 1px solid rgba(0, 144, 224, 0.22);
  border-bottom-right-radius: 4px;
}

.km-tc-msg.bot {
  align-self: flex-end;
  background: #f4f7fb;
  color: var(--km-navy);
  border: 1px solid var(--km-line);
  border-bottom-left-radius: 4px;
}

.km-tc-msg.bot a {
  color: var(--km-blue, #0090e0);
  font-weight: 700;
  text-decoration: underline;
  word-break: break-all;
}

.km-tc-msg.bot a:hover {
  color: var(--km-blue-hover, #00a8f0);
}

.km-tc-msg.welcome {
  align-self: stretch;
  max-width: 100%;
  background: linear-gradient(135deg, rgba(0, 144, 224, 0.08), rgba(0, 144, 224, 0.02));
  border: 1px dashed rgba(0, 144, 224, 0.35);
  color: var(--km-navy);
  white-space: normal;
}

.km-tc-msg.err {
  align-self: stretch;
  max-width: 100%;
  color: #9b1c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.km-tc-msg.meta {
  align-self: stretch;
  max-width: 100%;
  font-size: 0.72rem;
  color: var(--km-muted);
  white-space: normal;
  padding: 0.35rem 0.15rem;
  background: transparent;
  border: 0;
}

.km-tc-typing {
  align-self: flex-end;
  display: inline-flex;
  gap: 0.28rem;
  padding: 0.7rem 0.95rem;
  background: #f4f7fb;
  border: 1px solid var(--km-line);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.km-tc-typing span {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 50%;
  background: var(--km-blue);
  opacity: 0.45;
  animation: kmTcDot 1.1s ease-in-out infinite;
}

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

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

.km-tc-sources {
  display: grid;
  gap: 0.4rem;
  margin: 0;
  align-self: stretch;
}

.km-tc-source-card {
  display: block;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--km-line);
  background: var(--km-white);
  color: var(--km-navy) !important;
  text-decoration: none !important;
  font-size: 0.8rem;
  line-height: 1.45;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.km-tc-source-card:hover {
  border-color: var(--km-blue);
  box-shadow: 0 4px 14px rgba(0, 144, 224, 0.1);
}

.km-tc-source-card strong {
  display: block;
  color: var(--km-blue-dark);
  font-size: 0.72rem;
  margin-bottom: 0.15rem;
}

.km-tc-form {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.km-tc-form textarea {
  flex: 1;
  resize: vertical;
  min-height: 52px;
  max-height: 140px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--km-line);
  border-radius: 12px;
  font: inherit;
  background: var(--km-white);
}

.km-tc-form textarea:focus {
  outline: none;
  border-color: var(--km-blue);
  box-shadow: 0 0 0 3px rgba(0, 144, 224, 0.16);
}

.km-tc-form button,
.km-tc-rfq button {
  border: 0;
  background: var(--km-blue);
  color: #fff;
  padding: 0.7rem 1.1rem;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  border-radius: 12px;
  box-shadow: 0 6px 18px rgba(0, 144, 224, 0.28);
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  white-space: nowrap;
}

.km-tc-form button:hover,
.km-tc-rfq button:hover {
  background: var(--km-blue-hover);
  transform: translateY(-1px);
}

.km-tc-form button:disabled,
.km-tc-rfq button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.km-tc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin-top: 0.7rem;
}

.km-tc-rfq-toggle {
  border: 1px solid var(--km-accent);
  background: rgba(245, 158, 11, 0.1);
  color: #92400e;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
}

.km-tc-rfq-toggle:hover {
  background: rgba(245, 158, 11, 0.18);
}

.km-tc-link {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--km-blue);
  text-decoration: none;
}

.km-tc-link:hover {
  color: var(--km-blue-dark);
  text-decoration: underline;
}

.km-tc-rfq {
  margin-top: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.75rem;
  border: 1px dashed rgba(245, 158, 11, 0.45);
  background: #fffbeb;
  border-radius: 12px;
}

.km-tc-rfq input,
.km-tc-rfq textarea {
  border: 1px solid var(--km-line);
  padding: 0.5rem 0.65rem;
  font: inherit;
  border-radius: 10px;
}

.km-tc-rfq-note,
.km-tc-rfq-status,
.km-tc-hint {
  font-size: 0.78rem;
  color: var(--km-muted);
  margin: 0.45rem 0 0;
}

.km-tc-hp {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
}

/* Floating dock */
.km-tc-float {
  position: fixed;
  z-index: 100050;
  left: 1rem;
  bottom: 5.5rem;
  font-family: var(--km-font, "Vazirmatn", Tahoma, sans-serif);
  pointer-events: none;
}

.km-tc-float .km-tc-fab,
.km-tc-float .km-tc-dock {
  pointer-events: auto;
}

/* Landing: laptop and wider only. Phones keep the page clear. */
@media (max-width: 1023px) {
  .km-tc-float--laptop {
    display: none !important;
  }
}

.km-tc-dock[hidden] {
  display: none !important;
}

.km-tc-float.is-open .km-tc-dock {
  display: block !important;
}

.km-tc-fab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  width: auto !important;
  height: auto !important;
  min-width: 5.4rem;
  min-height: 0;
  max-width: none !important;
  max-height: none !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  overflow: visible !important;
  background: transparent !important;
  aspect-ratio: auto;
  clip-path: none;
  cursor: pointer;
  box-shadow: none;
  transition: transform 0.2s ease;
}

.km-tc-fab-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  background: #fff;
  color: #0070b8;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
  white-space: nowrap;
  border: 1px solid #d5e2ef;
  box-shadow: 0 6px 16px rgba(16, 34, 52, 0.16);
}

.km-tc-fab-face {
  display: block;
  width: 5.4rem;
  height: 5.4rem;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 10px 26px rgba(16, 34, 52, 0.28);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.km-tc-fab img {
  display: block;
  width: 5.4rem !important;
  height: 5.4rem !important;
  max-width: none !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  object-position: center center !important;
  clip-path: circle(50%);
  pointer-events: none;
}

.km-tc-fab:hover {
  transform: translateY(-2px);
}

.km-tc-fab:hover .km-tc-fab-face {
  box-shadow: 0 14px 32px rgba(16, 34, 52, 0.34), 0 0 0 2px rgba(0, 144, 224, 0.45);
}

.km-tc-fab:focus-visible {
  outline: 3px solid #0090e0;
  outline-offset: 3px;
}

.km-tc-dock {
  position: absolute;
  left: 0;
  bottom: 8.35rem;
  width: min(92vw, 400px);
}

.km-tc-wrap--float {
  margin: 0;
  max-width: none;
  max-height: min(78vh, 640px);
  overflow: auto;
  box-shadow: 0 18px 44px rgba(16, 34, 52, 0.24);
}

.km-tc-wrap--float .km-tc-log {
  min-height: 140px;
  max-height: 240px;
}

.km-tc-finder-banner {
  display: none !important;
}

@media (max-width: 640px) {
  .km-tc-form {
    flex-direction: row;
    align-items: flex-end;
  }

  .km-tc-form button {
    width: auto;
    min-width: 4.5rem;
    padding: 0.7rem 0.85rem;
  }

  .km-tc-float {
    left: 0.65rem;
    right: auto;
    bottom: 5.25rem;
  }

  .km-tc-dock {
    left: 0;
    right: auto;
    width: min(92vw, 400px);
    bottom: 8.2rem;
  }

  /* Open state: take the whole phone screen */
  .km-tc-float.is-open {
    inset: 0;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    z-index: 100080;
    pointer-events: auto;
  }

  .km-tc-float.is-open .km-tc-fab {
    display: none;
  }

  .km-tc-float.is-open .km-tc-dock {
    position: fixed;
    inset: 0;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    height: 100dvh;
    display: flex !important;
    flex-direction: column;
    margin: 0;
    padding: 0;
    z-index: 100081;
  }

  .km-tc-float.is-open .km-tc-wrap--float {
    margin: 0;
    width: 100%;
    max-width: none;
    max-height: none;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .km-tc-float.is-open .km-tc-head {
    flex: 0 0 auto;
    padding-top: calc(0.85rem + env(safe-area-inset-top, 0px));
  }

  .km-tc-float.is-open .km-tc-close {
    top: calc(0.55rem + env(safe-area-inset-top, 0px));
    width: 2.35rem;
    height: 2.35rem;
    font-size: 1.35rem;
  }

  .km-tc-float.is-open .km-tc-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
  }

  .km-tc-float.is-open .km-tc-chips {
    flex: 0 0 auto;
    max-height: 5.5rem;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .km-tc-float.is-open .km-tc-chips button {
    flex: 0 0 auto;
  }

  .km-tc-float.is-open .km-tc-log {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .km-tc-float.is-open .km-tc-form,
  .km-tc-float.is-open .km-tc-actions,
  .km-tc-float.is-open .km-tc-rfq {
    flex: 0 0 auto;
  }

  body.km-tc-mobile-open {
    overflow: hidden !important;
    touch-action: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .km-tc-typing span {
    animation: none;
    opacity: 0.7;
  }

  .km-tc-fab,
  .km-tc-chips button,
  .km-tc-form button {
    transition: none;
  }
}
