/* ==========================================================================
   CHIANGMAI CDR - AI SAAS COMMAND BAR & ASSISTANT (TESLA DARK THEME)
   Zero-Emoji Policy | Clean Monochrome SVG | Interleaved Solution Bundles
   ========================================================================== */

/* 1. Hero Command Bar Wrapper */
.tesla-ai-command-wrapper {
  width: 100%;
  max-width: 780px;
  margin: 40px auto 40px auto;
  position: relative;
  z-index: 10;
}

.tesla-ai-input-box {
  display: flex;
  align-items: center;
  position: relative;
  background: rgba(16, 18, 24, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-apple-pill, 980px);
  padding: 6px 8px 6px 20px;
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.tesla-ai-input-box:focus-within {
  border-color: #ffffff;
  background: rgba(22, 26, 36, 0.9);
  box-shadow: 0 0 35px rgba(255, 255, 255, 0.15), 0 10px 40px rgba(0, 0, 0, 0.6);
}

.tesla-ai-search-icon {
  display: flex;
  align-items: center;
  color: var(--text-tesla-muted, #9aa0a6);
  margin-right: 12px;
  flex-shrink: 0;
}

/* Input Container with Gemini Shimmer Placeholder */
.tesla-ai-input-container {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
}

.tesla-ai-input {
  width: 100%;
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 0.96rem;
  color: #ffffff;
  padding: 10px 4px;
}

.tesla-ai-input::placeholder,
.tesla-ai-footer-input::placeholder {
  color: transparent;
}

.tesla-ai-shimmer-placeholder {
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 500;
  user-select: none;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.35) 0%,
    rgba(255, 255, 255, 0.35) 25%,
    rgba(255, 255, 255, 0.75) 45%,
    #ffffff 50%,
    rgba(255, 255, 255, 0.75) 55%,
    rgba(255, 255, 255, 0.35) 75%,
    rgba(255, 255, 255, 0.35) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: geminiShimmer 3.2s linear infinite;
  will-change: background-position;
  transition: opacity 0.18s ease, visibility 0.18s ease;
  white-space: nowrap;
}

.tesla-ai-footer .tesla-ai-shimmer-placeholder {
  left: 18px;
  font-size: 0.9rem;
}

@keyframes geminiShimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: 0% 0;
  }
}

.tesla-ai-input:not(:placeholder-shown) + .tesla-ai-shimmer-placeholder,
.tesla-ai-footer-input:not(:placeholder-shown) + .tesla-ai-shimmer-placeholder {
  opacity: 0;
  visibility: hidden;
}

.tesla-ai-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #ffffff;
  color: #070709;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tesla-ai-submit-btn:hover {
  background: #e2e8f0;
  transform: scale(1.05);
}

.tesla-ai-submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* 2. Suggested Prompts Row */
.tesla-ai-prompts-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}

.tesla-ai-prompt-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.78);
  font-family: inherit;
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: var(--radius-apple-pill, 980px);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.tesla-ai-prompt-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: #ffffff;
  color: #ffffff;
  transform: translateY(-1px);
}

/* 3. Tesla Glass AI Assistant Overlay */
.tesla-ai-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(5, 6, 8, 0.82);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.tesla-ai-overlay.active {
  display: flex;
  opacity: 1;
}

.tesla-ai-dialog {
  width: 100%;
  max-width: 920px;
  height: 88vh;
  max-height: 850px;
  background: rgba(14, 16, 22, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8), 0 0 40px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Overlay Header */
.tesla-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(18, 21, 29, 0.6);
  flex-shrink: 0;
}

.tesla-ai-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tesla-ai-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 4px 10px;
  border-radius: 980px;
  font-weight: 600;
}

.tesla-ai-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.tesla-ai-close-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.tesla-ai-close-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: #ffffff;
}

/* Chat Stream Container */
.tesla-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  scroll-behavior: smooth;
}

.tesla-ai-messages::-webkit-scrollbar {
  width: 6px;
}
.tesla-ai-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* User Message Bubble */
.tesla-ai-user-msg {
  align-self: flex-end;
  max-width: 80%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 16px 16px 4px 16px;
  font-size: 0.92rem;
  line-height: 1.55;
  word-break: break-word;
}

