
/* Premium AI Chat UI Styles */
.market-analysis-dashboard .ai-chat-container {
  max-width: 1000px;
  margin: 30px auto;
  background: #f8fafc;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 570px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  position: relative;
  transition: all 0.3s ease;
}

.market-analysis-dashboard .ai-chat-header {
  padding: 24px 30px;
  background: #ffffff;
  border-bottom: 1px solid #f1f5f9;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 20px;
  z-index: 10;
  text-align: start;
}

html[dir="rtl"] .market-analysis-dashboard .ai-chat-header {
  flex-direction: row;
}

.market-analysis-dashboard .ai-chat-avatar {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #a7803d 0%, #059669 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2);
}

.market-analysis-dashboard .ai-chat-title-wrap h3 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.5px;
}

.market-analysis-dashboard .ai-chat-title-wrap p {
  margin: 0;
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 500;
}

.market-analysis-dashboard .ai-chat-back-btn {
  background: #1e293b;
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.2s;
  margin-inline-start: auto; /* Push to the opposite side of title */
}

.market-analysis-dashboard .ai-chat-back-btn:hover {
  background: #334155;
  transform: scale(1.05);
}

.market-analysis-dashboard .ai-chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a7803d;
  font-size: 1.4rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.market-analysis-dashboard .ai-chat-title-wrap h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.market-analysis-dashboard .ai-chat-title-wrap p {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 500;
}

.market-analysis-dashboard .ai-chat-messages {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: transparent;
}

.market-analysis-dashboard .chat-message {
  display: flex;
  gap: 14px;
  align-items: flex-end;
  animation: fadeInUp 0.3s ease-out forwards;
}

/* LTR: AI on left, User on right */
html[dir="ltr"] .market-analysis-dashboard .chat-message.ai {
  flex-direction: row;
  justify-content: flex-start;
}

