/* ============================================================
   1. GLOBAL LAYOUT & RESET
   ============================================================ */
body:has(.explorer-screen-wrapper) {
  overflow: hidden !important;
  height: 100dvh;
  background-color: #fff;
}

.explorer-screen-wrapper {
  height: calc(100dvh - 56px); /* Adjust based on your Navbar height */
  display: flex;
  flex-direction: column;
  background-color: #fff;
}

.explorer-main-container {
  display: flex;
  flex: 1;
  width: 100%;
  overflow: hidden;
  background-color: #fff;
}
.chat-column {
  display: flex;
  flex-direction: column;
  flex: 3; /* Takes 3 parts of available space */
  min-width: 0;
  border-right: 1px solid #f1f1f1;
  background-color: #fff;
}
/* ============================================================
   2. CHAT HISTORY (THE SCROLLING ENGINE)
   ============================================================ */
#chatHistory {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column; /* Allows align-self for bubbles */
  padding: 2rem; /* Horizontal and Vertical Gutter */
  padding-bottom: 50px; /* Space for last message visibility */
  scroll-behavior: smooth;
  background-color: #ffffff;
   color: var(--bs-primary);
  font-size:1.1rem;
}

  /* Custom Scrollbar for Chat History */
  #chatHistory::-webkit-scrollbar {
    width: 6px;
  }

  #chatHistory::-webkit-scrollbar-thumb {
    background: #eee;
    border-radius: 10px;
  }

  /* ============================================================
   3. MESSAGE BUBBLES (USER VS AI)
   ============================================================ */
  /* Common Message Content Typography */
  #chatHistory .message-content {
    font-size: 1.1rem;
    line-height: 1.6;
  }

/* USER MESSAGE: Pushed to the RIGHT */
.msg-user {
  align-self: flex-end;
  background-color: var(--bs-primary) !important;
  color: #fff !important;
  border: none;
  border-radius: 18px 18px 2px 18px !important;
  max-width: 80%;
  padding: 1.2rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  position: relative;
  animation: fadeInRight 0.3s ease;
}

  .msg-user small {
    color: rgba(255, 255, 255, 0.8) !important;
    font-size: 0.75rem;
  }

/* AI MESSAGE: Pushed to the LEFT */
.msg-ai {
  align-self: flex-start;
  background-color: transparent; /* Remove white box */
  color: #333;
  /* Keep the accent line but make it subtle */
 /* border-left: 3px solid var(--bs-secondary);*/
  border-top: none;
  border-right: none;
  border-bottom: none;
  border-radius: 0; /* Remove rounded corners */

  max-width: 95%; /* Give more room for tables/charts */
  padding: 0.5rem 1.5rem; /* Reduce padding since there's no box */
  margin-bottom: 2rem;
  box-shadow: none; /* Remove the shadow */

  animation: fadeInLeft 0.3s ease;
}

  /* Ensure Markdown elements look good without a box */
  .msg-ai .message-content p {
    margin-bottom: 1rem;
  }
  .msg-ai .dataTables_wrapper {
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid #eee;
    background-color: #fff;
    border-radius: 8px;
  }
/* ============================================================
   4. DATA PRESENTATION (TABLES, CARDS, IMAGES)
   ============================================================ */
/* DataTables Theme Integration */
#chatHistory .dataTables_wrapper {
  width: 100%;
  margin: 1rem 0;
  border: 1px solid #eee;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

#chatHistory table.dataTable thead th {
  background-color: var(--bs-primary) !important;
  color: #fff !important;
  border: none;
  padding: 12px;
  font-weight: 500;
}
/* Styling for tables inside AI bubbles */
.message-content table {
  width: 100% !important;
  margin: 10px 0;
  border-collapse: collapse;
  font-size: 0.85rem;
}

/* Fix for DataTables inside a scrollable chat container */
.dataTables_wrapper {
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
}