/* Bot Message Wrapper */
.tesla-ai-bot-msg {
  align-self: flex-start;
  width: 100%;
  max-width: 100%;
  color: #ffffff;
  font-size: 0.92rem;
  line-height: 1.6;
}

/* Loading Shimmer Text (Gemini Style - No Spinner Box) */
.tesla-ai-loading {
  display: flex;
  align-items: center;
  padding: 6px 2px;
}

.tesla-ai-loading-shimmer {
  font-family: inherit;
  font-size: 0.94rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  user-select: none;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.32) 0%,
    rgba(255, 255, 255, 0.32) 25%,
    rgba(255, 255, 255, 0.78) 45%,
    #ffffff 50%,
    rgba(255, 255, 255, 0.78) 55%,
    rgba(255, 255, 255, 0.32) 75%,
    rgba(255, 255, 255, 0.32) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: geminiShimmer 2.4s linear infinite;
  will-change: background-position;
}

/* Inline Highlighted Text (Borderless Clean Typography) */
.ai-text-highlight {
  color: #ffffff;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.09);
  padding: 1px 6px;
  border-radius: 4px;
}

/* Interleaved Solution Bundle Layout (Borderless Text + Mini Vertical Grid) */
.bundle-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bundle-intro {
  background: transparent;
  border: none;
  padding: 0 2px;
  font-size: 0.94rem;
  line-height: 1.72;
  color: #e2e8f0;
}

/* Google Search Grounding Pill & Market Trend */
.bundle-grounding-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-apple-pill, 980px);
  padding: 3px 11px;
  font-size: 0.74rem;
  color: var(--text-tesla-muted, #9aa0a6);
  width: fit-content;
  letter-spacing: 0.02em;
}

.bundle-grounding-pill svg {
  stroke: #ffffff;
  flex-shrink: 0;
}

.bundle-market-trend {
  background: transparent;
  border: none;
  border-left: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 0;
  padding: 2px 0 2px 12px;
  font-size: 0.86rem;
  line-height: 1.62;
  color: #cbd5e1;
}

/* Mini Vertical Product Grid (2 Columns on Desktop, 1 Compact Column on Mobile) */
.bundle-items {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

.bundle-items.bundle-items-single {
  grid-template-columns: minmax(0, 410px);
}

.tesla-ai-messages .tesla-product-card.ai-mini-card {
  background: rgba(16, 19, 27, 0.65) !important;
  border: 1px solid rgba(255, 255, 255, 0.09) !important;
  border-radius: 14px !important;
  padding: 14px !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: flex-start !important;
  transition: border-color 0.2s ease, background 0.2s ease !important;
  box-shadow: none !important;
}

.tesla-ai-messages .tesla-product-card.ai-mini-card:hover {
  border-color: rgba(255, 255, 255, 0.22) !important;
  background: rgba(20, 24, 34, 0.85) !important;
  transform: none !important;
}

.tesla-ai-messages .ai-mini-card .card-clickable-body {
  flex: 0 0 auto;
}

.tesla-ai-messages .ai-mini-card .tesla-card-media {
  aspect-ratio: auto !important;
  height: 138px !important;
  margin-bottom: 10px !important;
  border-radius: 10px !important;
  background: rgba(255, 255, 255, 0.03) !important;
  border: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.tesla-ai-messages .ai-mini-card .tesla-card-media img {
  padding: 8px !important;
  object-fit: contain !important;
}

.tesla-ai-messages .ai-mini-card .tesla-product-brand {
  font-size: 0.62rem !important;
  padding: 2px 7px !important;
  margin-bottom: 6px !important;
}

.tesla-ai-messages .ai-mini-card .tesla-product-name {
  font-size: 0.86rem !important;
  line-height: 1.38 !important;
  min-height: 2.4em !important;
  margin-bottom: 6px !important;
}

.bundle-item-role-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 2px 9px;
  border-radius: 980px;
  margin-bottom: 10px;
}

/* Minimal Left-Line Explanation Highlight (No Nested Box) */
.bundle-item-explanation {
  margin: 4px 0 12px 0;
  background: transparent;
  border: none;
  border-left: 2px solid rgba(255, 255, 255, 0.38);
  padding: 2px 0 2px 10px;
  border-radius: 0;
  font-size: 0.8rem;
  line-height: 1.55;
  color: #cbd5e1;
}

.tesla-ai-messages .ai-mini-card .tesla-product-actions {
  margin-top: auto !important;
  padding-top: 8px !important;
  gap: 6px !important;
}

.tesla-ai-messages .ai-mini-card .btn-card-buy,
.tesla-ai-messages .ai-mini-card .btn-card-inquire {
  min-height: 34px !important;
  padding: 6px 8px !important;
  font-size: 0.74rem !important;
}

.bundle-closing {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text-tesla-muted, #9aa0a6);
  padding: 2px 2px 0 2px;
  border-top: none;
}

/* Consultative Chat Text (Borderless Clean Stream - No Background Box) */
.bundle-consultative-box {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 2px 2px;
  line-height: 1.75;
}

.bundle-consultative-box p:last-child {
  margin-bottom: 0 !important;
}

/* Gemini Typing Caret */
.typing-caret {
  display: inline-block;
  width: 2px;
  height: 1.15em;
  background-color: #ffffff;
  margin-left: 3px;
  vertical-align: -2px;
  border-radius: 1px;
  animation: typingCaretBlink 0.75s ease-in-out infinite;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.7);
}