html[dir="ltr"] .market-analysis-dashboard .chat-message.user {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

/* RTL: AI on right, User on left (mirrored) */
html[dir="rtl"] .market-analysis-dashboard .chat-message.ai {
  flex-direction: row;
  justify-content: flex-start;
}

html[dir="rtl"] .market-analysis-dashboard .chat-message.user {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

/* Fallback for no dir attribute */
.market-analysis-dashboard .chat-message.user {
  justify-content: flex-end;
}

.market-analysis-dashboard .chat-message .msg-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.market-analysis-dashboard .chat-message.ai .msg-avatar {
  background: #fff;
  color: #a7803d;
}

.market-analysis-dashboard .chat-message.user .msg-avatar {
  background: #1e293b;
  color: #ffffff;
}

.market-analysis-dashboard .chat-message .msg-bubble {
  padding: 16px 24px;
  border-radius: 20px;
  font-size: 0.7rem;
  line-height: 1.6;
  max-width: 85%;
  position: relative;
  transition: all 0.2s ease;
  text-align: start;
}

/* LTR bubble tails */
.market-analysis-dashboard .chat-message.ai .msg-bubble {
  background: #ffffff;
  color: #334155;
  border: 1px solid #f1f5f9;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
  border-radius: 20px;
}

.market-analysis-dashboard .chat-message.user .msg-bubble {
  background: #1e293b;
  color: #ffffff;
  box-shadow: 0 10px 15px -3px rgba(30, 41, 59, 0.1);
  border-radius: 20px;
}

/* LTR bubble tails */
html[dir="ltr"] .market-analysis-dashboard .chat-message.ai .msg-bubble {
  border-bottom-left-radius: 4px;
}

html[dir="ltr"] .market-analysis-dashboard .chat-message.user .msg-bubble {
  border-bottom-right-radius: 4px;
}

/* RTL bubble tails (mirrored corners) */
html[dir="rtl"] .market-analysis-dashboard .chat-message.ai .msg-bubble {
  border-bottom-right-radius: 4px;
}

html[dir="rtl"] .market-analysis-dashboard .chat-message.user .msg-bubble {
  border-bottom-left-radius: 4px;
}

.market-analysis-dashboard .msg-bubble.typing {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 16px 20px;
}

.market-analysis-dashboard .ai-chat-input-area {
  padding: 30px;
  background: #ffffff;
  border-top: 1px solid #f1f5f9;
  display: flex;
  gap: 20px;
  align-items: center;
  direction: ltr; /* always keep input row LTR so send button stays on right */
}

/* RTL: flip input area so send button is on the left */
html[dir="rtl"] .market-analysis-dashboard .ai-chat-input-area {
  direction: rtl;
}

.market-analysis-dashboard .ai-chat-input-area input {
  flex: 1;
  padding: 18px 28px;
  border-radius: 16px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 1rem;
  outline: none;
  transition: all 0.3s;
  color: #1e293b;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
  text-align: start;
  height: 58px !important;
}

html[dir="rtl"] .market-analysis-dashboard .ai-chat-input-area input {
  direction: rtl;
}

.market-analysis-dashboard .ai-chat-input-area input:focus {
  border-color: #a7803d;
  background: #ffffff;
  box-shadow: 0 0 0 1px rgb(227 226 225);
}

.market-analysis-dashboard .ai-chat-input-area button {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  background: #a7803d;
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.4rem;
  box-shadow: 0 4px 12px rgb(167,128,61, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* RTL: flip send icon arrow direction */
html[dir="rtl"] .market-analysis-dashboard .ai-chat-input-area button .fa-paper-plane {
  transform: scaleX(-1);
}

.market-analysis-dashboard .ai-chat-input-area button:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: 0 12px 24px rgba(167, 128, 61, 0.4);
  background: #a7803d;
}

.market-analysis-dashboard .typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}

.market-analysis-dashboard .typing-dot:nth-child(1) {
  animation-delay: -0.32s;
}

.market-analysis-dashboard .typing-dot:nth-child(2) {
  animation-delay: -0.16s;
}

@keyframes typing {

  0%,
  80%,
  100% {
    transform: scale(0);
  }

  40% {
    transform: scale(1);
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .market-analysis-dashboard .ai-chat-container {
    margin: 0;
    border-radius: 0;
    height: 100vh;
    max-width: 100%;
    border: none;
  }

  .market-analysis-dashboard .ai-chat-header {
    padding: 20px;
  }

  .market-analysis-dashboard .ai-chat-messages {
    padding: 20px;
  }

  .market-analysis-dashboard .chat-message .msg-bubble {
    max-width: 90%;
    padding: 14px 18px;
    font-size: 0.7rem;
  }

  .market-analysis-dashboard .ai-chat-input-area {
    padding: 20px;
    padding-bottom: 30px;
  }
}


/* Premium AI Chat Response Styles */
.ai-chat-messages {
  scroll-behavior: smooth;
}

.msg-bubble.table-view {
  width: 100% !important;
  max-width: 100% !important;
  background: #ffffff !important;
  border: 1px solid #f1f5f9 !important;
  color: #334155 !important;
  padding: 15px !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  border-radius: 12px !important;
}

.ai-table-responsive {
  overflow-x: auto;
  margin-top: 10px;
}

.ai-response-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.7rem;
}

.ai-response-table th {
  background: transparent;
  padding: 10px 12px;
  text-align: start;
  font-weight: 700;
  color: #1e293b;
  border-bottom: 1px solid #edf2f7;
  white-space: nowrap;
}

.ai-response-table td {
  padding: 12px;
  border-bottom: 1px solid #f8fafc;
  color: #475569;
  text-align: start;
}

.ai-response-table tr:last-child td {
  border-bottom: none;
}

.ai-response-table tr:hover {
  background: #f1f5f9;
}

/* Highlighted View (TOP_DEALS) */
.msg-bubble.highlighted-view {
  background: #ffffff !important;
  color: #1e293b !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  padding: 20px !important;
  position: relative;
  overflow: hidden;
  border-radius: 12px !important;
}

.msg-bubble.highlighted-view::before {
  display: none !important;
}

.msg-bubble.highlighted-view .highlight,
.msg-bubble.list-view .highlight,
.chat-message.ai .highlight {
  background: transparent !important;
  color: #059669 !important;
  padding: 0;
  border-radius: 0;
  font-weight: 700;
  border-bottom: none;
}

/* List View (GET_PRODUCTS) */
.msg-bubble.list-view {
  background: #ffffff !important;
  border: none !important;
  color: #334155 !important;
  padding: 10px 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  width: 100% !important;
  max-width: 100% !important;
}

.ai-list-container {
  width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 0 20px;
  text-align: start;
}

.ai-list-container ul {
  padding-inline-start: 20px;
  margin: 0;
}

.ai-list-container li {
  margin-bottom: 8px;
}

.ai-card-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px;
}

.ai-card {
    background: #ffffff;
    border-radius: 10px;
    padding: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.ai-card-header {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 10px;
    color: #0f172a;
}

.ai-followup {
    margin-top: 12px;
    padding: 10px;
    background: #f1f5f9;
    border-radius: 8px;
    color: #334155;
}

.ai-card-title {
    font-weight: 600;
    margin-bottom: 6px;
    color: #1e293b;
}

.ai-card-row, .ai-card-title, .ai-card-price {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #475569;
    margin-bottom: 4px;
}

.ai-card-title svg {
    color: #2563eb; /* blue cart */
}

.ai-card-location svg {
    color: #ef4444; /* red location */
}

.ai-card-store svg {
    color: #f59e0b; /* orange store */
}

.ai-card-price svg {
    color: #16a34a; /* green price */
}

/* Typing animation enhancement */
.typing-dot {
  width: 6px;
  height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  display: inline-block;
  margin: 0 2px;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing {

  0%,
  80%,
  100% {
    transform: translateY(0);
  }

  40% {
    transform: translateY(-6px);
  }
}
/* =============================================
   Comparison Table (Store vs Store Pivot)
   ============================================= */
.comparison-table-wrapper {
    overflow-x: auto;
    margin-top: 10px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.ai-bubble .ai-comparison-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.7rem;
    background: #ffffff;
}

/* Header row */
.ai-bubble .ai-comparison-table thead tr {
    border-bottom: 2px solid #e2e8f0;
}

/* Descriptor header (Emirate / Product) */
.ai-bubble .ai-comparison-table thead th:first-child {
    background: #f8fafc;
    color: #1e293b;
    text-align: start;
    padding: 12px 16px;
    font-weight: 700;
    white-space: nowrap;
    border-inline-end: 1px solid #e2e8f0;
}

/* Store column headers — each gets a distinct tint */
.ai-bubble .ai-comparison-table thead th:nth-child(2) {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #1d4ed8;
    text-align: center;
    padding: 12px 16px;
    font-weight: 700;
    white-space: nowrap;
    border-right: 1px solid #e2e8f0;
}

.ai-bubble .ai-comparison-table thead th:nth-child(3) {
    background: linear-gradient(135deg, #f5f3ff, #ede9fe);
    color: #6d28d9;
    text-align: center;
    padding: 12px 16px;
    font-weight: 700;
    white-space: nowrap;
    border-right: 1px solid #e2e8f0;
}

.ai-bubble .ai-comparison-table thead th:nth-child(4) {
    background: linear-gradient(135deg, #fff7ed, #fed7aa);
    color: #c2410c;
    text-align: center;
    padding: 12px 16px;
    font-weight: 700;
    white-space: nowrap;
}

/* Data cells */
.ai-bubble .ai-comparison-table td {
    padding: 11px 16px;
    border-bottom: 1px solid #f1f5f9;
    text-align: center;
    color: #475569;
    white-space: nowrap;
}

/* Descriptor column (Emirate name) */
.ai-bubble .ai-comparison-table td:first-child {
    text-align: start;
    font-weight: 600;
    color: #1e293b;
    border-inline-end: 1px solid #e2e8f0;
    background: #fafafa;
}

.ai-bubble .ai-comparison-table tbody tr:last-child td {
    border-bottom: none;
}

.ai-bubble .ai-comparison-table tbody tr:hover td {
    background: #f8fafc;
}

.ai-bubble .ai-comparison-table tbody tr:hover td:first-child {
    background: #f1f5f9;
}

/* Cheapest price cell — green */
.ai-bubble .ai-comparison-table td.price-cheapest {
    color: #065f46 !important;
    font-weight: 700;
    background: #d1fae5 !important;
    position: relative;
}

.ai-bubble .ai-comparison-table td.price-cheapest::after {
    content: " ✓";
    font-size: 0.75rem;
    color: #059669;
}

/* Priciest cell — subtle red */
.ai-bubble .ai-comparison-table td.price-priciest {
    color: #991b1b !important;
    font-weight: 600;
    background: #fee2e2 !important;
}

/* Neutralise the generic last-child green rule inside comparison tables */
.ai-bubble .ai-comparison-table td:last-child {
    font-weight: inherit;
    color: inherit;
    white-space: nowrap;
}

/* =============================================
   Chat bubble content overrides
   ============================================= */
.chat-message.ai .msg-bubble p{
	margin: 0;
	font-size: 0.7rem;
}

/* Table styling within AI bubble */
.chat-message.ai .msg-bubble table {
    width: 100%;
    min-width: 500px;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.chat-message.ai .msg-bubble th {
    background: #eef2f7;
    font-weight: 600;
    padding: 10px;
    border-bottom: 1px solid #ddd;
    text-align: start;
}

.chat-message.ai .msg-bubble td {
    padding: 10px;
    border-bottom: 1px solid #eee;
    text-align: start;
}

.chat-message.ai .msg-bubble tr:nth-child(even) {
    background: #fafafa;
}

.chat-message.ai .msg-bubble tr:hover {
    background: #f1f5f9;
}

.chat-message.ai .msg-bubble hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 12px 0;
}

/* Cheapest card styles */
.ai-cheapest-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #ffffff;
  border: 1px solid #e6fffa;
  padding: 14px 16px;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(6, 95, 70, 0.04);
}
.ai-cheapest-card .cheapest-product {
  font-weight: 700;
  font-size: 1rem;
  color: #0f172a;
}
.ai-cheapest-card .cheapest-meta {
  font-size: 0.8rem;
  color: #475569;
}
.ai-cheapest-card .cheapest-price {
  margin-top: 6px;
  font-weight: 800;
  color: #065f46;
  font-size: 1.05rem;
}

/* Intent-specific table wrapper styling */
.ai-table-responsive.intent-GET_CHEAPEST {
  max-width: 560px;
  margin: 8px 0;
}
.ai-table-responsive.intent-COMPARE_STORES {
  border-radius: 8px;
  border: 1px solid #eef2ff;
  padding: 6px;
  background: #ffffff;
}

@media (max-width: 768px) {
  .ai-cheapest-card { padding: 12px; }
  .ai-cheapest-card .cheapest-product { font-size: 0.95rem; }
  .ai-cheapest-card .cheapest-price { font-size: 1rem; }
}

/* Follow-up suggestion bubble */
.market-analysis-dashboard .follow-up-bubble {
  background: #f0f4ff;
  border: 1px solid #c7d7fa;
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 460px;
}
.market-analysis-dashboard .follow-up-text {
  font-size: 0.93rem;
  color: #334155;
  line-height: 1.5;
}
.market-analysis-dashboard .follow-up-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.market-analysis-dashboard .follow-up-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px 7px 10px;
  border-radius: 20px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid #c7d7fa;
  background: #fff;
  color: #334155;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
}
.market-analysis-dashboard .follow-up-btn:hover {
  background: #4f46e5;
  border-color: #4f46e5;
  color: #fff;
}
.market-analysis-dashboard .option-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #4f46e5;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  flex-shrink: 0;
}
.market-analysis-dashboard .follow-up-btn:hover .option-key {
  background: #fff;
  color: #4f46e5;
}
.market-analysis-dashboard .option-label {
  font-size: 0.87rem;
}
.market-analysis-dashboard .follow-up-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* RTL: follow-up option buttons */
html[dir="rtl"] .market-analysis-dashboard .follow-up-actions {
  direction: rtl;
}
html[dir="rtl"] .market-analysis-dashboard .follow-up-btn {
  flex-direction: row-reverse;
  padding: 7px 10px 7px 16px;
}
.market-analysis-dashboard .msg-bubble.rtl .follow-up-actions {
  direction: rtl;
}
.market-analysis-dashboard .msg-bubble.rtl .follow-up-btn {
  flex-direction: row-reverse;
  padding: 7px 10px 7px 16px;
}

@media (max-width: 640px) {
  .market-analysis-dashboard .ai-chat-messages .msg-avatar {
    display: none;
  }
}