/* RTL Support for DataTables Controls */
.rtl-datatable {
  direction: rtl;
  text-align: right;
}

  .rtl-datatable .dataTables_filter {
    float: left !important;
    text-align: left;
  }

  .rtl-datatable .dataTables_length {
    float: right !important;
  }

/* AI Card Hover Effect (Profiles) */
.msg-ai .card {
  border: 1px solid #eee !important;
  background: #fff;
}

  .msg-ai .card:hover {
    border-color: var(--bs-primary) !important;
    transform: translateY(-3px);
    transition: 0.2s;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08) !important;
  }

/* Image Styling (Borderless & Clean) */
#chatHistory img {
  max-width: 180px;
  height: auto;
  border: none !important;
  padding: 0 !important;
  background: transparent !important;
  border-radius: 12px;
  margin: 10px 0;
  display: block;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transition: transform 0.2s ease-in-out;
}

  #chatHistory img:hover {
    transform: scale(1.05);
  }

/* ============================================================
   5. INTERACTIVE ELEMENTS (INPUT, BUTTONS, CHIPS)
   ============================================================ */
/* Sticky Footer Container */
.explorer-footer {
  flex-shrink: 0;
  padding: 1.5rem 0;
  border-top: 1px solid #f1f1f1;
  background: #fff;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

/* The Input Pill */
.ai-input-pill {
  border: 1.5px solid #e9ecef !important;
  border-radius: 1.5rem !important;
  overflow: hidden;
  transition: all 0.2s;
}

  .ai-input-pill:focus-within {
    border-color: var(--bs-primary) !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
  }

#chatInput {
  padding: 1rem 1.5rem;
  font-size: 1.1rem;
}

/* Suggestion Chips */
.suggestion-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  margin-bottom: 20px;
  align-self: flex-start; /* Aligns under the AI bubble */
  width: 100%;
}

.suggestion-chip {
  background-color: #ffffff;
  color: var(--bs-primary);
  border: 1.5px solid var(--bs-primary);
  border-radius: 50px;
  padding: 8px 20px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

  .suggestion-chip:hover {
    background-color: var(--bs-primary);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(13, 110, 253, 0.2);
  }

/* File Attachment Badges */
.file-badge {
  background-color: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 5px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #495057;
}

/* ============================================================
   6. SIDEBAR & UTILITIES
   ============================================================ */
#citationSidebar {
  flex: 1; /* Takes 1 part of available space */
  max-width: 320px; /* Limits how wide it can get */
  min-width: 260px; /* Limits how thin it can get */
  background: #fcfcfc; /* Slight off-white to distinguish from chat */
  border-left: 1px solid #f1f1f1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
@media (max-width: 992px) {
  #citationSidebar {
    display: none !important;
  }
}
/* Status Semantic Colors */
.text-status-warning {
  color: var(--bs-warning) !important;
  font-weight: bold;
}

.text-status-danger {
  color: var(--bs-danger) !important;
  font-weight: bold;
}

.text-status-success {
  color: var(--bs-success) !important;
  font-weight: bold;
}

/* Animations */
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}
/* Vertical Journey Styles */
.timeline-container {
  margin: 20px 0 30px 10px;
}

/* The pulse for the NEWEST event in the journey */
.timeline-item:first-child .timeline-dot {
  background-color: var(--bs-primary) !important;
  box-shadow: 0 0 0 4px rgba(var(--bs-primary-rgb), 0.2);
  animation: journey-pulse 2s infinite;
}

/* Connect the logic: Gray dots for past events */
.timeline-item:not(:first-child) .timeline-dot {
  background-color: var(--bs-secondary) !important;
  opacity: 0.6;
}

@keyframes journey-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0px rgba(var(--bs-primary-rgb), 0.4);
  }

  70% {
    transform: scale(1.2);
    box-shadow: 0 0 0 10px rgba(var(--bs-primary-rgb), 0);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0px rgba(var(--bs-primary-rgb), 0);
  }
}