@keyframes typingCaretBlink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.15;
  }
}

/* Refusal & Out-of-Scope Text (Borderless Clean Stream) */
.bundle-refusal-box {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 2px 2px;
  line-height: 1.7;
}

/* Chat Footer */
.tesla-ai-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(18, 21, 29, 0.6);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.tesla-ai-footer-input {
  width: 100%;
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 980px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 0.9rem;
  color: #ffffff;
  outline: none;
  transition: all 0.2s ease;
}

.tesla-ai-footer-input:focus {
  border-color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .tesla-ai-command-wrapper {
    margin: 28px auto 28px auto;
  }
  .tesla-ai-dialog {
    width: 96%;
    height: 94vh;
    border-radius: 14px;
  }
  .tesla-ai-header {
    padding: 12px 16px;
  }
  .tesla-ai-messages {
    padding: 16px;
    gap: 16px;
  }
  .tesla-ai-footer {
    padding: 12px 16px;
  }
  .tesla-ai-prompt-btn {
    font-size: 0.75rem;
    padding: 5px 10px;
  }
  .bundle-items,
  .bundle-items.bundle-items-single {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  .tesla-ai-messages .tesla-product-card.ai-mini-card {
    padding: 12px !important;
  }
  .tesla-ai-messages .ai-mini-card .tesla-card-media {
    height: 118px !important;
    margin-bottom: 8px !important;
  }
}


/* ==========================================================================
   AI ASSISTANT AUTH QUOTA PILL & IN-CHAT LOGIN GATE CARDS
   ========================================================================== */
.tesla-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tesla-ai-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tesla-ai-quota-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 500;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 3px 10px;
  border-radius: 980px;
  letter-spacing: 0.01em;
}

.tesla-ai-quota-pill.quota-warn {
  border-color: rgba(251, 191, 36, 0.4);
  color: #fde68a;
}

.tesla-ai-gate-card {
  background: rgba(18, 22, 32, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tesla-ai-gate-badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 4px 10px;
  border-radius: 980px;
}

.tesla-ai-gate-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  line-height: 1.4;
}

.tesla-ai-gate-desc {
  font-size: 0.88rem;
  color: #9aa0a6;
  line-height: 1.65;
  margin: 0;
}

.tesla-ai-gate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.btn-ai-google-login {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #ffffff;
  color: #06080a !important;
  border: 1px solid #ffffff;
  border-radius: 980px;
  padding: 11px 22px;
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 24px rgba(255, 255, 255, 0.16);
}

.btn-ai-google-login:hover {
  background: #f1f5f9;
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(255, 255, 255, 0.25);
}

.btn-ai-google-login:disabled {
  opacity: 0.65;
  cursor: wait;
}

.btn-ai-gate-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 980px;
  padding: 10px 18px;
  font-size: 0.84rem;
  font-weight: 500;
  text-decoration: none !important;
  transition: all 0.2s ease;
}

.btn-ai-gate-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.32);
}
