/* ─────────────────────────────────────────────
   Chat Page Styles (ChatGPT-like)
   ───────────────────────────────────────────── */

.chat-page-container {
  display: flex;
  height: calc(100vh - 100px); /* Smaller height to look like a floating app */
  margin: 20px; /* Add margin around to make it look "compact" */
  background-color: #fff;
  font-family: 'Inter', sans-serif;
  overflow: hidden;
  border-radius: 20px; /* Rounded corners for the whole container */
  box-shadow: 0 10px 30px rgba(0,0,0,0.08); /* Soft shadow */
  border: 1px solid rgba(0,0,0,0.05);
}

/* ── Sidebar (History) ──────────────────────── */
.chat-sidebar {
  width: 260px;
  background-color: #05396b; /* Clinera Blue */
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.3s ease;
  border-top-left-radius: 20px; /* Match container */
  border-bottom-left-radius: 20px;
}

.chat-sidebar__header {
  padding: 16px;
  padding-bottom: 0;
}

.chat-new-btn {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s;
  font-size: 14px;
  text-align: left;
}

.chat-new-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.chat-new-btn i {
  font-size: 16px;
  width: 20px; /* fixed width for alignment */
}

.chat-history-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-history-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  color: #ececf1;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-history-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.chat-history-item--active {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.chat-history-item i {
  font-size: 14px;
  opacity: 0.7;
}

/* ── Main Chat Area ─────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: #fff;
}

.chat-messages-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chat-message-row {
  width: 100%;
  display: flex;
  padding: 24px; /* Default left align */
  border-bottom: none;
}

.chat-message-row--user {
  justify-content: flex-end; /* Align user to right */
  background: transparent; /* Remove white background for user row to blend */
}

.chat-message-row--ai {
  background: #fff; /* Keep AI background white or transparent depending on design */
  justify-content: flex-start;
}

.chat-message-content {
  width: 100%;
  max-width: 800px;
  display: flex;
  gap: 16px;
}

/* Reverse layout for user messages so avatar is on the far right */
.chat-message-row--user .chat-message-content {
  flex-direction: row-reverse;
  justify-content: flex-start; /* items start from the right side because of row-reverse */
}

.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
}

/* ... existing bubble styles ... */

/* Skeleton Loading Styles */
.chat-loading-skeleton {
  width: 100%;
  max-width: 600px;
  padding: 12px 0;
}

.skeleton-line {
  height: 12px;
  background: #e0e0e0;
  border-radius: 4px;
  margin-bottom: 8px;
  animation: shimmer 1.5s infinite linear;
  background: linear-gradient(to right, #eeeeee 8%, #dddddd 18%, #eeeeee 33%);
  background-size: 800px 104px;
}

.skeleton-line:last-child {
  width: 70%;
}

@keyframes shimmer {
  0% {
    background-position: -468px 0;
  }
  100% {
    background-position: 468px 0;
  }
}

.chat-avatar--user {
  background: #f0f2f5;
  color: #555;
}

/* Specific bubble styling */
.chat-text {
  flex: 1;
  font-size: 15px;
  line-height: 1.6;
  color: #111827;
  padding: 12px 18px;
  border-radius: 12px;
  max-width: 100%;
}

/* User Message Bubble */
.chat-message-row--user .chat-text {
  background: #f3f4f6; /* Gray bubble */
  color: #1f2937;
  border-top-left-radius: 2px;
}

/* AI Message Bubble */
.chat-message-row--ai .chat-text {
  background: #e8f5e9; /* Light green bubble */
  color: #064e3b;
  border: 1px solid rgba(0,0,0,0.02);
  border-top-left-radius: 2px;
}

.chat-avatar--ai {
  background: #fff;
  border: 1px solid #e5e7eb;
}

.chat-avatar--ai i {
  color: #10a37f; /* OpenAI green-ish */
  font-size: 22px;
}

.chat-text {
  flex: 1;
  font-size: 15px;
  line-height: 1.6;
  color: #374151;
  margin-top: 6px; /* Align with avatar center roughly */
}

.chat-text p {
  margin-top: 0;
  margin-bottom: 16px;
}

.chat-text p:last-child {
  margin-bottom: 0;
}

.chat-text pre {
  background: #1e1e1e;
  padding: 16px;
  border-radius: 6px;
  color: #d4d4d4;
  overflow-x: auto;
  margin: 12px 0;
}

/* ── Input Area ─────────────────────────────── */
.chat-input-container {
  padding: 24px;
  background: #fff;
  border-top: 1px solid rgba(0,0,0,0.05);
  display: flex;
  justify-content: center;
}

.chat-input-wrapper {
  width: 100%;
  max-width: 800px;
  position: relative;
  display: flex;
  align-items: flex-end;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  background: #fff;
  padding: 12px 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.chat-input-wrapper:focus-within {
  border-color: #5cdb94;
  box-shadow: 0 0 0 3px rgba(92, 219, 148, 0.2);
}

.chat-input-field {
  flex: 1;
  border: none;
  resize: none;
  max-height: 200px;
  min-height: 24px;
  padding: 0;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  outline: none;
  background: transparent;
  color: #1f2937;
}

.chat-input-send {
  margin-left: 12px;
  width: 36px;
  height: 36px;
  border-radius: 8px; /* Slightly squarer like image */
  display: flex;
  align-items: center;
  justify-content: center;
  background: #24427D; /* Clinera Blue */
  color: #fff;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-input-send:disabled {
  background: #e5e7eb;
  color: #9ca3af;
  cursor: default;
}

.chat-input-send:hover:not(:disabled) {
  background: #1a3260; /* Darker blue */
}

/* ── Empty State ────────────────────────────── */
.chat-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  color: #374151;
}

.chat-empty-logo {
  font-size: 48px;
  color: #24427D;
  background: rgba(36, 66, 125, 0.1);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-empty-title {
  font-size: 24px;
  font-weight: 600;
}

.chat-suggestions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 600px;
  width: 100%;
  padding: 0 24px;
}

.chat-suggestion-card {
  padding: 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
}

.chat-suggestion-card:hover {
  background: #f9fafb;
  border-color: #d1d5db;
}

.chat-suggestion-header {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  color: #111827;
}

.chat-suggestion-text {
  font-size: 13px;
  color: #6b7280;
}

/* Markdown Table Styles for Chat Page */
.chat-text table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.05); /* Subtle border */
}

.chat-text th {
  background: #f3f4f6;
  color: #1f2937;
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid #e5e7eb;
}

.chat-text td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  color: #374151;
  vertical-align: top;
}

.chat-text tr:last-child td {
  border-bottom: none;
}

.chat-text tr:nth-child(even) {
  background-color: #f9fafb;
}

/* Adjustments for User Message Bubbles */
.chat-message-row--user .chat-text table {
  background: rgba(255, 255, 255, 0.5); /* Slightly transparent on user bubble */
  border: none;
  box-shadow: none;
}

.chat-message-row--user .chat-text th {
  background: rgba(0, 0, 0, 0.05);
  border-bottom: 2px solid rgba(0, 0, 0, 0.1);
}

.chat-message-row--user .chat-text td {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.chat-message-row--user .chat-text tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.03);
}