.timeline-item .card {
  border-radius: 12px;
  transition: all 0.2s ease;
}

  .timeline-item .card:hover {
    background-color: #fcfcfc;
    border-left: 3px solid var(--bs-primary) !important;
  }
/* RTL Alignment for Arabic Messages */
.rtl-message {
  direction: rtl !important;
  text-align: right !important;
}

/* Adjust AI Bubble border for RTL */
.msg-ai.rtl-message {
  border-left: none !important;
  border-right: 5px solid var(--bs-secondary) !important;
  border-radius: 18px 2px 18px 18px !important;
}

/* Flip the Suggestion Container for RTL */
.suggestion-container.rtl-message {
  flex-direction: row-reverse !important;
  justify-content: flex-start !important;
}

/* Ensure tables flip correctly */
.rtl-message table {
  direction: rtl !important;
  width: 100%;
}
/* Image Preview Thumbnail in Chat */
.msg-user .card {
  border-radius: 12px !important;
  background: rgba(255, 255, 255, 0.1); /* Subtle contrast against blue user bubble */
}

.msg-user img {
  cursor: zoom-in;
  transition: transform 0.2s;
}

  .msg-user img:hover {
    transform: scale(1.03);
  }
/* History Sidebar Styling */
#sessionList .list-group-item {
  border: none;
  padding: 15px 20px;
  transition: all 0.2s ease;
  cursor: pointer;
  background: transparent;
}

  #sessionList .list-group-item:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.05);
    border-left: 4px solid var(--bs-primary);
  }

  #sessionList .list-group-item.active-session {
    background-color: rgba(var(--bs-primary-rgb), 0.08);
    border-left: 4px solid var(--bs-primary);
    font-weight: 600;
  }

#sessionList .session-title {
  display: block;
  color: var(--bs-dark);
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sessionList .session-date {
  font-size: 0.75rem;
  /*color: var(--bs-secondary);*/
  margin-top: 4px;
}

/* Float Button Hover */
button[data-bs-target="#offcanvasHistory"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(0,0,0,0.1) !important;
  border-color: var(--bs-primary) !important;
}
#sessionList .list-group-item {
  transition: opacity 0.2s ease-in-out;
}

/* Style the search bar input specifically */
#historySearch::placeholder {
  font-size: 0.85rem;
  color: #adb5bd;
}

#historySearch:focus {
  background: transparent;
}
/* Show delete button on hover */
#sessionList .list-group-item:hover .btn-delete-session {
  opacity: 1 !important;
}

#sessionList .btn-delete-session {
  transition: opacity 0.2s ease, transform 0.2s ease;
}

  #sessionList .btn-delete-session:hover {
    transform: scale(1.2);
    color: var(--bs-danger) !important;
  }

/* Ensure the title doesn't overlap the button */
#sessionList .session-title {
  max-width: 85%;
}
.msg-ai-chart {
  background: #ffffff;
  border: 1px solid var(--bs-border-color);
  border-radius: 12px;
  padding: 15px;
  margin: 10px 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  width: 100%;
  max-width: 600px; /* Adjust based on your layout */
}
.bg-info-soft {
  background-color: rgba(13, 202, 240, 0.1);
  color: #0dcaf0;
  border: 1px solid rgba(13, 202, 240, 0.2) !important;
}

.bg-success-soft {
  background-color: rgba(25, 135, 84, 0.1);
}
/* Ensure message content doesn't force a code block style on cards */
.message-content > div.card {
  display: block !important;
  white-space: normal !important;
}

/* Remove default pre/code styles if they leak into the card */
.message-content pre:has(.card),
.message-content code:has(.card) {
  background: transparent !important;
  border: none !important;
  padding: 0 !important;
  font-family: inherit !important;
}
#ai-typing-indicator {
  background: transparent !important;
  border: none !important;
  padding: 10px 0 !important;
  box-shadow: none !important;
}

.spinner-border-sm {
  width: 1rem;
  height: 1rem;
  border-width: 0.15em;
}
